Changeset 10881 for code/branches/campaignHS15
- Timestamp:
- Nov 28, 2015, 9:17:24 AM (9 years ago)
- Location:
- code/branches/campaignHS15/src/orxonox/controllers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10880 r10881 364 364 (this->getProtect()->getWorldOrientation()* (targetRelativePosition))); 365 365 this->setTargetPosition(targetAbsolutePosition); 366 this->setTargetOrientation(this->getProtect()->getWorldOrientation()); 366 this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ; 367 if (this->actionConter_ % 3 == 0) 368 this->setTargetOrientation(this->getProtect()->getWorldOrientation()); 367 369 } 368 370 void ActionpointController::nextActionpoint() -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10877 r10881 39 39 { 40 40 RegisterObject(DivisionController); 41 41 this->actionCounter_ = 0; 42 42 this->setFormationMode(FormationMode::DIAMOND); 43 43 this->target_ = 0; -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
r10880 r10881 38 38 { 39 39 this->rotationProgress_ = 0; 40 this->tickCounter_ = 0;41 40 this->spread_ = 200; 42 41 this->tolerance_ = 80; … … 95 94 { 96 95 ControllableEntity* entity = this->getControllableEntity(); 97 this->tickCounter_ += this->tickCounter_ < 100000 ? 1 : -this->tickCounter_ ;98 96 99 97 float distance = ( target - this->getControllableEntity() ->getPosition() ).length(); 100 98 101 99 102 if ( distance > this->tolerance_ )100 if ( distance >= this->tolerance_ ) 103 101 { 104 102 Vector2 coord = get2DViewCoordinates … … 115 113 if (distance > this->tolerance_*1.5f || (rotateX > -0.01 && rotateX < 0.01 && rotateY > -0.01 && rotateY < 0.01)) 116 114 this->getControllableEntity() ->moveFrontBack( SPEED * dt ); 117 if (this->tickCounter_ % 10 == 0 )118 copyTargetOrientation( dt );119 115 } 120 116 else 121 117 { 122 118 bHasTargetPosition_ = false; 123 bHasTargetOrientation_ = false;124 }119 } 120 copyTargetOrientation(dt); 125 121 } 126 122 … … 136 132 137 133 Quaternion myOrient = this->getControllableEntity()->getOrientation(); 138 this->rotationProgress_ += 5*dt;134 this->rotationProgress_ += dt; 139 135 140 136 if (this->rotationProgress_ > 1) 141 137 { 142 138 this->rotationProgress_ = 0; 139 this->bHasTargetOrientation_ = false; 143 140 } 144 141 else 145 142 { 143 146 144 Quaternion delta = Quaternion::Slerp(rotationProgress_, myOrient, orient, true); 147 145 146 //rotate roll builds a Quaternion in roll method of WorldEntity, then it sets orientation. 147 //it is faster just to set orientation, plus that way there is no need in calculating the roll angle. 148 //On the downside, however, ship might also yaw and pitch, but this effect is neglectable, as we only call 149 //copyOrientation after we move our ship, thus it doesn't affect ships's flying direction too much. 150 //If you don't like the code style, you are welcomed to uncomment the code below 151 //and comment out setOrientation part, it will work just fine, but it will also be a tiny bit slower. 152 //P.S. apperantly it did affect ship's direction and did so way too much. 148 153 Matrix3 orientMatrix, myMatrix; 154 149 155 delta.ToRotationMatrix(orientMatrix); 150 156 myOrient.ToRotationMatrix (myMatrix); … … 153 159 orientMatrix.ToEulerAnglesYXZ(yRad, pRad, rRad); 154 160 myMatrix.ToEulerAnglesYXZ (yMy, pMy, rMy); 155 this->getControllableEntity()->rotateRoll (50.0f * dt*(rRad.valueRadians() - rMy.valueRadians())); 156 //this->getControllableEntity()->setOrientation(delta); 161 162 this->getControllableEntity()->rotateRoll ((rRad.valueRadians() - rMy.valueRadians())*ROTATEFACTOR*dt); 163 // this->getControllableEntity()->setOrientation(delta); 157 164 } 158 165 -
code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
r10880 r10881 83 83 84 84 float rotationProgress_; 85 int tickCounter_;85 int actionCounter_; 86 86 bool bHasTargetPosition_; 87 87 Vector3 targetPosition_; -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10880 r10881 98 98 LeaderController* newDivisionLeader = findNewDivisionLeader(); 99 99 this->myDivisionLeader_ = newDivisionLeader; 100 //spread copyOrientation called equally among the division 100 101 if (this->myDivisionLeader_) 101 102 { 102 103 this->actionCounter_ = 8; 103 104 } 104 105 } … … 170 171 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 171 172 + (orient* (targetRelativePosition))); 172 173 this->setAction (Action::FLY, targetAbsolutePosition, orient); 173 //let ship finish rotating. also don't call copyOrientation to often as it is a slow function. 174 if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_) 175 this->setAction (Action::FLY, targetAbsolutePosition, orient); 176 else 177 this->setAction (Action::FLY, targetAbsolutePosition); 178 174 179 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 175 180 { … … 190 195 } 191 196 } 192 197 this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ; 198 193 199 } 194 200 -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10880 r10881 87 87 if (this->myLeader_) 88 88 { 89 89 //spread copyOrientation called equally among the division 90 if (this->myLeader_->getIdentifier()->getName() == "SectionController") 91 this->actionCounter_ = 2; 92 else 93 this->actionCounter_ = 5; 90 94 } 91 95 } … … 147 151 (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5) 148 152 + (orient* (targetRelativePosition))); 149 150 this->setAction (Action::FLY, targetAbsolutePosition, orient); 151 153 //let ship finish rotating. also don't call copyOrientation to often as it is a slow function. 154 if (this->actionCounter_ % 9 == 0 && !this->bHasTargetOrientation_) 155 this->setAction (Action::FLY, targetAbsolutePosition, orient); 156 else 157 this->setAction (Action::FLY, targetAbsolutePosition); 152 158 if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f) 153 159 { … … 168 174 } 169 175 } 170 176 this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ; 171 177 } 172 178
Note: See TracChangeset
for help on using the changeset viewer.