From 1104459617c3ee318024d2ea352e222e2f372008 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Tue, 4 Jul 2023 12:29:13 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20une=20=C3=A9bauche=202D=20avec=20plusieu?= =?UTF-8?q?rs=20fl=C3=A8ches?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/buffers.c | 45 +++++++++++++++++++++++++++++++---------- src/graphics/graphics.c | 4 ++-- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/graphics/buffers.c b/src/graphics/buffers.c index 880d07c..d4408c8 100644 --- a/src/graphics/buffers.c +++ b/src/graphics/buffers.c @@ -50,6 +50,8 @@ int plans_ndx = 0; #define EDGE 0.999999 #define S2 0 +#define L 0 +#define V 1 static bool compute_space_2D(int space_size_x, int space_size_y, int space_size_z, @@ -86,6 +88,7 @@ static bool compute_space_2D(int space_size_x, *(vertex_origin + k * 6 + 5) = 0.0f; vertex_ndx += 6; + if (V) printf(" => vertex_ndx = %d\n", vertex_ndx); *(color_origin + k * 6 + 0) = 1; *(color_origin + k * 6 + 1) = 0; @@ -101,6 +104,7 @@ static bool compute_space_2D(int space_size_x, *(line_origin + k * 2 + 1) = k * 2 + 1; lines_ndx += 2; + if (L) printf(" => lines_ndx = %d\n", lines_ndx); } *(color_origin + 0) = 0; @@ -128,25 +132,32 @@ static bool compute_space_2D(int space_size_x, *(line_origin + lines_ndx + 3) = space_size_x * 2 - 1; // barre horizontale du haut lines_ndx += 4; + if (L) printf("H=> lines_ndx = %d\n", lines_ndx); if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) // diagonales to mark first space unit { *(line_origin + lines_ndx + 0) = 0; *(line_origin + lines_ndx + 1) = 3; + *(line_origin + lines_ndx + 2) = 1; *(line_origin + lines_ndx + 3) = 2; lines_ndx += 4; + if (L) printf("X=> lines_ndx = %d\n", lines_ndx); + } if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) // diagonales to mark last space unit { *(line_origin + lines_ndx + 0) = (space_size_x - 2) * 2 + 0; *(line_origin + lines_ndx + 1) = (space_size_x - 2) * 2 + 3; + *(line_origin + lines_ndx + 2) = (space_size_x - 2) * 2 + 1; *(line_origin + lines_ndx + 3) = (space_size_x - 2) * 2 + 2; lines_ndx +=4; + if (L) printf("X=> lines_ndx = %d\n", lines_ndx); + } if (S2) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x); @@ -182,12 +193,14 @@ static int compute_arrow_2D(int space_size_x, int buffer_lines_size, int buffer_plans_size) { + printf("compute_arrow_2D load = %d site = %d x = %d\n", weight, site, x); float zero = 0.0f; float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2); - // float tip = center + (2 * site - 1) * (1.0f / space_size_x); + float tip = center + (2 * site - 1) * (1.0f / space_size_x); + tip = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f); float base = center + (2 * site - 1) * (0.1f / space_size_x); - *(vertex_origin + vertex_ndx + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f); + *(vertex_origin + vertex_ndx + 0) = tip; *(vertex_origin + vertex_ndx + 1) = zero; *(vertex_origin + vertex_ndx + 2) = zero; @@ -200,19 +213,23 @@ static int compute_arrow_2D(int space_size_x, *(vertex_origin + vertex_ndx + 8) = zero; vertex_ndx += 9; + if (V) printf(" => vertex_ndx = %d\n", vertex_ndx); if (pref_style_lines_planes == 0) { - *(line_origin + lines_ndx + 0) = vertex_ndx / 3 + 0; - *(line_origin + lines_ndx + 1) = vertex_ndx / 3 + 1; + if (V) printf("0=> lines_ndx = %d\n", lines_ndx); - *(line_origin + lines_ndx + 2) = vertex_ndx / 3 + 0; - *(line_origin + lines_ndx + 3) = vertex_ndx / 3 + 2; + *(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 3; + *(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 2; - *(line_origin + lines_ndx + 4) = vertex_ndx / 3 + 1; - *(line_origin + lines_ndx + 5) = vertex_ndx / 3 + 2; + *(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 3; + *(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 1; + + *(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 2; + *(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 1; lines_ndx += 6; + if (V) printf("|=> lines_ndx = %d\n", lines_ndx); } @@ -274,6 +291,9 @@ static bool compute_space_3D (int space_size_x, *(vertex_origin + k * 12 + 10) = - 1.0f / space_size_x; *(vertex_origin + k * 12 + 11) = 1.0f / space_size_x; + vertex_ndx += 12; + if (V) printf(" => vertex_ndx = %d\n", vertex_ndx); + *(color_origin + k * 12 + 0) = 1; // 1 - (k / space_size_x); *(color_origin + k * 12 + 1) = 0; *(color_origin + k * 12 + 2) = 0; @@ -453,6 +473,9 @@ static bool compute_arrow_3D(int space_size_x, *(vertex_origin + vgap + 13) = - 0.4f / space_size_x; *(vertex_origin + vgap + 14) = 0.4f / space_size_x; + vertex_ndx += 15; + if (V) printf(" => vertex_ndx = %d\n", vertex_ndx); + if (A3) printf("center = %f tip = %f base = %f\n",\ center, tip, base); // vgap=%d igap=%d @@ -619,11 +642,11 @@ bool compute_space_and_arrows(int model_space_size_x, // arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 } - if (SA) for (int i = 0; i < model_arrows_nb; i++) { + if (SA) for (int i = 0; i < model_arrows_nb; i++) printf("[%2d] = %2d, %2d, %2d \n",\ i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2)); - if (pref_3D_xor_2D_arrows) compute_arrow_2D(model_space_size_x, + for (int i = 0; i < model_arrows_nb; i++) if (pref_3D_xor_2D_arrows) compute_arrow_2D(model_space_size_x, model_space_size_y, model_space_size_z, @@ -682,7 +705,7 @@ bool compute_space_and_arrows(int model_space_size_x, /* compute_arrow_3D(entry, model_space_size_x, vgap, igap, 1, 0, model_space_size_x - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */ /* compute_arrow_3D(entry, model_space_size_x, vgap, igap, 1, 1, model_space_size_x - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */ - } + return 0; } diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index cfd6f25..aa75fbb 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -525,8 +525,8 @@ bool graphics_init_shaders(const void *gl_area) static void get_model_data_and_user_preferences(){ - model_space_size_x = 6; // 2 < model_space_size_x < 32 - model_arrows_nb = 1; // assert : l'emplacement des flèches est contraint + model_space_size_x = 8; // 2 < model_space_size_x < 32 + model_arrows_nb = 6; // assert : l'emplacement des flèches est contraint // par model_space_size_x, y, z et le nombre de sites pref_3D_xor_2D_space = 1; // 0 = 3D 1 = 2D pref_3D_xor_2D_arrows = 1; // 0 = 3D 1 = 2D