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.
ghiboz
Posts: 37 Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:
Post
by ghiboz » Mon Mar 10, 2008 2:52 pm
Hi!
I have a IAnimatedMeshSceneNode that contains IAnimatedMesh as child.
How can I cycle across the childrens?
I tried with ->getChildren but retrieve a IMesh and my node contains only animated meshes
thanks
hybrid
Admin
Posts: 14143 Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:
Post
by hybrid » Mon Mar 10, 2008 4:22 pm
getChildren should return a list of scene nodes. You can check the type of a scene node and cast to the proper interface.
MasterGod
Posts: 2061 Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:
Post
by MasterGod » Mon Mar 10, 2008 5:03 pm
ghiboz wrote: Hi!
I have a IAnimatedMeshSceneNode that contains IAnimatedMesh as child.
How can I cycle across the childrens?
First a scene node can only have other scene nodes as children not meshes ('fix me' if I'm wrong).
Second, to iterate across its (the scene node's) children you can do something like this:
Code: Select all
const core::list<ISceneNode*>& list = YourNode->getChildren();
core::list<ISceneNode*>::ConstIterator it = list.begin();
for (; it!=list.end(); ++it)
{
// (*it) is the current children.
// do with *it whatever you want
// e.g: (*it)->remove();
}
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
rogerborg
Admin
Posts: 3590 Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:
Post
by rogerborg » Mon Mar 10, 2008 5:55 pm
ghiboz wrote: I have a IAnimatedMeshSceneNode that contains IAnimatedMesh as child. How can I cycle across the childrens ?
IAnimatedMeshSceneNode has at most one (1) IAnimatedMesh.
Code: Select all
IAnimatedMesh* IAnimatedMeshSceneNode::getMesh(void);
ghiboz wrote: I tried with ->getChildren but retrieve a IMesh
Which getChildren() method do you think is returning you an IMesh, or an array of IMesh? Can you point at that method in the API?
IAnimatedMeshSceneNode::getChildren() resolves to ISceneNode::getChildren().
Code: Select all
const core::list<ISceneNode*>& getChildren() const
ISceneNode*, not IMesh*
ghiboz wrote: and my node contains only animated meshes
It contains at most one (1) IAnimatedMesh. What is leading you to believe otherwise?
ghiboz
Posts: 37 Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:
Post
by ghiboz » Mon Mar 10, 2008 8:47 pm
thanks for your replies:
I explain better...
I made my personal file importer and I have this:
Code: Select all
IAnimatedMeshSceneNode* gbzNode = 0;
for( int gm = 0; gm < gbzMeshes.size(); gm ++ )
{
IAnimatedMesh* mesh = readStaticMesh( gm );
gbzNode = Smgr->addAnimatedMeshSceneNode( mesh );
}
return gbzNode;
gbzNode is an AnimatedMeshSceneNode that contains many animatedmeshshenenodes (right?)
i tried to do this:
Code: Select all
core::list<scene::ISceneNode*>::ConstIterator it gbzNode->getChildren().begin();
for (; it != gbzNode->getChildren().end(); it = gbzNode->getChildren().begin())
(*it)->setDebugDataVisible(scene::EDS_OFF);
but doesn't work, 'cause the getChildren retrieve a MeshNode and not AnimatedMeshNode
hybrid
Admin
Posts: 14143 Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:
Post
by hybrid » Mon Mar 10, 2008 8:59 pm
No, that pointer only contains the latest added animated mesh scene node. Simply because that's the way C++ handles such stuff
ghiboz
Posts: 37 Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:
Post
by ghiboz » Mon Mar 10, 2008 9:31 pm
hybrid wrote: No, that pointer only contains the latest added animated mesh scene node. Simply because that's the way C++ handles such stuff
ok, but what's the best way to do?
I have many animatedmesh to insert in one or more animatedmeshscenenode...
thanks
hybrid
Admin
Posts: 14143 Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:
Post
by hybrid » Mon Mar 10, 2008 10:20 pm
No, you only have *one* per scene node. Simply use many scene nodes.
ghiboz
Posts: 37 Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:
Post
by ghiboz » Tue Mar 11, 2008 7:16 am
hybrid wrote: No, you only have *one* per scene node. Simply use many scene nodes.
yes, but can I have 1 main animatedscenenode (empty) and many animatedscenenodes with one mesh inside??
thanks mate!
hybrid
Admin
Posts: 14143 Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:
Post
by hybrid » Tue Mar 11, 2008 8:38 am
I guess that an empty animated mesh scene node is unnecessary overhead, better use an empty scene node. What do you want to achieve with this?
rogerborg
Admin
Posts: 3590 Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:
Post
by rogerborg » Tue Mar 11, 2008 9:20 am
I'd imagine that you want something like this:
Code: Select all
ISceneNode * yourFunctionOrMethod(...)
{
...
ISceneNode * parent = Smgr->addEmptySceneNode(0);
IAnimatedMeshSceneNode* gbzNode = 0;
for( int gm = 0; gm < gbzMeshes.size(); gm ++ )
{
IAnimatedMesh* mesh = readStaticMesh( gm );
if(mesh)
(void)Smgr->addAnimatedMeshSceneNode( mesh, parent );
}
return parent;
}
but doesn't work, 'cause the getChildren retrieve a MeshNode and not AnimatedMeshNode
No, it does not.
IAnimatedMeshSceneNode::getChildren() returns core::list<
ISceneNode *>&, not any form of "MeshNode". You presumably already know this, because you're using an appropriate iterator.