Browse Source

EasyPhysics : Added Capsules.

legacy
Benjamin ‘Touky’ Huet touky 12 years ago
parent
commit
444ed1df81
3 changed files with 23 additions and 1 deletions
  1. +12
    -1
      test/PhysicObject.h
  2. +6
    -0
      test/Physics/EasyPhysics.cpp
  3. +5
    -0
      test/Physics/EasyPhysics.h

+ 12
- 1
test/PhysicObject.h View File

@@ -71,6 +71,15 @@ public:
MeshRand << "[sc#ada scb#ada ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";
MeshRand << "[sc#aad scb#aad ad16 2 0 rx180 ty-1 my ac16 2 2 2 0 0]";

int CapsLimit = MeshRand.Count();

MeshRand << "[sc#add scb#add asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]";
MeshRand << "[sc#dad scb#dad asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]";
MeshRand << "[sc#dda scb#dda asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]";
MeshRand << "[sc#daa scb#daa asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]";
MeshRand << "[sc#ada scb#ada asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]";
MeshRand << "[sc#aad scb#aad asph16 2 2 2 ty-1 my ac16 2 1 1 0 0]";

int RandValue = (int)(lol::RandF() * (MeshRand.Count() - 1));

m_mesh.Compile(MeshRand[RandValue]);
@@ -81,8 +90,10 @@ public:
m_physics.SetShapeToSphere(BoxSize.x);
else if (RandValue < CylLimit)
m_physics.SetShapeToCone(BoxSize.x, BoxSize.y);
else
else if (RandValue < CapsLimit)
m_physics.SetShapeToCylinder(BoxSize);
else
m_physics.SetShapeToCapsule(BoxSize.x, BoxSize.y);

m_physics.SetMass(base_mass);
m_physics.SetBaseTransform(base_location);


+ 6
- 0
test/Physics/EasyPhysics.cpp View File

@@ -93,6 +93,12 @@ void EasyPhysics::SetShapeToCylinder(lol::vec3& cyl_size)
SetShapeTo(new btCylinderShape(LOL2BT_VEC3(new_cyl_size)));
}

void EasyPhysics::SetShapeToCapsule(float radius, float height)
{
SetShapeTo(new btCapsuleShape( radius * LOL2BT_UNIT * LOL2BT_SIZE,
height * LOL2BT_UNIT * LOL2BT_SIZE));
}

//-------------------------------------------------------------------------
//Base Location/Rotation setup
//--


+ 5
- 0
test/Physics/EasyPhysics.h View File

@@ -40,6 +40,7 @@ public:
void SetShapeToSphere(float radius);
void SetShapeToCone(float radius, float height);
void SetShapeToCylinder(lol::vec3& cyl_size);
void SetShapeToCapsule(float radius, float height);

void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
void SetMass(float mass);
@@ -67,6 +68,10 @@ public:

void SetShapeToBox(lol::vec3& BoxSize) { }
void SetShapeToSphere(float radius) { }
void SetShapeToCone(float radius, float height) { }
void SetShapeToCylinder(lol::vec3& cyl_size) { }
void SetShapeToCapsule(float radius, float height) { }

void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { }
void SetMass(float mass) { }
void InitBodyToRigid() { }


Loading…
Cancel
Save