浏览代码

EasyPhysics : Added Capsules.

legacy
Benjamin ‘Touky’ Huet touky 12 年前
父节点
当前提交
444ed1df81
共有 3 个文件被更改,包括 23 次插入1 次删除
  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 查看文件

@@ -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 查看文件

@@ -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 查看文件

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


正在加载...
取消
保存