REF: Any X, Y, Z space size. Grids +/- volume vertex. Central stars +/- OK+
This commit is contained in:
parent
46a9884c63
commit
d05bde8f7c
|
@ -26,9 +26,7 @@
|
|||
#include <stdbool.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
bool compute_space(int cube_side,
|
||||
// long model_space_size_y,
|
||||
// long model_space_size_z,
|
||||
bool compute_space(int space_X, int space_Y, int space_Z,
|
||||
|
||||
GLuint *arrows,
|
||||
int model_arrows_nb,
|
||||
|
|
|
@ -426,39 +426,33 @@ static void draw_a_central_star_in_a_cubic_space(GLuint *lines_origin, int n, in
|
|||
bool draw_some_arrows (GLuint *lines_origin, int s, int stx, int sty,
|
||||
GLuint *arrows, int arrows_nb) {return 1;}
|
||||
|
||||
bool compute_space(int cube_side,
|
||||
bool compute_space(int space_X, int space_Y, int space_Z,
|
||||
GLuint *arrows, int model_arrows_nb,
|
||||
int pref_show_grid,
|
||||
int pref_test_diagonal,
|
||||
GLfloat *vertex_origin, GLfloat *colors_origin,
|
||||
GLuint *lines_origin, GLuint *plans_origin)
|
||||
|
||||
{
|
||||
grids_intersections_volume (cube_side, cube_side, cube_side, vertex_origin, colors_origin);
|
||||
central_stars (cube_side, cube_side, cube_side, vertex_origin, colors_origin);
|
||||
centers (cube_side, cube_side, cube_side, vertex_origin, colors_origin);
|
||||
|
||||
int step_z = 1, step_y = cube_side + 1, step_x = (cube_side + 1) * (cube_side + 1);
|
||||
|
||||
if (pref_show_grid > 0) draw_ridges_3D (cube_side, cube_side, cube_side, step_x, step_y, step_z, lines_origin);
|
||||
draw_grids_3D(cube_side, cube_side, cube_side, step_x, step_y, step_z, lines_origin, pref_show_grid);
|
||||
int s = step_z * cube_side + step_y * cube_side + step_x * cube_side + 1;
|
||||
int side_size = cube_side; /* IT IS A CUBE ! space_x = space_y = space_z */
|
||||
draw_a_central_star_in_a_cubic_space (lines_origin, s, side_size);
|
||||
draw_EW_ZA_SN_in_a_cubic_space (lines_origin, s, side_size);
|
||||
draw_3_x_4_around_6_poles (lines_origin, s, side_size);
|
||||
|
||||
if (0) for (int i = 0; i < side_size * side_size * side_size; i ++)
|
||||
grids_intersections_volume (space_X, space_Y, space_Z, vertex_origin, colors_origin);
|
||||
central_stars (space_X, space_Y, space_Z, vertex_origin, colors_origin);
|
||||
centers (space_X, space_Y, space_Z, vertex_origin, colors_origin);
|
||||
int step_z = 1, step_y = space_Z + 1, step_x = (space_Z + 1) * (space_Y + 1);
|
||||
if (pref_show_grid > 0) draw_ridges_3D (space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin);
|
||||
draw_grids_3D(space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin, pref_show_grid);
|
||||
int s = step_z * space_Z + step_y * space_Y + step_x * space_X + 1;
|
||||
if (1) for (int i = 0; i < space_X * space_Y * space_Z; i ++)
|
||||
draw_a_central_star (lines_origin, s + i * 6);
|
||||
|
||||
int CUBE = 0, side_size = 0;
|
||||
if ((space_X == space_Y) && (space_X == space_Z)) CUBE = 1;
|
||||
if (CUBE) side_size = space_X; /* IF IT IS A CUBE, space_x = space_y = space_z */
|
||||
if (CUBE) draw_a_central_star_in_a_cubic_space (lines_origin, s, side_size);
|
||||
if (CUBE) draw_EW_ZA_SN_in_a_cubic_space (lines_origin, s, side_size);
|
||||
if (CUBE) draw_3_x_4_around_6_poles (lines_origin, s, side_size);
|
||||
printf("side = %d step_x = %d step_y = %d step_z = %d\n",\
|
||||
cube_side, (cube_side + 1) * (cube_side + 1), cube_side + 1, 1);
|
||||
|
||||
if (pref_test_diagonal) diagonal_test (cube_side, cube_side, cube_side, step_x, step_y, step_z, lines_origin);
|
||||
|
||||
space_X, (space_Z + 1) * (space_Y + 1), space_Z + 1, 1);
|
||||
if (pref_test_diagonal) diagonal_test (space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin);
|
||||
printf(" Prochain objectif : dessiner les croix E, W, N, S, Z A puis EN, ES, etc.\n\
|
||||
Puis dessiner toutes les croix limitant un voisinage de Moore 3D sphérique.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
|
||||
/* ----------------- V A R I A B L E S G L O B A L E S ------------------ */
|
||||
|
||||
// int model_dim; < INUTILE : dim est fonction de cube_side, y ,z) */
|
||||
int cube_side = 0;
|
||||
// int model_dim; < INUTILE : dim est fonction de space_X, Y ,Z) */
|
||||
int space_X = 0, space_Y = 0, space_Z = 0;
|
||||
int arrows_nb = 0;
|
||||
int nb_of_central_stars_to_draw = 0;
|
||||
|
||||
|
@ -555,7 +555,9 @@ GLuint arrows[] = {
|
|||
|
||||
static void get_model_data_and_user_preferences(){
|
||||
|
||||
cube_side = 7; // 0 < cube_side assert TODO
|
||||
space_X = 5; // 0 < space_X assert TODO
|
||||
space_Y = 4; // 0 < space_Y assert TODO
|
||||
space_Z = 3; // 0 < space_Z assert TODO
|
||||
pref_grid_anchors_on_faces_only = 0; // 0 = on faces only
|
||||
pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc.
|
||||
// xyz, 0, x, y, z, xy, xz, yz, xyz (repeat)
|
||||
|
@ -565,8 +567,9 @@ static void get_model_data_and_user_preferences(){
|
|||
arrows_nb = arrows_array_size / 5; // L'emplacement des flèches est contraint
|
||||
// par space_size_x, y, z et le nombre de sites
|
||||
// >>> assert TODO
|
||||
nb_of_central_stars_to_draw = 1 + 6 + 24; // max = cube_side * cube_side * cube_side
|
||||
pref_test_diagonal = 0;
|
||||
nb_of_central_stars_to_draw = 0; // 1 + 6 + 24; // max = space_X * space_Y * space_Z
|
||||
nb_of_central_stars_to_draw = space_X * space_Y * space_Z;
|
||||
pref_test_diagonal = 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -574,29 +577,35 @@ static void get_model_data_and_user_preferences(){
|
|||
|
||||
|
||||
|
||||
static void compute_buffers_sizes(int cube_side,
|
||||
static void compute_buffers_sizes(int space_X, int space_Y, int space_Z,
|
||||
int pref_test_diagonal)
|
||||
{
|
||||
// XXX ONLY space and no arrows
|
||||
int grids_intersections_volume = (cube_side + 1)
|
||||
* (cube_side + 1)
|
||||
* (cube_side + 1);
|
||||
int grids_intersections_surface = (cube_side + 1)
|
||||
* (cube_side + 1)
|
||||
* 6; // minus ridges and corners ? (cube_side + 1) * 12 + 8
|
||||
int grids_intersections_volume = (space_X + 1)
|
||||
* (space_Y + 1)
|
||||
* (space_Z + 1);
|
||||
int grids_intersections_surface = (space_X + 1)
|
||||
* (space_X + 1)
|
||||
* 6; // minus ridges and corners ? In cubes, (side + 1) * 12 + 8
|
||||
// (or do repeat to make it simpler ? <> the algorithm is the same ! )
|
||||
// The benefit appears only for cube sides sizes larger than 5
|
||||
// 4 faces <> 450 vertex volume <> 375 vertex
|
||||
// 5 ----- <> 648 ------ ------ <> 648 ------
|
||||
// 6 ----- <> 882 ------ ------ <> 1029 ------
|
||||
// 60 ----- <> 66978 ------ ------ <> 680943 ------ (x 10)
|
||||
int central_stars = (cube_side)
|
||||
* (cube_side)
|
||||
* (cube_side)
|
||||
// WARNING 1D spaces or when a face has small dimensions (< 5)
|
||||
// ex : x = 40, y = 1, z = 1 >>> 492 (volume) vs. 30258 (surface) !!!
|
||||
// ex : x = 40, y = 4, z = 4 >>> 3075 (volume) vs. 30258 (surface) !!!
|
||||
// ex : x = 40, y = 5, z = 5 >>> 30258 (volume) vs. 30258 (surface) !!!
|
||||
// ex : x = 40, y = 6, z = 6 >>> 6027 (volume) vs. 30258 (surface) !!!
|
||||
// ex : x = 40, y = 7, z = 7 >>> 7872 (volume) vs. 30258 (surface) !!!
|
||||
int central_stars = (space_X)
|
||||
* (space_Y)
|
||||
* (space_Z)
|
||||
* 6; // 6 is to draw the small central star
|
||||
int centers = (cube_side)
|
||||
* (cube_side)
|
||||
* (cube_side)
|
||||
int centers = (space_X)
|
||||
* (space_Y)
|
||||
* (space_Z)
|
||||
* 2; // and 2 is to draw two centers for each cube
|
||||
// one will be for the arrows sources (blue ?)
|
||||
// and the other, for their targets (red ?)
|
||||
|
@ -612,9 +621,9 @@ static void compute_buffers_sizes(int cube_side,
|
|||
buffer_plans_size = 0;
|
||||
|
||||
int grids_lines =
|
||||
(pref_show_grid % 2 == 0) * (cube_side + 1) * (cube_side + 1)
|
||||
+ (pref_show_grid % 3 == 0) * (cube_side + 1) * (cube_side + 1)
|
||||
+ (pref_show_grid % 5 == 0) * (cube_side + 1) * (cube_side + 1);
|
||||
(pref_show_grid % 2 == 0) * (space_X + 1) * (space_Y + 1)
|
||||
+ (pref_show_grid % 3 == 0) * (space_X + 1) * (space_Z + 1)
|
||||
+ (pref_show_grid % 5 == 0) * (space_Y + 1) * (space_Z + 1);
|
||||
|
||||
if (pref_show_grid != 1) buffer_lines_size = grids_lines * 2;
|
||||
if (pref_show_grid > 0) buffer_lines_size += 12 * 2; // space ridges
|
||||
|
@ -624,7 +633,7 @@ static void compute_buffers_sizes(int cube_side,
|
|||
|
||||
buffer_lines_size += 6 * nb_of_central_stars_to_draw; // test central stars
|
||||
|
||||
// buffer_lines_size -= 2; // == TEST LINES BUFFER SIZE
|
||||
// buffer_lines_size -= 2; // == TESTS LINES BUFFER SIZE ON THE DIAGONAL
|
||||
|
||||
if (0) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",
|
||||
|
@ -665,14 +674,14 @@ void graphics_init_buffers(const void *gl_area)
|
|||
get_model_data_and_user_preferences();
|
||||
/* une struct en retour pour ne plus utiliser de variables globales ? */
|
||||
|
||||
compute_buffers_sizes (cube_side, pref_test_diagonal);
|
||||
compute_buffers_sizes (space_X, space_Y, space_Z, pref_test_diagonal);
|
||||
|
||||
buffer_vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
||||
buffer_colors_origin = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
||||
buffer_lines_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLuint) * 2);
|
||||
buffer_plans_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLuint) * 2);
|
||||
|
||||
compute_space (cube_side,
|
||||
compute_space (space_X, space_Y, space_Z,
|
||||
|
||||
arrows,
|
||||
arrows_nb,
|
||||
|
@ -686,13 +695,13 @@ void graphics_init_buffers(const void *gl_area)
|
|||
buffer_plans_origin);
|
||||
|
||||
int step_z = 1,
|
||||
step_y = cube_side + 1,
|
||||
step_x = (cube_side + 1) * (cube_side + 1);
|
||||
int s = step_z * cube_side + step_y * cube_side
|
||||
+ step_x * cube_side;
|
||||
step_y = space_Z + 1,
|
||||
step_x = (space_Y + 1) * (space_Z + 1);
|
||||
int s = step_z * space_Z + step_y * space_Y
|
||||
+ step_x * space_X;
|
||||
|
||||
draw_some_arrows (buffer_lines_origin, s,
|
||||
cube_side * cube_side, cube_side,
|
||||
space_X * space_Y, space_Z,
|
||||
arrows, arrows_nb);
|
||||
|
||||
GLuint vao, vertex_buffer, color_buffer;
|
||||
|
|
Loading…
Reference in New Issue