From 4cfa52b23883111973e8834326656c30a97a7876 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 12 Oct 2023 23:12:32 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20premi=C3=A8res=20=C3=A9bauches=20de=20fl?= =?UTF-8?q?=C3=A8ches...=20=C3=A7a=20fait=20plaisir;=20(on=20mettra=20de?= =?UTF-8?q?=20l'ordre=20demain...)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/arrows.c | 29 ++++++++++++++++++----------- src/graphics/graphics.c | 18 +++++++++--------- src/graphics/grid.c | 16 ++++++++-------- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/graphics/arrows.c b/src/graphics/arrows.c index 48fac9c..ebc6d15 100644 --- a/src/graphics/arrows.c +++ b/src/graphics/arrows.c @@ -171,10 +171,11 @@ void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, int weight, int site, int x, int y, int z) { float nuance = 0.24f, - max = fmax(space_X, space_Y), + max = fmax(space_X, space_Y); + max = fmax(max, space_Z); // arrow_basis_width donne la dimension de l'étoile centrale - arrow_basis_width = 0.3f * (1 / max), + float arrow_basis_width = 0.3f * (1 / max), // décale légèrement les pointes des flèches // pour qu'elles n'aillent pas jusqu'aux faces des cubes @@ -184,8 +185,6 @@ void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, vy = (2 * y / space_Y - 1) * space_Y / max + (1 / max), vz = (2 * z / space_Z - 1) * space_Z / max + (1 / max); - max = fmax(max, space_Z); - // X - X axis - central star (basis) graphics_write_vertex(vx + arrow_basis_width, vy, vz); graphics_write_vertex(vx - arrow_basis_width, vy, vz); @@ -204,6 +203,18 @@ void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, graphics_write_color(0.3f, 0.3f, 0.3f); graphics_write_color(0.3f, 0.3f, 0.3f); + offset_vertex += 6; + offset_colors += 6; + + graphics_write_line (offset_vertex + 0, offset_vertex + 1); + graphics_write_line (offset_vertex + 2, offset_vertex + 3); + graphics_write_line (offset_vertex + 4, offset_vertex + 5); + + offset_lines += 3; // inutile... + + + + // X - X (EAST - WEST) axis - arrows tips (red - green) graphics_write_vertex (vx + (1 / max) - arrow_tip_padding, vy, vz); graphics_write_vertex (vx - (1 / max) + arrow_tip_padding, vy, vz); @@ -222,13 +233,8 @@ void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, graphics_write_color(0.0f + nuance, 0.0f + nuance, 1.0f - nuance / 4); graphics_write_color(1.0f - nuance / 3, 1.0f - nuance / 3, 0.0f + nuance); - - - graphics_write_line (offset_vertex + 0, offset_vertex + 1); - graphics_write_line (offset_vertex + 2, offset_vertex + 3); - graphics_write_line (offset_vertex + 4, offset_vertex + 5); - - + offset_vertex += 6; + offset_colors += 6; switch(site){ case EAST: case WEST: write_arrow_lines_east_west (offset_vertex, weight, site); break; @@ -237,6 +243,7 @@ void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, default: break; } + offset_lines += 4; // inutile... } diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index f482059..b755c4a 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -595,7 +595,7 @@ static void show_user_choices(struct arrow_t *arrows, int arrows_nb, if (show_all && prefer == 0) printf("prefer = %d <> show all grids", prefer); if (show_all && prefer == 1) printf("prefer = %d <> show no grid", prefer); if (show_all && prefer > 1) printf("show grids according rule (%d)", prefer); - if (style) printf("design... 'trop stylé' !"); + if (style) printf("orientations grilles alternées"); printf("\n"); @@ -887,7 +887,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) int pref_show_grids = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc // xyz, 0, x, y, z, xy, xz, yz, xyz int weight = 0, site = 0, x = 0, y = 0, z = 0;// stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0; - int style = 1; + int style = 0; show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 0, 0, style); @@ -909,10 +909,10 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) } show_arrows_array (arrows, arrows_nb); - offset_vertex += 8 + (space_X + space_Y + space_Z - 6) * 4; - offset_colors += 8 + (space_X + space_Y + space_Z - 6) * 4; - - if (style) offset_lines += space_X + space_Y + space_Z; + offset_vertex += (space_X + space_Y + space_Z - 3) * 4; + offset_colors += (space_X + space_Y + space_Z - 3) * 4; + if (style) offset_lines += 2 * (space_X + space_Y + space_Z - 3); + else offset_lines += 4 * (space_X + space_Y + space_Z - 3); for (int i = 0; i < arrows_nb; i++) { weight = arrows[i].load; @@ -921,9 +921,9 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) y = arrows[i].y; z = arrows[i].z; - void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, - int space_X, int space_Y, int space_Z, - int weight, int site, int x, int y, int z); + write_one_arrow(offset_vertex, offset_colors, offset_lines, + space_X, space_Y, space_Z, + weight, site, x, y, z); } free(arrows); diff --git a/src/graphics/grid.c b/src/graphics/grid.c index 233dfb7..c09496c 100644 --- a/src/graphics/grid.c +++ b/src/graphics/grid.c @@ -78,17 +78,17 @@ void write_grids_on_space_faces (long offset_vertex, long offset_colors, long of for (i = 0; i < x - 1; i ++) { - if (style != 1) + if (style) 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 != 1) + if (style) graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); } offset_vertex += (x - 1) * 4; offset_colors += (x - 1) * 4; - if (style != 1) offset_lines += 2; else offset_lines += (x - 1) * 4; + if (style) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4; for (i = 1; i < y; i++) { // (y - 2) * 4 @@ -105,9 +105,9 @@ void write_grids_on_space_faces (long offset_vertex, long offset_colors, long of for (i = 0; i < y - 1; i ++) { - if (style != 1) + if (style) graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); - if (style != 1) + if (style) 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); @@ -115,7 +115,7 @@ void write_grids_on_space_faces (long offset_vertex, long offset_colors, long of offset_vertex += (y - 1) * 4; offset_colors += (y - 1) * 4; - if (style != 1) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4; + if (style) offset_lines += (y - 1) * 2; else offset_lines += (y - 1) * 4; for (i = 1; i < z; i++) { // (z - 2) * 4 @@ -133,9 +133,9 @@ void write_grids_on_space_faces (long offset_vertex, long offset_colors, long of for (i = 0; i < z - 1; i ++) { graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); - if (style != 1) + if (style) graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); - if (style != 1) + if (style) 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); }