julio
06-06-2008 21:47:38
Hi,
First of all, thanks for doing this nice wrapper!
I am having some problems with the OgreBullet integration. What I am trying to do, is to create a rigid body for an Ogre object that has a starting position which is not zero.
When I call the method RigidBody::setShape, it seems that it always resets the scene node's position to (0,0,0), even when I set the parameters position and orientation when calling this method. So, when I call this method, the object is always moved to the origin.
Any ideas about what could be wrong?
Thanks in advance!
adam23
07-06-2008 16:59:10
Thank god i'm not the only one getting this, I have been banging my head on this problem for the last day and a half.
Before the call to setShape the position is valid, but immediately after it goes to 0,0,0.
Heres a screenshot of it happening.
This really holds me up, until I can figure out whats going wrong. I'm going to keep digging through OgreBullet to see I can figure this one out.
julio
07-06-2008 18:53:20
I finally solved with a path (outside ogrebullet)... what I do is to store the position and rotation before calling the setshape, and after it I restore them with the following code
m_rigidBody->getBulletObject()->getWorldTransform().setOrigin( OgreBulletCollisions::OgreBtConverter::to( pos ) );
m_rigidBody->getBulletObject()->getWorldTransform().setRotation( OgreBulletCollisions::OgreBtConverter::to( orientation ) );
Hope it helps
adam23
07-06-2008 20:13:31
Yup I had that in for a little while too, but I felt like I must be doing something wrong, and I finally figured it out.
I was passing a const Vector3& from the position of the node using the getPosition( ) call. Inside setShape it calls node->setPosition( pos ) which is where it seems to be failing. It must have something to do with assigning and using the same reference, but i'm not completely sure.
I'd be interested to know if you were doing it the same way.
To fix this all I ended up doing is this.
Ogre::Vector3 initialPos = ent->getParentNode( )->getPosition( );
And I passed in initialPos instead of the call to getPosition( ) and then it seemed to work fine.
julio
07-06-2008 20:38:58
Yes, I was doing the same, passing the reference...
And, yes, the bug is because inside OgreBullet, a new scene node is created, and when it is attached the object it resets the parent scene node (the one you have passed) to the position that the object has, which is zero...
Anyway, until it is fixed, your solution is simpler