Benjamin ‘Touky’ Huet touky pirms 12 gadiem
vecāks
revīzija
c0d15f170a
3 mainītis faili ar 58 papildinājumiem un 2 dzēšanām
  1. +42
    -1
      test/BtPhysTest.cpp
  2. +1
    -0
      test/BtPhysTest.h
  3. +15
    -1
      test/PhysicObject.h

+ 42
- 1
test/BtPhysTest.cpp Parādīt failu

@@ -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();


+ 1
- 0
test/BtPhysTest.h Parādīt failu

@@ -30,6 +30,7 @@ private:
Array<PhysicsObject*> m_ground_list;
Array<PhysicsObject*> m_platform_list;
Array<PhysicsObject*> m_character_list;
Array<PhysicsObject*> m_stairs_list;

float m_loop_value;
};


+ 15
- 1
test/PhysicObject.h Parādīt failu

@@ -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)


Notiek ielāde…
Atcelt
Saglabāt