VALUE MSNewton::Bodies::get_force_in_between(VALUE self, VALUE v_body1, VALUE v_body2) { const NewtonBody* body1 = Util::value_to_body(v_body1); const NewtonBody* body2 = Util::value_to_body(v_body2); Util::validate_two_bodies(body1, body2); dVector net_force(0.0f, 0.0f, 0.0f); for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(body1); joint; joint = NewtonBodyGetNextContactJoint(body1, joint)) { if (NewtonJointGetBody0(joint) == body2 || NewtonJointGetBody1(joint) == body2) { for (void* contact = NewtonContactJointGetFirstContact(joint); contact; contact = NewtonContactJointGetNextContact(joint, contact)) { NewtonMaterial* material = NewtonContactGetMaterial(contact); dVector force; NewtonMaterialGetContactForce(material, body1, &force[0]); net_force += force; } } } const NewtonWorld* world = NewtonBodyGetWorld(body1); WorldData* world_data = (WorldData*)NewtonWorldGetUserData(world); //BodyData* body1_data = (BodyData*)NewtonBodyGetUserData(body1); //BodyData* body2_data = (BodyData*)NewtonBodyGetUserData(body2); /*if (world_data->gravity_enabled && (body1_data->gravity_enabled || body2_data->gravity_enabled)) { for (int i = 0; i < 3; ++i) net_force[i] *= world_data->inverse_scale; }*/ return Util::vector_to_value(net_force, world_data->inverse_scale4); }
void GetForceOnStaticBody (NewtonBody* body, NewtonBody* staticBody) { for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint (body); joint; joint = NewtonBodyGetNextContactJoint (body, joint)) { NewtonBody* body0; NewtonBody* body1; body0 = NewtonJointGetBody0(joint); body1 = NewtonJointGetBody1(joint); if ((body0 == staticBody) || (body1 == staticBody)) { for (void* contact = NewtonContactJointGetFirstContact (joint); contact; contact = NewtonContactJointGetNextContact (joint, contact)) { float forceMag; dVector point; dVector normal; NewtonMaterial* material; material = NewtonContactGetMaterial (contact); NewtonMaterialGetContactForce (material, &forceMag); NewtonMaterialGetContactPositionAndNormal (material, &point.m_x, &normal.m_x); dVector force (normal.Scale (-forceMag)); // do wherever you want withteh force } } } }
static void GetCollisionSubShape(const NewtonJoint* const contactJoint, NewtonBody* const body) { NewtonCollisionInfoRecord collisionInfo; NewtonCollision* const collision = NewtonBodyGetCollision(body); NewtonCollisionGetInfo (collision, &collisionInfo); int count = 0; NewtonCollision* collidingSubShapeArrar[32]; // see if this is a compound collision or any other collision with sub collision shapes if (collisionInfo.m_collisionType == SERIALIZE_ID_COMPOUND) { // to get the torque we need the center of gravity in global space dVector origin; dMatrix bodyMatrix; NewtonBodyGetMatrix(body, &bodyMatrix[0][0]); NewtonBodyGetCentreOfMass(body, &origin[0]); origin = bodyMatrix.TransformVector(origin); for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) { // get the material of this contact, // this part contain all contact information, the sub colliding shape, NewtonMaterial* const material = NewtonContactGetMaterial (contact); NewtonCollision* const subShape = NewtonMaterialGetBodyCollidingShape (material, body); int i = count - 1; for (; i >= 0; i --) { if (collidingSubShapeArrar[i] == subShape) { break; } } if (i < 0) { collidingSubShapeArrar[count] = subShape; count ++; dAssert (count < int (sizeof (collidingSubShapeArrar) / sizeof (collidingSubShapeArrar[0]))); // you can also get the forces here, however when tho function is call form a contact material // we can only get resting forces, impulsive forces can not be read here since they has no being calculated yet. // whoever if this function function is call after the NetwonUpdate they the application can read the contact force, that was applied to each contact point dVector force; dVector posit; dVector normal; NewtonMaterialGetContactForce (material, body, &force[0]); NewtonMaterialGetContactPositionAndNormal (material, body, &posit[0], &normal[0]); // the torque on this contact is dVector torque ((origin - posit) * force); // do what ever you want wit this } } } // here we should have an array of all colling sub shapes if (count) { // do what you need with this sub shape list } }
PyObject* Material::GetContactForce ( ) { dFloat v[3]; NewtonMaterialGetContactForce( m_material, v ); PyObject* r = PyTuple_New( 3 ); PyTuple_SetItem( r, 0, PyFloat_FromDouble( v[0] ) ); PyTuple_SetItem( r, 1, PyFloat_FromDouble( v[1] ) ); PyTuple_SetItem( r, 2, PyFloat_FromDouble( v[2] ) ); return r; }
static void RenderBodyContactsForces (NewtonBody* const body, dFloat scale) { dFloat mass; dFloat Ixx; dFloat Iyy; dFloat Izz; NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz); //draw normal forces in term of acceleration. //this mean that two bodies with same shape but different mass will display the same force if (mass > 0.0f) { scale = scale/mass; for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(body); joint; joint = NewtonBodyGetNextContactJoint(body, joint)) { if (NewtonJointIsActive (joint)) { for (void* contact = NewtonContactJointGetFirstContact (joint); contact; contact = NewtonContactJointGetNextContact (joint, contact)) { dVector point(0.0f); dVector normal(0.0f); dVector tangnetDir0(0.0f); dVector tangnetDir1(0.0f); dVector contactForce(0.0f); NewtonMaterial* const material = NewtonContactGetMaterial (contact); NewtonMaterialGetContactForce(material, body, &contactForce.m_x); NewtonMaterialGetContactPositionAndNormal (material, body, &point.m_x, &normal.m_x); dVector normalforce (normal.Scale (contactForce % normal)); dVector p0 (point); dVector p1 (point + normalforce.Scale (scale)); glVertex3f (p0.m_x, p0.m_y, p0.m_z); glVertex3f (p1.m_x, p1.m_y, p1.m_z); // these are the components of the tangents forces at the contact point, the can be display at the contact position point. NewtonMaterialGetContactTangentDirections(material, body, &tangnetDir0[0], &tangnetDir1[0]); dVector tangentForce1 (tangnetDir0.Scale ((contactForce % tangnetDir0) * scale)); dVector tangentForce2 (tangnetDir1.Scale ((contactForce % tangnetDir1) * scale)); p1 = point + tangentForce1.Scale (scale); glVertex3f(p0.m_x, p0.m_y, p0.m_z); glVertex3f(p1.m_x, p1.m_y, p1.m_z); p1 = point + tangentForce2.Scale (scale); glVertex3f(p0.m_x, p0.m_y, p0.m_z); glVertex3f(p1.m_x, p1.m_y, p1.m_z); } } } } }
dVector ForceBetweenBody (NewtonBody* const body0, NewtonBody* const body1) { dVector reactionforce (0.0f); for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(body0); joint; joint = NewtonBodyGetNextContactJoint(body0, joint)) { if (NewtonJointIsActive(joint) && (NewtonJointGetBody0(joint) == body0) || (NewtonJointGetBody0(joint) == body1)) { for (void* contact = NewtonContactJointGetFirstContact (joint); contact; contact = NewtonContactJointGetNextContact (joint, contact)) { dVector point(0.0f); dVector normal(0.0f); dVector contactForce(0.0f); NewtonMaterial* const material = NewtonContactGetMaterial (contact); NewtonMaterialGetContactPositionAndNormal (material, body0, &point.m_x, &normal.m_x); NewtonMaterialGetContactForce(material, body0, &contactForce[0]); reactionforce += contactForce; } break; } } return reactionforce; }
dFloat ForceBodyAccelerationMichio (NewtonBody* const body) { dVector reactionforce (0.0f); // calcualte accelration generate by all contacts for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(body); joint; joint = NewtonBodyGetNextContactJoint(body, joint)) { if (NewtonJointIsActive(joint)) { for (void* contact = NewtonContactJointGetFirstContact(joint); contact; contact = NewtonContactJointGetNextContact(joint, contact)) { dVector contactForce(0.0f); NewtonMaterial* const material = NewtonContactGetMaterial(contact); NewtonMaterialGetContactForce(material, body, &contactForce[0]); reactionforce += contactForce; } } } dMatrix matrix; dVector accel; dVector veloc; dFloat Ixx; dFloat Iyy; dFloat Izz; dFloat mass; NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz); NewtonBodyGetAcceleration(body, &accel[0]); accel -= reactionforce.Scale (1.0f/mass); //calculate centripetal acceleration here. NewtonBodyGetMatrix(body, &matrix[0][0]); dVector radius(matrix.m_posit.Scale(-1.0f)); radius.m_w = 0.0f; dFloat radiusMag = dSqrt(radius.DotProduct3(radius)); dVector radiusDir (radius.Normalize()); NewtonBodyGetVelocity(body, &veloc[0]); veloc += radiusDir.Scale(veloc.DotProduct3(radiusDir)); dVector centripetalAccel(veloc.DotProduct3(veloc) / radiusMag); accel += centripetalAccel; return dSqrt (accel.DotProduct3(accel)); }
void cPhysicsMaterialNewton::ProcessContactCallback(const NewtonJoint* apJoint, float afTimeStep, int alThreadIndex) { cPhysicsContactData ContactData; int lContactNum = 0; iPhysicsBody * pContactBody1 = (iPhysicsBody*) NewtonBodyGetUserData(NewtonJointGetBody0(apJoint)); iPhysicsBody * pContactBody2 = (iPhysicsBody*) NewtonBodyGetUserData(NewtonJointGetBody1(apJoint)); for (void* pContact = NewtonContactJointGetFirstContact(apJoint); pContact; pContact = NewtonContactJointGetNextContact(apJoint, pContact)) { NewtonMaterial* pMaterial = NewtonContactGetMaterial(pContact); //Log(" Process contact between body '%s' and '%s'.\n",pContactBody1->GetName().c_str(), // pContactBody2->GetName().c_str()); //Normal speed float fNormSpeed = NewtonMaterialGetContactNormalSpeed(pMaterial); if (ContactData.mfMaxContactNormalSpeed < fNormSpeed) ContactData.mfMaxContactNormalSpeed = fNormSpeed; //Tangent speed float fTanSpeed0 = NewtonMaterialGetContactTangentSpeed(pMaterial, 0); float fTanSpeed1 = NewtonMaterialGetContactTangentSpeed(pMaterial, 1); if(std::abs(ContactData.mfMaxContactTangentSpeed) < std::abs(fTanSpeed0)) ContactData.mfMaxContactTangentSpeed = fTanSpeed0; if(std::abs(ContactData.mfMaxContactTangentSpeed) < std::abs(fTanSpeed1)) ContactData.mfMaxContactTangentSpeed = fTanSpeed1; //Force cVector3f vForce; NewtonMaterialGetContactForce(pMaterial,vForce.v); ContactData.mvForce += vForce; //Position and normal cVector3f vPos, vNormal; NewtonMaterialGetContactPositionAndNormal(pMaterial,vPos.v, vNormal.v); ContactData.mvContactNormal += vNormal; ContactData.mvContactPosition += vPos; //Log(" Norm: %f Tan0: %f Tan1: %f\n",fNormSpeed, fTanSpeed0, fTanSpeed1); //Log("Force: %s step %f\n", vForce.ToString().c_str(), afTimestep); if(pContactBody1->GetWorld()->GetSaveContactPoints()) { cCollidePoint collidePoint; collidePoint.mfDepth = 1; NewtonMaterialGetContactPositionAndNormal (pMaterial, collidePoint.mvPoint.v, collidePoint.mvNormal.v); pContactBody1->GetWorld()->GetContactPoints()->push_back(collidePoint); } lContactNum++; } //Log("--- End contact between body '%s' and '%s'.\n",mpContactBody1->GetName().c_str(), // mpContactBody2->GetName().c_str()); if(lContactNum <= 0) return; iPhysicsMaterial *pMaterial1 = pContactBody1->GetMaterial(); iPhysicsMaterial *pMaterial2 = pContactBody2->GetMaterial(); ContactData.mvContactNormal = ContactData.mvContactNormal / (float)lContactNum; ContactData.mvContactPosition = ContactData.mvContactPosition / (float)lContactNum; pMaterial1->GetSurfaceData()->CreateImpactEffect(ContactData.mfMaxContactNormalSpeed, ContactData.mvContactPosition, lContactNum,pMaterial2->GetSurfaceData()); int lPrio1 = pMaterial1->GetSurfaceData()->GetPriority(); int lPrio2 = pMaterial2->GetSurfaceData()->GetPriority(); if(lPrio1 >= lPrio2) { if(std::abs(ContactData.mfMaxContactNormalSpeed) > 0) pMaterial1->GetSurfaceData()->OnImpact(ContactData.mfMaxContactNormalSpeed, ContactData.mvContactPosition, lContactNum,pContactBody1); if(std::abs(ContactData.mfMaxContactTangentSpeed) > 0) pMaterial1->GetSurfaceData()->OnSlide(ContactData.mfMaxContactTangentSpeed, ContactData.mvContactPosition, lContactNum,pContactBody1,pContactBody2); } if(lPrio2 >= lPrio1 && pMaterial2 != pMaterial1) { if(std::abs(ContactData.mfMaxContactNormalSpeed) > 0) pMaterial2->GetSurfaceData()->OnImpact(ContactData.mfMaxContactNormalSpeed, ContactData.mvContactPosition, lContactNum,pContactBody2); if(std::abs(ContactData.mfMaxContactTangentSpeed) > 0) pMaterial2->GetSurfaceData()->OnSlide(ContactData.mfMaxContactTangentSpeed, ContactData.mvContactPosition, lContactNum,pContactBody2,pContactBody1); } pContactBody1->OnCollide(pContactBody2,&ContactData); pContactBody2->OnCollide(pContactBody1,&ContactData); }
Ogre::Vector3 ContactCallback::getContactForce() const { Ogre::Vector3 force; NewtonMaterialGetContactForce( m_material, &force.x ); return force; }
void GenericContactProcess (const NewtonJoint* contactJoint, dFloat timestep, int threadIndex) { #if 0 dFloat speed0; dFloat speed1; SpecialEffectStruct* currectEffect; // get the pointer to the special effect structure currectEffect = (SpecialEffectStruct *)NewtonMaterialGetMaterialPairUserData (material); // save the contact information NewtonMaterialGetContactPositionAndNormal (material, &currectEffect->m_position.m_x, &currectEffect->m_normal.m_x); NewtonMaterialGetContactTangentDirections (material, &currectEffect->m_tangentDir0.m_x, &currectEffect->m_tangentDir1.m_x); // Get the maximum normal speed of this impact. this can be used for positioning collision sound speed0 = NewtonMaterialGetContactNormalSpeed (material); if (speed0 > currectEffect->m_contactMaxNormalSpeed) { // save the position of the contact (for 3d sound of particles effects) currectEffect->m_contactMaxNormalSpeed = speed0; } // get the maximum of the two sliding contact speed speed0 = NewtonMaterialGetContactTangentSpeed (material, 0); speed1 = NewtonMaterialGetContactTangentSpeed (material, 1); if (speed1 > speed0) { speed0 = speed1; } // Get the maximum tangent speed of this contact. this can be used for particles(sparks) of playing scratch sounds if (speed0 > currectEffect->m_contactMaxTangentSpeed) { // save the position of the contact (for 3d sound of particles effects) currectEffect->m_contactMaxTangentSpeed = speed0; } #endif // read the table direction // dVector dir (tableDir); // dVector updir (TableDir); // NewtonBody* const body = NewtonJointGetBody0(contactJoint); // for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) { // dFloat speed; // dVector point; // dVector normal; // dVector dir0; // dVector dir1; // dVector force; // NewtonMaterial* material; // // material = NewtonContactGetMaterial (contact); // NewtonMaterialGetContactPositionAndNormal (material, body, &point.m_x, &normal.m_x); // // // if the normal is vertical is large the say 40 degrees // if (fabsf (normal % upDir) > 0.7f) { // // rotate the normal to be aligned with the table direction // NewtonMaterialContactRotateTangentDirections (material, dir); // } // } NewtonBody* const body = NewtonJointGetBody0(contactJoint); for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) { dVector point; dVector normal; dVector dir0; dVector dir1; dVector force; NewtonMaterial* const material = NewtonContactGetMaterial (contact); NewtonMaterialGetContactForce (material, body, &force.m_x); NewtonMaterialGetContactPositionAndNormal (material, body, &point.m_x, &normal.m_x); NewtonMaterialGetContactTangentDirections (material, body, &dir0.m_x, &dir1.m_x); //dFloat speed = NewtonMaterialGetContactNormalSpeed(material); //speed = NewtonMaterialGetContactNormalSpeed(material); // play sound base of the contact speed. // } }
void SimulationLister(DemoEntityManager* const scene, DemoEntityManager::dListNode* const mynode, dFloat timeStep) { m_delay --; if (m_delay > 0) { return; } // see if the net force on the body comes fr a high impact collision dFloat maxInternalForce = 0.0f; for (NewtonJoint* joint = NewtonBodyGetFirstContactJoint(m_myBody); joint; joint = NewtonBodyGetNextContactJoint(m_myBody, joint)) { for (void* contact = NewtonContactJointGetFirstContact (joint); contact; contact = NewtonContactJointGetNextContact (joint, contact)) { //dVector point; //dVector normal; dVector contactForce; NewtonMaterial* const material = NewtonContactGetMaterial (contact); //NewtonMaterialGetContactPositionAndNormal (material, &point.m_x, &normal.m_x); NewtonMaterialGetContactForce(material, m_myBody, &contactForce[0]); dFloat forceMag = contactForce % contactForce; if (forceMag > maxInternalForce) { maxInternalForce = forceMag; } } } // if the force is bigger than 4 Gravities, It is considered a collision force dFloat maxForce = BREAK_FORCE_IN_GRAVITIES * m_myweight; if (maxInternalForce > (maxForce * maxForce)) { NewtonWorld* const world = NewtonBodyGetWorld(m_myBody); dFloat Ixx; dFloat Iyy; dFloat Izz; dFloat mass; NewtonBodyGetMassMatrix(m_myBody, &mass, &Ixx, &Iyy, &Izz); dVector com; dVector veloc; dVector omega; dMatrix bodyMatrix; NewtonBodyGetVelocity(m_myBody, &veloc[0]); NewtonBodyGetOmega(m_myBody, &omega[0]); NewtonBodyGetCentreOfMass(m_myBody, &com[0]); NewtonBodyGetMatrix(m_myBody, &bodyMatrix[0][0]); com = bodyMatrix.TransformVector (com); dMatrix matrix (GetCurrentMatrix()); dQuaternion rotation (matrix); for (ShatterEffect::dListNode* node = m_effect.GetFirst(); node; node = node->GetNext()) { ShatterAtom& atom = node->GetInfo(); DemoEntity* const entity = new DemoEntity (NULL); entity->SetMesh (atom.m_mesh); entity->SetMatrix(*scene, rotation, matrix.m_posit); entity->InterpolateMatrix (*scene, 1.0f); scene->Append(entity); int materialId = 0; dFloat debriMass = mass * atom.m_massFraction; dFloat Ixx = debriMass * atom.m_momentOfInirtia.m_x; dFloat Iyy = debriMass * atom.m_momentOfInirtia.m_y; dFloat Izz = debriMass * atom.m_momentOfInirtia.m_z; //create the rigid body NewtonBody* const rigidBody = NewtonCreateBody (world, atom.m_collision, &matrix[0][0]); // set the correct center of gravity for this body NewtonBodySetCentreOfMass (rigidBody, &atom.m_centerOfMass[0]); // calculate the center of mas of the debris dVector center (matrix.TransformVector(atom.m_centerOfMass)); // calculate debris initial velocity dVector v (veloc + omega * (center - com)); // set initial velocity NewtonBodySetVelocity(rigidBody, &v[0]); NewtonBodySetOmega(rigidBody, &omega[0]); // set the debrie center of mass NewtonBodySetCentreOfMass (rigidBody, &atom.m_centerOfMass[0]); // set the mass matrix NewtonBodySetMassMatrix (rigidBody, debriMass, Ixx, Iyy, Izz); // activate // NewtonBodyCoriolisForcesMode (blockBoxBody, 1); // save the pointer to the graphic object with the body. NewtonBodySetUserData (rigidBody, entity); // 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::SetTransformCallback); // set the force and torque call back function NewtonBodySetForceAndTorqueCallback (rigidBody, PhysicsApplyGravityForce); } NewtonDestroyBody(world, m_myBody); scene->RemoveEntity (mynode); } };
static void DestroyThisBodyCallback (const NewtonBody* body, const NewtonJoint* contactJoint) { NewtonWorld* world; NewtonMesh* topMesh; NewtonMesh* bottomMesh; NewtonMesh* effectMesh; RenderPrimitive* srcPrimitive; dMatrix matrix; dFloat maxForce; dVector point; dVector dir0; dVector dir1; // Get the world; world = NewtonBodyGetWorld (body); // find a the strongest force maxForce = 0.0f; for (void* contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) { dVector force; NewtonMaterial* material; material = NewtonContactGetMaterial (contact); NewtonMaterialGetContactForce (material, &force.m_x); if (force.m_x > maxForce) { dVector normal; NewtonMaterialGetContactPositionAndNormal(material, &point[0], &normal[0]); NewtonMaterialGetContactTangentDirections (material, &dir0[0], &dir0[0]); } } // get the visual primitive srcPrimitive = (RenderPrimitive*) NewtonBodyGetUserData (body); // get the effect mesh that is use to create the debris pieces effectMesh = srcPrimitive->m_specialEffect; // calculate the cut plane plane NewtonBodyGetMatrix (body, &matrix[0][0]); dMatrix clipMatrix (dgGrammSchmidt(dir0) * dYawMatrix(30.0f * 3.1416f/180.0f * RandomVariable(1.0f)) * dRollMatrix(30.0f * 3.1416f/180.0f * RandomVariable(1.0f))); clipMatrix.m_posit = point; clipMatrix.m_posit.m_w = 1.0f; clipMatrix = clipMatrix * matrix.Inverse(); // break the mesh into two pieces NewtonMeshClip (effectMesh, meshClipper, &clipMatrix[0][0], &topMesh, &bottomMesh); if (topMesh && bottomMesh) { dFloat volume; NewtonMesh* meshPartA = NULL; NewtonMesh* meshPartB = NULL; volume = NewtonConvexCollisionCalculateVolume (NewtonBodyGetCollision(body)); // the clipper was able to make a cut now we can create new debris piece for replacement dMatrix clipMatrix1 (dgGrammSchmidt(dir1) * dYawMatrix(30.0f * 3.1416f/180.0f * RandomVariable(1.0f)) * dRollMatrix(30.0f * 3.1416f/180.0f * RandomVariable(1.0f))); NewtonMeshClip (bottomMesh, meshClipper, &clipMatrix1[0][0], &meshPartA, &meshPartB); if (meshPartA && meshPartB) { // creat another split (you can make as many depend of the FPS) CreateDebriPiece (body, meshPartA, volume); CreateDebriPiece (body, meshPartB, volume); NewtonMeshDestroy(meshPartA); NewtonMeshDestroy(meshPartB); } else { CreateDebriPiece (body, bottomMesh, volume); } NewtonMeshDestroy(bottomMesh); dMatrix clipMatrix2 (dgGrammSchmidt(dir1) * dYawMatrix(30.0f * 3.1416f/180.0f * RandomVariable(1.0f)) * dRollMatrix(30.0f * 3.1416f/180.0f * RandomVariable(1.0f))); NewtonMeshClip (topMesh, meshClipper, &clipMatrix2[0][0], &meshPartA, &meshPartB); if (meshPartA && meshPartB) { // creat another split (you can make as many depend of the FPS) CreateDebriPiece (body, meshPartA, volume); CreateDebriPiece (body, meshPartB, volume); NewtonMeshDestroy(meshPartA); NewtonMeshDestroy(meshPartB); } else { CreateDebriPiece (body, topMesh, volume); } NewtonMeshDestroy(topMesh); // remove the old visual from graphics world SceneManager* system = (SceneManager*) NewtonWorldGetUserData(world); delete srcPrimitive; system->Remove(srcPrimitive); // finally destroy this body; NewtonDestroyBody(world, body); } }
virtual void getContactForce(Math::Vector3& _forceVector) const { NewtonMaterialGetContactForce(m_pMaterial, _forceVector.m_array); }