removed unitcircle pos from camera base

This commit is contained in:
Sandro Sobczyński
2020-11-05 14:41:08 +01:00
parent 3fdbda4a4a
commit eba254f13b
4 changed files with 11 additions and 13 deletions
+2 -3
View File
@@ -21,10 +21,9 @@ class CameraBase
{ {
public: 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(){}; virtual ~CameraBase(){};
void setScreen();
void updatePlanes(Vector3 t_target); void updatePlanes(Vector3 t_target);
Plane planes[6]; Plane planes[6];
Matrix worldView; Matrix worldView;
@@ -33,7 +32,7 @@ protected:
ScreenSettings *screen; ScreenSettings *screen;
private: private:
Vector3 *position2, *up2, *unitCirclePosition2; Vector3 *p_position, *p_up;
float farPlaneDist, nearPlaneDist, nearHeight, nearWidth, farHeight, farWidth; float farPlaneDist, nearPlaneDist, nearHeight, nearWidth, farHeight, farWidth;
Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr;
}; };
+7 -8
View File
@@ -22,7 +22,7 @@
* @param fov (FOV in radians)/2 * @param fov (FOV in radians)/2
* @param ratio Aspect ratio * @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) : screen(t_screen)
{ {
PRINT_LOG("Initializing frustum"); PRINT_LOG("Initializing frustum");
@@ -33,9 +33,8 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t
nearWidth = nearHeight * screen->aspectRatio; nearWidth = nearHeight * screen->aspectRatio;
farHeight = tang * farPlaneDist; farHeight = tang * farPlaneDist;
farWidth = farHeight * screen->aspectRatio; farWidth = farHeight * screen->aspectRatio;
position2 = t_position; p_position = t_position;
up2 = t_up; p_up = t_up;
unitCirclePosition2 = t_unitCirclePosition;
PRINT_LOG("CameraBase initialized!"); PRINT_LOG("CameraBase initialized!");
} }
@@ -50,16 +49,16 @@ void CameraBase::updatePlanes(Vector3 t_target)
{ {
Vector3 nearCenter, farCenter, X, Y, Z; Vector3 nearCenter, farCenter, X, Y, Z;
// compute the Z axis of camera // compute the Z axis of camera
Z = *position2 - t_target; Z = *p_position - t_target;
Z.normalize(); Z.normalize();
// X axis of camera of given "up" vector and Z axis // X axis of camera of given "up" vector and Z axis
X = *up2 * Z; X = *p_up * Z;
X.normalize(); X.normalize();
// the real "up" vector is the cross product of Z and X // the real "up" vector is the cross product of Z and X
Y = Z * X; Y = Z * X;
// compute the center of the near and far planes // compute the center of the near and far planes
nearCenter = *position2 - Z * nearPlaneDist; nearCenter = *p_position - Z * nearPlaneDist;
farCenter = *position2 - Z * farPlaneDist; farCenter = *p_position - Z * farPlaneDist;
// compute the 8 corners of the frustum // compute the 8 corners of the frustum
ntl = nearCenter + Y * nearHeight - X * nearWidth; ntl = nearCenter + Y * nearHeight - X * nearWidth;
ntr = nearCenter + Y * nearHeight + X * nearWidth; ntr = nearCenter + Y * nearHeight + X * nearWidth;
+1 -1
View File
@@ -19,7 +19,7 @@ const float CAMERA_Y = 15.0F;
// Constructors/Destructors // 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"); PRINT_LOG("Initializing camera");
verticalLevel = 80.0F; verticalLevel = 80.0F;
+1 -1
View File
@@ -19,7 +19,7 @@ const float CAMERA_Y = 30.0F;
// Constructors/Destructors // 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"); PRINT_LOG("Initializing camera");
verticalLevel = 80.0F; verticalLevel = 80.0F;