This has been asked before, but I didn't find what I was looking for in the previous discussions.
I'm working on a spaceflight simulator, and I need to assemble stages of a rocket, and then "let them go" one by one. So, I need to join 2 objects together with a RIGID link (absolutely no degrees of freedom, as if whey were welded). Later, I need to destroy the link and let objects separate. What's the best way of doing this?
I tried a CustomHinge joint:
- Code: Select all
dMatrix mChildMatrix = dGetIdentityMatrix();
mChildMatrix.m_posit = entChild->m_curPosition;
hinge = new CustomHinge (mChildMatrix, entChild->nBody, entParent->nBody);
hinge->EnableLimits(true);
hinge->SetLimits(0.0,0.0);
printf("Objects connected\n");
However, the joint is unstable. I have a time-compression feature in my sim and when I speed up the sim rate, there is a lot of wobble in a supposedly rigid joint.
I also thought of constructing a compound collision:
- Code: Select all
NewtonCollision* object[2];
NewtonCollision* compound;
object[0] = NewtonBodyGetCollision (entParent->nBody);
object[1] = NewtonBodyGetCollision (entChild->nBody);
// make a compound collision
compound = NewtonCreateCompoundCollision (g_world, 0);
NewtonCompoundCollisionBeginAddRemove (compound);
NewtonCompoundCollisionAddSubCollision (compound, object[0]);
NewtonCompoundCollisionAddSubCollision (compound, object[1]);
NewtonCompoundCollisionEndAddRemove (compound);
for (int i = 0; i < int (sizeof (object) / sizeof (object[0])); i ++) {
NewtonDestroyCollision(object[i]);
}
NewtonBodySetCollision (entParent->nBody, compound);
printf("Objects 0 and 1 connected through compound collision\n");
but with this approach, I am not getting objects linked at all. I am not sure if I am doing this correctly... any thoughts?
Misho