mirror of
https://github.com/Kbz-8/42_vox.git
synced 2026-01-11 14:43:34 +00:00
improving render distance
This commit is contained in:
@@ -3,17 +3,17 @@
|
||||
|
||||
namespace Scop
|
||||
{
|
||||
FirstPerson3D::FirstPerson3D() : BaseCamera(), m_up(0, 1, 0), m_position(0.0, 0.0, 0.0)
|
||||
FirstPerson3D::FirstPerson3D() : BaseCamera(), c_up(0, 1, 0), m_position(0.0, 0.0, 0.0)
|
||||
{}
|
||||
|
||||
FirstPerson3D::FirstPerson3D(Vec3f position, float fov) : BaseCamera(), m_position(std::move(position)), m_up(0, 1, 0), m_fov(fov)
|
||||
FirstPerson3D::FirstPerson3D(Vec3f position, float fov, float speed) : BaseCamera(), m_position(std::move(position)), c_up(0, 1, 0), c_speed(speed), m_fov(fov)
|
||||
{}
|
||||
|
||||
void FirstPerson3D::Update(class Inputs& input, float aspect, float timestep)
|
||||
{
|
||||
UpdateView();
|
||||
m_target = m_position + m_direction;
|
||||
m_view = Mat4f::LookAt(m_position, m_target, m_up);
|
||||
m_view = Mat4f::LookAt(m_position, m_target, c_up);
|
||||
m_proj = Mat4f::Perspective(RadianAnglef(m_fov), aspect, 0.1f, 100'000.f);
|
||||
|
||||
if(input.IsKeyPressed(SDL_SCANCODE_F1))
|
||||
@@ -32,8 +32,8 @@ namespace Scop
|
||||
|
||||
if(input.IsMouseGrabbed())
|
||||
{
|
||||
m_theta -= input.GetXRel() * m_sensivity;
|
||||
m_phi -= input.GetYRel() * m_sensivity;
|
||||
m_theta -= input.GetXRel() * c_sensivity;
|
||||
m_phi -= input.GetYRel() * c_sensivity;
|
||||
}
|
||||
|
||||
if(input.IsKeyPressed(SDL_SCANCODE_ESCAPE))
|
||||
@@ -52,15 +52,15 @@ namespace Scop
|
||||
if(input.IsKeyPressed(SDL_SCANCODE_A) || input.IsKeyPressed(SDL_SCANCODE_LEFT))
|
||||
m_mov += m_left;
|
||||
if(input.IsKeyPressed(SDL_SCANCODE_LSHIFT) || input.IsKeyPressed(SDL_SCANCODE_RSHIFT))
|
||||
m_mov -= m_up;
|
||||
m_mov -= c_up;
|
||||
if(input.IsKeyPressed(SDL_SCANCODE_SPACE))
|
||||
m_mov += m_up;
|
||||
m_mov += c_up;
|
||||
|
||||
if(input.IsMouseWheelUp())
|
||||
m_speed_factor *= 1.5f;
|
||||
if(input.IsMouseWheelDown())
|
||||
m_speed_factor /= 1.5f;
|
||||
m_position += m_mov * m_speed * m_speed_factor * timestep;
|
||||
m_position += m_mov * c_speed * m_speed_factor * timestep;
|
||||
}
|
||||
|
||||
void FirstPerson3D::UpdateView()
|
||||
@@ -73,10 +73,10 @@ namespace Scop
|
||||
m_direction.y = std::sin(m_phi * Pi<float>() / 180);
|
||||
m_direction.z = std::cos(m_phi * Pi<float>() / 180) * std::sin(-m_theta * Pi<float>() / 180);
|
||||
|
||||
m_left = m_up.CrossProduct(m_direction);
|
||||
m_left = c_up.CrossProduct(m_direction);
|
||||
m_left.Normalize();
|
||||
|
||||
m_forward = m_up.CrossProduct(m_left);
|
||||
m_forward = c_up.CrossProduct(m_left);
|
||||
m_forward.Normalize();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user