EasyPhysics : Added Cone primitive.legacy
| @@ -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; | vec3 p1(r1, -h * .5f, 0.f), p2(r2, h * .5f, 0.f), n; | ||||
| /* Construct normal */ | /* 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; | n.y = r1 * (r1 - r2) / h; | ||||
| if (!smooth) | if (!smooth) | ||||
| n = mat3::rotate(180.0f / nsides, 0.f, 1.f, 0.f) * n; | n = mat3::rotate(180.0f / nsides, 0.f, 1.f, 0.f) * n; | ||||
| @@ -53,13 +53,23 @@ public: | |||||
| MeshRand << "[sc#ada asph16 2 2 2]"; | MeshRand << "[sc#ada asph16 2 2 2]"; | ||||
| MeshRand << "[sc#aad 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)); | 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); | ||||
| if (RandValue >= SphereLimit) | |||||
| if (RandValue >= SphereLimit && RandValue < ConeLimit) | |||||
| m_physics.SetShapeToSphere(BoxSize.x); | m_physics.SetShapeToSphere(BoxSize.x); | ||||
| else if (RandValue >= ConeLimit) | |||||
| m_physics.SetShapeToCone(BoxSize.x, BoxSize.y); | |||||
| else | else | ||||
| m_physics.SetShapeToBox(BoxSize); | m_physics.SetShapeToBox(BoxSize); | ||||
| m_physics.SetMass(base_mass); | m_physics.SetMass(base_mass); | ||||
| @@ -73,6 +73,12 @@ void EasyPhysics::SetShapeToSphere(float radius) | |||||
| SetShapeTo(new btSphereShape(radius * LOL2BT_UNIT * LOL2BT_SIZE)); | 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 | //Base Location/Rotation setup | ||||
| //-- | //-- | ||||
| @@ -37,6 +37,7 @@ public: | |||||
| void SetShapeToBox(lol::vec3& box_size); | void SetShapeToBox(lol::vec3& box_size); | ||||
| void SetShapeToSphere(float radius); | 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 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(); | ||||
| @@ -62,6 +63,7 @@ public: | |||||
| EasyPhysics() { } | EasyPhysics() { } | ||||
| void SetShapeToBox(lol::vec3& BoxSize) { } | 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 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() { } | ||||