From c0d15f170ac0948ec18540e6ddbc1414e6c23449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20=E2=80=98Touky=E2=80=99=20Huet?= Date: Fri, 31 Aug 2012 06:38:06 +0000 Subject: [PATCH] --- test/BtPhysTest.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- test/BtPhysTest.h | 1 + test/PhysicObject.h | 16 +++++++++++++++- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/test/BtPhysTest.cpp b/test/BtPhysTest.cpp index 522341ea..84e7a7a4 100644 --- a/test/BtPhysTest.cpp +++ b/test/BtPhysTest.cpp @@ -55,6 +55,7 @@ int gNumObjects = 64; #define USE_BODIES 1 #define USE_ROTATION 0 #define USE_CHARACTER 1 +#define USE_STAIRS 1 #define IPT_MOVE_FORWARD "Move_Forward" #define IPT_MOVE_BACKWARD "Move_Backward" @@ -90,6 +91,39 @@ BtPhysTest::BtPhysTest(bool editor) float offset = 29.5f; vec3 pos_offset = vec3(.0f, 30.f, .0f); + if (USE_STAIRS) + { + vec3 new_offset = vec3(1.0f, .125f, .0f); + quat NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f); + vec3 NewPosition = pos_offset + vec3(5.0f, -29.f, 15.0f); + { + NewRotation = quat::fromeuler_xyz(0.f, 0.f, 30.f); + NewPosition += vec3(4.0f, .0f, -4.0f); + + PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 3); + Ticker::Ref(NewPhyobj); + m_stairs_list << NewPhyobj; + } + { + NewRotation = quat::fromeuler_xyz(0.f, 0.f, 40.f); + NewPosition += vec3(4.0f, .0f, -4.0f); + + PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 3); + Ticker::Ref(NewPhyobj); + m_stairs_list << NewPhyobj; + } + NewPosition = pos_offset + vec3(5.0f, -29.5f, 15.0f); + NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f); + for (int i=0; i < 15; i++) + { + NewPosition += new_offset; + + PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 3); + Ticker::Ref(NewPhyobj); + m_stairs_list << NewPhyobj; + } + } + if (USE_WALL) { for (int i=0; i < 6; i++) @@ -163,7 +197,7 @@ BtPhysTest::BtPhysTest(bool editor) if (USE_CHARACTER) { quat NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f); - vec3 NewPosition = pos_offset + vec3(-15.0f, -10.0f, .0f); + vec3 NewPosition = pos_offset + vec3(-5.0f, -10.0f, 15.0f); PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 2); @@ -407,6 +441,13 @@ BtPhysTest::~BtPhysTest() CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); Ticker::Unref(CurPop); } + while (m_stairs_list.Count()) + { + PhysicsObject* CurPop = m_stairs_list.Last(); + m_stairs_list.Pop(); + CurPop->GetPhysic()->RemoveFromSimulation(m_simulation); + Ticker::Unref(CurPop); + } while (m_character_list.Count()) { PhysicsObject* CurPop = m_character_list.Last(); diff --git a/test/BtPhysTest.h b/test/BtPhysTest.h index 8d5afa31..6439e932 100644 --- a/test/BtPhysTest.h +++ b/test/BtPhysTest.h @@ -30,6 +30,7 @@ private: Array m_ground_list; Array m_platform_list; Array m_character_list; + Array m_stairs_list; float m_loop_value; }; diff --git a/test/PhysicObject.h b/test/PhysicObject.h index 5813b44f..216f66c0 100644 --- a/test/PhysicObject.h +++ b/test/PhysicObject.h @@ -81,14 +81,28 @@ public: "]" " ty-.1 tx.05]" ); - vec3 BoxSize = vec3(.5f, 2.f, .5f); + vec3 BoxSize = vec3(1.f, 2.f, 1.f); m_character->SetCollisionChannel(0, 0xFF); m_character->SetShapeToCapsule(BoxSize.x, BoxSize.y); m_character->SetMass(.0f); + m_character->SetStepHeight(1.f); m_character->SetTransform(base_location, base_rotation); m_character->InitBodyToGhost(); m_character->AddToSimulation(new_sim); } + else if (dummy == 3) //for Stairs purpose + { + m_physics = new EasyPhysic(this); + + m_mesh.Compile("[sc#aae afcb4 .25 4 -.01]"); + vec3 BoxSize = vec3(4.f, .25f, 4.f); + m_physics->SetCollisionChannel(0, 0xFF); + m_physics->SetShapeToBox(BoxSize); + m_physics->SetMass(.0f); + m_physics->SetTransform(base_location, base_rotation); + m_physics->InitBodyToRigid(true); + m_physics->AddToSimulation(new_sim); + } } PhysicsObject(Simulation* new_sim, float base_mass, const vec3 &base_location, int RandValue = -1)