Moving physic objects to specific pos
Page 1 of 1 • Share •
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:
but the object is still in the same pos. And another problem is that the object often becomes invisible after this(disappears from the screen) and I have to move the camera around for a while before I can see it again, there is definitely some thing wrong with the resource culling for me.
- 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 );
but the object is still in the same pos. And another problem is that the object often becomes invisible after this(disappears from the screen) and I have to move the camera around for a while before I can see it again, there is definitely some thing wrong with the resource culling for me.
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 );
_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

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

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?

sakrist- Posts: 23
Join date: 2009-04-28
Age: 25

Re: Moving physic objects to specific pos
You got it... you need to call sio2PhysicPlay in order to let Bullet take over...
_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

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

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.
_________________
SIO2 Interactive
Free Open Source 3D Game Engine for iPhone and iPod Touch
http://sio2interactive.com

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

Similar topics» We are moving .... AGAIN!
» Moving back to Oz
» MUST READ :FMU IS MOVING ON ..
» Moving the Site
» [A-2034] Moving from 32-bit to 64-bit
» Moving back to Oz
» MUST READ :FMU IS MOVING ON ..
» Moving the Site
» [A-2034] Moving from 32-bit to 64-bit
Permissions in this forum:
You cannot reply to topics in this forum