Skip to content
Snippets Groups Projects
Commit 44a44d65 authored by Martin Štourač's avatar Martin Štourač
Browse files

math include fix, mouse left hold to look around

parent 2d88efd6
No related branches found
No related tags found
No related merge requests found
class Frame
{
public:
vec3 get_pos();
quat get_rot()l;
vec3 get_axis_x();
vec3 get_axis_y();
vec3 get_axis_z();
mat3 get_rot_matrix();
mat4 get_from_matrix();
mat4 get_to_matrix();
mat4 get_world_matrix();
void set_pos(vec3 pos_) { pos = pos_; }
void move(vec3 dpos) { pos += dpos; invalidate_wolrd_matrices(); }
void set_rot(quat rot_) { rot = rot_; }
void rotate(quat rot_) { rot *= rot_; }
mat4& get_world_matrix()
{
if (to_world == nullptr)
to_world = vypocti;
return *to_world;
}
void invalidate_wolrd_matrices()
{
delete to_world;
to_world = nullptr;
// rekurzivne pro kazdeho potiomka totez.
for (Frame* chuild : children)
child->invalidate_wolrd_matrices();
}
Frame* parent;
std::vector<Frame*> children;
glm::mat4* to_world;
};
\ No newline at end of file
#include <studio/simulator.hpp>
#include <osi/opengl.hpp>
#include <osi/gui.hpp>
#include <utils/assumptions.hpp>
#include <gfx/vao.hpp>
#include <gfx/vbo.hpp>
......@@ -153,7 +154,9 @@ void gfx_draw(Shader &myShader, VAO &VAO, Camera camera)
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ASSUMPTION(glGetError() == GL_NO_ERROR); // !!!!!!!!!!!!!!!!!!!!!!!
VAO.Bind();
//glDrawArrays(GL_TRIANGLES, 0, 3);
glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);
......
......@@ -43,7 +43,7 @@ float vertices_cube[] =
Simulator::Simulator()
: osi::Simulator()
, myVAO{VAO{}}
, myVBO{VBO{}}
, myVBO{VBO{}} // camera frame, object frame, camera, object
, myEBO{EBO{}}
, myShader{create_shader_program()}
{
......@@ -91,18 +91,19 @@ void Simulator::present()
void Simulator::process_input()
{
if (! window().has_keyboard_focus())
if (!window().has_keyboard_focus())
return;
camera.setSpeed(timer().dt());
// Issues not occuring anymore
if (keyboard().down().contains("W"))
camera.forward();
if (keyboard().down().contains("S"))
camera.backward();
if (keyboard().down().contains("A") && !keyboard().just_released().contains("A"))
if (keyboard().down().contains("A"))
camera.left();
if (keyboard().down().contains("D") && !keyboard().just_released().contains("D"))
if (keyboard().down().contains("D"))
camera.right();
if (keyboard().down().contains("R"))
camera.up();
......@@ -121,7 +122,7 @@ void Simulator::process_mouse()
float xoffset = 0;
float yoffset = 0;
if (true /*mouse().down().contains("SDL_BUTTON_LMASK")*/
if (mouse().down().contains("MouseLeft")
&& window().is_mouse_in_window())
{
glm::i32vec2 offset = mouse().pos_delta();
......
#ifndef UTILS_ASSUMPTIONS_HPP_INCLUDED
# define UTILS_ASSUMPTIONS_HPP_INCLUDED
#ifndef UTILS_MATH_HPP_INCLUDED
# define UTILS_MATH_HPP_INCLUDED
# include <glm/glm.hpp>
# include <glm/gtc/matrix_access.hpp>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment