+ | Portal viewing angle teleportation

This commit is contained in:
TheRedShip
2025-02-06 00:16:25 +01:00
committed by tomoron
parent 63728e6476
commit b1c9718ae3
10 changed files with 72 additions and 27 deletions

View File

@ -41,6 +41,7 @@ class Camera
void processKeyboard(bool forward, bool backward, bool left, bool right, bool up, bool down);
void updateCameraVectors();
void updateCameraDirections();
int portalTeleport(Scene *scene, float delta_time);

View File

@ -23,6 +23,7 @@ class Window
Window(Scene *scene, int width, int height, const char *title, int sleep, Arguments &args);
~Window(void);
void updateDeltaTime();
void display();
void pollEvents();
bool shouldClose();

View File

@ -45,16 +45,10 @@ class Portal : public Object
_up = glm::vec3(x1, y1, z1);
_right = glm::vec3(x2, y2, z2);
// glm::vec3 temp_right = _right;
// _right = _invert_normal ? _up : _right;
// _up = _invert_normal ? temp_right : _up;
glm::vec3 right = glm::normalize(_right);
glm::vec3 up = glm::normalize(_up);
glm::vec3 forward = glm::normalize(glm::cross(right, up));
// up = normalize(glm::cross(forward, right));
_rotation = glm::mat3(right, up, forward);
_normal = forward * (_invert_normal ? -1.0f : 1.0f);
@ -72,10 +66,6 @@ class Portal : public Object
glm::vec3 right_dir = glm::normalize(_right);
glm::vec3 up_dir = glm::normalize(_up);
// glm::vec3 temp_right = right_dir;
// right_dir = _invert_normal ? right_dir : up_dir;
// up_dir = _invert_normal ? up_dir : temp_right;
float right_length = glm::length(_right) + extension;
float up_length = glm::length(_up) + extension;
@ -84,7 +74,7 @@ class Portal : public Object
glm::vec3 right = right_dir * right_length;
glm::vec3 up = up_dir * up_length;
// position += 10;
return (new Quad(position, right, up, _normal, 1, _mat_index));
}