Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following situation: I've got a box with its center of mass transform matrix that I'm obtaining from physics simulation, i.e. it keeps changing with time. I've also got two points (actually two transformation matrices) which are static (the simulation doesn't calculate them, neither do I want it to) that I want to 'keep in sync' with the original state (t=0 in the picture).

enter image description here

Any ideas how do I calculate the other two matrices when the center of mass changes, while keeping their original offsets satisfied?

I'm using jBullet for physics.

share|improve this question
up vote 0 down vote accepted

As long as the transformation applied to the center of mass is only composed of rotation and translation (given that it comes from a physics simulation that should be true), that same transformation applied to your two non-simulated points will put them in the same relative position at t = 0.25 as they were in at t = 0.

Most physics engines provide a way for you to get the world transform of a given body's center of mass, either in matrix form or as separate translation and rotation components. For jBullet, that would be the getCenterOfMassTransform function.

Construct two Transform objects for both of your non-simulated points in their original position. Then use the mul method of Transform to multiply your non-simulated point transforms by the rigid body's transformation to bring your non-simulated points into the same relative orientation and position as the new center of mass.

share|improve this answer
    
That's pretty much what I've been doing, but it doesn't quite work as expected. First, I get the center of mass, then I multiply the world bind matrix (those non-simulated points are actually part of my skeleton) by it. Do you think that the fact of the points being actually bones changes the equations? – Pateman Oct 31 at 19:15
    
It is possible, yes. Your diagram suggests the two points are in the same coordinate space as the model-space center-of-mass, but if they're bones they may be in some slightly different space you'd need to account for (bringing them into the COM model-space) first. :\ – Josh Petrie Oct 31 at 19:34
    
I thought so, but it's strange because I'm passing the world bind matrix into the calculations... I'll accept your answer, because you pretty much confirmed my original assumptions. I need to figure out the rest. Thank you :) – Pateman Oct 31 at 19:40
    
Try making one of these points essentially the same as the COM, for testing, and then follow it through the transformations. That can help illustrate when exactly things go off the rails. – Josh Petrie Oct 31 at 19:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.