This commit is contained in:
Your Name
2024-10-17 11:30:36 -06:00
parent 29ab40e33d
commit c2adfc2bda
3 changed files with 146 additions and 35 deletions

View File

@@ -16,6 +16,23 @@ unsigned char palette[] =
0x7A,0x1C,0xAC,0xff,
};
void calc_normal(float* v1, float* v2, float* v3, float* norm_vec)
{
vec3 lado1, lado2, normal;
glm_vec3_sub(v2, v1, lado1);
glm_vec3_sub(v3, v1, lado2);
glm_vec3_cross(lado1, lado2, normal);
glm_vec3_normalize(normal);
//para menos p2, ahora lo guarda en norm_vec
norm_vec[0] = normal[0];
norm_vec[1] = normal[1];
norm_vec[2] = normal[2];
}
const char * wname = "manigraph: manifold grapher";
int main( void )
@@ -32,6 +49,18 @@ int main( void )
glewInit();
//nostoy seguro de como escribir esto en cube.h, pero supongo que lo que me decias era así.
for (int i = 0; i < 3 * 3 * 2 * 6; i += 9) {
float* v1 = &d_cube[i];
float* v2 = &d_cube[i + 3];
float* v3 = &d_cube[i + 6];
float norm_vec[3];
calc_normal(v1, v2, v3, norm_vec);
n_cube[i] = norm_vec[0];
n_cube[i + 1] = norm_vec[1];
n_cube[i + 2] = norm_vec[2];
}
if( !( shader = create_shader() ) )
goto error_shader;