Do the extra credit
This commit is contained in:
parent
ac5aa57d80
commit
fdbbd5c51a
1 changed files with 23 additions and 3 deletions
|
@ -548,6 +548,20 @@ void update() {
|
||||||
view_angle -= viewing_window::ANGLE_BY;
|
view_angle -= viewing_window::ANGLE_BY;
|
||||||
else if (is_spin_right_held)
|
else if (is_spin_right_held)
|
||||||
view_angle += viewing_window::ANGLE_BY;
|
view_angle += viewing_window::ANGLE_BY;
|
||||||
|
|
||||||
|
if (is_spin_up_held)
|
||||||
|
vertical_view_angle += viewing_window::ANGLE_BY;
|
||||||
|
else if (is_spin_down_held)
|
||||||
|
vertical_view_angle -= viewing_window::ANGLE_BY;
|
||||||
|
|
||||||
|
while (view_angle > 2 * PI)
|
||||||
|
view_angle -= 2 * PI;
|
||||||
|
while (view_angle < 0)
|
||||||
|
view_angle += 2 * PI;
|
||||||
|
while (vertical_view_angle > 2 * PI)
|
||||||
|
vertical_view_angle -= 2 * PI;
|
||||||
|
while (vertical_view_angle < 0)
|
||||||
|
vertical_view_angle += 2 * PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up normalization matrix
|
// Set up normalization matrix
|
||||||
|
@ -577,14 +591,20 @@ void update() {
|
||||||
auto m = Globals::view.m;
|
auto m = Globals::view.m;
|
||||||
auto eye = Globals::eye_pos;
|
auto eye = Globals::eye_pos;
|
||||||
|
|
||||||
eye_dir[0] = sin(view_angle);
|
eye_dir[0] = sin(view_angle) * cos(vertical_view_angle);
|
||||||
eye_dir[2] = cos(view_angle);
|
eye_dir[2] = cos(view_angle) * cos(vertical_view_angle);
|
||||||
|
eye_dir[1] = -sin(vertical_view_angle);
|
||||||
|
|
||||||
|
const float up_vertical_view_angle = vertical_view_angle + PI / 2;
|
||||||
|
up_dir[0] = sin(view_angle) * cos(up_vertical_view_angle);
|
||||||
|
up_dir[2] = cos(view_angle) * cos(up_vertical_view_angle);
|
||||||
|
up_dir[1] = -sin(up_vertical_view_angle);
|
||||||
|
|
||||||
Vec3f n = eye_dir * -1.0f;
|
Vec3f n = eye_dir * -1.0f;
|
||||||
n.normalize();
|
n.normalize();
|
||||||
|
|
||||||
// Up direction is (0, 1, 0)
|
// Up direction is (0, 1, 0)
|
||||||
Vec3f u = Globals::up_dir.cross(n);
|
Vec3f u = up_dir.cross(n);
|
||||||
u.normalize();
|
u.normalize();
|
||||||
|
|
||||||
// v = n x u
|
// v = n x u
|
||||||
|
|
Loading…
Reference in a new issue