Changeset 8714 in orxonox.OLD for branches/bsp_model/src/lib/collision_reaction
- Timestamp:
- Jun 22, 2006, 1:40:09 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/collision_reaction/cr_physics_ground_walk.cc
r8699 r8714 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2004 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: Patrick Boenzli … … 24 24 #include "cr_physics_ground_walk.h" 25 25 26 #include "aabb.h"27 28 #include "debug.h"29 30 26 #include <vector> 31 27 … … 37 33 */ 38 34 CRPhysicsGroundWalk::CRPhysicsGroundWalk () 39 : CollisionReaction()35 : CollisionReaction() 40 36 { 41 37 this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk"); … … 47 43 */ 48 44 CRPhysicsGroundWalk::~CRPhysicsGroundWalk () 49 { 50 } 45 {} 51 46 52 47 … … 59 54 CollisionEvent* ce = collision->getCollisionEvents().front(); 60 55 Vector normal = ce->getGroundNormal(); 56 // normal.normalize(); 61 57 62 AABB* box = ce->getEntityB()->getModelAABB(); 58 // put it back 59 // PRINTF(0)("putting it back to lastPos: \n"); 60 // this->lastPositions[0].debug(); 61 // PRINTF(0)("current pos:\n"); 62 // collision->getEntityB()->getAbsCoor().debug(); 63 63 64 Vector center = ce->getEntityB()->getAbsCoor() /*+ box->center*/;65 Vector collisionPos = ce->getCollisionPosition() - center;66 64 67 float objSize = box->halfLength[1];65 Vector height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor(); 68 66 69 if( normal.len() <= 0.1f) 70 { 67 if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) { 71 68 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor()); 72 69 return; 73 70 } 74 75 if( collisionPos.y <= -(objSize + 0.1f)) 76 { 71 if(ce->getGroundNormal().len() <= 0.1f) { 72 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor()); 73 return; 74 } 75 if(ce->getGroundNormal().len() >= 1.4f) { 77 76 downspeed++; 78 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -0.03 * downspeed, 0.0)); 79 } 80 else 81 { 82 if( collisionPos.y > -objSize && 83 collisionPos.y < (objSize + 0.4)) 84 { 85 //if(downspeed <= 0) downspeed =1; 86 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + 87 Vector(0.0, collisionPos.y + objSize + 0.1, 0.0)); 88 } 89 downspeed = 0; 77 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0)); 78 return; 90 79 } 91 80 92 81 82 if(height.y < -3.510001 + 10.0) // Above ground 83 { 84 if(height.y > -15.6) // Snap in 85 { 86 downspeed = 0; 87 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,height.y+3.500005 + 10.0,0.0)); 88 } else 89 { 90 downspeed++; 91 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0)); 92 } 93 94 } 95 else { 96 if(height.y > -3.50000 + 10.0 && height.y < 9.9+ 10.0) // below ground 97 { 98 //if(downspeed <= 0) downspeed =1; 99 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, 0.00001 /*height.y+3.500005 + 10.0*/,0.0)); 100 //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0)); 101 downspeed = 0; 102 } 103 104 } 105 106 107 /* 108 PRINTF(0)("Collision with Ground: \n"); 109 collision->getEntityB()->getAbsCoor().debug(); 110 collision->getEntityB()->setVelocity(Vector()); 111 collision->getEntityB()->setAbsCoor(this->lastPositions[1]); 112 113 */ 93 114 } 94 115 … … 103 124 for( int i = 9; i > 0; i--) { 104 125 this->lastPositions[i] = this->lastPositions[i-1]; 105 // PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z);126 // PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z); 106 127 } 107 128 this->lastPositions[0] = owner->getAbsCoor();
Note: See TracChangeset
for help on using the changeset viewer.