Page 1 of 1

OgreODE question regardin body and geometry!

Posted: Thu Jan 13, 2005 4:11 pm
by eugen
i have a parent node translated from its 0,0,0...then i have a child of this node translated again from its 0,0,0...now, when i create the geometry for this node, i set its position using the _getDerivedPosition() of the node...i suppose the body gets its position from the geometry is tide to...but the body sets the position of its parent node using setPosition() .. so my geometry always appears translated with the parent's translation value!
i'm doing something wrong but i dont know what!

Posted: Thu Jan 13, 2005 4:21 pm
by eugen
if i use the setPosition() to set geometry's position, my geometry will apear in the place it needs to be, but my graphical node representation is translated with the node translation!

Posted: Thu Jan 13, 2005 4:26 pm
by DWORD
It's because geometries are always at the same position as the body they're attached to. You need to use a TransformGeometry attached to the body, and attach your geometry to that using TransformGeometry::setEncapsulatedGeometry().

Posted: Thu Jan 13, 2005 4:47 pm
by eugen
this means i have to set the transform geometry's position with _getDerivedPosition, set normal geometry's position with getPosition(), attach the body to the transform geometry, then tie does 2 geometries together using encapsulator's method!?

Posted: Thu Jan 13, 2005 5:08 pm
by eugen
well, it doesnt work!
i'm under the impression i overcomplicate this!
the situation is like this: i have a parent node, and many child nodes, each having a body attached...i need to be able to move the parent node anywhere and keep the entire child arangement as it is!
is this something for which i need a TransformGeometry?

Posted: Thu Jan 13, 2005 5:12 pm
by DWORD
eugen wrote:is this something for which i need a TransformGeometry?
No, I don't think so. I didn't quite understand what you meant, sorry for the confusion. I if understand correctly, you want to just move the parent scene node and all the children should automatically move with it? Or do you want to move the parent scene node while the children should stay the same place in world space?

Posted: Thu Jan 13, 2005 5:19 pm
by eugen
no... just move the parent scene (the child will act normal as it is defined in OGRE) .. then create the bodies!
but when i create the bodies, regardless the position i give to them, either _getderived or simple, i get the geometry translated from the mesh with the parent's translation from 0,0,0 :(

Posted: Thu Jan 13, 2005 5:32 pm
by eugen
when i use node->_getDerivedPosition() to set the geometry position, i get the geometry in the right position, but the visual representation of the node which has the body containing the geometry attaced, is translated with the parent's translation from 0,0,0...

when i use node->getPosition(), i get the geometry in the wrong position but the visual representation in the right one :(

now, in case of using the derived position, since the body uses setPosition() to sync the node with, seems that i cannot have the node in the same place, since its position will include the translation's parent node given at the geometry creation time. (this being a local setposition, i'll get it translated)

so it remains using setposition()... but like that, the geometry will not be in right place since it needs world coordinates!

i'm really curious, cause if this is a problem, someone must had spot it before me, for sure!
I incline to say i'm wrong somehow!

Posted: Thu Jan 13, 2005 6:30 pm
by sinbad
The internal state of nodes are not updated immediately when you make changes to them. The reason is performance - if you were making a lot of changes to nodes in the scene graph, and we propagated all of those changes down the (potentially deep) tree immediately, lots of state would get needlessly updated because another change later on invalidates it.

Instead, we do a lazy update - this typically happens just before rendering but you can force it if you want to. That's what the _update method is about. Just only call it if absolutely, positively need to. You can usually get around the need to do so by synchronising all your node activity in one place, e.g. frameEnded.

Posted: Fri Jan 14, 2005 12:30 am
by robin_3d
sinbad wrote:You can usually get around the need to do so by synchronising all your node activity in one place, e.g. frameEnded.
Could I ask a question about this just for some confirmation?

I have a small test application that uses one framelistener. Eventually I want some basic AI dictating the positions of my entities etc. Would you say that the safest route to take is to use frameEnded to trigger all my update code, and not touch FrameStarted?
So basically I would leave FrameStarted blank, but in every frameEnded call I get my input (mouse and keyboard) go and ask my AI to calculate positions, I update my camera position, entity positions etc.

Is there any special order for these things to get best optimisation? Is there any updating that I really need to be doing in frameStarted at all?

Posted: Fri Jan 14, 2005 10:35 am
by eugen
i know about lasy updates...is not the problem here...i actually called root->_update(true, true) with no result...i get the node position as i should!

well, i have some questions to be answered (about OgreODE) :
1. does a static geometry needs world coordinates to be positioned in the right place? (for all i see it does)
2. does a body get its position from the geometry it implements? (if it does, then, calling body->setPosition to the attached node, will be a mistake, since setPosition sets local coordinates)

Thanx alot for replays!
If someone can aswer those! @Monster!? :)

i'm doint the things this way: create nodes structure, then, for each physical node, create the geometry, set its position (obtain pos from node->_getDerivedPosition()), then, for each dynamic geometry, create a body and attach it to the geometry.

Posted: Fri Jan 14, 2005 10:41 am
by eugen
i'll check the OgreODE code to convince myself...but if someone sees a wrong thing i'm doing, pls let me know!