Changeset 1722 for trunk/test/PhysicObject.h
- Timestamp:
- Aug 12, 2012, 5:23:25 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/PhysicObject.h
r1698 r1722 23 23 public: 24 24 PhysicsObject(Simulation* new_sim, const vec3 &base_location, const quat &base_rotation) 25 : m_ready(false), m_should_render(true) 25 : m_ready(false), m_should_render(true), m_is_character(false) 26 26 { 27 27 m_mesh.Compile("[sc#ddd afcb60 1 60 -.1]"); … … 36 36 37 37 PhysicsObject(Simulation* new_sim, const vec3 &base_location, const quat &base_rotation, int dummy) 38 : m_ready(false), m_should_render(true) 39 { 40 m_mesh.Compile("[sc#ddd afcb20 1 20 -.1]"); 41 vec3 BoxSize = vec3(20.f, 1.f, 20.f); 42 m_physics.SetCollisionChannel(0, 0xFF); 43 m_physics.SetShapeToBox(BoxSize); 44 m_physics.SetMass(.0f); 45 m_physics.SetTransform(base_location, base_rotation); 46 m_physics.InitBodyToRigid(true); 47 m_physics.AddToSimulation(new_sim); 38 : m_ready(false), m_should_render(true), m_is_character(false) 39 { 40 if (dummy == 1) //for Rope purpose 41 { 42 m_mesh.Compile("[sc#ddd afcb20 1 20 -.1]"); 43 //m_mesh.Compile("[sc#f00 afcb10 10 10 -.1]"); 44 45 vec3 BoxSize = vec3(20.f, 1.f, 20.f); 46 m_physics.SetCollisionChannel(0, 0xFF); 47 m_physics.SetShapeToBox(BoxSize); 48 m_physics.SetMass(.0f); 49 m_physics.SetTransform(base_location, base_rotation); 50 m_physics.InitBodyToRigid(true); 51 m_physics.AddToSimulation(new_sim); 52 } 53 else if (dummy == 2) //for character purpose 54 { 55 m_is_character = true; 56 m_mesh.Compile("[sc#f00 afcb10 10 10 -.1]"); 57 //m_mesh.Compile("[sc#fff scb#fff ac1 2 2 2 0 0]"); 58 vec3 BoxSize = vec3(2.f, 2.f, 2.f); 59 m_character.SetCollisionChannel(0, 0xFF); 60 m_character.SetShapeToCapsule(BoxSize.x, BoxSize.y); 61 m_character.SetMass(.0f); 62 m_character.SetTransform(base_location, base_rotation); 63 m_character.InitBodyToGhost(); 64 m_character.AddToSimulation(new_sim); 65 } 48 66 } 49 67 50 68 PhysicsObject(Simulation* new_sim, float base_mass, const vec3 &base_location, int RandValue = -1) 51 : m_ready(false), m_should_render(true) 69 : m_ready(false), m_should_render(true), m_is_character(false) 52 70 { 53 71 Array<char const *> MeshRand; … … 62 80 int SphereLimit = MeshRand.Count(); 63 81 64 MeshRand << "[sc#add asph1 52 2 2]";65 MeshRand << "[sc#dad asph1 52 2 2]";66 MeshRand << "[sc#dda asph1 52 2 2]";67 MeshRand << "[sc#daa asph1 52 2 2]";68 MeshRand << "[sc#ada asph1 52 2 2]";69 MeshRand << "[sc#aad asph1 52 2 2]";82 MeshRand << "[sc#add asph1 2 2 2]"; 83 MeshRand << "[sc#dad asph1 2 2 2]"; 84 MeshRand << "[sc#dda asph1 2 2 2]"; 85 MeshRand << "[sc#daa asph1 2 2 2]"; 86 MeshRand << "[sc#ada asph1 2 2 2]"; 87 MeshRand << "[sc#aad asph1 2 2 2]"; 70 88 71 89 int ConeLimit = MeshRand.Count(); 72 90 73 MeshRand << "[sc#add scb#add ad 48 2 0 rx180 ty-1 ac482 2 0 0 0]";74 MeshRand << "[sc#dad scb#dad ad 48 2 0 rx180 ty-1 ac482 2 0 0 0]";75 MeshRand << "[sc#dda scb#dda ad 48 2 0 rx180 ty-1 ac482 2 0 0 0]";76 MeshRand << "[sc#daa scb#daa ad 48 2 0 rx180 ty-1 ac482 2 0 0 0]";77 MeshRand << "[sc#ada scb#ada ad 48 2 0 rx180 ty-1 ac482 2 0 0 0]";78 MeshRand << "[sc#aad scb#aad ad 48 2 0 rx180 ty-1 ac482 2 0 0 0]";91 MeshRand << "[sc#add scb#add ad1 2 0 rx180 ty-1 ac1 2 2 0 0 0]"; 92 MeshRand << "[sc#dad scb#dad ad1 2 0 rx180 ty-1 ac1 2 2 0 0 0]"; 93 MeshRand << "[sc#dda scb#dda ad1 2 0 rx180 ty-1 ac1 2 2 0 0 0]"; 94 MeshRand << "[sc#daa scb#daa ad1 2 0 rx180 ty-1 ac1 2 2 0 0 0]"; 95 MeshRand << "[sc#ada scb#ada ad1 2 0 rx180 ty-1 ac1 2 2 0 0 0]"; 96 MeshRand << "[sc#aad scb#aad ad1 2 0 rx180 ty-1 ac1 2 2 0 0 0]"; 79 97 80 98 int CylLimit = MeshRand.Count(); 81 99 82 MeshRand << "[sc#add scb#add ad 96 2 0 rx180 ty-1 my ac962 2 2 0 0]";83 MeshRand << "[sc#dad scb#dad ad 96 2 0 rx180 ty-1 my ac962 2 2 0 0]";84 MeshRand << "[sc#dda scb#dda ad 96 2 0 rx180 ty-1 my ac962 2 2 0 0]";85 MeshRand << "[sc#daa scb#daa ad 96 2 0 rx180 ty-1 my ac962 2 2 0 0]";86 MeshRand << "[sc#ada scb#ada ad 96 2 0 rx180 ty-1 my ac962 2 2 0 0]";87 MeshRand << "[sc#aad scb#aad ad 96 2 0 rx180 ty-1 my ac962 2 2 0 0]";100 MeshRand << "[sc#add scb#add ad1 2 0 rx180 ty-1 my ac1 2 2 2 0 0]"; 101 MeshRand << "[sc#dad scb#dad ad1 2 0 rx180 ty-1 my ac1 2 2 2 0 0]"; 102 MeshRand << "[sc#dda scb#dda ad1 2 0 rx180 ty-1 my ac1 2 2 2 0 0]"; 103 MeshRand << "[sc#daa scb#daa ad1 2 0 rx180 ty-1 my ac1 2 2 2 0 0]"; 104 MeshRand << "[sc#ada scb#ada ad1 2 0 rx180 ty-1 my ac1 2 2 2 0 0]"; 105 MeshRand << "[sc#aad scb#aad ad1 2 0 rx180 ty-1 my ac1 2 2 2 0 0]"; 88 106 89 107 int CapsLimit = MeshRand.Count(); 90 108 91 MeshRand << "[sc#add scb#add acap 21 2 1]";92 MeshRand << "[sc#dad scb#dad acap 21 2 1]";93 MeshRand << "[sc#dda scb#dda acap 21 2 1]";94 MeshRand << "[sc#daa scb#daa acap 21 2 1]";95 MeshRand << "[sc#ada scb#ada acap 21 2 1]";96 MeshRand << "[sc#aad scb#aad acap 21 2 1]";109 MeshRand << "[sc#add scb#add acap1 2 1]"; 110 MeshRand << "[sc#dad scb#dad acap1 2 1]"; 111 MeshRand << "[sc#dda scb#dda acap1 2 1]"; 112 MeshRand << "[sc#daa scb#daa acap1 2 1]"; 113 MeshRand << "[sc#ada scb#ada acap1 2 1]"; 114 MeshRand << "[sc#aad scb#aad acap1 2 1]"; 97 115 98 116 switch (RandValue) … … 168 186 void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) 169 187 { 170 m_physics.SetTransform(base_location, base_rotation); 188 if (m_is_character) 189 m_character.SetTransform(base_location, base_rotation); 190 else 191 m_physics.SetTransform(base_location, base_rotation); 171 192 } 172 193 173 194 lol::mat4 GetTransform() 174 195 { 175 return m_physics.GetTransform(); 196 if (m_is_character) 197 return m_character.GetTransform(); 198 else 199 return m_physics.GetTransform(); 176 200 } 177 201 … … 183 207 EasyMesh *GetMesh() { return &m_mesh; } 184 208 EasyPhysic *GetPhysic() { return &m_physics; } 209 EasyPhysic *GetCharacter() { return &m_character; } 185 210 186 211 ~PhysicsObject() … … 207 232 208 233 if (m_should_render) 209 m_mesh.Render(m_physics.GetTransform()); 234 { 235 if (m_is_character) 236 m_mesh.Render(m_character.GetTransform()); 237 else 238 m_mesh.Render(m_physics.GetTransform()); 239 } 210 240 } 211 241 212 242 private: 213 243 //Base datas 214 EasyMesh m_mesh; 215 EasyPhysic m_physics; 244 EasyMesh m_mesh; 245 EasyPhysic m_physics; 246 EasyCharacterController m_character; 216 247 217 248 bool m_ready; 218 249 bool m_should_render; 250 bool m_is_character; 219 251 }; 220 252
Note: See TracChangeset
for help on using the changeset viewer.