Error using ChildNodeIteratorWrap

pjcast

13-06-2006 01:45:44

First, I want to say good job on the bindings! I was able to grab the precompiled bindings for VS8, and have Ogre in my Winform's app in less then half an hour.

However, I did not build OgreDotNet myself, so i don't really have the source to step into. I was hoping maybe someone would show me what I am doing wrong, or have an idea of what is wring.

Anyway, I'm trying to iterate over the nodes in the Ogre scenegraph (for an editor, to build a treeview). I can get the rootscenenode, and then grab the iteratr. However, using the hasMoreElement() method causes an instant crash with no exception information or anything. So, i tried working around that, and using the getNext(0 method, however, it only ever returns bad references, and eventually causes a crash.

Here is my code:

mOgreContainer.mSceneManager.RootSceneNode.CreateChildSceneNode(new Math3D.Vector3(0.0f, 6.5f, -67.0f)).AttachObject(mParticleSystem);
mOgreContainer.mSceneManager.RootSceneNode.CreateChildSceneNode("Test1");
mOgreContainer.mSceneManager.RootSceneNode.CreateChildSceneNode("Test2");

Node rootNode = mOgreContainer.mSceneManager.GetRootSceneNode();
ChildNodeIteratorWrap children = rootNode.GetChildIterator();

Node nextNode = null;
while (children.hasMoreElements())
{
nextNode = children.getNext();
}


I am using the standard startup stuff as in the demos right now (my app works if I do not traverse the iterator). I am using Visual Studio 8 Standard, and the latestet OgreDotNet bindings for VC8 + Dagon 1.2 SDK. As you can see, I should have a few scenenodes to travers through. Any ideas of why I'm crashing with this? Has anyone else used this iterator with no troubles?

rastaman

13-06-2006 04:43:00

This is a bug in the custom wrap code for Node.getChildIterator. Its not able to just return the address of the instance of Ogre::Node::ChildNodeIterator that Ogre returns.

If you want to fix it and recompile, you need to change OgreNode.I at line 260. Just past the changed code belo over the function that starts on that line. Then reSWIG and compile. OgreBindings and OgreDotNet.

Ogre::ChildNodeIteratorWrap* GetChildIterator()
{
Ogre::Node::ChildNodeIterator * jresult;
SwigValueWrapper< Ogre::Node::ChildNodeIterator > result;

result = self->getChildIterator();
jresult = new Ogre::Node::ChildNodeIterator( (Ogre::Node::ChildNodeIterator&)result );
return new Ogre::ChildNodeIteratorWrap( jresult );
}

pjcast

13-06-2006 05:55:25

Ah, I figured I would need to build OgreDotNet myself eventually anyway :) Thanks for your quick answer. One question though, is this updated in CVS? In anycase, I'll get to compiling this.. I absultely love these bindings :)

pjcast

14-06-2006 09:07:27

That fixed worked perfectly, thanks again ;)