40 #ifndef _cameracontroller_cpp
41 #define _cameracontroller_cpp
43 #include "cameracontroller.h"
46 #include "rayquerytool.h"
54 Controlled(ToBeControlled),
55 CurrentMMode(CCM_Fly),
72 void CameraController::CheckAngleRollover(
Real Angle)
77 Angle = -Pi + (Angle - Pi);
81 Angle = Pi + (Angle + Pi);
85 void CameraController::CheckAngleLimits()
89 if(YawRad > this->YawLimits->Upper) YawRad = this->YawLimits->Upper;
90 if(YawRad < this->YawLimits->Lower) YawRad = this->YawLimits->Lower;
94 if(PitchRad > this->PitchLimits->Upper) PitchRad = this->PitchLimits->Upper;
95 if(PitchRad < this->PitchLimits->Lower) PitchRad = this->PitchLimits->Lower;
99 if(RollRad > this->RollLimits->Upper) RollRad = this->RollLimits->Upper;
100 if(RollRad < this->RollLimits->Lower) RollRad = this->RollLimits->Lower;
104 void CameraController::CheckAllAngles()
106 this->CheckAngleLimits();
107 this->CheckAngleRollover(this->YawRad);
108 this->CheckAngleRollover(this->PitchRad);
109 this->CheckAngleRollover(this->RollRad);
112 void CameraController::CheckHeight()
115 Real Dist = this->FindDistanceToGround();
118 Real DeltaDist = Dist - this->HoverHeight;
123 Real CameraController::FindDistanceToGround()
126 Vector3 Dest(Loc + Vector3(0,-2000,0));
127 Ray GroundRay(Loc,Dest);
128 UInt32 flags = Mezzanine::WO_MeshTerrain | Mezzanine::WO_HeightfieldTerrain | Mezzanine::WO_VectorFieldTerrain | Mezzanine::WO_VoxelTerrain;
140 return this->Controlled;
148 this->CurrentMMode = MoveMode;
153 return this->CurrentMMode;
158 this->HoverHeight = Hover;
163 return this->HoverHeight;
170 this->YawLimits->Upper = UpperLimit;
171 this->YawLimits->Lower = LowerLimit;
178 delete this->YawLimits;
179 this->YawLimits = NULL;
185 if(!this->PitchLimits)
187 this->PitchLimits->Upper = UpperLimit;
188 this->PitchLimits->Lower = LowerLimit;
193 if(this->PitchLimits)
195 delete this->PitchLimits;
196 this->PitchLimits = NULL;
202 if(!this->RollLimits)
204 this->RollLimits->Upper = UpperLimit;
205 this->RollLimits->Lower = LowerLimit;
212 delete this->RollLimits;
213 this->RollLimits = NULL;
255 this->PitchRad += Pitch;
256 this->RollRad += Roll;
257 this->CheckAllAngles();
260 if(0 == this->YawRad)
265 if(0 == this->PitchRad)
270 if(0 == this->RollRad)
275 Quaternion CamRot = YawQuat * PitchQuat * RollQuat;