Moving physic objects to specific pos
5 posters
Moving physic objects to specific pos
I need to move a physic object to a specific position in my level. The problem is that there is object blocking a straight way, so setting the line velocity is hard but not impossible. Is there any way to set the x, y and z pos of a physic object and send it to bullet? I have tried this:
- Code:
_SIO2object->_SIO2transform->loc->x = a random number;
_SIO2object->_SIO2transform->loc->y = one more random;
_SIO2object->_SIO2transform->loc->z = 5;
sio2TransformBindMatrix(bots[i].botObj->_SIO2transform);
btMatrix3x3 mat3;
mat3.setFromOpenGLSubMatrix( (btScalar *)bots[i].botObj->_SIO2transform->mat );
bots[i].botObj->_btRigidBody->getWorldTransform().setBasis( mat3 );
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: Moving physic objects to specific pos
Use this:
_SIO2object->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );
_SIO2object->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: Moving physic objects to specific pos
does the line
_SIO2object->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );
go after sio2ObjectRender or should it be called after the transforms??
oh, and is it correct to call sio2PhysicPause before the transforms and sio2PhysicPlay right after sio2TransformApply ?
Thanks
_SIO2object->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );
go after sio2ObjectRender or should it be called after the transforms??
oh, and is it correct to call sio2PhysicPause before the transforms and sio2PhysicPlay right after sio2TransformApply ?
Thanks
sctm81- Posts : 29
Join date : 2009-04-24
Re: Moving physic objects to specific pos
sctm81 wrote:does the line
_SIO2object->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );
go after sio2ObjectRender or should it be called after the transforms??
oh, and is it correct to call sio2PhysicPause before the transforms and sio2PhysicPlay right after sio2TransformApply ?
Thanks
What doing this functions sio2PhysicPlay, sio2PhysicPause ?
If i add physics for my object but not run sio2PhysicPlay then my object not access physics?
Re: Moving physic objects to specific pos
You got it... you need to call sio2PhysicPlay in order to let Bullet take over...
Re: Moving physic objects to specific pos
Hi, All,
May I ask actually which specific postion has the above code moved the object to?
If I am not wrong, _SIO2object->_SIO2transform->mat should be a pointer to float. So can you please give some more complete codes?
And another question: what if the _SIO2object is originally set as stactic, such as the plane, and later I want to move it to a specific position?
Thanks and Regards,
djjd
May I ask actually which specific postion has the above code moved the object to?
If I am not wrong, _SIO2object->_SIO2transform->mat should be a pointer to float. So can you please give some more complete codes?
And another question: what if the _SIO2object is originally set as stactic, such as the plane, and later I want to move it to a specific position?
Thanks and Regards,
djjd
djjd- Posts : 3
Join date : 2009-06-22
Re: Moving physic objects to specific pos
Hi, All,
I tried the following code. It seems working.
_SIO2object->_SIO2transform->loc->x = a;
_SIO2object->_SIO2transform->loc->y = b;
_SIO2object->_SIO2transform->loc->z = c;
sio2TransformBindMatrix(_SIO2object->_SIO2transform);
_SIO2object->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );
Thanks and Regards,
djjd
I tried the following code. It seems working.
_SIO2object->_SIO2transform->loc->x = a;
_SIO2object->_SIO2transform->loc->y = b;
_SIO2object->_SIO2transform->loc->z = c;
sio2TransformBindMatrix(_SIO2object->_SIO2transform);
_SIO2object->_btRigidBody->getWorldTransform().setFromOpenGLMatrix( _SIO2object->_SIO2transform->mat );
Thanks and Regards,
djjd
djjd- Posts : 3
Join date : 2009-06-22
Re: Moving physic objects to specific pos
that's right and like that when you call sio2PhysicResetAll the physic body will be placed back to its original position... this is the best way to manipulate objects with physic.
Similar topics
» Moving an Object before physic
» Physic objects - ghost, invisible...
» picking and moving 3d objects
» number of moving physics objects
» duplicating objects at runtime and changing textures on the duplicated objects
» Physic objects - ghost, invisible...
» picking and moving 3d objects
» number of moving physics objects
» duplicating objects at runtime and changing textures on the duplicated objects
Permissions in this forum:
You cannot reply to topics in this forum