Skip to content

Commit

Permalink
[Renderer] 3D axis depend on Fov
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthou committed Aug 23, 2024
1 parent d6b44c0 commit 26455d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/overworld/Engine/Common/Camera/Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace owds {
glm::mat4 getProjectionMatrix() const { return proj_matrix_; }
ViewAntiAliasing_e getAASetting() const { return aa_setting_; }
CameraView_e getViewType() const { return view_type_; }
float getFov() const { return field_of_view_; }

float getNearPlane() const { return planes_[0]; }
float getFarPlane() const { return planes_[1]; }
Expand Down
6 changes: 5 additions & 1 deletion src/Engine/Graphics/OpenGL/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,11 @@ namespace owds {
glLineWidth(3);
glm::mat4 model = glm::scale(glm::mat4(1), glm::vec3(0.05, 0.05, 0.05));
glm::mat4 view = glm::mat4(glm::mat3(render_camera_.getViewMatrix()));
glm::mat4 view_translation = glm::translate(glm::mat4(1), glm::vec3(0.75 * (double)screen_.width_ / (double)screen_.height_, -0.75, -1.));
double aspect = (double)screen_.width_ / (double)screen_.height_;
double trans = tan(render_camera_.getFov() / 2.);
double trans_x = trans - 0.05;
double trans_y = trans - 0.05 * aspect;
glm::mat4 view_translation = glm::translate(glm::mat4(1), glm::vec3(trans_x * aspect, -trans_y, -1.));
view = view_translation * view;

lines_shader.setMat4("projection", render_camera_.getProjectionMatrix());
Expand Down

0 comments on commit 26455d9

Please sign in to comment.