Allow droping klein files

This commit is contained in:
PedroEdiaz
2024-12-01 21:33:27 -06:00
parent 733ababde0
commit fd598255f4
3 changed files with 36 additions and 42 deletions

View File

@@ -9,7 +9,7 @@ unsigned char selected_axis = 0;
int window_width;
int window_height;
unsigned char animate_index=0;
unsigned char animate_index = 0;
versor q = GLM_QUAT_IDENTITY_INIT;
@@ -56,23 +56,22 @@ void __key_callback_input(
projection.w = projection.x;
projection.x = tmp;
animate_index=1;
animate_index = 1;
break;
case GLFW_KEY_O:
tmp = projection.w;
projection.w = projection.y;
projection.y = tmp;
animate_index=2;
animate_index = 2;
break;
case GLFW_KEY_P:
tmp = projection.w;
projection.w = projection.z;
projection.z = tmp;
animate_index=3;
animate_index = 3;
break;
}
return;
}
@@ -114,9 +113,9 @@ void __scroll_callback_input(GLFWwindow *window, double xoffset, double yoffset)
versor p = GLM_QUAT_IDENTITY_INIT;
versor r = GLM_QUAT_IDENTITY_INIT;
//glm_quatv(p, yoffset * ANGLE, axis[selected_axis]);
glm_quatv(p, yoffset * ANGLE * 2, (vec3){-1,0,0});
glm_quatv(r, xoffset * ANGLE * 2, (vec3){0,1,0});
// glm_quatv(p, yoffset * ANGLE, axis[selected_axis]);
glm_quatv(p, yoffset * ANGLE * 2, (vec3){-1, 0, 0});
glm_quatv(r, xoffset * ANGLE * 2, (vec3){0, 1, 0});
glm_quat_mul(p, q, q);
glm_quat_mul(r, q, q);
@@ -129,6 +128,23 @@ void __scroll_callback_input(GLFWwindow *window, double xoffset, double yoffset)
glm_quat_rotatev(r, axis[2], axis[2]);
}
void __drop_callback_input(GLFWwindow *window, int count, char **path)
{
struct surface surface;
if (create_surface_klein(*path, &surface))
return;
if (!(projection.mesh = create_mesh(surface)))
return;
projection.m = surface.dim;
set_projection_mesh(projection);
free(surface.norm);
free(surface.data);
}
quat_t poll_input(window_t window)
{
versor p = GLM_QUAT_IDENTITY_INIT;
@@ -172,10 +188,11 @@ end:
glm_quat_normalize(q);
// LOG INFO
if(0)
if (0)
{
printf("QUAT: %2.5f %2.5f %2.5f %2.5f\n", q[0], q[1], q[2], q[3]);
printf("PROY: %3d %3d %3d (%3d)\n", projection.x, projection.y, projection.z, projection.w );
printf("PROY: %3d %3d %3d (%3d)\n", projection.x, projection.y,
projection.z, projection.w);
printf("\n");
}
return q;