mirror of
git://windcorp.ru/ProgressiaTexturePreviewer.git
synced 2025-04-21 22:50:45 +03:00
Added isometric projection
This commit is contained in:
parent
1759b2257a
commit
00e110acb7
49
main.cpp
49
main.cpp
@ -160,6 +160,9 @@ GLFWwindow *window;
|
|||||||
enum MODE {
|
enum MODE {
|
||||||
BLOCK, PLANE
|
BLOCK, PLANE
|
||||||
} currentMode = BLOCK;
|
} currentMode = BLOCK;
|
||||||
|
enum CAMERA {
|
||||||
|
ANIMATED, ISOMETRIC
|
||||||
|
} currentCamera = ANIMATED;
|
||||||
int selection = 0;
|
int selection = 0;
|
||||||
bool light_theme = true;
|
bool light_theme = true;
|
||||||
|
|
||||||
@ -214,6 +217,7 @@ void glfw_shutdown_hook() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void switch_mode();
|
void switch_mode();
|
||||||
|
void switch_camera();
|
||||||
void switch_theme();
|
void switch_theme();
|
||||||
void change_texture(int direction);
|
void change_texture(int direction);
|
||||||
void close_texture();
|
void close_texture();
|
||||||
@ -238,6 +242,9 @@ void on_key(GLFWwindow*, int key, int, int action, int mods) {
|
|||||||
case GLFW_KEY_DELETE:
|
case GLFW_KEY_DELETE:
|
||||||
close_texture();
|
close_texture();
|
||||||
return;
|
return;
|
||||||
|
case GLFW_KEY_TAB:
|
||||||
|
switch_camera();
|
||||||
|
return;
|
||||||
default:
|
default:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
break;
|
break;
|
||||||
@ -252,8 +259,6 @@ void on_drop(GLFWwindow*, int count, const char** paths) {
|
|||||||
|
|
||||||
|
|
||||||
void switch_mode() {
|
void switch_mode() {
|
||||||
if (LOADED_TEXTURES.empty()) return;
|
|
||||||
|
|
||||||
switch (currentMode) {
|
switch (currentMode) {
|
||||||
case BLOCK:
|
case BLOCK:
|
||||||
currentMode = PLANE;
|
currentMode = PLANE;
|
||||||
@ -265,6 +270,18 @@ void switch_mode() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void switch_camera() {
|
||||||
|
switch (currentCamera) {
|
||||||
|
case ANIMATED:
|
||||||
|
currentCamera = ISOMETRIC;
|
||||||
|
break;
|
||||||
|
case ISOMETRIC:
|
||||||
|
currentCamera = ANIMATED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void switch_theme() {
|
void switch_theme() {
|
||||||
light_theme = !light_theme;
|
light_theme = !light_theme;
|
||||||
}
|
}
|
||||||
@ -716,11 +733,31 @@ void draw_block() {
|
|||||||
1.0f
|
1.0f
|
||||||
));
|
));
|
||||||
|
|
||||||
float t = static_cast<float>(glfwGetTime()) / 20;
|
switch (currentCamera) {
|
||||||
|
case ANIMATED:
|
||||||
|
{
|
||||||
|
float t = static_cast<float>(glfwGetTime()) / 20;
|
||||||
|
|
||||||
transform = glm::rotate(transform, t * 3, glm::vec3(1, 0, 0));
|
transform = glm::rotate(transform, t * 3, glm::vec3(1, 0, 0));
|
||||||
transform = glm::rotate(transform, t * 7, glm::vec3(0, 1, 0));
|
transform = glm::rotate(transform, t * 7, glm::vec3(0, 1, 0));
|
||||||
transform = glm::rotate(transform, t * 11, glm::vec3(0, 0, 1));
|
transform = glm::rotate(transform, t * 11, glm::vec3(0, 0, 1));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ISOMETRIC:
|
||||||
|
constexpr const float SQRT_2 = 1.41421356237309504880168872420969808;
|
||||||
|
constexpr const float SQRT_3 = 1.73205080756887729352744634150587236;
|
||||||
|
constexpr const float SQRT_6 = SQRT_2 * SQRT_3;
|
||||||
|
|
||||||
|
transform *= glm::mat4(
|
||||||
|
|
||||||
|
1 / SQRT_2, 0, -1 / SQRT_2, 0,
|
||||||
|
1 / SQRT_6, SQRT_2 / SQRT_3, 1 / SQRT_6, 0,
|
||||||
|
1 / SQRT_3, -1 / SQRT_3, 1 / SQRT_3, 0,
|
||||||
|
0, 0, 0, 1
|
||||||
|
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
transform = glm::scale(transform, glm::vec3(0.5));
|
transform = glm::scale(transform, glm::vec3(0.5));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user