howto add a simple material to a node ?

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.
Post Reply
tft67
Posts: 19
Joined: Sat Nov 08, 2008 2:56 am

howto add a simple material to a node ?

Post by tft67 »

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

Re: howto add a simple material to a node ?

Post by randomMesh »

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

Add ind a material

Post by tft67 »

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: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
tft67
Posts: 19
Joined: Sat Nov 08, 2008 2:56 am

Post by tft67 »

Ok.
so i can only change an existing material.
Thanks a lot.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Materials are copied from meshbuffers - one material per meshbuffer. So that is what you can set/change.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply