WIP: vérif en cours : le nombre de vertex a l'air bon; le pb est du côté des lignes

This commit is contained in:
Jean Sirmai 2023-10-17 12:45:52 +02:00
parent 8b7e7c0f28
commit 6af1ece434
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 29 additions and 16 deletions

View File

@ -151,6 +151,8 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z)
buffer_vertex_origin[buffer_vertex_size + 1] = y;
buffer_vertex_origin[buffer_vertex_size + 2] = z;
printf("buffer_vertex_size = %d (%6.3f,%6.3f,%6.3f)\n", buffer_vertex_size, x, y, z);
buffer_vertex_size += 3;
}
@ -676,16 +678,16 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
int arbitrary = 30;
int space_X = 1 + rand() % arbitrary,
space_Y = 1 + rand() % arbitrary,
space_Z = 1 + rand() % arbitrary;
int space_X = 3,//1 + rand() % arbitrary,
space_Y = 3,//1 + rand() % arbitrary,
space_Z = 3;//1 + rand() % arbitrary;
int density_max = space_X * space_Y * space_Z;
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
int show_space_design = 0, print_arrows_data = 0;
int load = 0, site = 0, x = 0, y = 0, z = 0;
int specif_arrows_nb = rand() % density_max / 3;
int specif_arrows_nb = 0;//rand() % density_max / 3;
int arrows_nb = 0;
while (arrows_nb < specif_arrows_nb){
@ -714,9 +716,16 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
offset_vertex += write_space_ridges_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
offset_colors = offset_vertex;
printf("offset_vertex after writing_space_ridges_vertex : %d (x 3 = %d)\n\n", offset_vertex, offset_vertex * 3);
offset_vertex += write_grids_on_space_faces_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
offset_colors = offset_vertex;
printf("offset_vertex after writing_space_faces_vertex = %2d - 8 = %d (x 3 = %d)\n", offset_vertex, offset_vertex - 8, (offset_vertex - 8) * 3);
printf("(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4 = %2d (x 3 = %d)\n\n",\
(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4, ((space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4) * 3);
/* A R R O W S */
for (int i = 0; i < arrows_nb; i++) {
@ -732,6 +741,8 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
offset_colors = offset_vertex;
}
printf("offset_vertex after writing_arrows_vertex : %d (x 3 = %d) (arrows_nb = %d)\n", offset_vertex, offset_vertex * 3, arrows_nb);
/*---------------------------------------------------------------*/

View File

@ -62,10 +62,10 @@ int write_space_ridges_lines (long offset_vertex, long offset_colors, long offse
graphics_write_line ( 1, 5); graphics_write_line ( 3, 5);
graphics_write_line ( 2, 6); graphics_write_line ( 3, 6);
return 8;
return 12;
}
long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style)
long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
{
float i, max = fmax(x, y); max = fmax(max, z);
@ -118,46 +118,48 @@ long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors,
}
long write_grids_on_space_faces_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style)
long write_grids_on_space_faces_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
{
float i, max = fmax(x, y); max = fmax(max, z);
design = 1;
for (i = 0; i < x - 1; i ++) {
if (style)
if (design)
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
if (style)
if (design)
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
}
/* if (style) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4; */
/* if (design) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4; */
for (i = 0; i < y - 1; i ++) {
if (style)
if (design)
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
if (style)
if (design)
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
}
/* if (style) offset_lines += (y - 1) * 2; else offset_lines += (y - 1) * 4; */
/* if (design) offset_lines += (y - 1) * 2; else offset_lines += (y - 1) * 4; */
for (i = 0; i < z - 1; i ++) {
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
if (style)
if (design)
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
if (style)
if (design)
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
}
return (x + y + z - 3) * 4;
/* if (style) offset_lines += 2 * (space_X + space_Y + space_Z - 3); */
/* if (design) offset_lines += 2 * (space_X + space_Y + space_Z - 3); */
/* else offset_lines += 4 * (space_X + space_Y + space_Z - 3); */