WIP: J'aimerais bien que ce soit WIP ! Mais ça stagne ! Enfin... le problème est posé. C'est déjà ça.
This commit is contained in:
parent
36baf07117
commit
f932ed040b
|
@ -491,7 +491,6 @@ static bool draw_ridges_3D (long x, long y, long z,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool grids_intersections (long x, long y, long z,
|
static bool grids_intersections (long x, long y, long z,
|
||||||
int pref_style_mix_colors,
|
|
||||||
GLfloat *vertex_origin,
|
GLfloat *vertex_origin,
|
||||||
GLfloat *colors_origin)
|
GLfloat *colors_origin)
|
||||||
{
|
{
|
||||||
|
@ -523,15 +522,6 @@ static bool grids_intersections (long x, long y, long z,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool diagonal_test(long x, long y, long z, GLuint *lines_origin)
|
|
||||||
{
|
|
||||||
long step_z = 1, step_y = z, step_x = y * z;
|
|
||||||
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++;
|
|
||||||
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_index ++;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static bool draw_grids_3D (long x, long y, long z,
|
static bool draw_grids_3D (long x, long y, long z,
|
||||||
|
@ -575,6 +565,17 @@ static bool draw_grids_3D (long x, long y, long z,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static bool diagonal_test(long x, long y, long z,
|
||||||
|
long step_x, long step_y, long step_z,
|
||||||
|
GLuint *lines_origin)
|
||||||
|
{
|
||||||
|
// Je la déplace un peu pour chercher l'autre ligne ...
|
||||||
|
*(lines_origin + lines_index) = step_z * 1 + step_y * 0 + step_x * 1; lines_index ++;
|
||||||
|
*(lines_origin + lines_index) = step_z * (z - 2) + step_y * (y - 2) + step_x * (x - 1); lines_index ++;
|
||||||
|
// *(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++;
|
||||||
|
// *(lines_origin + lines_index) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_index ++;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -618,6 +619,84 @@ static bool draw_grids_3D (long x, long y, long z,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static bool arrows_anchors (long x, long y, long z,
|
||||||
|
long step_x, long step_y, long step_z,
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *colors_origin,
|
||||||
|
GLfloat *lines_origin)
|
||||||
|
{
|
||||||
|
|
||||||
|
float i, j, k, vx, vy, vz, max = fmax(x, y);
|
||||||
|
max = fmax(max, z) + 1;
|
||||||
|
|
||||||
|
for (i = 0; i < x; i++)
|
||||||
|
for (j = 0; j < y; j++)
|
||||||
|
for (k = 0; k < z; k++){
|
||||||
|
|
||||||
|
vx = (2 * i / (x - 1) - 1) * x / max + x / 2 * max;
|
||||||
|
vy = (2 * j / (y - 1) - 1) * y / max + y / 2 * max;
|
||||||
|
vz = (2 * k / (z - 1) - 1) * z / max + z / 2 * max;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 0) = vx;
|
||||||
|
*(vertex_origin + vertex_index + 1) = vy;
|
||||||
|
*(vertex_origin + vertex_index + 2) = vz;
|
||||||
|
|
||||||
|
vertex_index += 3;
|
||||||
|
|
||||||
|
*(colors_origin + colors_index + 0) = 1.0f;
|
||||||
|
*(colors_origin + colors_index + 1) = 0.2f;
|
||||||
|
*(colors_origin + colors_index + 2) = 0.0f;
|
||||||
|
|
||||||
|
colors_index += 3;
|
||||||
|
};
|
||||||
|
|
||||||
|
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++;
|
||||||
|
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_index ++;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool a_simple_test (long x, long y, long z,
|
||||||
|
long step_x, long step_y, long step_z,
|
||||||
|
GLfloat *vertex_origin,
|
||||||
|
GLfloat *colors_origin,
|
||||||
|
GLfloat *lines_origin)
|
||||||
|
{
|
||||||
|
*(vertex_origin + vertex_index + 0) = 0.5f;
|
||||||
|
*(vertex_origin + vertex_index + 1) = 0.5f;
|
||||||
|
*(vertex_origin + vertex_index + 2) = 0.5f;
|
||||||
|
|
||||||
|
vertex_index += 3;
|
||||||
|
|
||||||
|
*(vertex_origin + vertex_index + 0) = 0.4f;
|
||||||
|
*(vertex_origin + vertex_index + 1) = 0.4f;
|
||||||
|
*(vertex_origin + vertex_index + 2) = 0.4f;
|
||||||
|
|
||||||
|
vertex_index += 3;
|
||||||
|
|
||||||
|
*(colors_origin + colors_index + 0) = 1.0f;
|
||||||
|
*(colors_origin + colors_index + 1) = 0.2f;
|
||||||
|
*(colors_origin + colors_index + 2) = 0.0f;
|
||||||
|
|
||||||
|
colors_index += 3;
|
||||||
|
|
||||||
|
*(colors_origin + colors_index + 0) = 0.5f;
|
||||||
|
*(colors_origin + colors_index + 1) = 0.3f;
|
||||||
|
*(colors_origin + colors_index + 2) = 0.1f;
|
||||||
|
|
||||||
|
colors_index += 3;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Ça devrait me faire la diagonale test [0 - max] !
|
||||||
|
//
|
||||||
|
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++;
|
||||||
|
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_index ++;
|
||||||
|
// *(lines_origin + lines_index) = step_z * 1 + step_y * 1 + step_x * 1; lines_index ++;
|
||||||
|
// *(lines_origin + lines_index) = step_z * 2 + step_y * 2 + step_x * 2; lines_index ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -667,13 +746,13 @@ static void show_user_choices(long model_size_x,
|
||||||
if (pref_show_grid == 6) printf("pref_show_grid = %d <> show grids xy & xz ", pref_show_grid);
|
if (pref_show_grid == 6) printf("pref_show_grid = %d <> show grids xy & xz ", pref_show_grid);
|
||||||
if (pref_show_grid == 10) printf("pref_show_grid = %d <> show grids xy & yz ", pref_show_grid);
|
if (pref_show_grid == 10) printf("pref_show_grid = %d <> show grids xy & yz ", pref_show_grid);
|
||||||
if (pref_show_grid == 15) printf("pref_show_grid = %d <> show grids xz & yz ", pref_show_grid);
|
if (pref_show_grid == 15) printf("pref_show_grid = %d <> show grids xz & yz ", pref_show_grid);
|
||||||
if (1) printf("\n");
|
if (model_arrows_nb > 0) printf("\n[ n] load site x y z ---- < arrows array >\
|
||||||
if (model_arrows_nb > 0) printf("[ n] load site x y z ---- < arrows array >\
|
|
||||||
------------------------------------------------------------\n");
|
------------------------------------------------------------\n");
|
||||||
// (DEPRECATED) arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
// (DEPRECATED) arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
||||||
for (int i = 0; i < model_arrows_nb; i++)
|
for (int i = 0; i < model_arrows_nb; i++)
|
||||||
printf("[%2d] = %2d, %2d, %2d, %2d, %2d \n",\
|
printf("[%2d] = %2d, %2d, %2d, %2d, %2d \n",\
|
||||||
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -698,10 +777,11 @@ bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_s
|
||||||
step_y = model_size_z + 1,
|
step_y = model_size_z + 1,
|
||||||
step_x = (model_size_z + 1) * (model_size_y + 1);
|
step_x = (model_size_z + 1) * (model_size_y + 1);
|
||||||
|
|
||||||
grids_intersections (model_size_x + 1, model_size_y + 1, model_size_z + 1, pref_style_mix_colors, vertex_origin, colors_origin);
|
grids_intersections (model_size_x + 1, model_size_y + 1, model_size_z + 1, vertex_origin, colors_origin);
|
||||||
draw_grids_3D (model_size_x + 1, model_size_y + 1, model_size_z + 1, step_x, step_y, step_z, lines_origin, pref_show_grid);
|
draw_grids_3D (model_size_x + 1, model_size_y + 1, model_size_z + 1, step_x, step_y, step_z, lines_origin, pref_show_grid);
|
||||||
if (pref_show_grid != 0) draw_ridges_3D (model_size_x + 1, model_size_y + 1, model_size_z + 1, step_x, step_y, step_z, lines_origin);
|
if (pref_show_grid != 0) draw_ridges_3D (model_size_x + 1, model_size_y + 1, model_size_z + 1, step_x, step_y, step_z, lines_origin);
|
||||||
if (pref_test_diagonal) diagonal_test (model_size_x + 1, model_size_y + 1, model_size_z + 1, lines_origin);
|
if (pref_test_diagonal) diagonal_test (model_size_x + 1, model_size_y + 1, model_size_z + 1, step_x, step_y, step_z, lines_origin);
|
||||||
|
a_simple_test (model_size_x + 1, model_size_y + 1, model_size_z + 1, step_x, step_y, step_z, vertex_origin, colors_origin, lines_origin);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -712,3 +792,4 @@ bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_s
|
||||||
/* vertex_origin, colors_origin, lines_origin, plans_origin); */
|
/* vertex_origin, colors_origin, lines_origin, plans_origin); */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -567,10 +567,10 @@ static void get_model_data_and_user_preferences(){
|
||||||
|
|
||||||
model_space_size_x = 4; // 0 < model_space_size_x
|
model_space_size_x = 4; // 0 < model_space_size_x
|
||||||
model_space_size_y = 3; // 0 < model_space_size_y
|
model_space_size_y = 3; // 0 < model_space_size_y
|
||||||
model_space_size_z = 2; // 0 < model_space_size_z
|
model_space_size_z = 3; // 0 < model_space_size_z
|
||||||
|
|
||||||
// XXX ONLY space drawed, no arrows
|
// XXX ONLY space drawed, no arrows
|
||||||
model_arrows_nb = 1; // 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
|
// par model_space_size_x, y, z et le nombre de sites
|
||||||
// OLD ARROWS (DEPRECATED)
|
// OLD ARROWS (DEPRECATED)
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ static void get_model_data_and_user_preferences(){
|
||||||
pref_mark_unit_space = 0; // 0 = no marks, 1 = 1st, 2 = last, 3 = both
|
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_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix
|
||||||
pref_style_mix_colors = 0; // TODO
|
pref_style_mix_colors = 0; // TODO
|
||||||
pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
pref_show_grid = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||||
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||||
pref_test_diagonal = 1;
|
pref_test_diagonal = 1;
|
||||||
}
|
}
|
||||||
|
@ -604,12 +604,19 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
long grids_intersections = (model_space_size_x + 1)
|
long grids_intersections = (model_space_size_x + 1)
|
||||||
* (model_space_size_y + 1)
|
* (model_space_size_y + 1)
|
||||||
* (model_space_size_z + 1);
|
* (model_space_size_z + 1);
|
||||||
|
long arrows_anchors = (model_space_size_x)
|
||||||
|
* (model_space_size_y)
|
||||||
|
* (model_space_size_z)
|
||||||
|
// * (8 + 6); // this will be to draw the small cube
|
||||||
|
// with (almost) centered faces inside
|
||||||
|
* 1; // today, I just search for the centers...
|
||||||
|
|
||||||
long cubes_nb = model_space_size_x * model_space_size_y * model_space_size_z;
|
long cubes_nb = model_space_size_x * model_space_size_y * model_space_size_z;
|
||||||
|
|
||||||
buffer_vertex_size = grids_intersections * 3; // 3 numbers per vertex
|
buffer_vertex_size = grids_intersections * 3; // 3 numbers per vertex
|
||||||
// + cubes_nb * (8 + 6);
|
// + cubes_nb * (8 + 6) + 15 * model_arrows_nb;// OLD ARROWS (DEPRECATED)
|
||||||
// buffer_vertex_size += 15 * model_arrows_nb;// OLD ARROWS (DEPRECATED)
|
buffer_vertex_size += arrows_anchors * 3;
|
||||||
|
|
||||||
|
|
||||||
buffer_colors_size = buffer_vertex_size;
|
buffer_colors_size = buffer_vertex_size;
|
||||||
|
|
||||||
|
@ -620,13 +627,15 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
+ (pref_show_grid % 3 == 0) * (model_space_size_x + 1) * (model_space_size_z + 1)
|
+ (pref_show_grid % 3 == 0) * (model_space_size_x + 1) * (model_space_size_z + 1)
|
||||||
+ (pref_show_grid % 5 == 0) * (model_space_size_y + 1) * (model_space_size_z + 1);
|
+ (pref_show_grid % 5 == 0) * (model_space_size_y + 1) * (model_space_size_z + 1);
|
||||||
|
|
||||||
buffer_lines_size = grids_lines * 2;
|
|
||||||
// if (model_arrows_nb > 0) buffer_lines_size += model_arrows_nb * 16 // DEPRECATED
|
// if (model_arrows_nb > 0) buffer_lines_size += model_arrows_nb * 16 // DEPRECATED
|
||||||
if (pref_show_grid % 1 == 0) buffer_lines_size += 12 * 2; // space ridges
|
if (pref_show_grid % 1 == 0) buffer_lines_size += 12 * 2; // space ridges
|
||||||
// sinon, les arêtes de l'espace sont tracées par les grilles
|
// sinon, les arêtes de l'espace sont tracées par les grilles
|
||||||
|
else buffer_lines_size = grids_lines * 2;
|
||||||
|
|
||||||
if (pref_test_diagonal) buffer_lines_size += 2; // la diagonale test [0 - max]
|
if (pref_test_diagonal) buffer_lines_size += 2; // la diagonale test [0 - max]
|
||||||
|
|
||||||
|
buffer_lines_size += 2; // test flèche
|
||||||
|
//
|
||||||
if (1) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
if (1) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||||
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",
|
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",
|
||||||
buffer_vertex_size, buffer_vertex_size / 3,
|
buffer_vertex_size, buffer_vertex_size / 3,
|
||||||
|
@ -804,3 +813,4 @@ void graphics_draw(const void *gl_area)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue