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.

Reposition a static physics object

4 posters

Go down

Reposition a static physics object Empty Reposition a static physics object

Post  jj Fri Nov 14, 2008 3:18 pm

Hi,

I am attempting to reposition an existing static physic object inside the world from its original x,y,z position.

What is the best implementation of this? Is this possible?

My visible objects render in the new location OK, but collisions happen in the original coords (where the object used to be)...

jj

Posts : 77
Join date : 2008-09-24

Back to top Go down

Reposition a static physics object Empty Re: Reposition a static physics object

Post  sio2interactive Sat Nov 15, 2008 4:15 pm

It is definitely possible, however you need to understand that what you render and what is sent to Bullet for collision is 2 different things. You have to make sure that both coordinate of your object & physic object match at all time for a static object its a bit less trivial than for dynamic/rigid object. You can do it like that (check sio2_physic.cc -> addRigidBody for more info)

Code:


   memcpy( m, _SIO2object->mat, 64 );
   
   m[  0 ] /= _SIO2object->scl->x;
   m[  1 ] /= _SIO2object->scl->x;
   m[  2 ] /= _SIO2object->scl->x;

   m[  4 ] /= _SIO2object->scl->y;
   m[  5 ] /= _SIO2object->scl->y;
   m[  6 ] /= _SIO2object->scl->y;
   
   m[  8 ] /= _SIO2object->scl->z;
   m[  9 ] /= _SIO2object->scl->z;
   m[ 10 ] /= _SIO2object->scl->z;
   
   _btTransform.setFromOpenGLMatrix( ( btScalar * )m );

   _btDefaultMotionState = new btDefaultMotionState( _btTransform );

sio2interactive
sio2interactive

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

http://sio2interactive.com

Back to top Go down

Reposition a static physics object Empty why only scale?

Post  freakTheMighty Tue Apr 07, 2009 4:00 pm

In the example code it looks like you copy the objects matrix into m. Then you copy the objects scale values into the first 9 values of the matrix. Why can't you just pass that object's matrix directly into _btTransform? And why do you only manipulate the scale?

freakTheMighty

Posts : 12
Join date : 2009-03-05

Back to top Go down

Reposition a static physics object Empty Re: Reposition a static physics object

Post  Fish Tue Jun 23, 2009 9:36 am

Hi, a bump to this thread....

I am also trying to move a static physics object and have encountered the same problem (ie- the object visually moves but the collision doesn't.)

Does anyone have sample code to do this?

Much appreciated!
Fish

Fish

Posts : 9
Join date : 2009-04-30

Back to top Go down

Reposition a static physics object Empty Re: Reposition a static physics object

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

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