Resetting object position

View previous topic View next topic Go down

Resetting object position

Post  CadetCrusher on Sun Oct 18, 2009 3:01 pm

What is the best way to reset an object's position? For example, when a ball goes out of the play area I'd like to move it back to it's starting position. I've tried setting the _SIO2transform->loc vector of the object then calling sio2TransformBindMatrix(), but that doesn't work. The object is a physics object, BTW.

CadetCrusher

Posts : 21
Join date : 2009-10-07

View user profile

Back to top Go down

Re: Resetting object position

Post  CadetCrusher on Sun Oct 18, 2009 3:10 pm

Ok, so I can now reset the object's position, but the physics simulation won't re-enable. Here's what I'm doing:

Code:

theBall->_SIO2objectphysic->_btRigidBody->setActivationState(DISABLE_SIMULATION);
         
theBall->_SIO2transform->loc->y = -7.967f;
theBall->_SIO2transform->loc->x = 21.383f;
theBall->_SIO2transform->loc->z = 0.598f;
sio2TransformBindMatrix(theBall->_SIO2transform);
         
theBall->_SIO2objectphysic->_btRigidBody->setActivationState(ACTIVE_TAG);

Am I disabling/enabling physics incorrectly?

Thanks!

CadetCrusher

Posts : 21
Join date : 2009-10-07

View user profile

Back to top Go down

Re: Resetting object position

Post  sio2interactive on Sun Oct 18, 2009 3:44 pm

_SIO2object->_SIO2objectphysic->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );

_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com
avatar
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 38
Location : Shanghai

View user profile http://sio2interactive.com

Back to top Go down

Re: Resetting object position

Post  CadetCrusher on Sun Oct 18, 2009 9:15 pm

Works great! Thanks. Very Happy

CadetCrusher

Posts : 21
Join date : 2009-10-07

View user profile

Back to top Go down

Re: Resetting object position

Post  Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum