Page 1 of 1

blank nodes

Posted: Wed Mar 02, 2011 11:26 pm
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.

Posted: Thu Mar 03, 2011 4:09 am
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.

Posted: Thu Mar 03, 2011 10:09 am
by agamemnus
I wanner preserve material options...

Posted: Thu Mar 03, 2011 10:17 am
by Bate

Code: Select all

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

Posted: Thu Mar 03, 2011 5:54 pm
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?

Posted: Fri Mar 04, 2011 12:37 am
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?

Posted: Mon Mar 07, 2011 1:31 am
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.

Posted: Mon Mar 07, 2011 5:40 pm
by agamemnus
Thanks.