Attaching a scenenode with a body to other scenenode

kjs335

23-04-2006 05:21:31

As the title says, I created a scenenode then I attached OgreNewt::Body to the scenenode.
Then I created another scenenode then I attached the scenenode with the body to the second scenenode.
But then the program crashes after exiting. Why does it crash?

CaseyB

23-04-2006 07:11:04

Do you remember to delete the collision model and the World before your app exits?

kjs335

23-04-2006 08:47:17

Yes, the program works perfectly fine when I don't attach a node with a body to another node.

walaber

23-04-2006 19:07:53

you made the SceneNode with a rigid body the child of another node?

why?

kjs335

24-04-2006 11:59:55

To make camera follow the body and I want the body to change direction without changing the camera's direction.

kjs335

28-04-2006 11:24:45

Oops, my bad.
What I should say was that
I attached a node with an entity to a node with body
then I got an error after exiting.

Kencho

28-04-2006 22:42:55

I don't see why that could be wrong. Check your detaching and deleting order, and be sure there are no references from one element to other already destructed in the destruction time. I mean, don't delete the node and then try to detach and delete the entity or something similar.

kjs335

29-04-2006 07:12:20

I was using Dotscene and I found that node needs to be created manually using new SceneNode(...).

So I did that and I get no error after exiting.
But now, objects attached to a node with body are not placed properly.
Their positions are not relative to body's position. But the initial position of the parent scenenode.

I'm stuck again : S

EDIT:
Again, I was doing something very wrong.
I found that creating scenenode manually is not recommended ( new SceneNode(...) )
So I tried mSceneMgr->getRootSceneNode()->createChildSceneNode(...)
And then, it works!
In the end, the first problem was, I was using
mSceneMgr->createSceneNode(...)

That was it.
It's working fine now.