Changeset 8724 in orxonox.OLD for trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
- Timestamp:
- Jun 22, 2006, 3:14:58 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/collision_reaction/cr_physics_ground_walk.cc
r8490 r8724 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 "debug.h"27 28 26 #include <vector> 29 27 … … 35 33 */ 36 34 CRPhysicsGroundWalk::CRPhysicsGroundWalk () 37 : CollisionReaction()35 : CollisionReaction() 38 36 { 39 37 this->setClassID(CL_CR_PHYSICS_GROUND_WALK, "CRPhysicsGroundWalk"); … … 45 43 */ 46 44 CRPhysicsGroundWalk::~CRPhysicsGroundWalk () 47 { 48 } 45 {} 49 46 50 47 … … 57 54 CollisionEvent* ce = collision->getCollisionEvents().front(); 58 55 Vector normal = ce->getGroundNormal(); 59 normal.normalize();56 // normal.normalize(); 60 57 61 58 // put it back 62 // PRINTF(0)("putting it back to lastPos: \n");63 // this->lastPositions[0].debug();64 // PRINTF(0)("current pos:\n");65 // collision->getEntityB()->getAbsCoor().debug();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(); 66 63 64 65 Vector height = ce->getCollisionPosition() - collision->getEntityB()->getAbsCoor(); 66 67 if(ce->getCollisionPosition().x <= 0.9 && ce->getGroundNormal().len() <= 1.4f) { 68 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor()); 69 return; 70 } 71 if(ce->getGroundNormal().len() <= 0.1f) { 72 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getLastAbsCoor()); 73 return; 74 } 75 if(ce->getGroundNormal().len() >= 1.4f) { 76 downspeed++; 77 collision->getEntityB()->setAbsCoor(collision->getEntityB()->getAbsCoor() + Vector(0.0,-0.08*downspeed,0.0)); 78 return; 79 } 80 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 /* 67 108 PRINTF(0)("Collision with Ground: \n"); 68 109 collision->getEntityB()->getAbsCoor().debug(); 110 collision->getEntityB()->setVelocity(Vector()); 111 collision->getEntityB()->setAbsCoor(this->lastPositions[1]); 69 112 70 //collision->getEntityB()->setVelocity(Vector()); 71 //collision->getEntityB()->setAbsCoor(this->lastPositions[5]); 113 */ 72 114 } 115 73 116 74 117 … … 81 124 for( int i = 9; i > 0; i--) { 82 125 this->lastPositions[i] = this->lastPositions[i-1]; 83 // 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); 84 127 } 85 128 this->lastPositions[0] = owner->getAbsCoor();
Note: See TracChangeset
for help on using the changeset viewer.