Sfoglia il codice sorgente

Added sphere in EasyPhysics

legacy
Benjamin ‘Touky’ Huet touky 12 anni fa
parent
commit
9c5364c734
3 ha cambiato i file con 19 aggiunte e 5 eliminazioni
  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 Vedi File

@@ -44,11 +44,24 @@ public:
MeshRand << "[sc#ada 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));

m_mesh.Compile(MeshRand[RandValue]);
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.SetBaseTransform(base_location);
m_physics.InitBodyToRigid();


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

@@ -68,10 +68,10 @@ void EasyPhysics::SetShapeToBox(lol::vec3& 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


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

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

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 SetMass(float mass);
void InitBodyToRigid();


Caricamento…
Annulla
Salva