diff --git a/src/engine/include/modules/camera_base.hpp b/src/engine/include/modules/camera_base.hpp index c536ece..0544e6f 100644 --- a/src/engine/include/modules/camera_base.hpp +++ b/src/engine/include/modules/camera_base.hpp @@ -21,10 +21,9 @@ class CameraBase { public: - CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up, Vector3 *t_unitCirclePosition); + CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up); virtual ~CameraBase(){}; - void setScreen(); void updatePlanes(Vector3 t_target); Plane planes[6]; Matrix worldView; @@ -33,7 +32,7 @@ protected: ScreenSettings *screen; private: - Vector3 *position2, *up2, *unitCirclePosition2; + Vector3 *p_position, *p_up; float farPlaneDist, nearPlaneDist, nearHeight, nearWidth, farHeight, farWidth; Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; }; diff --git a/src/engine/modules/camera_base.cpp b/src/engine/modules/camera_base.cpp index 4fca370..e6823ba 100644 --- a/src/engine/modules/camera_base.cpp +++ b/src/engine/modules/camera_base.cpp @@ -22,7 +22,7 @@ * @param fov (FOV in radians)/2 * @param ratio Aspect ratio */ -CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up, Vector3 *t_unitCirclePosition) +CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up) : screen(t_screen) { PRINT_LOG("Initializing frustum"); @@ -33,9 +33,8 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t nearWidth = nearHeight * screen->aspectRatio; farHeight = tang * farPlaneDist; farWidth = farHeight * screen->aspectRatio; - position2 = t_position; - up2 = t_up; - unitCirclePosition2 = t_unitCirclePosition; + p_position = t_position; + p_up = t_up; PRINT_LOG("CameraBase initialized!"); } @@ -50,16 +49,16 @@ void CameraBase::updatePlanes(Vector3 t_target) { Vector3 nearCenter, farCenter, X, Y, Z; // compute the Z axis of camera - Z = *position2 - t_target; + Z = *p_position - t_target; Z.normalize(); // X axis of camera of given "up" vector and Z axis - X = *up2 * Z; + X = *p_up * Z; X.normalize(); // the real "up" vector is the cross product of Z and X Y = Z * X; // compute the center of the near and far planes - nearCenter = *position2 - Z * nearPlaneDist; - farCenter = *position2 - Z * farPlaneDist; + nearCenter = *p_position - Z * nearPlaneDist; + farCenter = *p_position - Z * farPlaneDist; // compute the 8 corners of the frustum ntl = nearCenter + Y * nearHeight - X * nearWidth; ntr = nearCenter + Y * nearHeight + X * nearWidth; diff --git a/src/samples/ari/camera.cpp b/src/samples/ari/camera.cpp index dba2bdb..045c656 100644 --- a/src/samples/ari/camera.cpp +++ b/src/samples/ari/camera.cpp @@ -19,7 +19,7 @@ const float CAMERA_Y = 15.0F; // Constructors/Destructors // ---- -Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up, &unitCirclePosition) +Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up) { PRINT_LOG("Initializing camera"); verticalLevel = 80.0F; diff --git a/src/samples/floors/camera.cpp b/src/samples/floors/camera.cpp index ab47a40..d0919a9 100644 --- a/src/samples/floors/camera.cpp +++ b/src/samples/floors/camera.cpp @@ -19,7 +19,7 @@ const float CAMERA_Y = 30.0F; // Constructors/Destructors // ---- -Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up, &unitCirclePosition) +Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position, &up) { PRINT_LOG("Initializing camera"); verticalLevel = 80.0F;