Moderators: Sascha Willems, walaber
Overhertz wrote:So if possible to create a newton body like usual, disable the simulation of this object but not the collision callback, this way I can check how much objects intersect and can add forces and damage as necessary. I think this will give the most realistic simulation. So nothing in the newtonworld should react with this object, but it still should callback that it is intersecting/colliding with another object/body
NewtonBody* CreateSimpleBody (NewtonWorld* const world, void* const userData, dFloat mass, const dMatrix& matrix, NewtonCollision* const collision, int materialId)
{
//create the rigid body
NewtonBody* const rigidBody = NewtonCreateDynamicBody (world, collision, &matrix[0][0]);
// old method obsolete
//dVector origin;
//dVector inertia;
//NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);
//dFloat Ixx = mass * inertia[0];
//dFloat Iyy = mass * inertia[1];
//dFloat Izz = mass * inertia[2];
//NewtonBodySetCentreOfMass (rigidBody, &origin[0]);
//NewtonBodySetMassMatrix (rigidBody, mass, Ixx, Iyy, Izz);
// use a more convenient function for setting mass and inertia matrix
NewtonBodySetMassProperties (rigidBody, mass, collision);
// save the pointer to the graphic object with the body.
NewtonBodySetUserData (rigidBody, userData);
// assign the wood id
NewtonBodySetMaterialGroupID (rigidBody, materialId);
// set continue collision mode
// NewtonBodySetContinuousCollisionMode (rigidBody, continueCollisionMode);
// set a destructor for this rigid body
NewtonBodySetDestructorCallback (rigidBody, PhysicsBodyDestructor);
// set the transform call back function
NewtonBodySetTransformCallback (rigidBody, DemoEntity::TransformCallback);
// set the force and torque call back function
NewtonBodySetForceAndTorqueCallback (rigidBody, PhysicsApplyGravityForce);
return rigidBody;
}
Overhertz wrote:Edit: Maybe it is problem now with my terrain class since NewtonCreateBody is now Dynamic body ? Or is this still fine?
Users browsing this forum: No registered users and 0 guests