From bf0e192615a65a3fa7dc51f1ffc0e61499132323 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Thu, 19 Oct 2023 12:37:55 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20(micro)=20>=20deux=20vertex=20par=20fl?= =?UTF-8?q?=C3=A8che=20(1=C3=A8re=20=C3=A9bauche)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/arrows.c | 66 +++++++++++++---------------------------- src/graphics/graphics.c | 52 ++++++++++++++++---------------- 2 files changed, 46 insertions(+), 72 deletions(-) diff --git a/src/graphics/arrows.c b/src/graphics/arrows.c index 4a9b8f7..754860f 100644 --- a/src/graphics/arrows.c +++ b/src/graphics/arrows.c @@ -134,45 +134,23 @@ int write_one_arrow_vertex (int offset_vertex, // pour qu'elles n'aillent pas jusqu'aux faces des cubes GLfloat arrow_tip_padding = (1 / max) / 10; - /* // X - X axis - central star (basis) */ - /* graphics_write_vertex(vx + arrow_basis_width, vy, vz); */ - /* graphics_write_vertex(vx - arrow_basis_width, vy, vz); */ - /* graphics_write_color(0.3f, 0.3f, 0.3f); */ - /* graphics_write_color(0.3f, 0.3f, 0.3f); */ + switch(site){ + case EAST: case WEST: + graphics_write_vertex (vx + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, vy, vz); + graphics_write_color (1.0f, 0.0f, 0.0f); + break; + case ZENITH: case NADIR: + graphics_write_vertex (vx, vy + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, vz); + graphics_write_color(0.0f, 1.0f, 0.0f); + break; + case SOUTH: case NORTH: + graphics_write_vertex (vx, vy, vz + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding); + graphics_write_color(0.0f, 0.0f, 1.0f); + break; + default: break; + } - /* // Y - Y axis - central star (basis) */ - /* graphics_write_vertex(vx, vy + arrow_basis_width, vz); */ - /* graphics_write_vertex(vx, vy - arrow_basis_width, vz); */ - /* graphics_write_color(0.3f, 0.3f, 0.3f); */ - /* graphics_write_color(0.3f, 0.3f, 0.3f); */ - - /* // Z - Z axis - central star (basis) */ - /* graphics_write_vertex(vx, vy, vz + arrow_basis_width); */ - /* graphics_write_vertex(vx, vy, vz - arrow_basis_width); */ - /* graphics_write_color(0.3f, 0.3f, 0.3f); */ - /* graphics_write_color(0.3f, 0.3f, 0.3f); */ - - GLfloat nuance = 0.24f; - - // 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); - graphics_write_color(1.0f - nuance / 3, 0.0f + nuance, 0.0f + nuance); - graphics_write_color(0.0f + nuance, 1.0f - nuance, 1.0f - nuance); - - // Y - Y (ZENITH - NADIR) axis - arrows tips (cyan - magenta) - graphics_write_vertex (vx, vy + (1 / max) - arrow_tip_padding, vz); - graphics_write_vertex (vx, vy - (1 / max) + arrow_tip_padding, vz); - graphics_write_color(0.0f + nuance, 1.0f - nuance / 3, 0.0f + nuance); - graphics_write_color(1.0f - nuance, 0.0f + nuance, 1.0f - nuance); - - // Z - Z (NORTH - SOUTH) axis - arrows tips (blue - yellow) - graphics_write_vertex (vx, vy, vz + (1 / max) - arrow_tip_padding); - graphics_write_vertex (vx, vy, vz - (1 / max) + arrow_tip_padding); - graphics_write_color(0.0f + nuance * 2, 0.0f + nuance * 2, 1.0f - nuance); - graphics_write_color(1.0f - nuance / 3, 1.0f - nuance / 3, 0.0f + nuance); - - return 7;//12; + return 2; } @@ -180,18 +158,14 @@ int write_one_arrow_lines(int offset_vertex, int space_X_int, int space_Y_int, int space_Z_int, int weight, int site, int arrow_x, int arrow_y, int arrow_z) { - /* 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); */ - switch(site){ - case EAST: case WEST: graphics_write_line (offset_vertex + 0, offset_vertex + 1 + site % 2); break; - case ZENITH: case NADIR: graphics_write_line (offset_vertex + 0, offset_vertex + 3 + site % 2); break; - case SOUTH: case NORTH: graphics_write_line (offset_vertex + 0, offset_vertex + 5 + site % 2); break; + case EAST: case WEST: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break; + case ZENITH: case NADIR: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break; + case SOUTH: case NORTH: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break; default: break; } - return 7; + return 2; } diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 28249c6..49150e8 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -113,26 +113,6 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id, /* -------------------------------------------------------------------------- */ -/* - * Writes values to describe a line from a to b into the line buffer - * - * @param coords GLuint (a,b) - * - * @return void - */ -void graphics_write_line (GLuint a, GLuint b) -{ - buffer_lines_origin = g_realloc (buffer_lines_origin, - (buffer_lines_size + 2) * sizeof(GLuint)); - - assert (buffer_lines_origin); - - buffer_lines_origin[buffer_lines_size + 0] = a; - buffer_lines_origin[buffer_lines_size + 1] = b; - - buffer_lines_size += 2; -} - /* * Writes values to describe a vertex at (x,y,z) into the vertex buffer * @@ -177,6 +157,26 @@ void graphics_write_color (GLfloat r, GLfloat g, GLfloat b) buffer_colors_size += 3; } +/* + * Writes values to describe a line from a to b into the line buffer + * + * @param coords GLuint (a,b) + * + * @return void + */ +void graphics_write_line (GLuint a, GLuint b) +{ + buffer_lines_origin = g_realloc (buffer_lines_origin, + (buffer_lines_size + 2) * sizeof(GLuint)); + + assert (buffer_lines_origin); + + buffer_lines_origin[buffer_lines_size + 0] = a; + buffer_lines_origin[buffer_lines_size + 1] = b; + + buffer_lines_size += 2; +} + /* * Writes values to describe an (a,b,c) plan (triangle) into the plan buffer * @@ -676,14 +676,14 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) int rand(void); void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min); - int arbitrary = 160; + int arbitrary = 8; int space_X = 1 + rand() % arbitrary, space_Y = 1 + rand() % arbitrary, space_Z = 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 = 1, print_arrows_data = 0; + int show_space_design = 1, print_arrows_data = 1; int load = 0, site = 0, x = 0, y = 0, z = 0; int specif_arrows_nb = rand() % density_max / 3; @@ -715,13 +715,13 @@ 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; - if (0) printf("offset_vertex after writing_space_ridges_vertex : %d (x 3 = %d)\n\n", offset_vertex, offset_vertex * 3); + if (1) 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; - if (0) printf("offset_vertex after writing_space_faces_vertex = %4d - 8 = %3d (x 3 = %4d)\n", offset_vertex, offset_vertex - 8, (offset_vertex - 8) * 3); - if (0) printf("(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4 = %3d (x 3 = %4d)\n\n",\ + if (1) printf("offset_vertex after writing_space_faces_vertex = %4d - 8 = %3d (x 3 = %4d)\n", offset_vertex, offset_vertex - 8, (offset_vertex - 8) * 3); + if (1) printf("(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4 = %3d (x 3 = %4d)\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); @@ -740,7 +740,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) offset_colors = offset_vertex; } - if (0) printf("offset_vertex after writing_arrows_vertex : %d (x 3 = %d) (arrows_nb = %d)\n", offset_vertex, offset_vertex * 3, arrows_nb); + if (1) printf("offset_vertex after writing_arrows_vertex : %d (x 3 = %d) (arrows_nb = %d)\n", offset_vertex, offset_vertex * 3, arrows_nb); /*---------------------------------------------------------------*/