Weird btCompoundshape problem... :( [ HELP ]

Post Reply
johnsonalpha
Posts: 73
Joined: Fri May 01, 2015 8:23 pm

Weird btCompoundshape problem... :( [ HELP ]

Post by johnsonalpha »

this is my code so far what im trying to do is get the compound shapes child transforms to update but it doesn't work... im not sure what to put g1->updateChildTransform(z, /* what transform from what goes here i tried g1->getChildTransform(z) but it doesn't move at all when i do that */ );

Code: Select all

for (int z = 0; z < comcounter; z++)  {

btTransform asdf;
asdf.setIdentity();//important

btTransform ctrans = g1->getChildTransform(z);

//what am i doing wrong here i dont understand! its makes no sense please help!
g1->updateChildTransform(z, g1->getChildTransform(z) );

}
aviator
Posts: 13
Joined: Thu Apr 02, 2015 5:15 pm

Re: Weird btCompoundshape problem... :( [ HELP ]

Post by aviator »

johnsonalpha wrote:this is my code so far what im trying to do is get the compound shapes child transforms to update but it doesn't work... im not sure what to put g1->updateChildTransform(z, /* what transform from what goes here i tried g1->getChildTransform(z) but it doesn't move at all when i do that */ );

Code: Select all

for (int z = 0; z < comcounter; z++)  {

btTransform asdf;
asdf.setIdentity();//important

btTransform ctrans = g1->getChildTransform(z);

//what am i doing wrong here i dont understand! its makes no sense please help!
g1->updateChildTransform(z, g1->getChildTransform(z) );

}
This could be because getChildTransform returns the local transformation matrix of the child object relative to its parent, the local transformation won't change unless you force to change it, so basically you need to get the parent transformation matrix, and calculate from the parents location matrix (with a use of previously calculated offset matrix for a child shape) new child shapes global position.
aviator
Posts: 13
Joined: Thu Apr 02, 2015 5:15 pm

Re: Weird btCompoundshape problem... :( [ HELP ]

Post by aviator »

To add a little bit more information for my previous post:

All offset matrices should be always calculated at programs start up/initialize method, also the local transformation matrix should be build.
So to calculate the offset-matrix for the child shape we do this:
void initialize()
{
Child shape offset matrix = child shape local transformation with respect to parent ( not world transformation) * inverse parent transformation matrix
}

Then at update we would do just simply
void update()
{
Child global position matrix = parent transformation matrix * child shape offset matrix
}
Post Reply