Adjustments to follow mouse.

This commit is contained in:
David Vereb
2022-06-16 15:11:58 -04:00
parent e5af7a1f30
commit 94a7264386
5 changed files with 100 additions and 61 deletions

View File

@@ -33,7 +33,7 @@ void Camera::Refresh()
0.0,1.0,0.0); // up
else
gluLookAt(m_x, m_y, m_z, // eye at
0.0f, 0.0f, 0.0f, // look at
2.0f, 0.0f, -4.0f, // look at
0.0f, 1.0f, 0.0f); // up
// printf("Camera: %f %f %f Direction vector: %f %f %f\n", m_x, m_y, m_z, m_lx, m_ly, m_lz);
@@ -45,7 +45,7 @@ void Camera::SetPos(float x, float y, float z)
m_y = y;
m_z = z;
Refresh();
// Refresh();
}
void Camera::GetPos(float &x, float &y, float &z)
@@ -73,7 +73,7 @@ void Camera::SetTarget(Target t, float x, float y, float z)
t_z = z;
}
Refresh();
// Refresh();
}
void Camera::Move(float incr)
@@ -86,7 +86,7 @@ void Camera::Move(float incr)
m_y = m_y + incr*ly;
m_z = m_z + incr*lz;
Refresh();
// Refresh();
}
void Camera::Strafe(float incr)
@@ -94,21 +94,21 @@ void Camera::Strafe(float incr)
m_x = m_x + incr*m_strafe_lx;
m_y = m_y + incr*m_strafe_ly;
Refresh();
// Refresh();
}
void Camera::Fly(float incr)
{
m_y = m_y + incr;
Refresh();
// Refresh();
}
void Camera::RotateYaw(float angle)
{
m_yaw += angle;
Refresh();
// Refresh();
}
void Camera::RotatePitch(float angle)
@@ -123,19 +123,19 @@ void Camera::RotatePitch(float angle)
if(m_pitch > limit)
m_pitch = limit;
Refresh();
// Refresh();
}
void Camera::SetYaw(float angle)
{
m_yaw = angle;
Refresh();
// Refresh();
}
void Camera::SetPitch(float angle)
{
m_pitch = angle;
Refresh();
// Refresh();
}

View File

@@ -2,7 +2,7 @@
#define __CAMERA_H__
/*
Generic camera class by Nghia Ho
Generic camera class by Nghia Ho
*/
class Camera
@@ -19,8 +19,8 @@ public:
void Init();
void Refresh();
void SetPos(float x, float y, float z);
void GetPos(float &x, float &y, float &z);
void GetDirectionVector(float &x, float &y, float &z);
void GetPos(float &x, float &y, float &z);
void GetDirectionVector(float &x, float &y, float &z);
void SetYaw(float angle);
void SetPitch(float angle);