Applying a MeshManipulator to an ISceneNode?

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
Spinland
Posts: 32
Joined: Fri May 14, 2010 1:06 pm
Location: Upstate NY, USA

Applying a MeshManipulator to an ISceneNode?

Post by Spinland »

Apologies in advance for my confusion, but I'm stuck and it feels like I'm going over the same examples and just not getting it.

Let's say I create a node in this manner:

Code: Select all

	const SColor YELLOW    = SColor(255, 255, 255, 0);
	ISceneManager *smgr = device->getSceneManager();
	IMeshSceneNode* node=NULL;

	node = smgr->addCubeSceneNode(2.0, 0, 1000, vector3df(0,0,0), vector3df(0,0,0), vector3df(4.0,1.0,1.0));
Now for various reasons the value of node has changed, and I want to go back the one I created above and set its color. I tried this:

Code: Select all

	node = smgr->getSceneNodeFromId(1000,0);
		
	smgr->getMeshManipulator()->setVertexColors(node->getMesh(), YELLOW);
Of course this doesn't compile because getSceneNodeFromId() returns an ISceneNode* and node is of the wrong type. I got it to work by casting node but of course got a warning as well as the promise that would be a hard error in the future.

Please lend a hand and tell me how to convert the results of getSceneNodeFromId() into the proper form so I can use setVertexColors() on it?

Many thanks in advance!
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

You can use:

Code: Select all

node->getType()
To get the type of node.
Here is a list of types: http://irrlicht.sourceforge.net/docu/na ... 9120f3b7bd

So, if it turns out the node's type is ESNT_MESH, you can always safely cast it to IMeshSceneNode.

Although in the case that you have, check for ESNT_CUBE, and you should still always be able to cast it to IMeshSceneNode if it is that type.
Spinland
Posts: 32
Joined: Fri May 14, 2010 1:06 pm
Location: Upstate NY, USA

Post by Spinland »

Indeed, it's type ESNT_CUBE and I was able to cast it with no problems.

Thanks again! 8)
Post Reply