changes to match latest matrix/vector3 api

This commit is contained in:
h4570
2020-12-24 10:34:56 +01:00
parent 8589a298da
commit e39c8c5de8
9 changed files with 15 additions and 22 deletions
+4 -4
View File
@@ -18,7 +18,7 @@
// Constructors/Destructors
// ----
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t_up)
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
: screen(t_screen)
{
PRINT_LOG("Initializing frustum");
@@ -30,7 +30,7 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t
farHeight = tang * farPlaneDist;
farWidth = farHeight * screen->aspectRatio;
p_position = t_position;
p_up = t_up;
up.set(0.0F, 1.0F, 0.0F);
PRINT_LOG("CameraBase initialized!");
}
@@ -41,7 +41,7 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position, Vector3 *t
void CameraBase::lookAt(Vector3 &t_target)
{
updatePlanes(t_target);
worldView.lookAt(*p_up, *p_position, t_target);
worldView.lookAt(*p_position, t_target);
}
void CameraBase::updatePlanes(Vector3 t_target)
@@ -51,7 +51,7 @@ void CameraBase::updatePlanes(Vector3 t_target)
Z = *p_position - t_target;
Z.normalize();
// X axis of camera of given "up" vector and Z axis
X = *p_up * Z;
X = up * Z;
X.normalize();
// the real "up" vector is the cross product of Z and X
Y = Z * X;
+2 -2
View File
@@ -277,8 +277,8 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
if (!t_mesh.isDataLoaded())
PRINT_ERR("Can't draw, because no mesh data was loaded!");
Vector3 rotatedCamera = Vector3(*renderData.cameraPosition);
rotatedCamera.rotate(t_mesh.rotation, true);
camRotation.rotation(-t_mesh.rotation);
Vector3 rotatedCamera = Vector3(camRotation * *renderData.cameraPosition);
if (t_mesh.getCurrentAnimationFrame() != t_mesh.getNextAnimationFrame())
t_mesh.animate();