diff --git a/src/graphics/buffers.c b/src/graphics/buffers.c index a1d1081..be7547b 100644 --- a/src/graphics/buffers.c +++ b/src/graphics/buffers.c @@ -54,9 +54,10 @@ int plans_ndx = 0; #define S 0 #define S3 0 #define SA 1 +#define A3 0 -#define L 1 -#define V 1 +#define L 0 +#define V 0 #define C 0 #define P 0 @@ -420,7 +421,6 @@ static bool compute_space_3D (int space_size_x, return 1; } -#define A3 1 static bool compute_arrow_3D(int space_size_x, int space_size_y, int space_size_z, @@ -472,52 +472,50 @@ static bool compute_arrow_3D(int space_size_x, if (pref_style_lines_planes == 0) { - *(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 5;//+ 0; - *(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 4;//+ 1; + *(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 5; + *(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 4; - *(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 5;//+ 0; - *(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 3;//+ 2; + *(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 5; + *(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 3; - /* *(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 5;// + 0; */ - /* *(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 2;// + 3; */ + *(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 5; + *(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 2; - /* *(line_origin + lines_ndx + 6) = vertex_ndx / 3 - 5;// + 0; */ - /* *(line_origin + lines_ndx + 7) = vertex_ndx / 3 - 1;// + 4; */ + *(line_origin + lines_ndx + 6) = vertex_ndx / 3 - 5; + *(line_origin + lines_ndx + 7) = vertex_ndx / 3 - 1; - /* *(line_origin + lines_ndx + 8) = vertex_ndx / 3 - 4;// + 1; */ - /* *(line_origin + lines_ndx + 9) = vertex_ndx / 3 - 3;// + 2; */ + *(line_origin + lines_ndx + 8) = vertex_ndx / 3 - 4; + *(line_origin + lines_ndx + 9) = vertex_ndx / 3 - 3; - /* *(line_origin + lines_ndx + 10) = vertex_ndx / 3 - 3;// + 2; */ - /* *(line_origin + lines_ndx + 11) = vertex_ndx / 3 - 2;// + 3; */ + *(line_origin + lines_ndx + 10) = vertex_ndx / 3 - 3; + *(line_origin + lines_ndx + 11) = vertex_ndx / 3 - 2; - /* *(line_origin + lines_ndx + 12) = vertex_ndx / 3 - 2;// + 3; */ - /* *(line_origin + lines_ndx + 13) = vertex_ndx / 3 - 1;// + 4; */ + *(line_origin + lines_ndx + 12) = vertex_ndx / 3 - 2; + *(line_origin + lines_ndx + 13) = vertex_ndx / 3 - 1; - /* *(line_origin + lines_ndx + 14) = vertex_ndx / 3 - 1;// + 4; */ - /* *(line_origin + lines_ndx + 15) = vertex_ndx / 3 - 4;// + 1; */ + *(line_origin + lines_ndx + 14) = vertex_ndx / 3 - 1; + *(line_origin + lines_ndx + 15) = vertex_ndx / 3 - 4; lines_ndx += 16; if (L) printf("|=> lines_ndx = %3d arrow_3D\n", lines_ndx); } if (pref_style_lines_planes == 1) { - int pgap = 0; // ?? TODO (REMOVE) + *(plan_origin + plans_ndx + 0) = space_size_x * 12 / 3 + 0; + *(plan_origin + plans_ndx + 1) = space_size_x * 12 / 3 + 1; + *(plan_origin + plans_ndx + 2) = space_size_x * 12 / 3 + 2; - *(plan_origin + pgap + 0) = space_size_x * 12 / 3 + 0; - *(plan_origin + pgap + 1) = space_size_x * 12 / 3 + 1; - *(plan_origin + pgap + 2) = space_size_x * 12 / 3 + 2; + *(plan_origin + plans_ndx + 3) = space_size_x * 12 / 3 + 0; + *(plan_origin + plans_ndx + 4) = space_size_x * 12 / 3 + 3; + *(plan_origin + plans_ndx + 5) = space_size_x * 12 / 3 + 4; - *(plan_origin + pgap + 3) = space_size_x * 12 / 3 + 0; - *(plan_origin + pgap + 4) = space_size_x * 12 / 3 + 3; - *(plan_origin + pgap + 5) = space_size_x * 12 / 3 + 4; + *(plan_origin + plans_ndx + 0) = space_size_x * 12 / 3 + 0; + *(plan_origin + plans_ndx + 1) = space_size_x * 12 / 3 + 1; + *(plan_origin + plans_ndx + 2) = space_size_x * 12 / 3 + 3; - *(plan_origin + pgap + 0) = space_size_x * 12 / 3 + 0; - *(plan_origin + pgap + 1) = space_size_x * 12 / 3 + 1; - *(plan_origin + pgap + 2) = space_size_x * 12 / 3 + 3; - - *(plan_origin + pgap + 3) = space_size_x * 12 / 3 + 0; - *(plan_origin + pgap + 4) = space_size_x * 12 / 3 + 2; - *(plan_origin + pgap + 5) = space_size_x * 12 / 3 + 4; + *(plan_origin + plans_ndx + 3) = space_size_x * 12 / 3 + 0; + *(plan_origin + plans_ndx + 4) = space_size_x * 12 / 3 + 2; + *(plan_origin + plans_ndx + 5) = space_size_x * 12 / 3 + 4; plans_ndx += 12; if (P) printf("|=> plans_ndx = %3d arrow_3D\n", plans_ndx); } @@ -552,8 +550,8 @@ static void show_user_choices(int model_space_size_x, if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes); if (! pref_style_mix_colors) printf("style_mix_colors = 0 "); if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors); - printf("\n[ n] load site x ---- < arrows array >\ - ----------------------------------------------------------------------\n"); + if (model_arrows_nb > 0) printf("\n[ n] load site x ---- < arrows array >\ + ---------------------------------------------------------------------\n"); // 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++) printf("[%2d] = %2d, %2d, %2d \n",\ @@ -626,7 +624,7 @@ bool compute_space_and_arrows(int model_space_size_x, model_space_size_y, model_space_size_z, - *(arrows + i * 3 + 0), // weight + *(arrows + i * 3 + 0), // weight (load) *(arrows + i * 3 + 1), // site *(arrows + i * 3 + 2), // x 0, // y @@ -645,7 +643,7 @@ bool compute_space_and_arrows(int model_space_size_x, model_space_size_y, model_space_size_z, - *(arrows + i * 3 + 0), // weight + *(arrows + i * 3 + 0), // weight (load) *(arrows + i * 3 + 1), // site *(arrows + i * 3 + 2), // x 0, // y diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index f61e019..fac867c 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -527,11 +527,11 @@ GLubyte arrows[] = { 1, 1, 0, 1, 0, 1, 1, 1, 4, 1, 0, 5, 1, 1, 8, 1, 0, 9 static void get_model_data_and_user_preferences(){ model_space_size_x = 11; // 2 < model_space_size_x < 32 - model_arrows_nb = 1; // assert : l'emplacement des flèches est contraint + 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_space = 0; // 0 = 3D 1 = 2D pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D - pref_mark_unit_space = 2; // 0 = no marks, 1 = 1st, 2 = last, 3 = both + pref_mark_unit_space = 3; // 0 = no marks, 1 = 1st, 2 = last, 3 = both pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix pref_style_mix_colors = 0; // TODO } @@ -573,24 +573,35 @@ static void compute_buffers_sizes(int model_space_size_x, int two_ladder_amounts = 4; // 2 parallels to connect 4 vertices if (pref_3D_xor_2D_space) { // 2D the ladder has 2 amounts - buffer_vertex_size = model_space_size_x * 6 + model_arrows_nb * 9; - buffer_colors_size = model_space_size_x * 6 + model_arrows_nb * 9; + buffer_vertex_size = model_space_size_x * 6; + buffer_colors_size = model_space_size_x * 6; buffer_plans_size = 0; - buffer_lines_size = model_space_size_x * 2 + model_arrows_nb * 6 - + two_ladder_amounts; + buffer_lines_size = model_space_size_x * 2 + two_ladder_amounts; } else { // 3D the ladder has 4 amounts, now - buffer_vertex_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 15; - buffer_colors_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 15; + buffer_vertex_size = (model_space_size_x + 1) * 12; + buffer_colors_size = (model_space_size_x + 1) * 12; buffer_plans_size = 0; - buffer_lines_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 15 - + 2 * two_ladder_amounts; + buffer_lines_size = (model_space_size_x + 1) * 12 + 2 * two_ladder_amounts; } /* Increment in buffer_lines_size is the same for 2D & 3D */ if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines + if (pref_3D_xor_2D_arrows) { // 2D + buffer_vertex_size += model_arrows_nb * 9; + buffer_colors_size += model_arrows_nb * 9; + buffer_plans_size += 0; + buffer_lines_size += model_arrows_nb * 6; + + } else { // 3D + buffer_vertex_size += model_arrows_nb * 15; + buffer_colors_size += model_arrows_nb * 15; + buffer_plans_size += 0; + buffer_lines_size += model_arrows_nb * 16; + } + /* buffer_plans_size est fonction de : model_space_size_x, model_arrows_nb et de pref_style_lines_planes */ if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\