Changeset 10667 in orxonox.OLD for branches/vs-enhencements/src
- Timestamp:
- Jun 1, 2007, 12:01:20 PM (18 years ago)
- Location:
- branches/vs-enhencements/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/vs-enhencements/src/defs/include_paths.am
r10376 r10667 31 31 32 32 AM_CXXFLAGS+=-I$(MAINSRCDIR)/../extern_libs 33 34 AM_LDFLAGS+=-L$(MAINSRCDIR)/../extern_libs -
branches/vs-enhencements/src/util/track/action_box.cc
r10645 r10667 127 127 bool ActionBox::isPointInBox( const Vector & pos ) 128 128 { 129 bool result = true; //TODO remove130 129 for ( int i = 0; i<6; i++ ) 131 130 { 132 131 if ( planes[i].distancePoint( pos ) < 0 ) 133 132 { 134 result = false; // TODO return false; 135 printf("PLANE %i FAILED %f\n", i, planes[i].distancePoint( pos ) ); 133 return false; 136 134 } 137 135 } 138 return result; //TODO returntrue;136 return true; 139 137 } 140 138 -
branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.cc
r10662 r10667 41 41 this->dPitch = 0.0; 42 42 43 this->maxSpeed = 10;43 this->maxSpeed = 30; 44 44 this->acceleration = 3; 45 45 this->speed = 0; 46 46 47 this->onEscape = false; 48 47 49 if ( root ) 48 50 this->loadParams( root ); … … 60 62 void ActionboxEnemy::tick( float dt ) 61 63 { 64 this->bFire = false; 65 66 if ( !State::getPlayer() || !State::getPlayer()->getPlayable() ) 67 return; 68 69 Vector playerDir = State::getPlayer()->getPlayable()->getAbsDir().apply( Vector(1, 0, 0) ); 70 Vector dist = this->getAbsCoor() - State::getPlayer()->getPlayable()->getAbsCoor(); 71 72 bool behindPlayer = playerDir.dot( dist ) < 0; 73 74 if ( behindPlayer ) 75 return; 76 62 77 myDir = this->getAbsDir(); 63 78 myCoor = this->getAbsCoor(); … … 73 88 qPitch = Quaternion( pitch, Vector( 1, 0, 0 ) ); 74 89 75 moveTowardsBox( NULL, dt );76 77 90 if ( isActive && State::getActionBox() ) 78 91 { … … 85 98 { 86 99 moveTowardsBox( box, dt ); 100 onEscape = false; 87 101 } 88 102 } … … 96 110 void ActionboxEnemy::attackPlayer( ActionBox * box, float dt ) 97 111 { 98 } 99 100 void ActionboxEnemy::moveTowardsBox( ActionBox * box, float dt ) 101 { 102 //Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor(); 103 static float time = 0; 104 time += dt; 105 Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor() + State::getPlayer()->getPlayable()->getAbsDir().apply(Vector(1, 0, 0))*50*(1.5 + sin(time/5)); 106 Vector targetDir = targetPos - myCoor; 107 112 if ( !State::getPlayer() || !State::getPlayer()->getPlayable() || !box ) 113 return; 114 115 float distance = (State::getPlayer()->getPlayable()->getAbsCoor() - getAbsCoor() ).len(); 116 117 if ( distance > box->getDepth()/4.0 && !onEscape ) 118 { 119 Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor(); 120 Vector targetDir = State::getPlayer()->getPlayable()->getAbsCoor()-this->getAbsCoor(); 121 moveTowards( targetPos, targetDir, dt ); 122 if ( this->getAbsDir().apply( Vector(1, 0, 0) ).dot(targetDir) > 0.9 ) 123 { 124 this->bFire = true; 125 PRINTF(0)("FIRE\n"); 126 } 127 } 128 else 129 { 130 if ( !onEscape ) 131 { 132 Vector ds = this->getAbsCoor() - State::getPlayer()->getPlayable()->getAbsCoor(); 133 float projy = box->getAbsDir().apply( Vector(0, 1, 0) ).dot( ds ); 134 float projz = box->getAbsDir().apply( Vector(0, 0, 1) ).dot( ds ); 135 this->escapePoint = Vector( 0, projy, projz ); 136 this->escapePoint.normalize(); 137 this->escapePoint*= 2*box->getWidth_2(); 138 PRINTF(0)("ESCAPE\n"); 139 } 140 onEscape = true; 141 142 Vector rEscapePoint = box->getAbsDir().apply(escapePoint); 143 Vector targetPos = State::getPlayer()->getPlayable()->getAbsCoor() + rEscapePoint; 144 Vector targetDir = State::getPlayer()->getPlayable()->getAbsCoor() + rEscapePoint - this->getAbsCoor(); 145 moveTowards( targetPos, targetDir, dt ); 146 } 147 } 148 149 void ActionboxEnemy::moveTowards( Vector targetPos, Vector targetDir, float dt ) 150 { 108 151 Quaternion cur = myDir; 109 152 Quaternion rx( dt, Vector( 0, 0, 1 ) ); … … 144 187 } 145 188 189 void ActionboxEnemy::moveTowardsBox( ActionBox * box, float dt ) 190 { 191 192 Vector targetPos = box->getAbsCoor() + box->getAbsDir().apply( Vector( 1, 0, 0 ) )*box->getDepth()*0.66f; 193 Vector targetDir = targetPos - myCoor; 194 195 moveTowards(targetPos, targetDir, dt); 196 } 197 146 198 void ActionboxEnemy::draw( ) const 147 199 { -
branches/vs-enhencements/src/world_entities/npcs/actionbox_enemy.h
r10662 r10667 33 33 Vector myCoor; 34 34 35 bool bFire; 36 37 Vector escapePoint; 38 bool onEscape; 39 35 40 void attackPlayer( ActionBox* box, float dt ); 36 41 void moveTowardsBox( ActionBox* box, float dt ); 42 void moveTowards( Vector targetPos, Vector targetDir, float dt ); 37 43 }; 38 44 -
branches/vs-enhencements/src/world_entities/space_ships/space_ship.cc
r10662 r10667 571 571 if (!(State::getCamera()->getEventHandling())) 572 572 { 573 //PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera()); 573 574 if( event.type == KeyMapper::PEV_VIEW0) 574 575 { … … 851 852 //State::getCameraTargetNode()->setParentSoft(this); 852 853 //State::getCameraTargetNode()->setRelCoorSoft(0,0,0); 853 this->setCameraMode(Camera::ViewNormal);854 //this->setCameraMode(Camera::ViewNormal); 854 855 State::getCamera()->setEventHandling(false); 856 857 PRINTF(0)("\n\n\n\n\n\n\n\nSETCAMERA %x\n\n\n\n\n\n\n", State::getCamera()); 858 State::getCamera()->setViewMode(Camera::ViewNormal); 859 State::getCameraTargetNode()->setParent(this); 860 State::getCamera()->setParent(this); 861 862 863 855 864 registerEvent(KeyMapper::PEV_VIEW0); 856 865 registerEvent(KeyMapper::PEV_VIEW1);
Note: See TracChangeset
for help on using the changeset viewer.