目录
物理引擎系统-ode
一、物理引擎系统-ode——dBodySetAngularVel
二、物理引擎系统-ode——dBodySetMass
三、物理引擎系统-ode——dBodyGetMass
四、物理引擎系统-ode——dBodyAddForce
五、物理引擎系统-ode——dBodyAddTorque
六、物理引擎系统-ode——dBodyAddRelForce
void dBodySetAngularVel (dBodyID b, dReal x, dReal y, dReal z)
{
dAASSERT (b);
b->avel[0] = x;
b->avel[1] = y;
b->avel[2] = z;
}
const dReal * dBodyGetPosition (dBodyID b)
{
dAASSERT (b);
return b->pos;
}
const dReal * dBodyGetRotation (dBodyID b)
{
dAASSERT (b);
return b->R;
}
const dReal * dBodyGetQuaternion (dBodyID b)
{
dAASSERT (b);
return b->q;
}
const dReal * dBodyGetLinearVel (dBodyID b)
{
dAASSERT (b);
return b->lvel;
}
const dReal * dBodyGetAngularVel (dBodyID b)
{
dAASSERT (b);
return b->avel;
}
void dBodySetMass (dBodyID b, const dMass *mass)
{
dAASSERT (b && mass);
memcpy (&b->mass,mass,sizeof(dMass));
if (dInvertPDMatrix (b->mass.I,b->invI,3)==0) {
dDEBUGMSG ("inertia must be positive definite");
dRSetIdentity (b->invI);
}
b->invMass = dRecip(b->mass.mass);
}
void dBodyGetMass (dBodyID b, dMass *mass)
{
dAASSERT (b && mass);
memcpy (mass,&b->mass,sizeof(dMass));
}
void dBodyAddForce (dBodyID b, dReal fx, dReal fy, dReal fz)
{
dAASSERT (b);
b->facc[0] += fx;
b->facc[1] += fy;
b->facc[2] += fz;
}
void dBodyAddTorque (dBodyID b, dReal fx, dReal fy, dReal fz)
{
dAASSERT (b);
b->tacc[0] += fx;
b->tacc[1] += fy;
b->tacc[2] += fz;
}
void dBodyAddRelForce (dBodyID b, dReal fx, dReal fy, dReal fz)
{
dAASSERT (b);
dVector3 t1,t2;
t1[0] = fx;
t1[1] = fy;
t1[2] = fz;
t1[3] = 0;
dMULTIPLY0_331 (t2,b->R,t1);
b->facc[0] += t2[0];
b->facc[1] += t2[1];
b->facc[2] += t2[2];
}