[SOLVED]Newbie irrlicht question: how to set a material col.

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
Tranen
Posts: 34
Joined: Mon May 05, 2008 5:43 pm

[SOLVED]Newbie irrlicht question: how to set a material col.

Post by Tranen »

Hi I'm trying to set the emissive color of cube:

IMeshSceneNode* node = smgr->addCubeSceneNode();
SMaterial mat = node->getMaterial(0);
mat.EmissiveColor.set(1,1,0,0);

but once I've done this I must do something like node.setMaterial(mat) ?

I come from Java. SMaterial mat = node->getMaterial(0); means that I don't get a pointer to the object but a new object so every change I make to this object (ex mat.EmissiveColor.set(1,1,0,0)) doesn't affect the material of the cube. This is right?

Thanks
Last edited by Tranen on Tue Feb 23, 2010 2:11 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

yes, you're copying into the new object. Instead, write SMaterial& mat, which uses the usual Java reference semantics.
Tranen
Posts: 34
Joined: Mon May 05, 2008 5:43 pm

Post by Tranen »

Thanks
Cheers
Tranen
erivera
Posts: 3
Joined: Mon Mar 22, 2010 1:23 am

Post by erivera »

Tranen wrote:Thanks
Cheers
Tranen
Sorrry, but i can't apply the material to my cube with cube.setMaterial(mat);

My code is:

ISceneNode* cube = smgr->addCubeSceneNode( );

cube->setPosition(vector3df(0,0,100));
SMaterial& mat = cube->getMaterial(0);
mat.EmissiveColor.set(1,1,0,0);
cube.setMaterial(mat);
To share is great! Thanks.
Post Reply