Converting a node back into a mesh?

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
dgrafix
Posts: 116
Joined: Sun Nov 18, 2007 2:36 pm

Converting a node back into a mesh?

Post by dgrafix »

If i have a scene node, how do i reference its original mesh data? (Without heeping the original mesh handle from when it was loaded/created)
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com :)
huydotnet
Posts: 81
Joined: Tue Sep 25, 2007 12:26 pm
Location: Danang, Vietnam

Post by huydotnet »

You can use
node->getMesh()
dgrafix
Posts: 116
Joined: Sun Nov 18, 2007 2:36 pm

Post by dgrafix »

It doesnt work, it says iscenenode has no member named getMesh()
C++/Irrlicht Noob pl3se B p4t1ent.
Visit www.d-grafix.com :)
twilight17
Posts: 362
Joined: Sun Dec 16, 2007 9:25 pm

Post by twilight17 »

I think it's
node->getmesh(0)

or the number of your mesh
Post this userbar I made on other websites to show your support for Irrlicht!
Image
http://img147.imageshack.us/img147/1261 ... wernq4.png
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You have to cast the ISceneNode* to the correct derived interface type [IMeshSceneNode*, IAnimatedMeshSceneNode* or whatever] based on the result of the getType() method. Once you've got a pointer to the derived interface there are usually methods for accessing the mesh.

Travis
huydotnet
Posts: 81
Joined: Tue Sep 25, 2007 12:26 pm
Location: Danang, Vietnam

Post by huydotnet »

:D use this (convert it from ISceneNode to IAnimatedSceneNode)
(IAnimatedMeshSceneNode*)node->getMesh()
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Post by kornwaretm »

and some handler

Code: Select all

if(node->getType( )==ESNT_MESH ){
   //get mesh here 
   //remember iAnimatedMeshSceneNode and IMeshSceneNode are different
}
 
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

huydotnet wrote::D use this (convert it from ISceneNode to IAnimatedSceneNode)
(IAnimatedMeshSceneNode*)node->getMesh()
I believe that's converting the returned value from getMesh() and not node.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
huydotnet
Posts: 81
Joined: Tue Sep 25, 2007 12:26 pm
Location: Danang, Vietnam

Post by huydotnet »

yes, it mean converting ISceneNode to IAnimatedSceneNode first, then we can get mesh :D
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Post by kornwaretm »

i assume u need the static mesh, if u need the animated mesh use only the second case.

Code: Select all

IMesh* mesh;
switch(node->getType( ){
case (ESNT_MESH ):
     IMeshSceneNode* meshNode=0;
     meshNode = node;
     mesh = meshNode->getMesh()
     break;
case (ESNT_ANIMATED_MESH ):
     IAnimatedMeshSceneNode* aniMeshNode=0;
     aniMeshNode = node;
     mesh = aniMeshNode->getMesh()->getMesh(0);//which one u will take
     break;
} 
just obtain the pointer, copy it to your mesh node, obtain the pointer to the mesh

if this is not what u need, may be u need to get meshes via mesh cache?
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

huydotnet wrote:yes, it mean converting ISceneNode to IAnimatedSceneNode first, then we can get mesh :D
No =P, it converts the returned value of getMesh() and not the node of which you call with to getMesh().
In other words you don't cast the node object.. or correct me if I'm wrong but I'm pretty sure I'm right :wink:
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
huydotnet
Posts: 81
Joined: Tue Sep 25, 2007 12:26 pm
Location: Danang, Vietnam

Post by huydotnet »

ah, yes, i understand :D
now, the code is:

Code: Select all

IAnimatedMeshSceneNode* convertedNode;
convertedNode = (IAnimatedMeshSceneNode*)node;
IAnimatedMesh* mesh;
mesh = convertedNode->getMesh();
is this right?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

or simply this:

Code: Select all

IAnimatedMesh* mesh = ((IAnimatedMeshSceneNode*)node)->getMesh();
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

Yes. And what Acki suggested would be even better :)
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
huydotnet
Posts: 81
Joined: Tue Sep 25, 2007 12:26 pm
Location: Danang, Vietnam

Post by huydotnet »

yes :D
Post Reply