From 1879b3f281322f7bb466c1d0f846bfab00be07bc Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Wed, 23 Aug 2023 00:22:32 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20On=20d=C3=A9cortique...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/buffers.h | 22 +++---- src/graphics/buffers.c | 124 ++++++++++++++++++++++------------------ src/graphics/graphics.c | 16 ++++-- à résoudre | 36 ++++++++++++ 4 files changed, 121 insertions(+), 77 deletions(-) diff --git a/include/buffers.h b/include/buffers.h index 756c882..1bce47e 100644 --- a/include/buffers.h +++ b/include/buffers.h @@ -27,21 +27,13 @@ #include bool compute_space(int space_X, int space_Y, int space_Z, - - GLuint *arrows, - int model_arrows_nb, - -// int pref_mark_unit_space, -// int pref_style_lines_planes, -// int pref_style_mix_colors, - int pref_show_grid, - int pref_central_stars_nb, - int pref_test_diagonal, - - GLfloat *vertex_origin, - GLfloat *color_origin, - GLuint *line_origin, - GLuint *plan_origin); + GLuint *arrows, int model_arrows_nb, + int pref_show_grid, int pref_central_stars_nb, + int pref_test_diagonal, + int buffer_vertex_size_after_grids, + int buffer_vertex_size_after_stars, + GLfloat *vertex_origin, GLfloat *colors_origin, + GLuint *lines_origin, GLuint *plans_origin); bool draw_some_arrows (GLuint *lines_origin, int s, int stx, int sty, diff --git a/src/graphics/buffers.c b/src/graphics/buffers.c index d566891..fdcf43a 100644 --- a/src/graphics/buffers.c +++ b/src/graphics/buffers.c @@ -427,72 +427,38 @@ static float radius(int x, int y, int z, int space_X, int space_Y, int space_Z){ return r; } -// (1,2,2) (2,1,2) (2,2,1) (2,2,2) (2,2,3) (2,3,2) (3,2,2) - -/* #define D 0 */ -/* static int experimental_1_verbose(GLuint *lines_origin, */ -/* int space_X, int space_Y, int space_Z, int step_x, int step_y) */ -/* { */ -/* float r = 0.0f, limit = 1.0f; */ -/* int nb_in_neighborhood = 0, step_z = 1; */ -/* int s = space_X * space_Y * space_Z / 2; */ - -/* printf("buffers : with limit = %3.1f, %d/%d neighboors, ",\ */ -/* limit, nb_in_neighborhood, s * 2 + 1); */ - -/* // int z = space_Z; */ -/* // int y = z * space_Z; */ -/* // int x = y * space_Y; */ -/* for (int i = 0; i < space_X; i++){ */ -/* for (int j = 0; j < space_Y; j++){ */ -/* if (D && (i == 0 || i == space_X - 1)) printf(" "); */ -/* for (int k = 0; k < space_Z; k++){ */ -/* if (D && (k == 0 && j == space_X - 1)) printf(" "); */ -/* r = radius(i, j, k, space_X, space_Y, space_Z); */ -/* if (r < limit){ // 2.5f */ -/* if (D) printf("%6.3f (%d,%d,%d) ", r, i, j, k); */ -/* return draw_a_central_star(lines_origin, */ -/* s + ((i + 0) * step_x */ -/* + (j + 0) * step_y */ -/* + (k + 0) * step_z) * 6 */ -/* + 10 ); */ - // printf("buffers : (444) n = %d i * step_x + j * step_y + k = %d 125 / 2 = %d\n", - // s + (i * step_x + j * step_y + k) * 6 + 10, i * step_x + j * step_y + k, 125/2); - // nb_in_neighborhood ++; //printf("r = %f (%d,%d,%d)\n", r, i, j ,k); -/* } */ -/* } */ -/* if (D) printf("\n"); */ -/* } */ -/* if (D) printf("\n "); */ -/* } */ -/* return 0; */ -/* } */ - -static int experimental_1(GLuint *lines_origin, int space_X, int space_Y, int space_Z) +// a = buffer_vertex_size_after_grids, b = buffer_vertex_size_after_stars +static void experimental_1(GLuint *lines_origin, int space_X, int space_Y, int space_Z, int a, int b) { - float rayon = 0.0f, limit_sup = 3.9f, limit_inf = 3.6f; - int nb_in_neighborhood = 0; + float rayon = 0.0f, limit_sup = 1.4f, limit_inf = 0.0f; int center = space_X * space_Y * space_Z / 2; int step_z = 1, step_y = space_Z, step_x = space_Z * space_Y; int coeff = step_z * space_Z + step_y * space_Y + step_x * space_X; + int u = 0, v = 0, delta = - 400; // - space_Y * space_Z * 4 - 5; + for (int i = 0; i < space_X; i++) for (int j = 0; j < space_Y; j++) for (int k = 0; k < space_Z; k++){ rayon = radius(i, j, k, space_X, space_Y, space_Z); - if (rayon < limit_sup && rayon > limit_inf){ - int u = (i - space_X / 2) * step_x + (j - space_Y / 2) * step_y + (k - space_Z / 2) * step_z, - delta = - 49 * 4 - 2; - u = i * step_x + j * step_y + k * step_z; - if (1) printf("%d * %d * %d rayon = %4.2f i,j,k = %2d,%2d,%2d coeff = %d center = %d u = %d delta = %d\n",\ - space_X, space_Y, space_Z, rayon, space_X / 2 - i, space_Y / 2 - j, space_Z / 2 - k, coeff, center, u, delta); - draw_a_central_star(lines_origin, coeff + center + u * 6 + delta); - // + cubes_nb * 6 / 2 - 2 - nb_in_neighborhood ++; + if (rayon < limit_sup && rayon >= limit_inf){ + +u = (i - space_X / 2) * step_x + (j - space_Y / 2) * step_y + (k - space_Z / 2) * step_z; +v = i * step_x + j * step_y + k * step_z; + +if (1) printf("i,j,k =%2d,%2d,%2d v = %d u = %d\n", space_X / 2 - i, space_Y / 2 - j, space_Z / 2 - k, v, u); + + draw_a_central_star(lines_origin, // + cubes_nb * 6 / 2 - 2 + coeff + + center + + v * 6 + + delta); + } } - if (0) printf("buffers g: with limits sup = %3.1f, inf = %3.1f, %d/%d neighboors, ", limit_sup, limit_inf, nb_in_neighborhood, coeff * 2 + 1); - return 0; +if (1) printf("\n%d*%d*%d = %d (b-a)/18 = %d r=%4.2f coeff = %d center = %d delta = %d\n",\ +space_X, space_Y, space_Z, center * 2, (b-a)/18, rayon, coeff, center, delta); + } // I'm standing on Earth (any planet or star or spinning spheroid, in fact) @@ -521,6 +487,8 @@ bool compute_space(int space_X, int space_Y, int space_Z, GLuint *arrows, int model_arrows_nb, int pref_show_grid, int pref_central_stars_nb, int pref_test_diagonal, + int buffer_vertex_size_after_grids, + int buffer_vertex_size_after_stars, GLfloat *vertex_origin, GLfloat *colors_origin, GLuint *lines_origin, GLuint *plans_origin) { @@ -539,8 +507,8 @@ bool compute_space(int space_X, int space_Y, int space_Z, if (0 && pref_central_stars_nb == 1) draw_a_central_star (lines_origin, coeff + cubes_nb * 3 - 3); if (pref_central_stars_nb == cubes_nb) for (int i = 0; i < space_X * space_Y * space_Z; i ++) draw_a_central_star (lines_origin, coeff + i * 6); - if (1) ad_hoc = experimental_1(lines_origin, space_X, space_Y, space_Z); - if (1) draw_a_central_central_star (lines_origin, coeff, cubes_nb * 6 / 2 - 2); + if (1) experimental_1(lines_origin, space_X, space_Y, space_Z, buffer_vertex_size_after_grids, buffer_vertex_size_after_stars); + if (0) draw_a_central_central_star (lines_origin, coeff, cubes_nb * 6 / 2 - 2); if (0) draw_EW_ZA_SN_in_a_cubic_space (lines_origin, coeff, space_X, space_Y, space_Z); if (0) draw_3_x_4_around_6_poles (lines_origin, coeff, side_size); @@ -666,3 +634,45 @@ bool compute_space(int space_X, int space_Y, int space_Z, +// (1,2,2) (2,1,2) (2,2,1) (2,2,2) (2,2,3) (2,3,2) (3,2,2) + +/* #define D 0 */ +/* static int experimental_1_verbose(GLuint *lines_origin, */ +/* int space_X, int space_Y, int space_Z, int step_x, int step_y) */ +/* { */ +/* float r = 0.0f, limit = 1.0f; */ +/* int nb_in_neighborhood = 0, step_z = 1; */ +/* int s = space_X * space_Y * space_Z / 2; */ + +/* printf("buffers : with limit = %3.1f, %d/%d neighboors, ",\ */ +/* limit, nb_in_neighborhood, s * 2 + 1); */ + +/* // int z = space_Z; */ +/* // int y = z * space_Z; */ +/* // int x = y * space_Y; */ +/* for (int i = 0; i < space_X; i++){ */ +/* for (int j = 0; j < space_Y; j++){ */ +/* if (D && (i == 0 || i == space_X - 1)) printf(" "); */ +/* for (int k = 0; k < space_Z; k++){ */ +/* if (D && (k == 0 && j == space_X - 1)) printf(" "); */ +/* r = radius(i, j, k, space_X, space_Y, space_Z); */ +/* if (r < limit){ // 2.5f */ +/* if (D) printf("%6.3f (%d,%d,%d) ", r, i, j, k); */ +/* return draw_a_central_star(lines_origin, */ +/* s + ((i + 0) * step_x */ +/* + (j + 0) * step_y */ +/* + (k + 0) * step_z) * 6 */ +/* + 10 ); */ + // printf("buffers : (444) n = %d i * step_x + j * step_y + k = %d 125 / 2 = %d\n", + // s + (i * step_x + j * step_y + k) * 6 + 10, i * step_x + j * step_y + k, 125/2); + // nb_in_neighborhood ++; //printf("r = %f (%d,%d,%d)\n", r, i, j ,k); +/* } */ +/* } */ +/* if (D) printf("\n"); */ +/* } */ +/* if (D) printf("\n "); */ +/* } */ +/* return 0; */ +/* } */ + + diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index cd7286d..9b9ca3c 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -63,6 +63,8 @@ int pref_central_stars_nb = 0; // diagonal test int pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc. // xyz, 0, x, y, z, xy, xz, yz, xyz (repeat) int buffer_vertex_size = 0; +int buffer_vertex_size_after_grids = 0; +int buffer_vertex_size_after_stars = 0; int buffer_colors_size = 0; int buffer_lines_size = 0; // previously in graphics.h struct gl_area_entry.GLuint line_indices_nb; int buffer_plans_size = 0; // previously in graphics.h struct gl_area_entry.GLuint plan_indices_nb; @@ -550,9 +552,9 @@ GLuint arrows[] = { static void get_model_data_and_user_preferences(){ - space_X = 7; // 0 < space_X assert TODO - space_Y = 7; // 0 < space_Y assert TODO - space_Z = 15; // 0 < space_Z assert TODO + space_X = 11; // 0 < space_X assert TODO + space_Y = 11; // 0 < space_Y assert TODO + space_Z = 11; // 0 < space_Z assert TODO cubes_nb = space_X * space_Y * space_Z; pref_show_grid = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc. // xyz, 0, x, y, z, xy, xz, yz, xyz (repeat) @@ -564,8 +566,7 @@ static void get_model_data_and_user_preferences(){ // >>> assert TODO pref_central_stars_nb = cubes_nb; // cubes_nb = max = space_X * space_Y * space_Z pref_central_stars_nb = 1 + 6 + 24 + 6 + 6 + 24 + 70; -// pref_central_stars_nb = 1 + 6; - pref_central_stars_nb = 160; + pref_central_stars_nb = 1 + 6; pref_test_diagonal = 0; } @@ -646,8 +647,10 @@ static void compute_buffers_sizes(int space_X, int space_Y, int space_Z, if (grids_intersections_surface < grids_intersections_volume) // pas toujours le cas ! buffer_vertex_size = grids_intersections_volume * 3; else buffer_vertex_size = grids_intersections_surface * 3; + buffer_vertex_size_after_grids = buffer_vertex_size; if (0) printf("draw_grids_3D_surface buffer_vertex_size = %d\n", buffer_vertex_size); buffer_vertex_size += central_stars * 3; + buffer_vertex_size_after_stars = buffer_vertex_size; if (arrows_nb > 0) buffer_vertex_size += centers * 3; // 3 numbers per vertex buffer_colors_size = buffer_vertex_size; buffer_plans_size = 0; @@ -721,6 +724,9 @@ void graphics_init_buffers(const void *gl_area) pref_central_stars_nb, pref_test_diagonal, + buffer_vertex_size_after_grids, + buffer_vertex_size_after_stars, + buffer_vertex_origin, buffer_colors_origin, buffer_lines_origin, diff --git a/à résoudre b/à résoudre index 65c4954..e7a6d3c 100644 --- a/à résoudre +++ b/à résoudre @@ -49,3 +49,39 @@ space_X * space_Y * space_Z * 6 / 2 5 * 5 * 5 rayon = 1,41 i,j,k = -1,-1, 0 coeff = 155 center = 62 u = 92 delta = -1 ----------------------------------------------------------------------------------------------- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +d8065ec 2023-08-20 14:31 +0200 Jean Sirmai o WIP: une approche par step_x, _y, _z <> commit avant de repartir +d8065ecf5f73276276353a60786ba4ae3e40c61f - commit 5 of 202 +