WIP: marche pas, mais je sais pourquoi
This commit is contained in:
parent
7ca5eb9f03
commit
e9d5dda889
|
@ -36,6 +36,7 @@ bool compute_space_and_arrows(long model_space_size_x,
|
|||
int pref_mark_unit_space,
|
||||
int pref_style_lines_planes,
|
||||
int pref_style_mix_colors,
|
||||
int pref_show_grid,
|
||||
|
||||
GLfloat *vertex_origin,
|
||||
GLfloat *color_origin,
|
||||
|
|
|
@ -278,6 +278,7 @@ static bool compute_space_3D (long x,
|
|||
int pref_mark_unit_space,
|
||||
int pref_style_lines_planes,
|
||||
int pref_style_mix_colors,
|
||||
int pref_show_grid,
|
||||
|
||||
GLfloat *vertex_origin,
|
||||
GLfloat *colors_origin,
|
||||
|
@ -326,30 +327,35 @@ static bool compute_space_3D (long x,
|
|||
if (P) printf("[%ldx%ld=%ld]+[%ldx%ld=%ld]+[%ldx%ld=%ld] = %ld lines [%ldx%ldx%ld] = %ld vertices step_x = %ld step_y = %ld step_z = %ld ",\
|
||||
x,y,x*y, x,z,x*z, y,z,y*z, x*y + x*z + y*z, x,y,z, x*y*z, step_x, step_y, step_z);
|
||||
|
||||
/* for (int u = 0; u < z; u ++){ */
|
||||
/* for (int w = 0; w < x; w ++){ */
|
||||
/* calcul = step_x * w + step_z * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size ++; */
|
||||
/* } */
|
||||
/* } */
|
||||
float calcul = 0;
|
||||
|
||||
/* for (int u = 0; u < y; u ++){ */
|
||||
/* for (int w = 0; w < x; w ++){ */
|
||||
/* calcul = step_x * w + step_y * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_y - step_z; lines_buffer_size ++; */
|
||||
/* // printf("(%ld>%ld) ", calcul, calcul + step_y - 1); */
|
||||
/* } */
|
||||
/* } */
|
||||
if (! (pref_show_grid % 2))
|
||||
for (int u = 0; u < y; u ++){
|
||||
for (int w = 0; w < x; w ++){
|
||||
calcul = step_x * w + step_y * u;
|
||||
*(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = calcul + step_y - step_z; lines_buffer_size ++;
|
||||
// printf("(%ld>%ld) ", calcul, calcul + step_y - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/* for (int u = 0; u < z; u ++){ */
|
||||
/* for (int w = 0; w < y; w ++){ */
|
||||
/* calcul = step_y * w + step_y * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_x * (x - 1); lines_buffer_size ++; */
|
||||
/* } */
|
||||
/* } */
|
||||
if (! (pref_show_grid % 3))
|
||||
for (int u = 0; u < z; u ++){
|
||||
for (int w = 0; w < x; w ++){
|
||||
calcul = step_x * w + step_z * u;
|
||||
*(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size ++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! (pref_show_grid % 5))
|
||||
for (int u = 0; u < z; u ++){
|
||||
for (int w = 0; w < y; w ++){
|
||||
calcul = step_y * w + step_y * u;
|
||||
*(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = calcul + step_x * (x - 1); lines_buffer_size ++;
|
||||
}
|
||||
}
|
||||
|
||||
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 0; lines_buffer_size ++; */
|
||||
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 2; lines_buffer_size ++; */
|
||||
|
@ -471,7 +477,7 @@ static bool compute_space_3D (long x,
|
|||
|
||||
|
||||
|
||||
#define ARR 0
|
||||
#define ARR 1
|
||||
|
||||
static void draw_an_arrow_3D_at(long load, long site, long x, long y, long z,
|
||||
long maximum,
|
||||
|
@ -524,8 +530,13 @@ static void draw_an_arrow_3D_at(long load, long site, long x, long y, long z,
|
|||
if (V) printf(" => vertex_buffer_size = %3ld arrow_3D\n", vertex_buffer_size);
|
||||
|
||||
|
||||
*(lines_origin + lines_buffer_size + 0) = vertex_buffer_size - 9;
|
||||
*(lines_origin + lines_buffer_size + 1) = vertex_buffer_size + 210;
|
||||
long step_z = 1, step_y = z + 1, step_x = (y + 1) * (z + 1);
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
|
||||
|
||||
/* *(lines_origin + lines_buffer_size + 0) = vertex_buffer_size - 0; */
|
||||
/* *(lines_origin + lines_buffer_size + 1) = vertex_buffer_size + 56; */
|
||||
|
||||
/* *(lines_origin + lines_buffer_size + 0) = vertex_buffer_size / 3 - 5; */
|
||||
/* *(lines_origin + lines_buffer_size + 1) = vertex_buffer_size / 3 - 4; */
|
||||
|
@ -662,11 +673,11 @@ static void draw_a_cube_at(long u, long v, long w,
|
|||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
|
||||
|
||||
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
|
||||
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -839,6 +850,7 @@ bool compute_space_and_arrows(long model_size_x,
|
|||
int pref_mark_unit_space,
|
||||
int pref_style_lines_planes,
|
||||
int pref_style_mix_colors,
|
||||
int pref_show_grid,
|
||||
|
||||
GLfloat *vertex_origin,
|
||||
GLfloat *colors_origin,
|
||||
|
@ -864,18 +876,31 @@ bool compute_space_and_arrows(long model_size_x,
|
|||
pref_mark_unit_space,
|
||||
pref_style_lines_planes,
|
||||
pref_style_mix_colors,
|
||||
pref_show_grid,
|
||||
|
||||
vertex_origin,
|
||||
colors_origin,
|
||||
lines_origin,
|
||||
plans_origin);
|
||||
|
||||
for (long i = 0; i < model_size_x; i++)
|
||||
for (long j = 0; j < model_size_y; j++)
|
||||
for (long k = 0; k < model_size_z; k++)
|
||||
if ((i + j + k) % 2 == 0) draw_a_cube_at (i, j, k, lines_origin,
|
||||
/* for (long i = 0; i < model_size_x; i++) */
|
||||
/* for (long j = 0; j < model_size_y; j++) */
|
||||
/* for (long k = 0; k < model_size_z; k++) */
|
||||
/* if ((i + j + k) % 2 == 0) */
|
||||
/* draw_a_cube_at ( */
|
||||
/* i, j, k, lines_origin, */
|
||||
/* model_size_x + 1, model_size_y + 1, model_size_z + 1, */
|
||||
/* pref_mark_unit_space); // shows the diagonals of each small cube */
|
||||
|
||||
draw_a_cube_at (
|
||||
1, 1, 1, lines_origin,
|
||||
model_size_x + 1, model_size_y + 1, model_size_z + 1,
|
||||
0); // < set to 1 (TRUE) to see the diagonals
|
||||
0); // shows the diagonals of each small cube
|
||||
|
||||
draw_a_cube_at (
|
||||
model_size_x - 2, model_size_y - 2, model_size_z - 2, lines_origin,
|
||||
model_size_x + 1, model_size_y + 1, model_size_z + 1,
|
||||
0); // shows the diagonals of each small cube
|
||||
|
||||
long maximum = fmax(model_size_x, model_size_y);
|
||||
maximum = fmax(maximum, model_size_z);
|
||||
|
@ -913,3 +938,103 @@ bool compute_space_and_arrows(long model_size_x,
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// REMEMBER (another way to draw space)
|
||||
|
||||
/* for (int u = 0; u < z; u ++){ */
|
||||
/* for (int w = 0; w < y; w ++){ */
|
||||
/* calcul = step_y * w + step_z * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_z - step_x; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
/* for (int u = 0; u < z; u ++){ */
|
||||
/* for (int w = 0; w < y; w ++){ */
|
||||
/* calcul = step_y * w + step_z * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + z * step_x; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* for (int u = 0; u < y; u ++){ */
|
||||
/* for (int w = 0; w < x; w ++){ */
|
||||
/* calcul = step_x * w + step_y * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_y - step_z; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* for (int u = 0; u < x; u ++){ */
|
||||
/* for (int w = 0; w < z; w ++){ */
|
||||
/* calcul = step_z * w + step_x * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
/* for (int u = 0; u < y; u ++){ */
|
||||
/* for (int w = 0; w < z; w ++){ */
|
||||
/* *(lines_origin + lines_buffer_size) = w + z * u; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = x * y * z - y * z + w + z * u; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ GLuint *buffer_plans_origin = NULL;
|
|||
int pref_mark_unit_space = 0; // default == 0 == no marks
|
||||
int pref_style_lines_planes = 0; // arrows as lines = 0, as planes = 1
|
||||
int pref_style_mix_colors = 0; // ... don't know yet ...
|
||||
int pref_show_grid = 0; // 0, 2, 3, 5, 6, 10, 15, 30
|
||||
|
||||
int buffer_vertex_size = 0;
|
||||
int buffer_colors_size = 0;
|
||||
|
@ -511,58 +512,45 @@ bool graphics_init_shaders(const void *gl_area)
|
|||
|
||||
|
||||
|
||||
// REMEMBER (It worked almost fine)
|
||||
|
||||
/* for (int u = 0; u < z; u ++){ */
|
||||
/* for (int w = 0; w < y; w ++){ */
|
||||
/* calcul = step_y * w + step_z * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_z - step_x; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
/* for (int u = 0; u < z; u ++){ */
|
||||
/* for (int w = 0; w < y; w ++){ */
|
||||
/* calcul = step_y * w + step_z * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + z * step_x; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* for (int u = 0; u < y; u ++){ */
|
||||
/* for (int w = 0; w < x; w ++){ */
|
||||
/* calcul = step_x * w + step_y * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_y - step_z; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* for (int u = 0; u < x; u ++){ */
|
||||
/* for (int w = 0; w < z; w ++){ */
|
||||
/* calcul = step_z * w + step_x * u; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
/* for (int u = 0; u < y; u ++){ */
|
||||
/* for (int w = 0; w < z; w ++){ */
|
||||
/* *(lines_origin + lines_buffer_size) = w + z * u; lines_buffer_size += 1; */
|
||||
/* *(lines_origin + lines_buffer_size) = x * y * z - y * z + w + z * u; lines_buffer_size += 1; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GLuint arrows[] = {
|
||||
1, 0, 0, 0, 0,
|
||||
1, 1, 0, 0, 0,
|
||||
1, 0, 1, 0, 0,
|
||||
1, 1, 1, 0, 0,
|
||||
1, 0, 2, 0, 0,
|
||||
1, 1, 2, 0, 0,
|
||||
1, 0, 3, 0, 0,
|
||||
|
@ -575,12 +563,12 @@ GLuint arrows[] = {
|
|||
|
||||
static void get_model_data_and_user_preferences(){
|
||||
|
||||
model_space_size_x = 5; // 0 < model_space_size_x
|
||||
model_space_size_y = 4; // 0 < model_space_size_y
|
||||
model_space_size_z = 3; // 0 < model_space_size_z
|
||||
model_space_size_x = 4; // 0 < model_space_size_x
|
||||
model_space_size_y = 6; // 0 < model_space_size_y
|
||||
model_space_size_z = 5; // 0 < model_space_size_z
|
||||
|
||||
// XXX ONLY space drawed, no arrows
|
||||
model_arrows_nb = 8; // assert : l'emplacement des flèches est contraint
|
||||
model_arrows_nb = 0; // assert : l'emplacement des flèches est contraint
|
||||
// par model_space_size_x, y, z et le nombre de sites
|
||||
|
||||
// pref_1D_shown_as_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D
|
||||
|
@ -588,6 +576,8 @@ static void get_model_data_and_user_preferences(){
|
|||
pref_mark_unit_space = 0; // 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
|
||||
pref_show_grid = 5; // 0, 2, 3, 5, 6, 10, 15, 30
|
||||
// 0, x, y, z, xy, xz, yz, xyz
|
||||
}
|
||||
|
||||
|
||||
|
@ -642,13 +632,36 @@ static void compute_buffers_sizes(int model_space_size_x,
|
|||
/* + ((model_space_size_y + 1) * (model_space_size_z + 1)); */
|
||||
|
||||
// XXX drawing unit cubes plus space limits (ridges)
|
||||
buffer_lines_size = (model_space_size_x)
|
||||
* (model_space_size_y)
|
||||
* (model_space_size_z)
|
||||
* 12 // les petits cubes dans l'espace
|
||||
long small_cubes_nb = 0;
|
||||
for (long i = 0; i < model_space_size_x; i++)
|
||||
for (long j = 0; j < model_space_size_y; j++)
|
||||
for (long k = 0; k < model_space_size_z; k++)
|
||||
if ((i + j + k) % 2 == 0) small_cubes_nb ++;
|
||||
small_cubes_nb = small_cubes_nb * 2;
|
||||
|
||||
small_cubes_nb = 2;
|
||||
|
||||
buffer_lines_size = small_cubes_nb * 24 // small cubes in space
|
||||
+ 24 // les arêtes de l'espace
|
||||
+ 12
|
||||
+ model_arrows_nb * 16;
|
||||
+ (! (pref_show_grid % 2))
|
||||
* (model_space_size_x + 1)
|
||||
* (model_space_size_y + 1)
|
||||
* 2
|
||||
+ (! (pref_show_grid % 3))
|
||||
* (model_space_size_x + 1)
|
||||
* (model_space_size_z + 1)
|
||||
* 2
|
||||
+ (! (pref_show_grid % 5))
|
||||
* (model_space_size_y + 1)
|
||||
* (model_space_size_z + 1)
|
||||
* 2
|
||||
// + (model_space_size_x + 1) * (model_space_size_z + 1) * 2
|
||||
// + (model_space_size_x + 1) * (model_space_size_z + 1) * 2
|
||||
+ model_arrows_nb * 16
|
||||
;//+ 0; // expérimental
|
||||
|
||||
if (pref_mark_unit_space)
|
||||
buffer_lines_size += small_cubes_nb * 8; // small cubes diagonals (if...)
|
||||
|
||||
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",
|
||||
|
@ -660,6 +673,27 @@ static void compute_buffers_sizes(int model_space_size_x,
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Initializes the buffer of a gl_area
|
||||
* Calls according to the user preferences
|
||||
* @param gl_area, ptr to the gl_area widget
|
||||
|
@ -700,6 +734,7 @@ void graphics_init_buffers(const void *gl_area)
|
|||
pref_mark_unit_space,
|
||||
pref_style_lines_planes,
|
||||
pref_style_mix_colors,
|
||||
pref_show_grid,
|
||||
|
||||
buffer_vertex_origin,
|
||||
buffer_colors_origin,
|
||||
|
|
Loading…
Reference in New Issue