IAnimatedMesh in IAnimatedMeshSceneNode

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
ghiboz
Posts: 37
Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:

IAnimatedMesh in IAnimatedMeshSceneNode

Post by ghiboz »

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 :wink:
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

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:

Re: IAnimatedMesh in IAnimatedMeshSceneNode

Post by MasterGod »

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();
}
Image
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:

Re: IAnimatedMesh in IAnimatedMeshSceneNode

Post by rogerborg »

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?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
ghiboz
Posts: 37
Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:

Post by ghiboz »

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 »

No, that pointer only contains the latest added animated mesh scene node. Simply because that's the way C++ handles such stuff :lol:
ghiboz
Posts: 37
Joined: Tue Jan 15, 2008 12:09 pm
Location: Centallo (I)
Contact:

Post by ghiboz »

hybrid wrote:No, that pointer only contains the latest added animated mesh scene node. Simply because that's the way C++ handles such stuff :lol:
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 »

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 »

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 »

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 »

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 :(
:roll:

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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply