WIP: pas arrivé, certes. Mais dans une bonne direction.

This commit is contained in:
Jean Sirmai 2023-08-06 19:04:59 +02:00
parent b396da22ca
commit b31320b6ba
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 92 additions and 91 deletions

View File

@ -451,84 +451,52 @@ static bool draw_ridges_3D (long x, long y, long z,
GLuint *lines_origin) GLuint *lines_origin)
{ {
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * (y - 1) + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * y + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * 0; 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 * 0 + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * z + 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 * z + step_y * y + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * (y - 1) + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * y + step_x * x; 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 * z + step_y * y + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * (y - 1) + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * y + 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 * z + step_y * y + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * 0 + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * (y - 1) + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * y + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * 0 + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * 0 + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * 0 + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * 0 + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * (y - 1) + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * y + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * (y - 1) + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * y + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * (y - 1) + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * y + step_x * x; lines_index ++;
*(lines_origin + lines_index) = step_z * 0 + step_y * (y - 1) + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * 0 + step_y * y + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * (y - 1) + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * y + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * 0 + step_x * 0; lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * 0 + step_x * 0; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_index ++; *(lines_origin + lines_index) = step_z * z + step_y * 0 + step_x * x; lines_index ++;
return 0; return 0;
} }
static bool grids_intersections (long x, long y, long z,
GLfloat *vertex_origin,
GLfloat *colors_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;
vy = (2 * j / (y - 1) - 1) * y / max;
vz = (2 * k / (z - 1) - 1) * z / 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) = 3 * vx / 2;
*(colors_origin + colors_index + 1) = 3 * vy / 2;
*(colors_origin + colors_index + 2) = 3 * vz / 2;
colors_index += 3;
};
return 1;
}
static bool draw_grids_3D (long x, long y, long z, static bool draw_grids_3D (long x, long y, long z,
long step_x, long step_y, long step_z, long step_x, long step_y, long step_z,
GLuint *lines_origin, GLuint *lines_origin,
int pref_show_grid) int pref_show_grid)
{ {
x ++; y ++; z ++;
float calcul = 0; float calcul = 0;
if (pref_show_grid % 2 == 0) if (pref_show_grid % 2 == 0)
@ -569,10 +537,10 @@ static bool diagonal_test(long x, long y, long z,
long step_x, long step_y, long step_z, long step_x, long step_y, long step_z,
GLuint *lines_origin) GLuint *lines_origin)
{ {
*(lines_origin + lines_index) = 0; lines_index ++; *(lines_origin + lines_index) = 0; lines_index ++;
*(lines_origin + lines_index) = step_z * (z - 1) *(lines_origin + lines_index) = step_z * z
+ step_y * (y - 1) + step_y * y
+ step_x * (x - 1); lines_index ++; + step_x * x; lines_index ++;
return 1; return 1;
} }
@ -620,23 +588,20 @@ static bool diagonal_test(long x, long y, long z,
static bool arrows_anchors (long x, long y, long z, static bool grids_intersections (long x, long y, long z,
long step_x, long step_y, long step_z, GLfloat *vertex_origin, GLfloat *colors_origin)
GLfloat *vertex_origin,
GLfloat *colors_origin,
GLfloat *lines_origin)
{ {
float i, j, k, vx, vy, vz, max = fmax(x, y); float i, j, k, vx, vy, vz, max = fmax(x, y);
max = fmax(max, z) + 1; max = fmax(max, z);
for (i = 0; i < x; i++) for (i = 0; i <= x; i++)
for (j = 0; j < y; j++) for (j = 0; j <= y; j++)
for (k = 0; k < z; k++){ for (k = 0; k <= z; k++){
vx = (2 * i / (x - 1) - 1) * x / max + x / 2 * max; vx = (2 * i / x - 1) * x / max;
vy = (2 * j / (y - 1) - 1) * y / max + y / 2 * max; vy = (2 * j / y - 1) * y / max;
vz = (2 * k / (z - 1) - 1) * z / max + z / 2 * max; vz = (2 * k / z - 1) * z / max;
*(vertex_origin + vertex_index + 0) = vx; *(vertex_origin + vertex_index + 0) = vx;
*(vertex_origin + vertex_index + 1) = vy; *(vertex_origin + vertex_index + 1) = vy;
@ -644,9 +609,9 @@ static bool arrows_anchors (long x, long y, long z,
vertex_index += 3; vertex_index += 3;
*(colors_origin + colors_index + 0) = 1.0f; *(colors_origin + colors_index + 0) = 3 * vx / 2;
*(colors_origin + colors_index + 1) = 0.2f; *(colors_origin + colors_index + 1) = 3 * vy / 2;
*(colors_origin + colors_index + 2) = 0.0f; *(colors_origin + colors_index + 2) = 3 * vz / 2;
colors_index += 3; colors_index += 3;
}; };
@ -655,6 +620,41 @@ static bool arrows_anchors (long x, long y, long z,
} }
static bool arrows_anchors (long x, long y, long z,
GLfloat *vertex_origin, GLfloat *colors_origin)
{
float i, j, k, vx, vy, vz, max = fmax(x, y), ad = 0.5f;
max = fmax(max, z);
printf("arrows_anchors max = %5.2f max / 2 = %5.2f\n", max, max / 2);
for (i = 0; i <= x; i++)
for (j = 0; j <= y; j++)
for (k = 0; k <= z; k++){
vx = (2 * i / x - 1) * x / max + ad;
vy = (2 * j / y - 1) * y / max + ad;
vz = (2 * k / z - 1) * z / max + ad;
*(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;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 0;
colors_index += 3;
};
return 1;
}
@ -719,11 +719,11 @@ static void show_user_choices(long model_size_x,
static bool a_simple_test (GLuint *lines_origin) static bool draw_line (GLuint *lines_origin, int a, int b)
{ {
printf("lines_index = %ld lines_origin = %ld\n", lines_index, lines_origin); // printf("lines_index = %ld lines_origin = %ld\n", lines_index, lines_origin);
*(lines_origin + lines_index) = 0; lines_index ++; *(lines_origin + lines_index) = a; lines_index ++;
*(lines_origin + lines_index) = 50; lines_index ++; *(lines_origin + lines_index) = b; lines_index ++;
} }
bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_size_z, bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_size_z,
@ -742,20 +742,21 @@ bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_s
pref_mark_unit_space, pref_style_lines_planes, pref_mark_unit_space, pref_style_lines_planes,
pref_style_mix_colors, pref_show_grid); pref_style_mix_colors, pref_show_grid);
grids_intersections (model_size_x, model_size_y, model_size_z, vertex_origin, colors_origin);
arrows_anchors (model_size_x, model_size_y, model_size_z, vertex_origin, colors_origin);
long step_z = 1, long step_z = 1,
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, vertex_origin, colors_origin); draw_grids_3D (model_size_x, model_size_y, model_size_z, step_x, step_y, step_z, lines_origin, pref_show_grid);
arrows_anchors (model_size_x, model_size_y, model_size_z, step_x,step_y, step_z, if (pref_show_grid > 0) draw_ridges_3D (model_size_x, model_size_y, model_size_z, step_x, step_y, step_z, lines_origin);
vertex_origin, colors_origin, lines_origin); if (pref_test_diagonal) diagonal_test (model_size_x, model_size_y, model_size_z, step_x, step_y, step_z, lines_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); long s = step_z * model_size_z + step_y * model_size_y + step_x * model_size_x;
draw_line (lines_origin, 0, 25);
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); draw_line (lines_origin, 0, s + 3);
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); draw_line (lines_origin, s + 3, s + 1);
a_simple_test (lines_origin);
printf("lines_index = %ld lines_origin = %ld\n", lines_index, lines_origin); printf("lines_index = %ld lines_origin = %ld\n", lines_index, lines_origin);
return 0; return 0;

View File

@ -565,9 +565,9 @@ GLuint arrows[] = {
static void get_model_data_and_user_preferences(){ static void get_model_data_and_user_preferences(){
model_space_size_x = 4; // 0 < model_space_size_x model_space_size_x = 2; // 0 < model_space_size_x
model_space_size_y = 5; // 0 < model_space_size_y model_space_size_y = 3; // 0 < model_space_size_y
model_space_size_z = 6; // 0 < model_space_size_z model_space_size_z = 4; // 0 < model_space_size_z
// XXX ONLY space drawed, no arrows // XXX ONLY space drawed, no arrows
model_arrows_nb = 0; // assert : l'emplacement des flèches est contraint model_arrows_nb = 0; // assert : l'emplacement des flèches est contraint
@ -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;
} }
@ -634,7 +634,7 @@ static void compute_buffers_sizes(int model_space_size_x,
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 buffer_lines_size += 6; // 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",