Moving physic objects to specific pos

View previous topic View next topic Go down

Moving physic objects to specific pos

Post  oioioi on Tue Apr 21, 2009 1:29 pm

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 );
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

View user profile

Back to top Go down

Re: Moving physic objects to specific pos

Post  sio2interactive on Tue Apr 21, 2009 3:26 pm

Use this:

_SIO2object->_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: Moving physic objects to specific pos

Post  oioioi on Wed Apr 22, 2009 4:58 am

Thanks!

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

View user profile

Back to top Go down

Re: Moving physic objects to specific pos

Post  sctm81 on Tue May 19, 2009 2:34 am

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

sctm81

Posts : 29
Join date : 2009-04-24

View user profile

Back to top Go down

Re: Moving physic objects to specific pos

Post  sakrist on Tue May 19, 2009 6:19 am

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?
avatar
sakrist

Posts : 23
Join date : 2009-04-28
Age : 29

View user profile http://www.developers-life.com

Back to top Go down

Re: Moving physic objects to specific pos

Post  sio2interactive on Tue May 19, 2009 2:13 pm

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
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: Moving physic objects to specific pos

Post  djjd on Mon Jun 22, 2009 2:43 am

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

djjd

Posts : 3
Join date : 2009-06-22

View user profile

Back to top Go down

Re: Moving physic objects to specific pos

Post  djjd on Mon Jun 22, 2009 4:01 am

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

djjd

Posts : 3
Join date : 2009-06-22

View user profile

Back to top Go down

Re: Moving physic objects to specific pos

Post  sio2interactive on Mon Jun 22, 2009 4:24 am

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
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: Moving physic objects to specific pos

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