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.
blank nodes
-
- Posts: 47
- Joined: Mon Jan 10, 2011 8:01 pm
- Location: SoCal
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.
Code: Select all
addAnimatedMeshSceneNode(pMesh, pParent, id, position, rotation, scale, alsoAddIfMeshPointerZero);
Never take advice from someone who likes to give advice, so take my advice and don't take it.
-
- Posts: 47
- Joined: Mon Jan 10, 2011 8:01 pm
- Location: SoCal
Thanks mang!Bate wrote:Set the last paramater "alsoAddIfMeshPointerZero" to true.Code: Select all
addAnimatedMeshSceneNode(pMesh, pParent, id, position, rotation, scale, alsoAddIfMeshPointerZero);
I load the mesh afterward, so I know what it looks like.Whirled Peas wrote: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 wrote:I wanner preserve material options...
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?
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.
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
-Dale Gribble