here is my code:
this is the initalize part:
- Code: Select all
static NewtonWorld* ntWorld;
static NewtonBody* ribidBodyBox;
ntWorld=NewtonCreate(NULL, NULL);
NewtonCollision* collision;
boxSize=1.0f;
collision = NewtonCreateBox (ntWorld, boxSize,boxSize ,boxSize , NULL);
ribidBodyBox=NewtonCreateBody(ntWorld,collision);
NewtonBodySetUserData(ribidBodyBox,bx);
NewtonBodySetAutoFreeze (ribidBodyBox, 0);
NewtonWorldUnfreezeBody (ntWorld, ribidBodyBox);
//NewtonBodySetTransformCallback(
NewtonBodySetForceAndTorqueCallback (ribidBodyBox, PhysicsApplyForceAndTorque);
NewtonReleaseCollision (ntWorld, collision);
the PhysicsApplyForceAndTorque callback
- Code: Select all
void PhysicsApplyForceAndTorque (const NewtonBody* body)
{
dFloat Ixx;
dFloat Iyy;
dFloat Izz;
dFloat mass;
NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
Vector3 force (0.0f, -mass * 9.8f, 0.0f);
NewtonBodySetForce (body, &force.y);
}
and i already have a NewtonUpdate(ntWorld,a); function added in the code at the drawscene loop,
I use this code to test X,Y,Z Pos
NewtonBodyGetMatrix(ribidBodyBox,&bxMatrix[0][0]);
Vector3 pos(bxMatrix[0][3],bxMatrix[1][3],bxMatrix[2][3]);
after i saw printf list ,the value list are just 0,0,0, what is going on? am i doing something wrong?
