CustomVehicleControllerBodyStateTire* AddTire (const dVector& offset, dFloat width, dFloat radius, dFloat mass, dFloat suspensionLength, dFloat suspensionSpring, dFloat suspensionDamper, dFloat lateralStiffness, dFloat longitudinalStiffness, dFloat aligningMomentTrail, const dMatrix& tireAligmentMatrix) { NewtonBody* const body = m_controller->GetBody(); // make the tire matrix from the offset and the body matrix dMatrix tireMatrix (GetNextMatrix()); tireMatrix.m_posit = offset; // add the visual representation of the is tire to as a child of the vehicle model NewtonCollision* const tireMeshGenerator = NewtonCreateChamferCylinder (NewtonBodyGetWorld(body), 0.5f, 1.0f, 0, NULL); NewtonCollisionSetScale (tireMeshGenerator, width, radius, radius); DemoEntity* const tireEntity = new DemoEntity (tireMatrix, this); DemoMesh* const visualMesh = new DemoMesh ("tireMesh", tireMeshGenerator, "smilli.tga", "smilli.tga", "smilli.tga"); tireEntity->SetMesh (visualMesh, dYawMatrix(3.141592f * 90.0f / 180.0f)); visualMesh->Release(); NewtonDestroyCollision (tireMeshGenerator); // add the tire to the vehicle CustomVehicleControllerBodyStateTire::TireCreationInfo tireInfo; tireInfo.m_location = tireMatrix.m_posit; tireInfo.m_mass = mass; tireInfo.m_radio = radius; tireInfo.m_width = width; tireInfo.m_dampingRatio = suspensionDamper; tireInfo.m_springStrength = suspensionSpring; tireInfo.m_suspesionlenght = suspensionLength; tireInfo.m_lateralStiffness = lateralStiffness; tireInfo.m_longitudialStiffness = longitudinalStiffness; tireInfo.m_aligningMomentTrail = aligningMomentTrail; tireInfo.m_userData = tireEntity; return m_controller->AddTire (tireInfo); }
void dVehicleChassis::Finalize() { dVector minP; dVector maxP; m_vehicle->CalculateNodeAABB(dGetIdentityMatrix(), minP, maxP); const dList<dVehicleNode*>& children = m_vehicle->GetChildren(); for (dList<dVehicleNode*>::dListNode* tireNode = children.GetFirst(); tireNode; tireNode = tireNode->GetNext()) { dVehicleVirtualTire* const tire = (dVehicleVirtualTire*)tireNode->GetInfo()->GetAsTire(); if (tire) { dVector tireMinP; dVector tireMaxP; dMatrix tireMatrix(tire->GetHardpointMatrix(0.0f)); tire->CalculateNodeAABB(tireMatrix, tireMinP, tireMaxP); minP = minP.Min (tireMinP); maxP = maxP.Max (tireMaxP); } } m_obbOrigin = (maxP + minP).Scale (0.5f); m_obbSize = (maxP - minP).Scale (0.5f) + dVector (0.1f, 0.1f, 0.1f, 0.0f); m_vehicle->RigidBodyToStates(); m_solver.Finalize(this); }