Changeset 10880 for code/branches/campaignHS15
- Timestamp:
- Nov 27, 2015, 10:37:59 PM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10879 r10880 221 221 </templates> 222 222 <controller> 223 <DivisionController team=0 formationMode=" Finger4" spread=100>223 <DivisionController team=0 formationMode="diamond" spread=100> 224 224 <actionpoints> 225 225 <Actionpoint position=" 0,2000, 0" action="FLY" loopStart=true/> -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10879 r10880 360 360 void ActionpointController::stayNearProtect() 361 361 { 362 Vector3* targetRelativePosition; 363 targetRelativePosition = new Vector3 (0, 300, 300); 362 Vector3 targetRelativePosition(0, 300, 300); 364 363 Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 365 (this->getProtect()->getWorldOrientation()* ( *targetRelativePosition)));364 (this->getProtect()->getWorldOrientation()* (targetRelativePosition))); 366 365 this->setTargetPosition(targetAbsolutePosition); 367 366 this->setTargetOrientation(this->getProtect()->getWorldOrientation()); … … 567 566 if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL) 568 567 { 569 if ( (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_) 570 || !this->target_ ) 568 if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_)) 571 569 { 572 570 Pawn* newTarget = this->closestTarget(); -
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
r10877 r10880 126 126 Vector3 diffUnit = diffVector/diffLength; 127 127 128 bool bTargetIsLookingAtThis = CommonController::isLooking ( this->target_, getControllableEntity(), math::pi/ 10.0f );128 bool bTargetIsLookingAtThis = CommonController::isLooking ( this->target_, getControllableEntity(), math::pi/20.0f ); 129 129 130 130 //too far? well, come closer then … … 191 191 ); 192 192 Vector3 projection = randVector->dotProduct( diffUnit )* diffUnit; 193 *randVector -= projection; 194 target += *randVector; 193 Vector3 randV = *randVector; 194 delete randVector; 195 randV -= projection; 196 target += randV; 195 197 this->setTargetPosition( thisPosition + target ); 196 198 } -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
r10879 r10880 38 38 { 39 39 this->rotationProgress_ = 0; 40 this->tickCounter_ = 0; 40 41 this->spread_ = 200; 41 42 this->tolerance_ = 80; … … 94 95 { 95 96 ControllableEntity* entity = this->getControllableEntity(); 96 Vector2 coord = get2DViewCoordinates 97 ( entity->getPosition() , 98 entity->getOrientation() * WorldEntity::FRONT, 99 entity->getOrientation() * WorldEntity::UP, 100 target ); 97 this->tickCounter_ += this->tickCounter_ < 100000 ? 1 : -this->tickCounter_ ; 101 98 102 99 float distance = ( target - this->getControllableEntity() ->getPosition() ).length(); 103 float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f ); 104 float rotateY = clamp( coord.y * 10, -1.0f, 1.0f ); 100 105 101 106 102 if ( distance > this->tolerance_ ) 107 103 { 104 Vector2 coord = get2DViewCoordinates 105 ( entity->getPosition() , 106 entity->getOrientation() * WorldEntity::FRONT, 107 entity->getOrientation() * WorldEntity::UP, 108 target ); 109 float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f ); 110 float rotateY = clamp( coord.y * 10, -1.0f, 1.0f ); 108 111 this->getControllableEntity() ->rotateYaw( ROTATEFACTOR * rotateX * dt ); 109 112 this->getControllableEntity() ->rotatePitch( ROTATEFACTOR * rotateY * dt ); … … 112 115 if (distance > this->tolerance_*1.5f || (rotateX > -0.01 && rotateX < 0.01 && rotateY > -0.01 && rotateY < 0.01)) 113 116 this->getControllableEntity() ->moveFrontBack( SPEED * dt ); 114 115 // if ( bHasTargetOrientation_ && (rotateX > -0.005 && rotateX < 0.005 && rotateY > -0.005 && rotateY < 0.005) ) 116 // { 117 if (this->tickCounter_ % 10 == 0 ) 117 118 copyTargetOrientation( dt ); 118 // }119 120 119 } 121 120 else … … 125 124 } 126 125 } 126 127 127 void FlyingController::moveToTargetPosition(float dt) 128 128 { … … 136 136 137 137 Quaternion myOrient = this->getControllableEntity()->getOrientation(); 138 this->rotationProgress_ += dt/50.0f;138 this->rotationProgress_ += 5*dt; 139 139 140 140 if (this->rotationProgress_ > 1) … … 144 144 else 145 145 { 146 Quaternion delta = Quaternion::Slerp( this->rotationProgress_, myOrient, orient, true);146 Quaternion delta = Quaternion::Slerp(rotationProgress_, myOrient, orient, true); 147 147 148 148 Matrix3 orientMatrix, myMatrix; … … 153 153 orientMatrix.ToEulerAnglesYXZ(yRad, pRad, rRad); 154 154 myMatrix.ToEulerAnglesYXZ (yMy, pMy, rMy); 155 orxout (internal_error) << "dt = " << dt << endl; 156 this->getControllableEntity()->rotateRoll (50.0f*dt*(rRad.valueRadians() - rMy.valueRadians())); 155 this->getControllableEntity()->rotateRoll (50.0f * dt*(rRad.valueRadians() - rMy.valueRadians())); 157 156 //this->getControllableEntity()->setOrientation(delta); 158 157 } 159 //this shit works. How?158 160 159 161 160 } -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
r10879 r10880 83 83 84 84 float rotationProgress_; 85 int tickCounter_; 85 86 bool bHasTargetPosition_; 86 87 Vector3 targetPosition_; -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10879 r10880 276 276 } 277 277 } 278 return *targetRelativePosition; 278 Vector3 result = *targetRelativePosition; 279 delete targetRelativePosition; 280 return result; 279 281 } 280 282 -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10879 r10880 149 149 150 150 this->setAction (Action::FLY, targetAbsolutePosition, orient); 151 151 152 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 152 153 { … … 217 218 } 218 219 } 219 220 return *targetRelativePosition; 220 Vector3 result = *targetRelativePosition; 221 delete targetRelativePosition; 222 return result; 221 223 } 222 224 //----POST: closest leader that is ready to take a new wingman is returned----
Note: See TracChangeset
for help on using the changeset viewer.