Changeset 8894 in orxonox.OLD for trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
- Timestamp:
- Jun 29, 2006, 12:19:48 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
r8796 r8894 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 … … 26 26 #include <vector> 27 27 28 #include "debug.h" 29 28 30 #include "aabb.h" 31 32 #include "cr_defs.h" 29 33 30 34 using namespace std; … … 64 68 // collision->getEntityB()->getAbsCoor().debug(); 65 69 66 Vectorheight;70 float height; 67 71 AABB* box = collision->getEntityB()->getModelAABB(); 68 69 70 71 if(box!=NULL) 72 WorldEntity* entity = collision->getEntityB(); 73 74 // collision position maths 75 Vector collPos = collision->getEntityB()->getAbsCoor() + box->center - ce->getCollisionPosition(); 76 77 float CR_MAX_WALK_HEIGHT = 2.0f; 78 float CR_THRESHOLD = 0.2f; 79 80 if( box == NULL) 81 { 82 PRINTF(2)("this model has no aabb box so there is no correct collision reaction implemented. skipping\n"); 83 return; 84 } 85 86 87 switch( ce->getType()) 88 { 89 case COLLISION_TYPE_AXIS_Y: 90 91 height = collPos.y - box->halfLength[1]; 92 // PRINTF(0)("height: %f , model height: %f\n", height, box->halfLength[1]); 93 // PRINTF(0)(" ground normal: %f, %f, %f\n", normal.x, normal.y, normal.z); 94 95 // object is beneath the plane (ground) 96 if( height <= 0.0f ) 97 { 98 entity->shiftCoor(Vector(0, -height, 0)); 99 } 100 // object is already in the wall 101 else if( ce->isInWall()) 102 { 103 entity->setAbsCoor(entity->getLastAbsCoor()); 104 } 105 break; 106 107 108 case COLLISION_TYPE_AXIS_X: 109 case COLLISION_TYPE_AXIS_Z: 110 break; 111 112 } 113 114 115 116 117 118 119 120 121 #if 0 122 if( box != NULL) 72 123 height = ( ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() )*(-1.0f) ; 73 124 else 74 125 height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor() ; 75 126 76 if(box!=NULL) { 127 128 if( box != NULL) { 77 129 78 130 … … 90 142 return; 91 143 } 92 93 144 145 94 146 if(ce->getGroundNormal().len() >= 1.4f) { 95 147 downspeed++; … … 101 153 if(height.y > box->halfLength[1] + 0.0f ) // Above ground 102 154 { 103 if(height.y < box->halfLength[1] + 1.3f) // Snap in155 if(height.y < box->halfLength[1] + 2.3f) // Snap in 104 156 { 105 157 downspeed = 0; … … 116 168 { 117 169 //if(downspeed <= 0) downspeed =1; 118 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y + box->halfLength[1] + 2.0f /* 0.00001 *//*height.y+3.500005 + 10.0*/,0.0));170 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0, -height.y + box->halfLength[1] + 2.0f,0.0)); 119 171 //collision->getEntityB()->setVelocity(Vector(0.0,0.0,0.0)); 120 172 downspeed = 0; … … 124 176 125 177 }// if(box!= NULL) 178 #endif 126 179 /* 127 180 PRINTF(0)("Collision with Ground: \n"); … … 131 184 132 185 */ 186 133 187 } 134 188 … … 141 195 void CRPhysicsGroundWalk::update(WorldEntity* owner) 142 196 { 143 for( int i = 9; i > 0; i--) { 144 this->lastPositions[i] = this->lastPositions[i-1]; 145 // PRINTF(0)("lastPosition[%i]: %f, %f, %f\n", i, lastPositions[i].x, lastPositions[i].y, lastPositions[i].z); 146 } 147 this->lastPositions[0] = owner->getAbsCoor(); 197 148 198 } 149 199
Note: See TracChangeset
for help on using the changeset viewer.