blank nodes

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
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

blank nodes

Post by agamemnus »

How do you create a blank node so that you can later add a mesh pointer to it via setMesh?

I tried addEmptySceneNode and then setMesh, but the setMesh crashed.

I tried addAnimatedMeshSceneNode(0) but that that gives me 0 for the node pointer as a result.
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

While adding an empty node can be done by using addEmptySceneNode(); when declaring the new node, you cannot do so with an IAnimatedMeshSceneNode. At least I don't think you can. However, what you could do is declare it as a type ISceneNode at first and then when you are ready to add the mesh in, just change the type into an IAnimatedMeshSceneNode. You should be able to accomplish what you need because all you have to change is the initial call as well as adding additional lines for loading the mesh and setting up texture and material options, which you would have to do anyway. The only real difference is switching "ISceneNode" with IAnimatedMeshSceneNode" when the time comes.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

I wanner preserve material options...
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

Code: Select all

addAnimatedMeshSceneNode(pMesh, pParent, id, position, rotation, scale, alsoAddIfMeshPointerZero);
Set the last paramater "alsoAddIfMeshPointerZero" to true.
Never take advice from someone who likes to give advice, so take my advice and don't take it.
Whirled Peas
Posts: 47
Joined: Mon Jan 10, 2011 8:01 pm
Location: SoCal

Post by Whirled Peas »

agamemnus wrote:I wanner preserve material options...
If you don't have a mesh loaded for the node in the first place, how can you have material options for it? Or rather, how can you see what the material options look like to even know if you like them on the not yet introduced mesh?
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Bate wrote:

Code: Select all

addAnimatedMeshSceneNode(pMesh, pParent, id, position, rotation, scale, alsoAddIfMeshPointerZero);
Set the last paramater "alsoAddIfMeshPointerZero" to true.
Thanks mang!


Whirled Peas wrote:
agamemnus wrote:I wanner preserve material options...
If you don't have a mesh loaded for the node in the first place, how can you have material options for it? Or rather, how can you see what the material options look like to even know if you like them on the not yet introduced mesh?
I load the mesh afterward, so I know what it looks like. :?


Side-question: setting a new mesh with setMesh doesn't seem to preserve entirely node material properties (or maybe at all).. is there something I can do to make the node material properties stay as they were when setMesh is used?
blAaarg
Posts: 94
Joined: Tue Mar 02, 2010 9:11 pm
Location: SoCal

Post by blAaarg »

You might want setReadOnlyMaterials(true), if you don't need to change materials later and you don't need individual scene nodes to have different materials for a common mesh. This forces any scene node calling this method to use the materials in the main mesh cache that the Irrlicht scene manager keeps (manages), so those nodes will use the materials (and materiel options) that got loaded with the mesh.

If you do need to alter the materials later (or per node), for non-animated meshes that's done in copyMaterials() which is protected and so you'd need to follow Whirled Peas' suggestion and use the proper constructor or else implement copying the materials like in CMeshSceneNode.cpp file. But, it's not implemented in the animated scene node so you'd have to come up with your own way of copying material qualities.
"Computers don't make mistakes! What they do they do on purpose!!"

-Dale Gribble
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Thanks.
Post Reply