Selaa lähdekoodia

EasyPhysics : Added Capsules.

legacy
Benjamin ‘Touky’ Huet touky 12 vuotta sitten
vanhempi
commit
444ed1df81
3 muutettua tiedostoa jossa 23 lisäystä ja 1 poistoa
  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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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() { }


Ladataan…
Peruuta
Tallenna