mirror of
https://github.com/leozide/leocad
synced 2025-01-28 19:58:12 +01:00
Added Camera::GetAngles for LPub.
This commit is contained in:
parent
ab94e51cf3
commit
7c81198e7d
2 changed files with 20 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Add table
Reference in a new issue