Jump to content

[SOLVED] Access to a material with Lua


DoerrSt
 Share

Recommended Posts

Hi,

 

I load models with the material automatically with LoadModel("....").

 

After the model is correctly loaded I try to change the material of this model (a modeller complaint about blurred textures - looks like I've to change the texture filter). The problem is that I can't get access to the material itself but not one of this commands returns a valid material:

 

mat0=player.material

mat1=player:GetChild(1).material

mat2=GetEntityMaterial(player)

mat3=GetEntityMaterial(player:GetChild(1))

 

If I use

 

material=LoadMaterial("abstract::cobblestones.mat")

ground=CreateCube()

ground:SetScale(Vec3(100.0,1.0,100.0))

ground:SetPosition(Vec3(0.0,-2.0,0.0))

ground:Paint(material)

 

 

the commands

mat0=ground.material

mat2=GetEntityMaterial(ground)

are returning the correct value.

 

Do I undestand something or do I've just found a bug?

 

What I want to do is creating a look to set the texture filter for each material with PIXEL instead of MIPMAP:

 

Thanks,

 

 

 

Stefan

Link to comment
Share on other sites

Hi Rick,

 

I load the model with LoadMode("mymodel.gmf"). This loads automatically the "mymodel.mat" and applies the materials. If I load the object in the model viewer the textures are automatically applied. The model script contains no code but on another model with code I've the same trouble.

 

Regards,

 

 

 

Stefan

Link to comment
Share on other sites

i dont currently have access to LE but this should work as i have done similar code in the past in lua:

mat1 = GetSurfaceMaterial(GetSurface(model:GetChild(1),1)))

of course this assumes the material you want is on Surface1 of the mesh...

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...