Moving Platforms

GLPhysx
Posts: 14
Joined: Sat Nov 28, 2009 11:28 pm

Moving Platforms

Post by GLPhysx »

Hi!

I am basically doing the same problem as:

http://bulletphysics.org/Bullet/phpBB3/ ... &view=next

Basically Im using:

m_btRigidBody->getWorldTransform().setFromOpenGLMatrix( matrix );

to move the platform, which work great...

However whatever objects is on that platform doesn't move I double check that there is some friction on both object (the platform and let's say a cube) and there is...

The solution in the thread linked above doesn't work for me, as I suppose that there's no velocity since Im moving it manually, so my question is:

What is the proper way to move the platform in order to make the object(s) on top of it being affect by the platform movement, assuming that Im recalculating the transformation matrix of that platform every frame?
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Moving Platforms

Post by sparkprime »

You can set the velocity of static bodies of course. This can give you a 'conveyor' effect because dynamic bodies are moved along it even though it's not necessarily moving itself. I've used this to create spinning things before.
GLPhysx
Posts: 14
Joined: Sat Nov 28, 2009 11:28 pm

Re: Moving Platforms

Post by GLPhysx »

Allright fair enough... but how can I calculate the angular and linear velocity of 2 matrix... That's the part that puzzle me...

Basically Im interpolating using a bezier curve my translation XYZ (for now as test but later on angle XYZ as well) the final result is a 4x4 matrix... I have no clue how to make Bullet calculate the velocity from there... can't use setLinearVelocity or setAngularVelocity that's for sure ;)

Im really stuck at this point... any help would be great...

Maybe you can post your "conveyor" code, at least it would get me started with something new... cuz right now Im turning in circle ;)

TIA!
GLPhysx
Posts: 14
Joined: Sat Nov 28, 2009 11:28 pm

Re: Moving Platforms

Post by GLPhysx »

hO! wait a second... reading another time what you write, I know what you mean... What I want is the static object to translate taking along whatever objects is on it...

Basically what Im trying to reproduce is the same as in kinematic.blend

http://download.blender.org/demo/test/e ... view34.zip

I know its possible since Blender is using Bullet too ;)

I dig in the Blender source code, but nada...

Someone please help!
josemarin
Posts: 38
Joined: Fri Aug 12, 2005 5:37 pm

Re: Moving Platforms

Post by josemarin »

Hi,

Could moving platforms be implemented using joints?

I need that a platform (a simple box) move from point A to B and then back to A, then restart, at a certain velocity.

Other moviments are like pistons.

Thanks

Jose
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Moving Platforms

Post by sparkprime »

GL: it may be that kinematic objects are already doing this setting of the velocity actually, so you should look into that. Otherwise if you want to derive velocity from position updates, you just need to subtract and divide by the timestep. There is an equivalent operation on quaternions that would give you the rotational velocity (essentially it is a rotation change per second, which is just a rotation).
GLPhysx
Posts: 14
Joined: Sat Nov 28, 2009 11:28 pm

Re: Moving Platforms

Post by GLPhysx »

Ok well, kinda find it after try and error... using a kinematic object...

Seems that it work with simply affecting the matrix of the motion state:

btDefaultMotionState *_btDefaultMotionState = ( btDefaultMotionState * )m_btRigidBody->getMotionState();

btTransform xform = _btDefaultMotionState->m_graphicsWorldTrans;

...
...
...
_btDefaultMotionState->setWorldTransform( xform );

However is this enough? or should I also call:

m_btRigidBody->setCenterOfMassTransform
m_btRigidBody->setInterpolationLinearVelocity
m_btRigidBody->setInterpolationAngularVelocity
m_btRigidBody->updateInertiaTensor();

My guts tell me I should but however I am not seeing any difference if I call it or not... any advise would help!

Cheers!
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Moving Platforms

Post by sparkprime »

I've not use kinematic objects but at a guess I'd say you don't have to do anything more than update the motion state