If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
tft67
Posts: 19 Joined: Sat Nov 08, 2008 2:56 am
Post
by tft67 » Sat Oct 03, 2009 2:34 am
I want to add a material to a existing node and change it's color ( ambient, diffuse, emissive, backface.. )
but didn't found how to make it ( no glsl ) ?
Any one can help ?
randomMesh
Posts: 1186 Joined: Fri Dec 29, 2006 12:04 am
Post
by randomMesh » Sat Oct 03, 2009 2:40 am
Code: Select all
for (irr::u32 i = 0; i < node->getMaterialCount(); ++i)
{
irr::video::SMaterial& material = node->getMaterial(i);
material.DiffuseColor = irr::video::SColor(255, 255, 0, 0);
}
"Whoops..."
tft67
Posts: 19 Joined: Sat Nov 08, 2008 2:56 am
Post
by tft67 » Sun Oct 04, 2009 3:01 am
node->getMaterial(i) return an existing material.
I need to create one and adding it to the node :
something like this :
irr::video::SMaterial newMaterial ;
// change the material
material.DiffuseColor = irr::video::SColor(255, 255, 0, 0);
maretial.SpecularColor...
node->addMaterial ( newMaterial ) ;
CuteAlien
Admin
Posts: 9934 Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:
Post
by CuteAlien » Sun Oct 04, 2009 3:13 am
getMaterial returns a reference so if you assign it to that it will get changed. So you do like randomMesh proposed and just assign material = newMaterial; instead of just setting the DiffuseColor.
tft67
Posts: 19 Joined: Sat Nov 08, 2008 2:56 am
Post
by tft67 » Sun Oct 04, 2009 4:04 am
Ok.
so i can only change an existing material.
Thanks a lot.
CuteAlien
Admin
Posts: 9934 Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:
Post
by CuteAlien » Sun Oct 04, 2009 5:05 am
Materials are copied from meshbuffers - one material per meshbuffer. So that is what you can set/change.