diff --git a/newton-4.00/applications/media/buggy_sk.png b/newton-4.00/applications/media/buggy_sk.png index c65baa0ac..65ef4a91f 100644 Binary files a/newton-4.00/applications/media/buggy_sk.png and b/newton-4.00/applications/media/buggy_sk.png differ diff --git a/newton-4.00/applications/media/truck.png b/newton-4.00/applications/media/truck.png index a92d4ee42..1038a6fd8 100644 Binary files a/newton-4.00/applications/media/truck.png and b/newton-4.00/applications/media/truck.png differ diff --git a/newton-4.00/applications/media/tyre.png b/newton-4.00/applications/media/tyre.png index 249f40c68..cdc89d81f 100644 Binary files a/newton-4.00/applications/media/tyre.png and b/newton-4.00/applications/media/tyre.png differ diff --git a/newton-4.00/applications/ndSandbox/demos/ndBasicVehicle.cpp b/newton-4.00/applications/ndSandbox/demos/ndBasicVehicle.cpp index 491b91cbb..67587c561 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndBasicVehicle.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndBasicVehicle.cpp @@ -251,6 +251,8 @@ class ndBasicMultiBodyVehicle : public ndVehicleCommon ,m_fr_tire(nullptr) ,m_fl_tire(nullptr) { + SetNotifyCallback(new ndVehicleCommonNotify(this)); + ndDemoEntity* const vehicleEntityDummyRoot = LoadMeshModel(scene, desc.m_name); ndDemoEntity* const vehicleEntity = vehicleEntityDummyRoot->GetFirstChild(); @@ -322,7 +324,6 @@ class ndBasicMultiBodyVehicle : public ndVehicleCommon } } - // 4- add a motor ndMultiBodyVehicleMotor* const motor = AddMotor(m_configuration.m_motorMass, m_configuration.m_motorRadius); motor->SetMaxRpm(m_configuration.m_engine.GetRedLineRadPerSec() * dRadPerSecToRpm); @@ -391,8 +392,6 @@ class ndBasicMultiBodyVehicle : public ndVehicleCommon // //m_engineRpmSound->SetLoop(true); //m_skipMarks->SetLoop(true); - - SetNotifyCallback(new ndVehicleCommonNotify(this)); } ~ndBasicMultiBodyVehicle() diff --git a/newton-4.00/applications/ndSandbox/demos/ndHeavyVehicle.cpp b/newton-4.00/applications/ndSandbox/demos/ndHeavyVehicle.cpp index c4d2f9588..7b20f21c0 100644 --- a/newton-4.00/applications/ndSandbox/demos/ndHeavyVehicle.cpp +++ b/newton-4.00/applications/ndSandbox/demos/ndHeavyVehicle.cpp @@ -212,30 +212,24 @@ class ndHeavyMultiBodyVehicle : public ndVehicleCommon :ndVehicleCommon(desc) ,m_vehicleUI(vehicleUI) { - ndAssert(0); -#if 0 - ndDemoEntity* const vehicleEntity = LoadMeshModel(scene, desc.m_name); + SetNotifyCallback(new ndVehicleCommonNotify(this)); + ndDemoEntity* const vehicleEntityRoot = LoadMeshModel(scene, desc.m_name); + ndDemoEntity* const vehicleEntity = vehicleEntityRoot->GetFirstChild(); vehicleEntity->ResetMatrix(vehicleEntity->CalculateGlobalMatrix() * matrix); - - ndPhysicsWorld* const world = scene->GetWorld(); // create the vehicle chassis as a normal rigid body - ndBodyKinematic* const chassis = CreateChassis(scene, vehicleEntity, m_configuration.m_chassisMass); - chassis->SetAngularDamping(ndVector(m_configuration.m_chassisAngularDrag)); + //ndBodyKinematic* const chassis = CreateChassis(scene, vehicleEntity, m_configuration.m_chassisMass); + ndSharedPtr chassisBody (CreateChassis(scene, vehicleEntity, m_configuration.m_chassisMass)); + AddChassis(chassisBody); + m_chassis->SetAngularDamping(ndVector(m_configuration.m_chassisAngularDrag)); // lower vehicle com; - ndVector com(chassis->GetCentreOfMass()); + ndVector com(m_chassis->GetCentreOfMass()); com += m_localFrame.m_up.Scale(m_configuration.m_comDisplacement.m_y); com += m_localFrame.m_front.Scale(m_configuration.m_comDisplacement.m_x); com += m_localFrame.m_right.Scale(m_configuration.m_comDisplacement.m_z); - chassis->SetCentreOfMass(com); - - // 1- add chassis to the vehicle mode - SetChassis(chassis); - ndSharedPtr bodyPtr(chassis); - world->AddBody(bodyPtr); -#endif + m_chassis->SetCentreOfMass(com); } ~ndHeavyMultiBodyVehicle() @@ -303,8 +297,6 @@ class ndHeavyMultiBodyVehicle : public ndVehicleCommon void SetCamera(ndDemoEntityManager* const manager, ndFloat32) { - ndAssert(0); -#if 0 ndDemoCamera* const camera = manager->GetCamera(); ndDemoEntity* const chassisEntity = (ndDemoEntity*)m_chassis->GetNotifyCallback()->GetUserData(); ndMatrix camMatrix(camera->GetNextMatrix()); @@ -316,7 +308,6 @@ class ndHeavyMultiBodyVehicle : public ndVehicleCommon camOrigin -= frontDir.Scale(10.0f); camera->SetNextMatrix(camMatrix, camOrigin); -#endif } protected: @@ -750,15 +741,13 @@ class ndBigRigVehicle : public ndHeavyMultiBodyVehicle // this function will create the tire as a normal rigid body // and attach them to the chassis with the tire joints - ndAssert(0); -#if 0 - ndWorld* const world = scene->GetWorld(); + //ndWorld* const world = scene->GetWorld(); ndBodyKinematic* const chassis = m_chassis; ndVehicleDectriptor::ndTireDefinition f0_tireConfiguration(m_configuration.m_frontTire); ndVehicleDectriptor::ndTireDefinition f1_tireConfiguration(m_configuration.m_frontTire); - ndBodyKinematic* const fl_tire_body = CreateTireBody(scene, chassis, f0_tireConfiguration, "fl_tire"); - ndBodyKinematic* const fr_tire_body = CreateTireBody(scene, chassis, f1_tireConfiguration, "fr_tire"); + ndSharedPtr fl_tire_body (CreateTireBody(scene, chassis, f0_tireConfiguration, "fl_tire")); + ndSharedPtr fr_tire_body (CreateTireBody(scene, chassis, f1_tireConfiguration, "fr_tire")); AddTire(f0_tireConfiguration, fr_tire_body); AddTire(f0_tireConfiguration, fl_tire_body); @@ -766,29 +755,28 @@ class ndBigRigVehicle : public ndHeavyMultiBodyVehicle ndVehicleDectriptor::ndTireDefinition r1_tireConfiguration(m_configuration.m_rearTire); ndVehicleDectriptor::ndTireDefinition r2_tireConfiguration(m_configuration.m_rearTire); ndVehicleDectriptor::ndTireDefinition r3_tireConfiguration(m_configuration.m_rearTire); - ndBodyKinematic* const rl_tire0_body = CreateTireBody(scene, chassis, r0_tireConfiguration, "rl_midle_tire"); - ndBodyKinematic* const rr_tire0_body = CreateTireBody(scene, chassis, r1_tireConfiguration, "rr_midle_tire"); - ndBodyKinematic* const rl_tire1_body = CreateTireBody(scene, chassis, r2_tireConfiguration, "rl_tire"); - ndBodyKinematic* const rr_tire1_body = CreateTireBody(scene, chassis, r3_tireConfiguration, "rr_tire"); + ndSharedPtr rl_tire0_body (CreateTireBody(scene, chassis, r0_tireConfiguration, "rl_midle_tire")); + ndSharedPtr rr_tire0_body (CreateTireBody(scene, chassis, r1_tireConfiguration, "rr_midle_tire")); + ndSharedPtr rl_tire1_body (CreateTireBody(scene, chassis, r2_tireConfiguration, "rl_tire")); + ndSharedPtr rr_tire1_body (CreateTireBody(scene, chassis, r3_tireConfiguration, "rr_tire")); ndMultiBodyVehicleTireJoint* const rr_tire0 = AddTire(r0_tireConfiguration, rr_tire0_body); ndMultiBodyVehicleTireJoint* const rl_tire0 = AddTire(r1_tireConfiguration, rl_tire0_body); ndMultiBodyVehicleTireJoint* const rr_tire1 = AddTire(r2_tireConfiguration, rr_tire1_body); ndMultiBodyVehicleTireJoint* const rl_tire1 = AddTire(r3_tireConfiguration, rl_tire1_body); - ndSharedPtr fl_tire_body_Ptr(fl_tire_body); - ndSharedPtr fr_tire_body_Ptr(fr_tire_body); - ndSharedPtr rl_tire0_body_Ptr(rl_tire0_body); - ndSharedPtr rr_tire0_body_Ptr(rr_tire0_body); - ndSharedPtr rl_tire1_body_Ptr(rl_tire1_body); - ndSharedPtr rr_tire1_body_Ptr(rr_tire1_body); - - world->AddBody(fl_tire_body_Ptr); - world->AddBody(fr_tire_body_Ptr); - world->AddBody(rl_tire0_body_Ptr); - world->AddBody(rr_tire0_body_Ptr); - world->AddBody(rl_tire1_body_Ptr); - world->AddBody(rr_tire1_body_Ptr); + //ndSharedPtr fl_tire_body_Ptr(fl_tire_body); + //ndSharedPtr fr_tire_body_Ptr(fr_tire_body); + //ndSharedPtr rl_tire0_body_Ptr(rl_tire0_body); + //ndSharedPtr rr_tire0_body_Ptr(rr_tire0_body); + //ndSharedPtr rl_tire1_body_Ptr(rl_tire1_body); + //ndSharedPtr rr_tire1_body_Ptr(rr_tire1_body); + //world->AddBody(fl_tire_body_Ptr); + //world->AddBody(fr_tire_body_Ptr); + //world->AddBody(rl_tire0_body_Ptr); + //world->AddBody(rr_tire0_body_Ptr); + //world->AddBody(rl_tire1_body_Ptr); + //world->AddBody(rr_tire1_body_Ptr); m_currentGear = sizeof(m_configuration.m_transmission.m_forwardRatios) / sizeof(m_configuration.m_transmission.m_forwardRatios[0]) + 1; @@ -807,7 +795,6 @@ class ndBigRigVehicle : public ndHeavyMultiBodyVehicle // set a soft or hard mode SetVehicleSolverModel(m_configuration.m_useHardSolverMode ? true : false); -#endif } void ApplyInputs(ndWorld* const world, ndFloat32 timestep) @@ -820,10 +807,10 @@ void ndHeavyVehicle (ndDemoEntityManager* const scene) { ndMatrix sceneLocation(ndGetIdentityMatrix()); //BuildFloorBox(scene, sceneLocation); - //BuildFlatPlane(scene, true); + BuildFlatPlane(scene, true); //BuildGridPlane(scene, 120, 4.0f, 0.0f); //BuildStaticMesh(scene, "track.fbx", true); - BuildCompoundScene(scene, sceneLocation); + //BuildCompoundScene(scene, sceneLocation); //BuildStaticMesh(scene, "playerarena.fbx", true); //BuildSplineTrack(scene, "playerarena.fbx", true); //sceneLocation.m_posit.m_x = -200.0f; @@ -858,8 +845,7 @@ void ndHeavyVehicle (ndDemoEntityManager* const scene) ndSharedPtr vehicleUIPtr(vehicleUI); scene->Set2DDisplayRenderFunction(vehicleUIPtr); - ndAssert(0); - //ndSharedPtr vehicle0(new ndBigRigVehicle(scene, bigRigDesc, matrix, vehicleUI)); + ndSharedPtr vehicle0(new ndBigRigVehicle(scene, bigRigDesc, matrix, vehicleUI)); matrix.m_posit.m_x += 6.0f; matrix.m_posit.m_z += 6.0f; @@ -868,12 +854,12 @@ void ndHeavyVehicle (ndDemoEntityManager* const scene) matrix.m_posit.m_z -= 12.0f; //ndSharedPtr vehicle2(new ndTractorVehicle(scene, tractorDesc, matrix, vehicleUI)); - //world->AddModel(vehicle0); + world->AddModel(vehicle0); //world->AddModel(vehicle1); //world->AddModel(vehicle2); - //ndHeavyMultiBodyVehicle* const vehicle = (ndHeavyMultiBodyVehicle*)*vehicle0; - //vehicle->SetAsPlayer(scene); + ndHeavyMultiBodyVehicle* const vehicle = (ndHeavyMultiBodyVehicle*)*vehicle0; + vehicle->SetAsPlayer(scene); matrix.m_posit.m_x += 25.0f; matrix.m_posit.m_z += 6.0f; diff --git a/newton-4.00/applications/ndSandbox/ndDemoEntityManager.cpp b/newton-4.00/applications/ndSandbox/ndDemoEntityManager.cpp index 5f03c58e5..25b841759 100644 --- a/newton-4.00/applications/ndSandbox/ndDemoEntityManager.cpp +++ b/newton-4.00/applications/ndSandbox/ndDemoEntityManager.cpp @@ -49,8 +49,8 @@ //#define DEFAULT_SCENE 9 // static mesh collision //#define DEFAULT_SCENE 10 // static user mesh collision //#define DEFAULT_SCENE 11 // basic joints -#define DEFAULT_SCENE 12 // basic vehicle -//#define DEFAULT_SCENE 13 // heavy vehicle +//#define DEFAULT_SCENE 12 // basic vehicle +#define DEFAULT_SCENE 13 // heavy vehicle //#define DEFAULT_SCENE 14 // background vehicle prop //#define DEFAULT_SCENE 15 // basic player //#define DEFAULT_SCENE 16 // rag doll diff --git a/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.cpp b/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.cpp index e4041ebd2..678613097 100644 --- a/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.cpp +++ b/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.cpp @@ -338,16 +338,6 @@ bool ndVehicleCommon::IsPlayer() const return m_isPlayer; } -//void ndVehicleCommon::SetChassis(ndBodyKinematic* const chassis) -//{ -// ndAssert(0); -// AddChassis(chassis); -// // assign chassis material id. -// ndShapeInstance& instanceShape = chassis->GetCollisionShape(); -// instanceShape.m_shapeMaterial.m_userId = ndDemoContactCallback::m_modelPart; -// instanceShape.m_shapeMaterial.m_userParam[ndDemoContactCallback::m_modelPointer].m_ptrData = this; -//} - void ndVehicleCommon::CalculateTireDimensions(const char* const tireName, ndFloat32& width, ndFloat32& radius, ndDemoEntity* const vehEntity) const { // find the the tire visual mesh diff --git a/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.h b/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.h index b013202a8..3d2dc5390 100644 --- a/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.h +++ b/newton-4.00/applications/ndSandbox/toolbox/ndVehicleCommon.h @@ -208,8 +208,6 @@ class ndVehicleCommon : public ndMultiBodyVehicle protected: void Update(ndWorld* const world, ndFloat32 timestep); void PostUpdate(ndWorld* const world, ndFloat32 timestep); - - //void SetChassis(ndBodyKinematic* const chassis); void CalculateTireDimensions(const char* const tireName, ndFloat32& width, ndFloat32& radius, ndDemoEntity* const vehEntity) const; ndBodyKinematic* CreateTireBody(ndDemoEntityManager* const scene, ndBodyKinematic* const parentBody, ndVehicleDectriptor::ndTireDefinition& definition, const char* const tireName) const;