Reposition a static physics object
4 posters
Reposition a static physics object
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)...
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
Re: Reposition a static physics object
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 );
why only scale?
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
Re: Reposition a static physics object
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
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
Similar topics
» physics object inside another physics object
» Static Camera to follow an Object
» Static Objects
» Passing Through Static Object (Beating my iPod seems to help)
» rotate a physics object?
» Static Camera to follow an Object
» Static Objects
» Passing Through Static Object (Beating my iPod seems to help)
» rotate a physics object?
Permissions in this forum:
You cannot reply to topics in this forum