Changeset 10875
- Timestamp:
- Nov 27, 2015, 1:41:26 PM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10872 r10875 62 62 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 63 63 P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped --> 64 <!--64 65 65 <Model mesh="cube.mesh" scale=8 position="0,0,0" /> 66 66 … … 124 124 </SpaceShip> 125 125 126 -->126 127 127 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS --> 128 128 <!-- HERE STARTS DEMO FOR FIGHTING --> … … 210 210 <!-- HERE ENDS DEMO FOR FIGHTING --> 211 211 <!-- HERE STARTS DEMO FOR FORMATIONS --> 212 212 <!-- 213 213 <Model mesh="cube.mesh" scale=8 position=" 0,2000, 0" /> 214 214 <Model mesh="cube.mesh" scale=8 position=" 0,2000,-2000" /> … … 259 259 </controller> 260 260 </SpaceShip> 261 261 --> 262 262 <!-- HERE ENDS DEMO FOR FORMATIONS --> 263 263 -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10872 r10875 30 30 31 31 #include "core/XMLPort.h" 32 33 #include "controllers/NewHumanController.h" 32 #include <algorithm> 33 34 34 35 35 namespace orxonox … … 295 295 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 296 296 { 297 if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))297 if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && ((*itP)->getController()->getIdentifier()->getName() == "NewHumanController")) 298 298 { 299 299 this->setProtect (static_cast<ControllableEntity*>(*itP)); -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
r10871 r10875 38 38 #include "controllers/NewHumanController.h" 39 39 #include "controllers/DroneController.h" 40 #include "util/Math.h" 40 41 41 42 namespace orxonox -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
r10871 r10875 34 34 #include "worldentities/ControllableEntity.h" 35 35 #include "worldentities/pawns/Pawn.h" 36 #include "util/Math.h"37 36 38 37 #include "tools/Timer.h" 39 38 #include "tools/interfaces/Tickable.h" 40 39 #include <limits> 41 #include <algorithm>42 40 #include "worldentities/Actionpoint.h" 43 #include "worldentities/pawns/SpaceShip.h"44 41 45 42 namespace orxonox -
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
r10871 r10875 28 28 #include "controllers/FightingController.h" 29 29 #include "core/XMLPort.h" 30 #include <limits> //for finding closest target30 #include "util/Math.h" 31 31 32 32 -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
r10871 r10875 29 29 #include "core/XMLPort.h" 30 30 #include "worldentities/pawns/SpaceShip.h" 31 #include "util/Math.h" 31 32 32 33 namespace orxonox … … 128 129 void FlyingController::copyOrientation( const Quaternion& orient, float dt ) 129 130 { 130 //roll angle difference in radian 131 floatdiff=orient.getRoll(false).valueRadians() -131 132 double diff=orient.getRoll(false).valueRadians() - 132 133 ( this->getControllableEntity() ->getOrientation() .getRoll( false ).valueRadians() ); 133 while( diff>math::twoPi 134 while( diff>math::twoPi)diff-=math::twoPi; 134 135 while( diff<-math::twoPi )diff+=math::twoPi; 135 this->getControllableEntity() ->rotateRoll( diff*0.2f*ROTATEFACTOR * dt ); 136 137 this->getControllableEntity() ->rotateRoll(diff * ROTATEFACTOR * dt); 136 138 } 139 //change log: increased precision, increased rotation speed 137 140 void FlyingController::copyTargetOrientation( float dt ) 138 141 { -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
r10871 r10875 36 36 { 37 37 const float SPEED = 0.9f/0.02f; 38 const float ROTATEFACTOR = 1.0f/0.02f;38 const float ROTATEFACTOR = 0.6f/0.02f; 39 39 namespace FormationMode 40 40 { -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10873 r10875 78 78 if (!this->isActive()) 79 79 return; 80 81 80 81 //this doesn't fight in formation flight, thus we can afford executing following code in tick: when nobody fights, tick is anyway stable. 82 if (this->myDivisionLeader_ && this->myDivisionLeader_->getAction() != Action::FIGHT && this->myDivisionLeader_->getAction() != 83 Action::FIGHTALL && this->myDivisionLeader_->getAction() != Action::ATTACK) 84 { 85 ControllableEntity* myEntity = this->getControllableEntity(); 86 Vector3 myPosition = myEntity->getWorldPosition(); 87 if (!this->myDivisionLeader_) 88 { 89 return; 90 } 91 ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity(); 92 Quaternion orient = leaderEntity->getWorldOrientation(); 93 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 94 95 Vector3 targetRelativePosition = getFormationPosition(); 96 if (!this->myDivisionLeader_) 97 { 98 return; 99 } 100 Vector3 targetAbsolutePosition = 101 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 102 + (orient* (targetRelativePosition))); 103 104 this->setAction (Action::FLY, targetAbsolutePosition, orient); 105 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 106 { 107 this->boostControl(); 108 } 109 else 110 { 111 this->getControllableEntity()->boost(false); 112 } 113 } 82 114 SUPER(SectionController, tick, dt); 83 115 } … … 143 175 default: 144 176 { 145 ControllableEntity* myEntity = this->getControllableEntity(); 146 Vector3 myPosition = myEntity->getWorldPosition(); 147 if (!this->myDivisionLeader_) 148 { 149 return; 150 } 151 ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity(); 152 Quaternion orient = leaderEntity->getWorldOrientation(); 153 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 154 155 Vector3 targetRelativePosition = getFormationPosition(); 156 if (!this->myDivisionLeader_) 157 { 158 return; 159 } 160 Vector3 targetAbsolutePosition = 161 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 162 + (orient* (targetRelativePosition))); 163 164 this->setAction (Action::FLY, targetAbsolutePosition, orient); 165 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 166 { 167 this->boostControl(); 168 } 169 else 170 { 171 this->getControllableEntity()->boost(false); 172 } 177 //formation flight is executed in tick 173 178 } 174 179 } -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10873 r10875 68 68 if (!this->isActive()) 69 69 return; 70 70 if (this->myLeader_ && this->myLeader_->getAction() != Action::FIGHT && this->myLeader_->getAction() != 71 Action::FIGHTALL && this->myLeader_->getAction() != Action::ATTACK) 72 { 73 ControllableEntity* myEntity = this->getControllableEntity(); 74 Vector3 myPosition = myEntity->getWorldPosition(); 75 if (!this->myLeader_) 76 { 77 return; 78 } 79 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity(); 80 Quaternion orient = leaderEntity->getWorldOrientation(); 81 Vector3 leaderPosition = leaderEntity->getWorldPosition(); 82 83 Vector3 targetRelativePosition = getFormationPosition(); 84 if (!this->myLeader_) 85 { 86 return; 87 } 88 Vector3 targetAbsolutePosition = 89 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 90 + (orient* (targetRelativePosition))); 91 92 this->setAction (Action::FLY, targetAbsolutePosition, orient); 93 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 94 { 95 this->boostControl(); 96 } 97 else 98 { 99 this->getControllableEntity()->boost(false); 100 } 101 } 71 102 72 103 SUPER(WingmanController, tick, dt); … … 123 154 default: 124 155 { 125 ControllableEntity* myEntity = this->getControllableEntity();126 Vector3 myPosition = myEntity->getWorldPosition();127 if (!this->myLeader_)128 {129 return;130 }131 156 132 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();133 Quaternion orient = leaderEntity->getWorldOrientation();134 Vector3 leaderPosition = leaderEntity->getWorldPosition();135 136 Vector3 targetRelativePosition = getFormationPosition();137 if (!this->myLeader_)138 {139 return;140 }141 Vector3 targetAbsolutePosition =142 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)143 + (orient* (targetRelativePosition)));144 145 this->setAction (Action::FLY, targetAbsolutePosition, orient);146 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)147 {148 this->boostControl();149 }150 else151 {152 this->getControllableEntity()->boost(false);153 }154 157 } 155 158 }
Note: See TracChangeset
for help on using the changeset viewer.