FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Moving physic objects to specific pos

5 posters

Go down

Moving physic objects to specific pos Empty Moving physic objects to specific pos

Post  oioioi 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

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  sio2interactive Tue Apr 21, 2009 3:26 pm

Use this:

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

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

http://sio2interactive.com

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  oioioi Wed Apr 22, 2009 4:58 am

Thanks!

oioioi

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

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  sctm81 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

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

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

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

http://www.developers-life.com

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  sio2interactive Tue May 19, 2009 2:13 pm

You got it... you need to call sio2PhysicPlay in order to let Bullet take over...
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  djjd 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

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  djjd 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

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  sio2interactive 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.
sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Moving physic objects to specific pos Empty Re: Moving physic objects to specific pos

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


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