Changeset 10004
- Timestamp:
- Mar 27, 2014, 1:36:50 PM (11 years ago)
- Location:
- code/branches/turretFS14
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/turretFS14/data/levels/turretTest.oxw
r9939 r10004 17 17 include("templates/spaceshipAssff.oxt") 18 18 include("templates/spaceshipPirate.oxt") 19 include("templates/spaceshipTurret .oxt")19 include("templates/spaceshipTurretTest.oxt") 20 20 ?> 21 21 … … 48 48 <Turret position="0,10,0" pitch="90" yaw="0" roll="0"> 49 49 <templates> 50 <Template link=spaceshipturret />50 <Template link=spaceshipturrettest /> 51 51 </templates> 52 52 <controller> -
code/branches/turretFS14/src/modules/objects/Turret.cc
r9945 r10004 37 37 RegisterClass(Turret); 38 38 39 40 39 41 /** 40 42 * @brief Constructor … … 44 46 RegisterObject(Turret); 45 47 this->controller_ = new WaypointPatrolController(this->getContext()); 48 gotOrient_ = false; 46 49 } 47 50 … … 57 60 void Turret::rotatePitch(const Vector2& value) 58 61 { 59 orxout()<< "Turret rotate Pitch"<< endl; 60 61 const Quaternion& orient = this->getOrientation(); 62 Radian pitch = orient.getPitch(); 63 64 if((value.x > 0 && pitch < Radian(180)) || (value.x < 0 && pitch > Radian(0))) 65 SpaceShip::rotatePitch(value); 62 Radian currentPitch = this->getOrientation().getPitch(); 63 Radian startPitch = startOrient_.getPitch(); 64 Radian limit = Radian((Degree)45); 65 Radian upperBoundary = startPitch+limit; 66 if(upperBoundary > Radian(Degree(360))) 67 { 68 upperBoundary -= Radian(Degree(360)); 69 } 70 Radian lowerBoundary = startPitch-limit; 71 if(lowerBoundary < Radian(Degree(0))) 72 { 73 lowerBoundary += Radian(Degree(360)); 74 } 75 //orxout() << "Pitch:\t" << currentPitch << "\t" << startPitch << endl; 76 77 if(currentPitch > upperBoundary && value.x > 0 || 78 currentPitch < lowerBoundary && value.x < 0) 79 { 80 return; 81 } 82 83 //SpaceShip::rotatePitch(value); 66 84 } 67 85 86 void Turret::rotateYaw(const Vector2& value) 87 { 88 89 Radian currentYaw = this->getOrientation().getYaw(); 90 Radian startYaw = startOrient_.getYaw(); 91 Radian limit = Radian(Degree(45)); 92 Radian upperBoundary = startYaw + limit; 93 Radian lowerBoundary = startYaw - limit; 94 orxout() << currentYaw << " " << this->getOrientation().getRoll() << endl; 95 /*if(upperBoundary >= Radian(Degree(180))); 96 { 97 upperBoundary -= Radian(Degree(180)); 98 lowerBoundary -= Radian(Degree(180)); 99 currentYaw -= Radian(Degree(180)); 100 } 101 if(lowerBoundary <= Radian(Degree(-180))) 102 { 103 lowerBoundary += Radian(Degree(180)); 104 upperBoundary += Radian(Degree(180)); 105 currentYaw += Radian(Degree(180)); 106 }*/ 107 //orxout() << "Yaw:\t" << (Degree)currentYaw << "\t" << (Degree)upperBoundary << "\t" << (Degree)lowerBoundary << endl; 108 //if((currentYaw > upperBoundary && value.x > 0) || 109 // (currentYaw < lowerBoundary && value.x < 0)) 110 if((currentYaw < Radian(1) && value.x < 0) || (currentYaw > Radian(3) && value.x>0)) 111 { 112 //return; 113 } 114 SpaceShip::rotateYaw(value); 115 } 116 117 void Turret::rotateRoll(const Vector2& value) 118 { 119 return; 120 } 68 121 69 122 void Turret::setAlertnessRadius(float value) … … 82 135 } 83 136 137 void Turret::tick(float dt) 138 { 139 if(!gotOrient_) 140 { 141 startOrient_ = this->getOrientation(); 142 gotOrient_ = true; 143 } 144 SUPER(Turret, tick, dt); 145 } 84 146 85 147 } -
code/branches/turretFS14/src/modules/objects/Turret.h
r9667 r10004 37 37 38 38 #include "objects/ObjectsPrereqs.h" 39 #include "OgreQuaternion.h" 39 40 40 41 #include "worldentities/pawns/SpaceShip.h" … … 48 49 virtual ~Turret(); 49 50 50 //virtual void tick(float dt);51 52 51 virtual void rotatePitch(const Vector2& value); 52 virtual void rotateYaw(const Vector2& value); 53 virtual void rotateRoll(const Vector2& value); 53 54 54 55 void setAlertnessRadius(float value); … … 56 57 57 58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 59 virtual void tick(float dt); 58 60 59 61 … … 61 63 WaypointPatrolController* controller_; 62 64 private: 63 65 bool gotOrient_; 66 Quaternion startOrient_; 67 Quaternion firstOrient_; 64 68 }; 65 69 }
Note: See TracChangeset
for help on using the changeset viewer.