Page 1 of 1

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

Posted: Tue Feb 23, 2010 9:02 am
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

Posted: Tue Feb 23, 2010 9:22 am
by hybrid
yes, you're copying into the new object. Instead, write SMaterial& mat, which uses the usual Java reference semantics.

Posted: Tue Feb 23, 2010 2:12 pm
by Tranen
Thanks
Cheers
Tranen

Posted: Mon Mar 22, 2010 1:33 am
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);