[ODE] newbie joint question

Piotr Obrzut piotr_obrzut at o2.pl
Sun Dec 5 23:15:07 MST 2004


Hi Piotr,

W Twoim liœcie datowanym 3 grudnia 2004 (14:33:05) mo¿na przeczytaæ:

PO> Hi,

DL>> I'm not sure what you are asking, but if you are using Cal3D to draw your
DL>> model and you are setting the bone rotations manually (taken from ODE rigid
DL>> body positions) then make sure you call calculateState() for each bone that
DL>> you modify, it would look something like this:
pBone->>>setRotation ( pBone->getRotation() * DeltaQuat );

pBone->>>calculateState();

PO> actualy this is the way by which i'm updating Cal3d model pos (it is
PO> writien with use of CrystalSpace interface on ODE, but i think that
PO> the idea is clear enough, it looks quite nice only for geting bodies
PO> positions and aplaing them to the Cal3d model)

PO>   CalSkeleton* skeleton = cal_model->getSkeleton ();
PO>   std::vector<CalBone*> bone_vect = skeleton->getVectorBone ();

PO>   bone_vect[0]->setRotation (get_cal_quaternion
PO> (bodies[0]->GetOrientation ()));
PO>   csVector3 vec = bodies[0]->GetPosition ();
PO>   bone_vect[0]->setTranslation (CalVector (vec [0], vec[1], vec[2]));

PO>   for (unsigned int i = 1; i < bodies.size (); i++)
PO>   {
PO>     int p_id = bone_vect[i]->getCoreBone ()->getParentId ();
PO>     csReversibleTransform trans = bodies[i]->GetTransform ()
PO> / bodies[p_id]->GetTransform ();
PO>     bones[i]->setRotation (get_cal_quaternion (trans.GetO2T ()));
PO>     csVector3 vect = trans.GetO2TTranslation (); 
PO>     bones[i]->setTranslation (CalVector (vect[0], vect[1], vect [2]));
PO>   }

PO>   skeleton->calculateState ();

PO> The problem is in joints between mentioned ODE bodies and this is
PO> the way i'm making joints:

PO>   for (unsigned int i = 0; i < bodies.size (); i++)
PO>   {
PO>     std::string name = bones[i]->getCoreBone ()->getName ();

PO>     CalCoreBone* cbone = bones[i]->getCoreBone ();
PO>     std::list<int> ch_list = cbone->getListChildId ();
    
PO>     for (std::list<int>::iterator ch_it = ch_list.begin ();
PO> ch_it != ch_list.end (); ch_it++)
PO>     {
PO>       csRef<iJoint> joint = dyn_sys->CreateJoint ();
PO>       joint->SetTransConstraints (1, 1, 1);
PO>       joint->SetRotConstraints (0,0,0);
PO>       joint->SetTransform (csReversibleTransform ()); //0 transform
PO>       joint->Attach (bodies[i], bodies[*ch_it]);
      
PO>       /*here CrystalSpace is making ODE joint like this:
      
PO>         jointID = dJointCreateBall (dynsys->GetWorldID(), 0);
PO>           dJointAttach (jointID, bodyID[0], bodyID[1]);
PO>         pos = transform.GetOrigin();
PO>         dJointSetBallAnchor (jointID, pos.x, pos.y, pos.z);

PO>         it is a ball joint b/c its translation is all constrainted and
PO>         its rotation is not
PO>       */
PO>     }
PO>   }

PO> and after   bodies[2]->AddForce (csVector3 (0,20,0)) Caly model
PO> looks like that: http://mathrick.org/files/joint_error.JPG


is mine problem still ambiguous?

-- 
greetings,
 Piotr Obrzut



More information about the ODE mailing list