swap materials?

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
kimgar
Posts: 37
Joined: Fri Apr 13, 2007 2:53 pm
Location: norway

swap materials?

Post by kimgar »

Hi!

how change the material of a node? i wanted to swap between two materials, and was hoping that something like this would work:

Code: Select all

IAnimatedMesh* mesh = smgr->getMesh("../media/mesh/sydney.md2");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
node->setMaterialTexture( 0, driver->getTexture("../media/mesh/sydney.bmp") );

SMaterial blankMaterial;
node->setMaterial(0, blankMaterial);
...but obviously it doesn't, anyone know what i am missing?
kimgar
Posts: 37
Joined: Fri Apr 13, 2007 2:53 pm
Location: norway

Post by kimgar »

ah, it's been awhile :)

this works

Code: Select all

node->getMaterial(0) = blankMat;
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Is there any reason why you can't write

Code: Select all

node->getMaterial(0) = blankMaterial;
The getMaterial() method returns a reference to the material, so the above code just assigns the material directly [assuming there is a material at index 0].

Travis
kimgar
Posts: 37
Joined: Fri Apr 13, 2007 2:53 pm
Location: norway

Post by kimgar »

no reason at all :)

it's amazing, i've been struggling for hours and finally gave up and had to ask here, then a minute later i figured it out - oh well, thanks anyway vitek!
Post Reply