|
|
|
|
@ -123,7 +123,7 @@ camera g_camera;
|
|
|
|
|
bool initRenderer(SDL_Handles &handles, v2i vpDims); |
|
|
|
|
bool addTexture(SDL_Handles &handles, std::string path); |
|
|
|
|
bool createScene(std::vector<hex_info>* hexes); |
|
|
|
|
void moveCamera(bool up, bool left, bool down, bool right); |
|
|
|
|
void moveCamera(bool up, bool left, bool down, bool right, bool forward, bool backward); |
|
|
|
|
void rotateCamera(int32 xrel, int32 yrel); |
|
|
|
|
void renderFrame(const std::vector<hex_info> *hexes); |
|
|
|
|
void renderDebug(std::vector<Point> &vertices); |
|
|
|
|
@ -274,7 +274,7 @@ initMatrices(projection_type p)
|
|
|
|
|
if (p == PERSPECTIVE) |
|
|
|
|
{ |
|
|
|
|
g_scene_matrices.projection = glm::perspective( |
|
|
|
|
glm::radians(45.f), // FoV
|
|
|
|
|
glm::radians(60.f), // FoV
|
|
|
|
|
16.f / 9.f, // ascpect ratio
|
|
|
|
|
0.1f, // near clip plane
|
|
|
|
|
1000.0f // far clip plane
|
|
|
|
|
@ -289,6 +289,7 @@ initMatrices(projection_type p)
|
|
|
|
|
g_camera.vAngle = glm::atan((t.z - p.z) / (t.y - p.y)); |
|
|
|
|
|
|
|
|
|
//////
|
|
|
|
|
// TODO: add call to rotate camera here to remove duplicate code
|
|
|
|
|
camera &c = g_camera; |
|
|
|
|
float &h = c.hAngle; |
|
|
|
|
float &v = c.vAngle; |
|
|
|
|
@ -385,20 +386,24 @@ createScene(std::vector<hex_info>* hexes)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
moveCamera(bool up, bool left, bool down, bool right) |
|
|
|
|
moveCamera(bool up, bool left, bool down, bool right, bool forward, bool backward) |
|
|
|
|
{ |
|
|
|
|
if (!up && !left && !down && !right) |
|
|
|
|
if (!up && !left && !down && !right && !forward && !backward) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
glm::mat4 &m = g_scene_matrices.view; |
|
|
|
|
// TODO: fix vector addition bug doubling move speed vector magnitude when
|
|
|
|
|
// moving in 2 directions
|
|
|
|
|
|
|
|
|
|
float d = 5.f; // units per frame
|
|
|
|
|
|
|
|
|
|
glm::vec3 f = g_camera.forward; |
|
|
|
|
glm::vec3 u = g_camera.up; |
|
|
|
|
glm::vec3 old = g_camera.position; |
|
|
|
|
glm::vec3 &p = g_camera.position; |
|
|
|
|
if (up) p += (f * d); |
|
|
|
|
if (down) p -= (f * d); |
|
|
|
|
if (forward) p += f * d; |
|
|
|
|
if (backward) p -= f * d; |
|
|
|
|
if (up) p += u * d; |
|
|
|
|
if (down) p -= u * d; |
|
|
|
|
if (left) |
|
|
|
|
{ |
|
|
|
|
glm::vec3 l = glm::cross(f, u); |
|
|
|
|
@ -411,8 +416,8 @@ moveCamera(bool up, bool left, bool down, bool right)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
glm::vec3 diff = old - p; |
|
|
|
|
m = glm::translate(m, diff); |
|
|
|
|
g_scene_matrices.MVP = g_scene_matrices.projection * m * g_scene_matrices.model;
|
|
|
|
|
g_scene_matrices.view = glm::translate(g_scene_matrices.view, diff); |
|
|
|
|
g_scene_matrices.MVP = g_scene_matrices.projection * g_scene_matrices.view * g_scene_matrices.model;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
@ -429,9 +434,8 @@ rotateCamera(int32 xrel, int32 yrel)
|
|
|
|
|
glm::sin(v) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
glm::mat4 &m = g_scene_matrices.view; |
|
|
|
|
m = glm::lookAt(c.position, c.position + c.forward, c.up); |
|
|
|
|
g_scene_matrices.MVP = g_scene_matrices.projection * m * g_scene_matrices.model;
|
|
|
|
|
g_scene_matrices.view = glm::lookAt(c.position, c.position + c.forward, c.up); |
|
|
|
|
g_scene_matrices.MVP = g_scene_matrices.projection * g_scene_matrices.view * g_scene_matrices.model;
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|