Added Camera::GetAngles for LPub.

This commit is contained in:
Leonardo Zide 2019-08-15 17:33:37 -07:00
parent ab94e51cf3
commit 7c81198e7d
2 changed files with 20 additions and 0 deletions

View file

@ -1047,3 +1047,22 @@ void lcCamera::SetAngles(float Latitude, float Longitude)
UpdatePosition(1);
}
void lcCamera::GetAngles(float& Latitude, float& Longitude, float& Distance) const
{
lcVector3 FrontVector(mPosition - mTargetPosition);
lcVector3 X(1, 0, 0);
lcVector3 Y(0, 1, 0);
lcVector3 Z(0, 0, 1);
FrontVector.Normalize();
Latitude = acos(lcDot(-FrontVector, Z)) * LC_RTOD - 90.0f;
lcVector3 CameraXY = -lcNormalize(lcVector3(FrontVector.x, FrontVector.y, 0.0f));
Longitude = acos(lcDot(CameraXY, Y)) * LC_RTOD;
if (lcDot(CameraXY, X) > 0)
Longitude = -Longitude;
Distance = lcLength(mPosition);
}

View file

@ -286,6 +286,7 @@ public:
void MoveRelative(const lcVector3& Distance, lcStep Step, bool AddKey);
void SetViewpoint(lcViewpoint Viewpoint);
void SetViewpoint(const lcVector3& Position);
void GetAngles(float& Latitude, float& Longitude, float& Distance) const;
void SetAngles(float Latitude, float Longitude);
char m_strName[81];