Kaynağa Gözat

EasyMesh : Fixed normals on disc when one of the radius == 0

EasyPhysics : Added Cone primitive.
legacy
Benjamin ‘Touky’ Huet touky 12 yıl önce
ebeveyn
işleme
0ea021a40a
4 değiştirilmiş dosya ile 23 ekleme ve 2 silme
  1. +4
    -1
      src/easymesh/easymesh.cpp
  2. +11
    -1
      test/PhysicObject.h
  3. +6
    -0
      test/Physics/EasyPhysics.cpp
  4. +2
    -0
      test/Physics/EasyPhysics.h

+ 4
- 1
src/easymesh/easymesh.cpp Dosyayı Görüntüle

@@ -304,7 +304,10 @@ void EasyMesh::AppendCylinder(int nsides, float h, float r1, float r2,
vec3 p1(r1, -h * .5f, 0.f), p2(r2, h * .5f, 0.f), n;

/* Construct normal */
n = p2;
if (r2 != .0f)
n = vec3(r2, h * .5f, 0.f);
else
n = vec3(r1, h * .5f, 0.f);
n.y = r1 * (r1 - r2) / h;
if (!smooth)
n = mat3::rotate(180.0f / nsides, 0.f, 1.f, 0.f) * n;


+ 11
- 1
test/PhysicObject.h Dosyayı Görüntüle

@@ -53,13 +53,23 @@ public:
MeshRand << "[sc#ada asph16 2 2 2]";
MeshRand << "[sc#aad asph16 2 2 2]";

int ConeLimit = MeshRand.Count();

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

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

m_mesh.Compile(MeshRand[RandValue]);
vec3 BoxSize = vec3(2.0f);
if (RandValue >= SphereLimit)
if (RandValue >= SphereLimit && RandValue < ConeLimit)
m_physics.SetShapeToSphere(BoxSize.x);
else if (RandValue >= ConeLimit)
m_physics.SetShapeToCone(BoxSize.x, BoxSize.y);
else
m_physics.SetShapeToBox(BoxSize);
m_physics.SetMass(base_mass);


+ 6
- 0
test/Physics/EasyPhysics.cpp Dosyayı Görüntüle

@@ -73,6 +73,12 @@ void EasyPhysics::SetShapeToSphere(float radius)
SetShapeTo(new btSphereShape(radius * LOL2BT_UNIT * LOL2BT_SIZE));
}

void EasyPhysics::SetShapeToCone(float radius, float height)
{
SetShapeTo(new btConeShape( radius * LOL2BT_UNIT,
height * LOL2BT_UNIT));
}

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


+ 2
- 0
test/Physics/EasyPhysics.h Dosyayı Görüntüle

@@ -37,6 +37,7 @@ public:

void SetShapeToBox(lol::vec3& box_size);
void SetShapeToSphere(float radius);
void SetShapeToCone(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();
@@ -62,6 +63,7 @@ public:
EasyPhysics() { }

void SetShapeToBox(lol::vec3& BoxSize) { }
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() { }


Yükleniyor…
İptal
Kaydet