Changeset 1724
- Timestamp:
- Aug 12, 2012, 11:07:23 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/camera.cpp
r1442 r1724 73 73 return m_target; 74 74 } 75 vec3 Camera::GetPosition() 76 { 77 return m_position; 78 } 75 79 76 80 mat4 const &Camera::GetViewMatrix() -
trunk/src/camera.h
r1375 r1724 37 37 void SetTarget(vec3 const &pos); 38 38 vec3 GetTarget(); 39 vec3 GetPosition(); 39 40 40 41 mat4 const &GetViewMatrix(); -
trunk/test/BtPhysTest.cpp
r1722 r1724 52 52 #define USE_WALL 1 53 53 #define USE_PLATFORM 1 54 #define USE_ROPE 055 #define USE_BODIES 054 #define USE_ROPE 1 55 #define USE_BODIES 1 56 56 #define USE_ROTATION 0 57 57 #define USE_CHARACTER 1 … … 71 71 72 72 m_simulation = new Simulation(); 73 m_simulation->SetWorldLimit(vec3(-1000.0f, -1000.0f, -1000.0f), vec3(1000.0f, 1000.0f, 1000.0f)); 73 74 m_simulation->Init(); 74 75 vec3 NewGravity = vec3(.0f, -10.0f, .0f); … … 110 111 { 111 112 quat NewRotation = quat::fromeuler_xyz(5.f, 0.f, 0.f); 112 vec3 NewPosition = pos_offset + vec3(5.0f, -2 0.0f, -15.0f);113 vec3 NewPosition = pos_offset + vec3(5.0f, -25.0f, -15.0f); 113 114 114 115 PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 1); … … 128 129 { 129 130 quat NewRotation = quat::fromeuler_xyz(0.f, 0.f, 0.f); 130 vec3 NewPosition = pos_offset + vec3(.0f, 40.0f, .0f);131 vec3 NewPosition = pos_offset + vec3(.0f, 20.0f, .0f); 131 132 132 133 PhysicsObject* NewPhyobj = new PhysicsObject(m_simulation, NewPosition, NewRotation, 2); … … 410 411 { 411 412 PhysicsObject* PhysObj = m_character_list[i]; 413 EasyCharacterController* Character = (EasyCharacterController*)PhysObj->GetCharacter(); 414 415 int HMovement = Input::GetButtonState(275 /*SDLK_RIGHT*/) - Input::GetButtonState(276 /*SDLK_LEFT*/); 416 int VMovement = Input::GetButtonState(273 /*SDLK_UP*/) - Input::GetButtonState(274 /*SDLK_DOWN*/); 417 418 Character->SetMovementForFrame(vec3((float)VMovement * seconds * 4.f, .0f, (float)HMovement * seconds * 4.f)); 419 } 420 } 421 422 if (USE_CHARACTER) 423 { 424 PhysObjBarycenter = vec3(.0f); 425 factor = .0f; 426 427 for (int i = 0; i < m_character_list.Count(); i++) 428 { 429 PhysicsObject* PhysObj = m_character_list[i]; 412 430 mat4 GroundMat = PhysObj->GetTransform(); 413 431 … … 418 436 PhysObjBarycenter /= factor; 419 437 420 m_camera->SetTarget(PhysObjBarycenter); 421 m_camera->SetPosition(PhysObjBarycenter + vec3(-80.0f, 80.0f, .0f)); 438 m_camera->SetTarget(m_camera->GetTarget() + (seconds / (seconds + 0.18f)) * (PhysObjBarycenter - m_camera->GetTarget())); 439 vec3 CamPosCenter = m_camera->GetTarget() + vec3(.0f, 20.0f, .0f); 440 m_camera->SetPosition(CamPosCenter + normalize(m_camera->GetPosition() - CamPosCenter) * 5.0f); 422 441 } 423 442 else -
trunk/test/PhysicObject.h
r1722 r1724 41 41 { 42 42 m_mesh.Compile("[sc#ddd afcb20 1 20 -.1]"); 43 //m_mesh.Compile("[sc#f00 afcb10 10 10 -.1]");44 45 43 vec3 BoxSize = vec3(20.f, 1.f, 20.f); 46 44 m_physics.SetCollisionChannel(0, 0xFF); … … 54 52 { 55 53 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); 54 //m_mesh.Compile("[sc#f00 afcb10 10 10 -.1]"); 55 m_mesh.Compile( 56 "[sc#000 scb#000" 57 //"[sc#aaa scb#aaa" 58 "[ad8 2 0 rx180 ty-1]" 59 "[asph8 .5 .5 .5 ty1]" 60 "[ac32 2 .5 .5 0 0]" 61 "[asph6 .1 .1 .1 ty.9 tx.5 tz.15]" 62 "[asph6 .1 .1 .1 ty.9 tx.5 tz-.15]" 63 "[asph8 .05 .5 .05 ty.6 tz.5]" 64 "[asph8 .05 .5 .05 ty.6 tz-.5]" 65 "]" 66 "[sc#fd0 scb#fd0" 67 "[ac8 .4 .1 0 0 0 ty.25 rz-90 ty.7 tx.5]" 68 "]" 69 "[" 70 "[sc#fff scb#fff" 71 "[ad8 2 0 rx180 ty-1]" 72 "[asph8 .5 .5 .5 ty1]" 73 "[ac32 1.9 .5 .5 0 0]" 74 "]" 75 " ty-.1 tx.05]" 76 ); 77 vec3 BoxSize = vec3(.5f, 2.f, .5f); 59 78 m_character.SetCollisionChannel(0, 0xFF); 60 79 m_character.SetShapeToCapsule(BoxSize.x, BoxSize.y); … … 89 108 int ConeLimit = MeshRand.Count(); 90 109 91 MeshRand << "[sc#add scb#add ad1 2 0 rx180 ty-1 ac 12 2 0 0 0]";92 MeshRand << "[sc#dad scb#dad ad1 2 0 rx180 ty-1 ac 12 2 0 0 0]";93 MeshRand << "[sc#dda scb#dda ad1 2 0 rx180 ty-1 ac 12 2 0 0 0]";94 MeshRand << "[sc#daa scb#daa ad1 2 0 rx180 ty-1 ac 12 2 0 0 0]";95 MeshRand << "[sc#ada scb#ada ad1 2 0 rx180 ty-1 ac 12 2 0 0 0]";96 MeshRand << "[sc#aad scb#aad ad1 2 0 rx180 ty-1 ac 12 2 0 0 0]";110 MeshRand << "[sc#add scb#add ad1 2 0 rx180 ty-1 ac4 2 2 0 0 0]"; 111 MeshRand << "[sc#dad scb#dad ad1 2 0 rx180 ty-1 ac4 2 2 0 0 0]"; 112 MeshRand << "[sc#dda scb#dda ad1 2 0 rx180 ty-1 ac4 2 2 0 0 0]"; 113 MeshRand << "[sc#daa scb#daa ad1 2 0 rx180 ty-1 ac4 2 2 0 0 0]"; 114 MeshRand << "[sc#ada scb#ada ad1 2 0 rx180 ty-1 ac4 2 2 0 0 0]"; 115 MeshRand << "[sc#aad scb#aad ad1 2 0 rx180 ty-1 ac4 2 2 0 0 0]"; 97 116 98 117 int CylLimit = MeshRand.Count(); 99 118 100 MeshRand << "[sc#add scb#add ad1 2 0 rx180 ty-1 my ac 12 2 2 0 0]";101 MeshRand << "[sc#dad scb#dad ad1 2 0 rx180 ty-1 my ac 12 2 2 0 0]";102 MeshRand << "[sc#dda scb#dda ad1 2 0 rx180 ty-1 my ac 12 2 2 0 0]";103 MeshRand << "[sc#daa scb#daa ad1 2 0 rx180 ty-1 my ac 12 2 2 0 0]";104 MeshRand << "[sc#ada scb#ada ad1 2 0 rx180 ty-1 my ac 12 2 2 0 0]";105 MeshRand << "[sc#aad scb#aad ad1 2 0 rx180 ty-1 my ac 12 2 2 0 0]";119 MeshRand << "[sc#add scb#add ad1 2 0 rx180 ty-1 my ac4 2 2 2 0 0]"; 120 MeshRand << "[sc#dad scb#dad ad1 2 0 rx180 ty-1 my ac4 2 2 2 0 0]"; 121 MeshRand << "[sc#dda scb#dda ad1 2 0 rx180 ty-1 my ac4 2 2 2 0 0]"; 122 MeshRand << "[sc#daa scb#daa ad1 2 0 rx180 ty-1 my ac4 2 2 2 0 0]"; 123 MeshRand << "[sc#ada scb#ada ad1 2 0 rx180 ty-1 my ac4 2 2 2 0 0]"; 124 MeshRand << "[sc#aad scb#aad ad1 2 0 rx180 ty-1 my ac4 2 2 2 0 0]"; 106 125 107 126 int CapsLimit = MeshRand.Count(); -
trunk/test/Physics/EasyPhysics.cpp
r1722 r1724 308 308 } 309 309 310 //Set movement for this frame 311 void EasyCharacterController::SetMovementForFrame(vec3 &MoveQuantity) 312 { 313 m_character->setWalkDirection(LOL2BT_VEC3(MoveQuantity)); 314 } 315 316 310 317 //------------------------------------------------------------------------- 311 318 //EASY_CONSTRAINT -
trunk/test/Physics/EasyPhysics.h
r1722 r1724 143 143 virtual void AddToSimulation(class Simulation* current_simulation); 144 144 virtual void RemoveFromSimulation(class Simulation* current_simulation); 145 virtual void SetMovementForFrame(vec3 &MoveQuantity); 145 146 146 147 protected: -
trunk/test/Physics/LolPhysics.h
r1698 r1724 46 46 { 47 47 // Build the broadphase 48 m_broadphase = new btDbvtBroadphase(); 48 if (1) 49 { 50 m_Sweep_broadphase = new btAxisSweep3(LOL2BT_VEC3(m_world_min), LOL2BT_VEC3(m_world_max)); 51 m_Sweep_broadphase->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback()); 52 m_broadphase = m_Sweep_broadphase; 53 } 54 else 55 m_broadphase = new btDbvtBroadphase(); 49 56 50 57 // Set up the collision configuration and dispatcher … … 99 106 } 100 107 108 void CustomSetWorldLimit(vec3 &NewWorldMin, vec3 &NewWorldMax) 109 { 110 } 111 101 112 void CustomSetTimestep(float NewTimestep) { } 102 113 103 114 //broadphase 104 115 btBroadphaseInterface* m_broadphase; 116 btAxisSweep3* m_Sweep_broadphase; 105 117 // Set up the collision configuration and dispatc 106 118 btDefaultCollisionConfiguration* m_collision_configuration; … … 120 132 void CustomSetContinuousDetection(bool ShouldUseCCD) { } 121 133 void CustomSetGravity(vec3 &NewGravity) { } 134 void CustomSetWorldLimit(vec3 &NewWorldMin, vec3 &NewWorldMax) { } 122 135 void CustomSetTimestep(float NewTimestep) { } 123 136 … … 141 154 m_gravity = NewGravity; 142 155 CustomSetGravity(NewGravity); 156 } 157 158 //Sets the simulation gravity. 159 void SetWorldLimit(vec3 &NewWorldMin, vec3 &NewWorldMax) 160 { 161 m_world_min = NewWorldMin; 162 m_world_max = NewWorldMax; 163 CustomSetWorldLimit(NewWorldMin, NewWorldMax); 143 164 } 144 165 … … 173 194 bool m_using_CCD; 174 195 vec3 m_gravity; 196 vec3 m_world_min; 197 vec3 m_world_max; 175 198 }; 176 199
Note: See TracChangeset
for help on using the changeset viewer.