From 52c9b6ed5595f84dd3ff897b5dada05e7105e144 Mon Sep 17 00:00:00 2001 From: JulioJerez Date: Mon, 23 Dec 2019 16:16:01 -0800 Subject: [PATCH] adding final 3.14 build --- .../visualStudio_2013/demosSandbox.vcxproj | 1 - .../demosSandbox.vcxproj.filters | 3 - .../projects/visualStudio_2013/imgui.ini | 2 +- .../visualStudio_2015/demosSandbox.vcxproj | 1 - .../demosSandbox.vcxproj.filters | 3 - .../sdkDemos/DemoEntityManager.cpp | 25 +- .../sdkDemos/demos/ConstructionVehicle.cpp | 11 +- .../sdkDemos/demos/DynamicRagdoll.cpp | 386 ------------------ .../sdkDemos/demos/ServoJoints.cpp | 51 +-- 9 files changed, 29 insertions(+), 454 deletions(-) delete mode 100644 applications/demosSandbox/sdkDemos/demos/DynamicRagdoll.cpp diff --git a/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj b/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj index ce794706bb..44f05e3ecb 100644 --- a/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj +++ b/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj @@ -55,7 +55,6 @@ - diff --git a/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj.filters b/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj.filters index 92fc7fbb05..605ca77e35 100644 --- a/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj.filters +++ b/applications/demosSandbox/projects/visualStudio_2013/demosSandbox.vcxproj.filters @@ -51,9 +51,6 @@ utils - - demos - demos diff --git a/applications/demosSandbox/projects/visualStudio_2013/imgui.ini b/applications/demosSandbox/projects/visualStudio_2013/imgui.ini index 0824448a9c..1b78a2d2a9 100644 --- a/applications/demosSandbox/projects/visualStudio_2013/imgui.ini +++ b/applications/demosSandbox/projects/visualStudio_2013/imgui.ini @@ -35,6 +35,6 @@ Collapsed=0 [User Interface] Pos=995,20 -Size=292,352 +Size=289,262 Collapsed=0 diff --git a/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj b/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj index 39bbb75855..95e8315227 100644 --- a/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj +++ b/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj @@ -55,7 +55,6 @@ - diff --git a/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj.filters b/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj.filters index d20e12a323..20ae612fe2 100644 --- a/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj.filters +++ b/applications/demosSandbox/projects/visualStudio_2015/demosSandbox.vcxproj.filters @@ -51,9 +51,6 @@ utils - - demos - demos diff --git a/applications/demosSandbox/sdkDemos/DemoEntityManager.cpp b/applications/demosSandbox/sdkDemos/DemoEntityManager.cpp index 2f97b8397e..2041f6f7d8 100644 --- a/applications/demosSandbox/sdkDemos/DemoEntityManager.cpp +++ b/applications/demosSandbox/sdkDemos/DemoEntityManager.cpp @@ -59,21 +59,20 @@ //#define DEFAULT_SCENE 24 // simple convex fracturing //#define DEFAULT_SCENE 25 // multi ray casting using the threading Job scheduler //#define DEFAULT_SCENE 26 // standard joints -#define DEFAULT_SCENE 27 // servo joints -//#define DEFAULT_SCENE 28 // construction vehicle +//#define DEFAULT_SCENE 27 // servo joints +#define DEFAULT_SCENE 28 // construction vehicle //#define DEFAULT_SCENE 29 // six axis manipulator //#define DEFAULT_SCENE 30 // hexapod Robot //#define DEFAULT_SCENE 31 // basic rag doll //#define DEFAULT_SCENE 32 // balancing character -//#define DEFAULT_SCENE 33 // dynamic rag doll -//#define DEFAULT_SCENE 34 // single body vehicle -//#define DEFAULT_SCENE 35 // super Car -//#define DEFAULT_SCENE 36 // heavy vehicles -//#define DEFAULT_SCENE 37 // basic player controller -//#define DEFAULT_SCENE 38 // animated player controller -//#define DEFAULT_SCENE 39 // advanced player controller -//#define DEFAULT_SCENE 40 // cloth patch -//#define DEFAULT_SCENE 41 // soft bodies +//#define DEFAULT_SCENE 33 // single body vehicle +//#define DEFAULT_SCENE 34 // super Car +//#define DEFAULT_SCENE 35 // heavy vehicles +//#define DEFAULT_SCENE 36 // basic player controller +//#define DEFAULT_SCENE 37 // animated player controller +//#define DEFAULT_SCENE 38 // advanced player controller +//#define DEFAULT_SCENE 39 // cloth patch +//#define DEFAULT_SCENE 40 // soft bodies /// demos forward declaration void Friction (DemoEntityManager* const scene); @@ -112,7 +111,6 @@ void UserPlaneCollision (DemoEntityManager* const scene); void UserHeightFieldCollision (DemoEntityManager* const scene); void PassiveRagdoll (DemoEntityManager* const scene); void BalancingCharacter (DemoEntityManager* const scene); -void DynamicRagdoll (DemoEntityManager* const scene); void ServoJoints (DemoEntityManager* const scene); void ConstructionVehicle (DemoEntityManager* const scene); void StandardJoints (DemoEntityManager* const scene); @@ -154,7 +152,6 @@ DemoEntityManager::SDKDemos DemoEntityManager::m_demosSelection[] = {"Hexapod walker", "show using inverse dynamics to control robots", Hexapod }, {"Passive rag doll", "demonstrate passive rag doll", PassiveRagdoll}, {"Balancing character", "demonstrate dynamic character", BalancingCharacter}, - {"Dynamic rag doll", "demonstrate dynamic rag doll", DynamicRagdoll}, {"Single body car", "show a generalized coordinate system body", SingleBodyCar }, {"Super car", "implement a hight performance sport car", SuperCar}, {"Heavy vehicles", "implement military type heavy Vehicles", MilitaryTransport}, @@ -330,7 +327,7 @@ DemoEntityManager::DemoEntityManager () // m_autoSleepMode = false; // m_broadPhaseType = 1; // m_solverPasses = 4; -// m_workerThreads = 4; + m_workerThreads = 4; // m_solverSubSteps = 2; // m_showRaycastHit = true; // m_showNormalForces = true; diff --git a/applications/demosSandbox/sdkDemos/demos/ConstructionVehicle.cpp b/applications/demosSandbox/sdkDemos/demos/ConstructionVehicle.cpp index e87a279ac7..2e96ef273d 100644 --- a/applications/demosSandbox/sdkDemos/demos/ConstructionVehicle.cpp +++ b/applications/demosSandbox/sdkDemos/demos/ConstructionVehicle.cpp @@ -13,12 +13,11 @@ #include "SkyBox.h" #include "DemoMesh.h" #include "DemoCamera.h" +#include "DebugDisplay.h" #include "PhysicsUtils.h" #include "TargaToOpenGl.h" -#include "DemoEntityManager.h" #include "dWoodFracture.h" - -#include "DebugDisplay.h" +#include "DemoEntityManager.h" #include "HeightFieldPrimitive.h" #define ARTICULATED_VEHICLE_CAMERA_HIGH_ABOVE_HEAD 3.0f @@ -786,18 +785,18 @@ class ArticulatedVehicleManagerManager: public dModelManager NewtonMaterialSetCallbackUserData (world, material, material, this); NewtonMaterialSetCollisionCallback (world, material, material, StandardAABBOverlapTest, NULL); - NewtonMaterialSetDefaultElasticity(world, material, material, 0.1f); + NewtonMaterialSetDefaultElasticity(world, material, material, 0.0f); NewtonMaterialSetDefaultFriction(world, material, material, 0.9f, 0.9f); NewtonMaterialSetCallbackUserData(world, material, threadMaterialID, this); NewtonMaterialSetCollisionCallback (world, material, threadMaterialID, StandardAABBOverlapTest, NULL); - NewtonMaterialSetDefaultElasticity(world, material, threadMaterialID, 0.1f); + NewtonMaterialSetDefaultElasticity(world, material, threadMaterialID, 0.0f); NewtonMaterialSetDefaultFriction(world, material, threadMaterialID, 0.9f, 0.9f); NewtonMaterialSetCallbackUserData(world, threadMaterialID, threadMaterialID, this); NewtonMaterialSetCollisionCallback (world, threadMaterialID, threadMaterialID, StandardAABBOverlapTest, NULL); NewtonMaterialSetContactGenerationCallback (world, threadMaterialID, threadMaterialID, ThreadStaticContactsGeneration); - NewtonMaterialSetDefaultElasticity(world, threadMaterialID, threadMaterialID, 0.1f); + NewtonMaterialSetDefaultElasticity(world, threadMaterialID, threadMaterialID, 0.0f); NewtonMaterialSetDefaultFriction(world, threadMaterialID, threadMaterialID, 0.9f, 0.9f); } diff --git a/applications/demosSandbox/sdkDemos/demos/DynamicRagdoll.cpp b/applications/demosSandbox/sdkDemos/demos/DynamicRagdoll.cpp deleted file mode 100644 index 79a514822b..0000000000 --- a/applications/demosSandbox/sdkDemos/demos/DynamicRagdoll.cpp +++ /dev/null @@ -1,386 +0,0 @@ -/* Copyright (c) <2003-2019> -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely -*/ - -#include "toolbox_stdafx.h" -#include "SkyBox.h" -#include "DemoMesh.h" -#include "DemoCamera.h" -#include "PhysicsUtils.h" -#include "TargaToOpenGl.h" -#include "DemoEntityManager.h" -#include "DebugDisplay.h" -#include "HeightFieldPrimitive.h" - - -class dDynamicsRagdoll: public dAnimationRagdollRoot -{ - public: - dDynamicsRagdoll(NewtonBody* const body, const dMatrix& bindMarix) - :dAnimationRagdollRoot(body, bindMarix) - ,m_hipEffector(NULL) - ,m_leftFootEffector(NULL) - { - } - - ~dDynamicsRagdoll() - { - } - - void PreUpdate(dFloat timestep) - { - dAssert(0); -/* - // do most of the control here, so that the is no need do subclass - //dDynamicsRagdoll* const ragDoll = (dDynamicsRagdoll*)model; - NewtonBody* const rootBody = GetBody(); - NewtonBodySetSleepState(rootBody, 0); - - // calculate the center of mass - dVector com(CalculateCenterOfMass()); - - // get pivot - dMatrix rootMatrix; - dMatrix pivotMatrix; - NewtonBodyGetMatrix(GetBody(), &rootMatrix[0][0]); - NewtonBodyGetMatrix(m_leftFootEffector->GetBody(), &pivotMatrix[0][0]); - - dVector comRadius (com - pivotMatrix.m_posit); - dVector bodyRadius (rootMatrix.m_posit - pivotMatrix.m_posit); - - dFloat r0 = dSqrt(comRadius.DotProduct3(comRadius)); - dFloat r1 = dSqrt(bodyRadius.DotProduct3(bodyRadius)); - - dVector updir (0.0f, 1.0f, 0.0f, 0.0f); - dVector p1 (pivotMatrix.m_posit + updir.Scale (r0)); - dVector targtePosit (rootMatrix.m_posit + (p1 - com).Scale (r1/r0)); - targtePosit.m_w = 1.0f; - - dMatrix matrix(dPitchMatrix(0.0f * dDegreeToRad) * dYawMatrix(0.0f * dDegreeToRad) * dRollMatrix(0.0f * dDegreeToRad)); - //com.m_y = rootMatrix.m_posit.m_y; - //com.m_w = 1.0f; - //matrix.m_posit = rootMatrix.m_posit; - //matrix.m_posit = com; - - matrix.m_posit = targtePosit; - m_hipEffector->SetTarget(matrix); - -dVector error(matrix.m_posit - rootMatrix.m_posit); -dTrace(("%f %f %f\n", error[0], error[1], error[2])); -*/ - dAnimationRagdollRoot::PreUpdate(timestep); - } - - void SetHipEffector(dAnimationJoint* const hip) - { - m_hipEffector = new dAnimationRagDollEffector(hip); - m_loopJoints.Append(m_hipEffector); - } - - void SetFootEffector(dAnimationJoint* const joint) - { - m_leftFootEffector = new dAnimationRagDollEffector(joint); - m_loopJoints.Append(m_leftFootEffector); - } - - dAnimationRagDollEffector* m_hipEffector; - dAnimationRagDollEffector* m_leftFootEffector; -}; - - -class dDynamicRagdollManager: public dAnimationModelManager -{ - class dJointDefinition - { - public: - struct dJointLimit - { - dFloat m_minTwistAngle; - dFloat m_maxTwistAngle; - dFloat m_coneAngle; - }; - - struct dFrameMatrix - { - dFloat m_pitch; - dFloat m_yaw; - dFloat m_roll; - }; - - char m_boneName[32]; - dFloat m_friction; - dJointLimit m_jointLimits; - dFrameMatrix m_frameBasics; - dAnimationRagdollJoint::dRagdollMotorType m_type; - }; - - public: - - dDynamicRagdollManager(DemoEntityManager* const scene) - :dAnimationModelManager(scene->GetNewton()) -// , m_currentRig(NULL) - { -// scene->Set2DDisplayRenderFunction(RenderHelpMenu, NULL, this); - } - - ~dDynamicRagdollManager() - { - } - - static void ClampAngularVelocity(const NewtonBody* body, dFloat timestep, int threadIndex) - { - dVector omega; - NewtonBodyGetOmega(body, &omega[0]); - omega.m_w = 0.0f; - dFloat mag2 = omega.DotProduct3(omega); - if (mag2 > (100.0f * 100.0f)) { - omega = omega.Normalize().Scale(100.0f); - NewtonBodySetOmega(body, &omega[0]); - } - - //PhysicsApplyGravityForce(body, timestep, threadIndex); - dFloat Ixx; - dFloat Iyy; - dFloat Izz; - dFloat mass; - - dFloat gravity = -0.0f; - NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz); - dVector dir(0.0f, gravity, 0.0f); - dVector force(dir.Scale(mass)); - NewtonBodySetForce(body, &force.m_x); - } - - NewtonBody* CreateBodyPart(DemoEntity* const bodyPart) - { - NewtonWorld* const world = GetWorld(); - NewtonCollision* const shape = bodyPart->CreateCollisionFromchildren(world); - dAssert(shape); - - // calculate the bone matrix - dMatrix matrix(bodyPart->CalculateGlobalMatrix()); - - // create the rigid body that will make this bone - NewtonBody* const bone = NewtonCreateDynamicBody(world, shape, &matrix[0][0]); - - // calculate the moment of inertia and the relative center of mass of the solid - //NewtonBodySetMassProperties (bone, definition.m_mass, shape); - NewtonBodySetMassProperties(bone, 1.0f, shape); - - // save the user data with the bone body (usually the visual geometry) - NewtonBodySetUserData(bone, bodyPart); - - // assign the material for early collision culling - //NewtonBodySetMaterialGroupID(bone, m_material); - - // set the bod part force and torque call back to the gravity force, skip the transform callback - //NewtonBodySetForceAndTorqueCallback (bone, PhysicsApplyGravityForce); - NewtonBodySetForceAndTorqueCallback(bone, ClampAngularVelocity); - - // destroy the collision helper shape - NewtonDestroyCollision(shape); - return bone; - } - - void SetModelMass( dFloat mass, dAnimationJointRoot* const rootNode) const - { - dFloat volume = 0.0f; - for (dAnimationJoint* joint = GetFirstJoint(rootNode); joint; joint = GetNextJoint(joint)) { - volume += NewtonConvexCollisionCalculateVolume(NewtonBodyGetCollision(joint->GetBody())); - } - dFloat density = mass / volume; - - for (dAnimationJoint* joint = GetFirstJoint(rootNode); joint; joint = GetNextJoint(joint)) { - dFloat Ixx; - dFloat Iyy; - dFloat Izz; - NewtonBody* const body = joint->GetBody(); - NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz); - dFloat scale = density * NewtonConvexCollisionCalculateVolume(NewtonBodyGetCollision(body)); - mass *= scale; - Ixx *= scale; - Iyy *= scale; - Izz *= scale; - NewtonBodySetMassMatrix(body, mass, Ixx, Iyy, Izz); - } - } - - dAnimationJoint* CreateChildNode(NewtonBody* const boneBody, dAnimationJoint* const parent, const dJointDefinition& definition) const - { - dMatrix matrix; - NewtonBodyGetMatrix(boneBody, &matrix[0][0]); - - dJointDefinition::dFrameMatrix frameAngle(definition.m_frameBasics); - dMatrix pinAndPivotInGlobalSpace(dPitchMatrix(frameAngle.m_pitch * dDegreeToRad) * dYawMatrix(frameAngle.m_yaw * dDegreeToRad) * dRollMatrix(frameAngle.m_roll * dDegreeToRad)); - pinAndPivotInGlobalSpace = pinAndPivotInGlobalSpace * matrix; - - //dMatrix bindMatrix(entity->GetParent()->CalculateGlobalMatrix((DemoEntity*)NewtonBodyGetUserData(parentBody)).Inverse()); - dMatrix bindMatrix(dGetIdentityMatrix()); - dAnimationJoint* const joint = new dAnimationRagdollJoint(definition.m_type, pinAndPivotInGlobalSpace, boneBody, bindMatrix, parent); - return joint; - } - - - void CreateRagdollExperiment_0(const dMatrix& location) - { - static dJointDefinition jointsDefinition[] = - { - { "body" }, - { "leg", 100.0f,{ -15.0f, 15.0f, 30.0f },{ 0.0f, 0.0f, 180.0f }, dAnimationRagdollJoint::m_threeDof }, - { "foot", 100.0f,{ -15.0f, 15.0f, 30.0f },{ 0.0f, 90.0f, 0.0f }, dAnimationRagdollJoint::m_twoDof }, - }; - const int definitionCount = sizeof (jointsDefinition)/sizeof (jointsDefinition[0]); - - NewtonWorld* const world = GetWorld(); - DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(world); - - DemoEntity* const modelEntity = DemoEntity::LoadNGD_mesh("selfbalance_01.ngd", GetWorld(), scene->GetShaderCache()); - - dMatrix matrix0(modelEntity->GetCurrentMatrix()); - //matrix0.m_posit = location; - //modelEntity->ResetMatrix(*scene, matrix0); - scene->Append(modelEntity); - - // add the root childBody - NewtonBody* const rootBody = CreateBodyPart(modelEntity); - - // build the rag doll with rigid bodies connected by joints - dDynamicsRagdoll* const dynamicRagdoll = new dDynamicsRagdoll(rootBody, dGetIdentityMatrix()); - AddModel(dynamicRagdoll); - dynamicRagdoll->SetCalculateLocalTransforms(true); - - // save the controller as the collision user data, for collision culling - NewtonCollisionSetUserData(NewtonBodyGetCollision(rootBody), dynamicRagdoll); - - int stackIndex = 0; - DemoEntity* childEntities[32]; - dAnimationJoint* parentBones[32]; - - for (DemoEntity* child = modelEntity->GetChild(); child; child = child->GetSibling()) { - parentBones[stackIndex] = dynamicRagdoll; - childEntities[stackIndex] = child; - stackIndex++; - } - - // walk model hierarchic adding all children designed as rigid body bones. - while (stackIndex) { - stackIndex--; - DemoEntity* const entity = childEntities[stackIndex]; - dAnimationJoint* parentNode = parentBones[stackIndex]; - - const char* const name = entity->GetName().GetStr(); - for (int i = 0; i < definitionCount; i++) { - if (!strcmp(jointsDefinition[i].m_boneName, name)) { - NewtonBody* const childBody = CreateBodyPart(entity); - // connect this body part to its parent with a rag doll joint - parentNode = CreateChildNode(childBody, parentNode, jointsDefinition[i]); - - NewtonCollisionSetUserData(NewtonBodyGetCollision(childBody), parentNode); - break; - } - } - - for (DemoEntity* child = entity->GetChild(); child; child = child->GetSibling()) { - parentBones[stackIndex] = parentNode; - childEntities[stackIndex] = child; - stackIndex++; - } - } - - SetModelMass (100.0f, dynamicRagdoll); - - // set the collision mask - // note this container work best with a material call back for setting bit field - //dAssert(0); - //controller->SetDefaultSelfCollisionMask(); - - // transform the entire contraction to its location - dMatrix worldMatrix(modelEntity->GetCurrentMatrix() * location); - worldMatrix.m_posit = location.m_posit; - NewtonBodySetMatrixRecursive(rootBody, &worldMatrix[0][0]); - - // attach effectors here - for (dAnimationJoint* joint = GetFirstJoint(dynamicRagdoll); joint; joint = GetNextJoint(joint)) { - if (joint->GetAsRoot()) { - dAssert(dynamicRagdoll == joint); - dynamicRagdoll->SetHipEffector(joint); - } else if (joint->GetAsLeaf()) { - dynamicRagdoll->SetFootEffector(joint); - } - } - - dynamicRagdoll->Finalize(); - //return controller; - } - - void OnPostUpdate(dAnimationJointRoot* const model, dFloat timestep) - { - // do nothing for now - } - - virtual void OnUpdateTransform(const dAnimationJoint* const bone, const dMatrix& localMatrix) const - { - // calculate the local transform for this player body - NewtonBody* const body = bone->GetBody(); - DemoEntity* const ent = (DemoEntity*)NewtonBodyGetUserData(body); - DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(NewtonBodyGetWorld(body)); - - dQuaternion rot(localMatrix); - ent->SetMatrix(*scene, rot, localMatrix.m_posit); - } - - void OnPreUpdate(dAnimationJointRoot* const model, dFloat timestep) - { - // call the solver - dAnimationModelManager::OnPreUpdate(model, timestep); - } -}; - - -void DynamicRagdoll(DemoEntityManager* const scene) -{ - // load the sky box - scene->CreateSkyBox(); -dTrace(("sorry demo %s temporarilly disabled\n", __FUNCTION__)); -return; - - CreateLevelMesh(scene, "flatPlane.ngd", true); - - dDynamicRagdollManager* const manager = new dDynamicRagdollManager(scene); - NewtonWorld* const world = scene->GetNewton(); - int defaultMaterialID = NewtonMaterialGetDefaultGroupID(world); - NewtonMaterialSetDefaultFriction(world, defaultMaterialID, defaultMaterialID, 1.0f, 1.0f); - NewtonMaterialSetDefaultElasticity(world, defaultMaterialID, defaultMaterialID, 0.0f); - - dMatrix origin (dYawMatrix(0.0f * dDegreeToRad)); - origin.m_posit.m_y = 2.0f; - manager->CreateRagdollExperiment_0(origin); -/* -// int count = 10; -// count = 1; -//origin = dGetIdentityMatrix(); - origin.m_posit.m_x = 2.0f; -// origin.m_posit.m_y = 2.1f; - origin.m_posit.m_y = 3.0f; - for (int i = 0; i < count; i++) { - manager->CreateRagDoll(scene, origin); - //manager->CreateRagDoll (scene, origin1); - origin.m_posit.m_x += 1.0f; - } -*/ - origin.m_posit.m_x = -3.0f; - origin.m_posit.m_y = 1.0f; - origin.m_posit.m_z = 0.0f; - scene->SetCameraMatrix(dGetIdentityMatrix(), origin.m_posit); -} - - - - diff --git a/applications/demosSandbox/sdkDemos/demos/ServoJoints.cpp b/applications/demosSandbox/sdkDemos/demos/ServoJoints.cpp index e0dd88135d..ea6458f6eb 100644 --- a/applications/demosSandbox/sdkDemos/demos/ServoJoints.cpp +++ b/applications/demosSandbox/sdkDemos/demos/ServoJoints.cpp @@ -13,10 +13,11 @@ #include "SkyBox.h" #include "DemoMesh.h" #include "DemoCamera.h" +#include "DebugDisplay.h" #include "PhysicsUtils.h" #include "TargaToOpenGl.h" +#include "dWoodFracture.h" #include "DemoEntityManager.h" -#include "DebugDisplay.h" #include "HeightFieldPrimitive.h" #define D_TRACTOR_CAMERA_DIST 10.0f @@ -74,15 +75,6 @@ class dTractorEngine: public dCustomDoubleHinge EnableLimits1(false); } - void SubmitConstraints(dFloat timestep, int threadIndex) - { - //dMatrix matrix1; - //NewtonBodyGetMatrix(m_body1, &matrix1[0][0]); - //dMatrix matrix0(GetMatrix0().Inverse() * GetMatrix1() * matrix1); - //NewtonBodySetMatrixNoSleep(m_body0, &matrix0[0][0]); - dCustomDoubleHinge::SubmitConstraints(timestep, threadIndex); - } - void SubmitAngularRow(const dMatrix& matrix0, const dMatrix& matrix1, dFloat timestep) { dCustomDoubleHinge::SubmitAngularRow(matrix0, matrix1, timestep); @@ -528,7 +520,7 @@ class ServoVehicleManagerManager: public dModelManager int material = NewtonMaterialGetDefaultGroupID(world); NewtonMaterialSetCallbackUserData(world, material, material, this); - NewtonMaterialSetDefaultElasticity(world, material, material, 0.1f); + NewtonMaterialSetDefaultElasticity(world, material, material, 0.0f); NewtonMaterialSetDefaultFriction(world, material, material, 0.9f, 0.9f); } @@ -590,14 +582,6 @@ class ServoVehicleManagerManager: public dModelManager return tractor; } -/* - virtual void OnDebug(dModelRootNode* const model, dCustomJoint::dDebugDisplay* const debugContext) - { - dExcavatorModel* const excavator = (dExcavatorModel*)model; - excavator->OnDebug(debugContext); - } -*/ - virtual void OnPreUpdate(dModelRootNode* const model, dFloat timestep) const { dTractorModel* const tractor = (dTractorModel*)model; @@ -650,25 +634,6 @@ void ServoJoints (DemoEntityManager* const scene) matrix.m_posit = FindFloor(world, origin, 100.0f); matrix.m_posit.m_y += 1.5f; vehicleManager->CreateTractor("tractor.ngd", matrix); -/* - NewtonWorld* const world = scene->GetNewton(); - dVector origin (FindFloor (world, dVector (-10.0f, 50.0f, 0.0f, 1.0f), 2.0f * 50.0f)); - - // add an input Manage to manage the inputs and user interaction - ServoInputManager* const inputManager = new ServoInputManager (scene); - inputManager; - - // create a skeletal transform controller for controlling rag doll - ServoVehicleManagerManager* const vehicleManager = new ServoVehicleManagerManager (scene); - - dMatrix matrix (dGetIdentityMatrix()); - matrix.m_posit = FindFloor (world, origin, 100.0f); - matrix.m_posit.m_y += 0.5f; - - // load a the mesh of the articulate vehicle - dModelRootNode* const forklift = vehicleManager->CreateForklift(matrix, "forklift.ngd", sizeof(inverseKinematicsRidParts) / sizeof (inverseKinematicsRidParts[0]), inverseKinematicsRidParts); - inputManager->AddPlayer(forklift); -*/ #if 1 //place heavy load to show reproduce black bird dream problems @@ -683,11 +648,19 @@ void ServoJoints (DemoEntityManager* const scene) LoadLumberYardMesh(scene, dVector(10.0f, 0.0f, 2.0f, 0.0f), 0); LoadLumberYardMesh(scene, dVector(15.0f, 0.0f, 0.0f, 0.0f), 0); LoadLumberYardMesh(scene, dVector(15.0f, 0.0f, 6.0f, 0.0f), 0); + + int woodX = 8; + int woodZ = 8; + matrix.m_posit.m_z += 10.0f; + matrix.m_posit.m_x -= 5.0f; + AddFracturedWoodPrimitive(scene, 1000.0f, matrix.m_posit, dVector(0.3f, 3.0f, 0.3f, 0.0f), + woodX, woodZ, 0.5f, 0, 0, dGetIdentityMatrix()); + #endif origin.m_x -= 10.0f; origin.m_y += 4.0f; //origin.m_z = 6.0f; - dQuaternion rot (dVector (0.0f, 1.0f, 0.0f, 0.0f), 90.0f * dDegreeToRad); + dQuaternion rot (dVector (0.0f, 1.0f, 0.0f, 0.0f), 0.0f * dDegreeToRad); scene->SetCameraMatrix(rot, origin); }