Connected draw object with transform Callback

Raphael_Bartolome
Posts: 6
Joined: Mon Jun 04, 2007 1:00 pm

Connected draw object with transform Callback

Post by Raphael_Bartolome »

hi, i have another question, I do not understand how can I make a connection between my drawable object and the rigidbody.
What I would like to know, is their a value where i could store the object pointer, and if bullet will transform the rigidbody, then it will call a function where i could set the transform matrix to the drawable object.

We are testing bullet with our particle reconstruction system, at the moment we are using newton game dynamics, and in this library we have only to define a callback that will transfer the pointer from the drawable object and the transform matrix.

I couldn´t found a example in the demos, or I haven´t understand it.

regards,
raphael

P.S. I hope my english isn´t so bad
Last edited by Raphael_Bartolome on Tue Jun 05, 2007 9:11 am, edited 1 time in total.
Raphael_Bartolome
Posts: 6
Joined: Mon Jun 04, 2007 1:00 pm

Post by Raphael_Bartolome »

Ok, i have now the user pointer defined inside the rigidbody, but now I need a notification to know when the object need to be transformed, and in which manner.

regards,
raphael
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

You can derive your own motionstate class from btMotionState, and pass that into the btRigidBody constructor. Then make sure to implement the setWorldTransform and getWorldTransform. This can be used as callback.

Alternatively, you have to iterate through all objects, and update the world transform every frame. You can check if an object is inactive (sleeping) to avoid synchronizing the worldtransform.

Convex Hull can be created using btConvexHull shape. It is best to check the Bullet demos for functionality.
Hope this helps,
Erwin
Raphael_Bartolome
Posts: 6
Joined: Mon Jun 04, 2007 1:00 pm

Post by Raphael_Bartolome »

hi,
thank you for your reply.
That helps me a lot, but I didn´t understand, how can I access my Draw Object, which I have set in the rigid body with the user pointer var?
If i make a subclass from the btMotion class, I have to rewrite my draw object, that is written in objective-c.

Thanks alot and regards,
Raphael
Raphael_Bartolome
Posts: 6
Joined: Mon Jun 04, 2007 1:00 pm

Post by Raphael_Bartolome »

Hi, I have choose the loop alternative for startup,
until I have more experience with Bullet.
My problem now is, that my rigidbody move in the wronge way.
I position some bodys, and let them fall down.
The y value inside the transform matrix is increase, instead decrease...
I have take a code snipe from a demo application:

Code: Select all

if (body && body->getMotionState())
			{
				btDefaultMotionState* myMotionState = (btDefaultMotionState*)body->getMotionState();
				myMotionState->m_graphicsWorldTrans.getOpenGLMatrix(m);
			} else
			{
				colObj->getWorldTransform().getOpenGLMatrix(m);
			}

thanks for a replay,
Raphael
lolo
Posts: 4
Joined: Wed May 09, 2007 1:37 pm
Location: Brest, France

Post by lolo »

Hi,

I find this a bit strange because your snippet seems to be good.
Perhaps you can verify these points :
- orientation of the gravity in the world
- axis in physical world are equal to these of the graphical world ?
- axis in physical object are equal to these of the graphical object ?

I hope it will help you,
Laurent