Changeset 1911
- Timestamp:
- 05/12/00 16:46:14 (9 years ago)
- Files:
-
- trunk/juggler_1.0/samples/nav/pfBoxCollider.h (modified) (4 diffs)
- trunk/juggler_1.0/samples/nav/pfMoveCollider.h (deleted)
- trunk/juggler_1.0/samples/nav/pfPogoCollider.h (modified) (5 diffs)
- trunk/juggler_1.0/samples/nav/pfRayCollider.h (added)
- trunk/juggler_1.0/samples/nav/pfTerryBoxCollide.cxx (modified) (1 diff)
- trunk/juggler_1.0/samples/nav/pfTerryBoxCollide.h (modified) (1 diff)
- trunk/juggler_1.0/samples/nav/pfTerryCollide.cxx (modified) (2 diffs)
- trunk/juggler_1.0/samples/nav/pfTerryPogoCollide.cxx (modified) (2 diffs)
- trunk/juggler_1.0/samples/nav/pfTerryPogoCollide.h (modified) (1 diff)
- trunk/juggler_1.0/samples/nav/velocityNav.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/juggler_1.0/samples/nav/pfBoxCollider.h
r1909 r1911 32 32 */ 33 33 34 #ifndef JUGGLER_PF VOLUME_COLLIDER35 #define JUGGLER_PF VOLUME_COLLIDER34 #ifndef JUGGLER_PFBOX_COLLIDER 35 #define JUGGLER_PFBOX_COLLIDER 36 36 37 37 #include <collider.h> 38 #include < collide.h>38 #include <pfTerryBoxCollide.h> 39 39 40 40 //: Collider class for testing collisions in Performer … … 46 46 // So there is some coord system conversion that will be 47 47 // going on here. 48 class pf VolumeCollider : public collider48 class pfBoxCollider : public collider 49 49 { 50 50 public: 51 51 // ARGS: world - The node to start collision with 52 52 // it should be the one under the one being used for navigation ( ie. pfNaver) 53 pf VolumeCollider(pfNode* world) : terryCollide( 0x1 )53 pfBoxCollider(pfNode* world) : terryCollide( 0x1 ) 54 54 { 55 55 mWorldNode = world; … … 65 65 public: 66 66 pfNode* mWorldNode; // The world to collide with 67 pfTerry VCollide terryCollide;67 pfTerryBoxCollide terryCollide; 68 68 }; 69 69 70 70 71 bool pf VolumeCollider::testMove(vjVec3 whereYouAre, vjVec3 delta, vjVec3& correction, bool whereYouAreWithDelta)71 bool pfBoxCollider::testMove(vjVec3 whereYouAre, vjVec3 delta, vjVec3& correction, bool whereYouAreWithDelta) 72 72 { 73 73 //cout<<"Pos["<<whereYouAre<<"] :|: Vel["<<delta<<"]\n"<<flush; … … 92 92 vol_radius = 1.0f; 93 93 94 terryCollide.set VolumeRadius( vol_radius ); // Setup collision volume94 terryCollide.setRadius( vol_radius ); // Setup collision volume 95 95 96 if (terryCollide.collide Volume( pf_correction, mWorldNode, pf_new_pos) )96 if (terryCollide.collide( pf_correction, mWorldNode, pf_new_pos) ) 97 97 { 98 98 correction = vjGetVjVec(pf_correction); trunk/juggler_1.0/samples/nav/pfPogoCollider.h
r1909 r1911 36 36 37 37 #include <collider.h> 38 #include < collide.h>38 #include <pfTerryPogoCollide.h> 39 39 40 40 //: Collider class for testing collisions in Performer … … 46 46 // So there is some coord system conversion that will be 47 47 // going on here. 48 class pf RideCollider : public collider48 class pfPogoCollider : public collider 49 49 { 50 50 public: 51 51 // ARGS: world - The node to start collision with 52 52 // it should be the one under the one being used for navigation ( ie. pfNaver) 53 pf RideCollider(pfNode* world)53 pfPogoCollider(pfNode* world) 54 54 { 55 55 mWorldNode = world; … … 65 65 protected: 66 66 pfNode* mWorldNode; // The world to collide with 67 pfTerry RCollide terryCollide;67 pfTerryPogoCollide terryCollide; 68 68 }; 69 69 70 70 71 bool pf RideCollider::testMove(vjVec3 whereYouAre, vjVec3 delta, vjVec3& correction, bool whereYouAreWithDelta)71 bool pfPogoCollider::testMove(vjVec3 whereYouAre, vjVec3 delta, vjVec3& correction, bool whereYouAreWithDelta) 72 72 { 73 73 pfVec3 pf_cur_pos = vjGetPfVec(whereYouAre); … … 81 81 float delta_mag = pf_delta.length(); 82 82 if(delta_mag > height) 83 cerr << "ERROR: pf RideCollider: Trying to move faster than the vector is checking.\n";83 cerr << "ERROR: pfPogoCollider: Trying to move faster than the vector is checking.\n"; 84 84 85 85 // This function tests to make sure that for height straight down, there is no collision … … 89 89 pf_new_pos += pfVec3(0,0,height); 90 90 91 if (terryCollide.collide Ground(pf_correction,mWorldNode,0x1,pf_new_pos, height))91 if (terryCollide.collide( pf_correction, mWorldNode, 0x1, pf_new_pos, height)) 92 92 { 93 93 correction = vjGetVjVec(pf_correction); trunk/juggler_1.0/samples/nav/pfTerryBoxCollide.cxx
r1909 r1911 1 #include " collide.h"1 #include "pfTerryBoxCollide.h" 2 2 3 3 const int pfTerryBoxCollide::COLLIDE_SEGMENTS( 8 ); trunk/juggler_1.0/samples/nav/pfTerryBoxCollide.h
r1909 r1911 9 9 #include <iostream.h> 10 10 #include <math.h> 11 12 #include "pfTerryCollide.h" // my base class 11 13 12 14 /////////////////////////////////////////////////////////////////////////////////// trunk/juggler_1.0/samples/nav/pfTerryCollide.cxx
r1909 r1911 1 #include "pfTerryCollide.h" 2 1 3 // Set up intersection masks for collision detection using 'mask' as the 2 4 // intersection mask. Cache normals and such inside geosets if the geometry … … 4 6 void pfTerryCollide::nodeSetup( pfNode *node, int mode, int mask ) 5 7 { 6 int fullmode;8 int fullmode; 7 9 8 if (mode == COLLIDE_DYNAMIC) 9 fullmode = PFTRAV_SELF|PFTRAV_DESCEND|PFTRAV_IS_UNCACHE; 10 else 11 fullmode = PFTRAV_SELF|PFTRAV_DESCEND|PFTRAV_IS_CACHE; 12 node->setTravMask(PFTRAV_ISECT, mask, fullmode, PF_SET); 10 if (mode == COLLIDE_DYNAMIC) 11 fullmode = PFTRAV_SELF|PFTRAV_DESCEND|PFTRAV_IS_UNCACHE; 12 else 13 fullmode = PFTRAV_SELF|PFTRAV_DESCEND|PFTRAV_IS_CACHE; 14 15 node->setTravMask(PFTRAV_ISECT, mask, fullmode, PF_SET); 13 16 } trunk/juggler_1.0/samples/nav/pfTerryPogoCollide.cxx
r1910 r1911 1 bool pfTerryGroundCollide::collideGround( pfVec3 &bounce, pfNode *objNode, int mask, pfVec3 pos, float length ) 1 #include "pfTerryPogoCollide.h" 2 3 bool pfTerryPogoCollide::collide( pfVec3 &bounce, pfNode *objNode, int mask, pfVec3 pos, float length ) 2 4 { 3 5 pfHit **hit[1]; … … 41 43 42 44 43 bool pfTerry GroundCollide::collideGroundAndRide( pfVec3 &bounce, pfVec3 &ridexyz, pfVec3 &ridehpr, pfNode *objNode, int mask, pfVec3 pos, float length )45 bool pfTerryPogoCollide::collideRide( pfVec3 &bounce, pfVec3 &ridexyz, pfVec3 &ridehpr, pfNode *objNode, int mask, pfVec3 pos, float length ) 44 46 { 45 47 pfHit** hit[1]; trunk/juggler_1.0/samples/nav/pfTerryPogoCollide.h
r1910 r1911 10 10 #include <math.h> 11 11 12 #include "pfTerryCollide.h" // my base class 13 12 14 /////////////////////////////////////////////////////////////////////////////////// 13 15 // Down vector "Pogostick" (or ground) collision 14 16 ///////////////////////////////// 15 17 16 class pfTerryPogo stickCollide : public pfTerryCollide18 class pfTerryPogoCollide : public pfTerryCollide 17 19 { 18 20 public: trunk/juggler_1.0/samples/nav/velocityNav.h
r1907 r1911 35 35 #include <navigator.h> 36 36 #include <collider.h> 37 #include <vector> 37 38 #include "StopWatch.h" 38 39 … … 88 89 { mMode = new_mode; } 89 90 90 void setGravityCollider(collider* val) { mGravCollider = val;} 91 void setCorrectingCollider(collider* val) { mCorrectingCollider = val;} 92 91 //: yes! you can add any number of colliders! 92 void addCollider( collider* val ) 93 { 94 mCollider.push_back( val ); 95 } 96 93 97 // query the current speed. 94 98 float speed() const; … … 125 129 navMode mMode; 126 130 int mTimeHack; 131 132 std::vector<collider*> mCollider; 127 133 }; 128 134 … … 254 260 255 261 256 // Begin collision testing::: 257 // TODO: collision is limited to 2 colliders for now. This could easily be expanded. 258 // TODONOTE: if you do expand, then you'll need to fix the HACK(!) 259 260 if ((mGravCollider != NULL) && mGravCollider->testMove( whereYouAre, mcDist2Move, correction)) 261 { 262 //cout<<"Collide Grav!\n"<<flush; 263 mcDist2Move += correction; 264 //totalCorrections += correction; 265 266 // HACK(!) - use the correction vectors to decide how much velocity from gravity to remove 267 // here i'm just zeroing it out. 268 mVelocityFromGravityAccumulator.set( 0.0f, 0.0f, 0.0f ); 269 } 270 271 if ((mCorrectingCollider != NULL) && mCorrectingCollider->testMove( whereYouAre, mcDist2Move, correction)) 272 { 273 //cout<<"Collide Ray!\n"<<flush; 274 mcDist2Move += correction; 275 //totalCorrections += correction; 276 } 277 278 // End collision testing::: 262 //////////////////////////////////////////////////////////// 263 // Test for collisions with all registered colliders 264 //////////////////////////////////////////////////////////// 265 for (int x = 0; x < mCollider.size(); ++x) 266 { 267 // If collision, then ... 268 if (mCollider[x]->testMove( whereYouAre, mcDist2Move, correction )) 269 { 270 // ... apply the correction. 271 mcDist2Move += correction; 272 //totalCorrections += correction; 273 274 // HACK(!) - use the correction vectors to decide how much velocity from gravity to remove 275 // here i'm just zeroing it out... sometimes many times per frame!!! (real bad) 276 // this should really only be affected by the Y component of the correction vector. 277 mVelocityFromGravityAccumulator.set( 0.0f, 0.0f, 0.0f ); 278 } 279 } 279 280 280 281 … … 290 291 //mVelocityFromGravityAccumulator += subtractfromGravVel; 291 292 293 292 294 // the navTranslate() function requires a translation in local coordinates 293 295 // move the vector back from modelspace to localspace 294 295 296 distanceToMove.xformFull( IcurrentRotation, mcDist2Move ); 296 297 this->navTranslate( distanceToMove );
