From 1a780bd8f3b9d78bea807a2a40593eede970cc52 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 11 Sep 2023 09:35:54 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20main=5Ftest=5Fgraphics()=20et=20arrows?= =?UTF-8?q?=20simplifi=C3=A9s=20mais=20pb.=20calcul=20arrows=5Fnb=20=C3=A0?= =?UTF-8?q?=20partir=20de=20arrows[]=20cf.=20lignes=20140,=20170=20et=2064?= =?UTF-8?q?7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/arrows.c | 63 ++++------------------------------------- src/graphics/graphics.c | 26 ++++++++--------- 2 files changed, 19 insertions(+), 70 deletions(-) diff --git a/src/graphics/arrows.c b/src/graphics/arrows.c index 247e842..59eaae6 100644 --- a/src/graphics/arrows.c +++ b/src/graphics/arrows.c @@ -100,7 +100,7 @@ void arrows_write_terminations (long x, long y, long z) } /* - * Writes lines for arrow oriented to the east into lines buffer + * Writes lines for arrow oriented to the east or west into lines buffer * * @param s, * weight, @@ -108,7 +108,7 @@ void arrows_write_terminations (long x, long y, long z) * * @return void */ -void write_arrow_lines_east (long s, int weight, int site) +void write_arrow_lines_east_west (long s, int weight, int site) { graphics_write_line (s + 2, s + 6 + site % 2); graphics_write_line (s + 3, s + 6 + site % 2); @@ -117,7 +117,7 @@ void write_arrow_lines_east (long s, int weight, int site) } /* - * Writes lines for arrow oriented to the west into lines buffer + * Writes lines for arrow oriented to the zenith or nadir into lines buffer * * @param s, * weight, @@ -125,24 +125,7 @@ void write_arrow_lines_east (long s, int weight, int site) * * @return void */ -void write_arrow_lines_west (long s, int weight, int site) -{ - graphics_write_line (s + 2, s + 6 + site % 2); - graphics_write_line (s + 3, s + 6 + site % 2); - graphics_write_line (s + 4, s + 6 + site % 2); - graphics_write_line (s + 5, s + 6 + site % 2); -} - -/* - * Writes lines for arrow oriented to the zenith into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_zenith (long s, int weight, int site) +void write_arrow_lines_zenith_nadir (long s, int weight, int site) { graphics_write_line (s + 0, s + 8 + site % 2); graphics_write_line (s + 1, s + 8 + site % 2); @@ -151,7 +134,7 @@ void write_arrow_lines_zenith (long s, int weight, int site) } /* - * Writes lines for arrow oriented to the nadir into lines buffer + * Writes lines for arrow oriented to the south or north into lines buffer * * @param s, * weight, @@ -159,41 +142,7 @@ void write_arrow_lines_zenith (long s, int weight, int site) * * @return void */ -void write_arrow_lines_nadir (long s, int weight, int site) -{ - graphics_write_line (s + 0, s + 8 + site % 2); - graphics_write_line (s + 1, s + 8 + site % 2); - graphics_write_line (s + 4, s + 8 + site % 2); - graphics_write_line (s + 5, s + 8 + site % 2); -} - -/* - * Writes lines for arrow oriented to the south into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_south (long s, int weight, int site) -{ - graphics_write_line (s + 0, s + 10 + site % 2); - graphics_write_line (s + 1, s + 10 + site % 2); - graphics_write_line (s + 2, s + 10 + site % 2); - graphics_write_line (s + 3, s + 10 + site % 2); -} - -/* - * Writes lines for arrow oriented to the north into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_north (long s, int weight, int site) +void write_arrow_lines_south_north (long s, int weight, int site) { graphics_write_line (s + 0, s + 10 + site % 2); graphics_write_line (s + 1, s + 10 + site % 2); diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 12c540f..678e445 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -137,7 +137,7 @@ static void show_user_choices(long space_size_x, GLuint *arrows, int prefer) { - int arrows_nb = sizeof(arrows) / (5 * 4); + int arrows_nb = 3 * sizeof(arrows) / sizeof(arrows[0]); printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", space_size_x, space_size_y, space_size_z); if (arrows_nb > 0) printf("[%d] arrows ", arrows_nb); if (prefer == 1) printf("prefer = %d <> show no grid ", prefer); @@ -167,7 +167,7 @@ static void get_model_data_and_user_preferences() central_stars_nb = 0; // à calculer TODO // ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites) - central_stars_nb = sizeof(arrows) / (5 * 4); + central_stars_nb = sizeof(arrows) / sizeof(arrows[0]); pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc // xyz, 0, x, y, z, xy, xz, yz, xyz @@ -623,6 +623,7 @@ void main_test_graphics (void) long stx = z * y, sty = z, stz = 1; + long arrow_offset = 0; printf("offset_before_grid = %d\n", buffer_vertex_size / 3); @@ -636,29 +637,29 @@ void main_test_graphics (void) if (pref_show_grids > 0) grid_write_ridges (x, y, z); - int offset_after_grid = buffer_vertex_size / 3, cube_coord = 0; + int offset_after_grid = buffer_vertex_size / 3; printf("offset_after_ grid = %d\n", offset_after_grid); /* ARROWS */ arrows_write_terminations (x, y, z); - for (int i = 0; i < sizeof(arrows) / (5 * 4); i++) { + int arrows_nb_ad_hoc = 6; // 3 * sizeof(arrows) / sizeof(arrows[0]) ??? + + for (int i = 0; i < arrows_nb_ad_hoc; i++) { site = arrows[i * 5 + 1]; x = arrows[i * 5 + 2]; y = arrows[i * 5 + 3]; z = arrows[i * 5 + 4]; - cube_coord = 12 * (stx * x + sty * y + stz * z); - arrows_write_basis (offset_after_grid + cube_coord); + // cube coordinates = 12 * (stx * x + sty * y + stz * z); + arrow_offset = offset_after_grid + 12 * (stx * x + sty * y + stz * z); + arrows_write_basis (arrow_offset); switch(site){ - case EAST: write_arrow_lines_east (offset_after_grid + cube_coord, 1, site); break; - case WEST: write_arrow_lines_west (offset_after_grid + cube_coord, 1, site); break; - case ZENITH: write_arrow_lines_zenith(offset_after_grid + cube_coord, 1, site); break; - case NADIR: write_arrow_lines_nadir (offset_after_grid + cube_coord, 1, site); break; - case SOUTH: write_arrow_lines_south (offset_after_grid + cube_coord, 1, site); break; - case NORTH: write_arrow_lines_north (offset_after_grid + cube_coord, 1, site); break; + case EAST: case WEST: write_arrow_lines_east_west (arrow_offset, 1, site); break; + case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (arrow_offset, 1, site); break; + case SOUTH: case NORTH: write_arrow_lines_south_north (arrow_offset, 1, site); break; default: break; } } @@ -667,4 +668,3 @@ void main_test_graphics (void) } -