burgelkat Posted Saturday at 12:28 PM Posted Saturday at 12:28 PM Hallo, If I have a skeletal model with one mesh but two materials, how can I access the second material? The second material is used for the eyes. At game start the eyes should be dead (no emission) and only start glowing after activation. If the eyes were a child entity, this would be easy. But what is the correct way when there is only one mesh? Quote
Josh Posted Saturday at 10:33 PM Posted Saturday at 10:33 PM https://www.leadwerks.com/learn/Model?lang=lua https://www.leadwerks.com/learn/Lod?lang=lua mesh1 = model.lods[1],meshes[1] mesh2 = model.lods[1],meshes[2] 1 Quote Let's build cool stuff and have fun.
burgelkat Posted Sunday at 07:45 AM Author Posted Sunday at 07:45 AM Thanks Josh, that explanation helps to understand the internal structure. What I’ve confirmed so far: If a model (or mesh) uses only one material, GetMaterial() and SetMaterial() work as expected and the material can be fully replaced. However, if the same mesh uses multiple materials (multiple material slots), Lua does not provide a way to replace a single material slot. In that case, SetMaterial() affects the entire model and individual materials cannot be swapped — only modified (e.g. emission, color). So replacing the eye material entirely is only possible when the eyes are exported as a separate child model, or when the model uses a single material. Please let me know if I’m missing something on the Lua side — happy to learn My model LOD1 —> mesh1 body :material |—> mesh1 eye: material Quote
Josh Posted Sunday at 05:32 PM Posted Sunday at 05:32 PM The mesh class has a GetMaterial and SetMaterial command. Quote Let's build cool stuff and have fun.
Recommended Posts
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.