Parent / child style

jonmiller

29-07-2008 21:40:22

I was doing some thinking about the way Ogre works and PhysX works. Have you thought about implementing the parent/child relationship that Ogre has with it's scene nodes to NxOgre? Do you think it's a good idea or not and how involved do you think it would be to create this?

I think it would make sense because then you could have two separate actors that move together. This also would solve some problems that I'm running into myself. I am having problems because I just now realized that all physics objects don't do anything until World::simulate() is called. So I need to move all my physics stuff, call simulate, then move the scene nodes accordingly. If this all happens within different frame starts, it poses a problem of how to call all the physics updates separate from the scene node updates without breaking the structure of my program. But if one object was a child of another, I could just move the parent and the child should follow.

If you see anything wrong with this let me know before I start tearing into NxOgre.

Thanks

betajaen

29-07-2008 22:09:52

I can't see how a parent/child relationship could work. In Ogre a child's "world" center is actually it's parents coordinates. You don't have anything like that in PhysX because everything is regarded to be in global space. I can see where it may be useful; i.e. offsetting a bunch of Actors so they appear more away than they are.

But you don't need to tear or modify NxOgre to do that at all. You could make your own Body class, or if that isn't enough. A wrapper class for Actor and SceneNode would do.

[Edit]

Actually come to think of it; You could attach the nodes in Body to a offset "Root" scene node and those movements would have a new "fake" world center.

jonmiller

31-07-2008 16:11:33

Ok I appreciate the tips on this relationship and I guess I see that it kinda has limits on its use. I probably won't be trying this anytime soon because I need to finish my project, at least this deadline, before I can experiment some more.

If you remember some previous posts i was trying to figure out a way to get a moving sidewalk effect, in reality I need a camera moving around in the pilot house of my moving ship. Well I have it working about 95%. What I have right now is this:

My ship camera is a child of my ship's scene node, so when the ship moves my camera moves and it's positioned in the pilot house. My ship is moved by a kinematic actor and the ship's node is set to the actor's node each frame. Now having the camera move in the pilot house was a little tricky (and kinda hacky). When the camera isn't moving, I make the camera actor kinematic and move it to where the camera's scene node is. Then when the camera is moving, I clear the kinematic flag, apply a force to the camera actor and move the scene node to the actor's position. This works pretty good except for when the ship is moving at top speed I get a bounce when colliding into objects. If I move to the front of the ship and hold down forward, it kinda bounces there a little bit and then all of the sudden it shoots me to the back of the room and then continues forward again. I've printed some debug info out and it looks like my linear velocity and momentum peak out when I'm pushing against something, but when it tosses me back both of those values drop and then top off again as I move to the original position. Any ideas on what may cause velocity and/or momentum to just drop like that?

*EDIT*
So I'm still debugging and I've noticed something else about the momentum and velocity. When in release mode the stutter happens more often and worse, I checked the momentum and velocity of the ship and it's doubling then halving itself from one frame to the next. It doesn't steadily increase or decrease, it just doubles, then halves then a few frames later doubles again then halves. Really weird behavior and I have no clue what is causing it.