Browse Source

Added sphere in EasyPhysics

legacy
Benjamin ‘Touky’ Huet touky 12 years ago
parent
commit
9c5364c734
3 changed files with 19 additions and 5 deletions
  1. +14
    -1
      test/PhysicObject.h
  2. +4
    -4
      test/Physics/EasyPhysics.cpp
  3. +1
    -0
      test/Physics/EasyPhysics.h

+ 14
- 1
test/PhysicObject.h View File

@@ -44,11 +44,24 @@ public:
MeshRand << "[sc#ada afcb2 2 2 -.1]"; MeshRand << "[sc#ada afcb2 2 2 -.1]";
MeshRand << "[sc#aad afcb2 2 2 -.1]"; MeshRand << "[sc#aad afcb2 2 2 -.1]";


int SphereLimit = MeshRand.Count();

MeshRand << "[sc#add asph16 2 2 2]";
MeshRand << "[sc#dad asph16 2 2 2]";
MeshRand << "[sc#dda asph16 2 2 2]";
MeshRand << "[sc#daa asph16 2 2 2]";
MeshRand << "[sc#ada asph16 2 2 2]";
MeshRand << "[sc#aad asph16 2 2 2]";


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


m_mesh.Compile(MeshRand[RandValue]); m_mesh.Compile(MeshRand[RandValue]);
vec3 BoxSize = vec3(2.0f); vec3 BoxSize = vec3(2.0f);
m_physics.SetShapeToBox(BoxSize);
if (RandValue >= SphereLimit)
m_physics.SetShapeToSphere(BoxSize.x);
else
m_physics.SetShapeToBox(BoxSize);
m_physics.SetMass(base_mass); m_physics.SetMass(base_mass);
m_physics.SetBaseTransform(base_location); m_physics.SetBaseTransform(base_location);
m_physics.InitBodyToRigid(); m_physics.InitBodyToRigid();


+ 4
- 4
test/Physics/EasyPhysics.cpp View File

@@ -68,10 +68,10 @@ void EasyPhysics::SetShapeToBox(lol::vec3& box_size)
SetShapeTo(new btBoxShape(LOL2BT_VEC3(new_box_size))); SetShapeTo(new btBoxShape(LOL2BT_VEC3(new_box_size)));
} }


//void EasyPhysics::SetShapeToSphere(lol::vec3& box_size)
//{
// SetShapeTo(new btBoxShape(LOL2BT_VEC3(box_size * LOL2BT_UNIT * LOL2BT_SIZE)));
//}
void EasyPhysics::SetShapeToSphere(float radius)
{
SetShapeTo(new btSphereShape(radius * LOL2BT_UNIT * LOL2BT_SIZE));
}


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


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

@@ -36,6 +36,7 @@ public:
EasyPhysics(); EasyPhysics();


void SetShapeToBox(lol::vec3& box_size); void SetShapeToBox(lol::vec3& box_size);
void SetShapeToSphere(float radius);
void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))); void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
void SetMass(float mass); void SetMass(float mass);
void InitBodyToRigid(); void InitBodyToRigid();


Loading…
Cancel
Save