WIP: Un peu plus que WIP, ici. La lecture des flèches à partir du modèle XML est OK.

This commit is contained in:
Jean Sirmai 2023-08-10 15:23:27 +02:00
parent 056b89828f
commit ab256b8e8e
Signed by: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 103 additions and 84 deletions

View File

@ -33,9 +33,9 @@ bool compute_space_and_arrows(long model_space_size_x,
GLuint *arrows,
int model_arrows_nb,
int pref_mark_unit_space,
int pref_style_lines_planes,
int pref_style_mix_colors,
// int pref_mark_unit_space,
// int pref_style_lines_planes,
// int pref_style_mix_colors,
int pref_show_grid,
int pref_test_diagonal,

View File

@ -83,7 +83,13 @@ static bool grids_intersections (long x, long y, long z,
static bool arrows_anchors (long x, long y, long z,
GLfloat *vertex_origin, GLfloat *colors_origin)
{
// beaucoup de ^c ^v ici (peu d'info) (mais un peu)
/* beaucoup de ^c ^v ici (peu d'info) (mais un peu)
X - X = EAST - WEST = rouge - cyan
Y - Y = ZENITH - NADIR = vert - magenta
Z - Z = NORTH - SOUTH = bleu - jaune
*/
float max = fmax(x, y);
max = fmax(max, z);
@ -119,15 +125,15 @@ static bool arrows_anchors (long x, long y, long z,
vertex_index += 3;
*(colors_origin + colors_index + 0) = 1;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 0;
*(colors_origin + colors_index + 0) = 0.3f;
*(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 1) = 1;
*(colors_origin + colors_index + 2) = 1;
*(colors_origin + colors_index + 0) = 0.3f;
*(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3;
@ -146,15 +152,15 @@ static bool arrows_anchors (long x, long y, long z,
vertex_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 1) = 1;
*(colors_origin + colors_index + 2) = 0;
*(colors_origin + colors_index + 0) = 0.3f;
*(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3;
*(colors_origin + colors_index + 0) = 1;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 1;
*(colors_origin + colors_index + 0) = 0.3f;
*(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3;
@ -173,15 +179,15 @@ static bool arrows_anchors (long x, long y, long z,
vertex_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 1;
*(colors_origin + colors_index + 0) = 0.3f;
*(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3;
*(colors_origin + colors_index + 0) = 1;
*(colors_origin + colors_index + 1) = 1;
*(colors_origin + colors_index + 2) = 0;
*(colors_origin + colors_index + 0) = 0.3f;
*(colors_origin + colors_index + 1) = 0.3f;
*(colors_origin + colors_index + 2) = 0.3f;
colors_index += 3;
@ -201,15 +207,15 @@ static bool arrows_anchors (long x, long y, long z,
vertex_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 0) = 1;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 0;
colors_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 0;
*(colors_origin + colors_index + 1) = 1;
*(colors_origin + colors_index + 2) = 1;
colors_index += 3;
@ -229,14 +235,14 @@ static bool arrows_anchors (long x, long y, long z,
vertex_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 1) = 1;
*(colors_origin + colors_index + 2) = 0;
colors_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 0) = 1;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 0;
*(colors_origin + colors_index + 2) = 1;
colors_index += 3;
@ -257,12 +263,12 @@ static bool arrows_anchors (long x, long y, long z,
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 2) = 0;
*(colors_origin + colors_index + 2) = 1;
colors_index += 3;
*(colors_origin + colors_index + 0) = 0;
*(colors_origin + colors_index + 1) = 0;
*(colors_origin + colors_index + 0) = 1;
*(colors_origin + colors_index + 1) = 1;
*(colors_origin + colors_index + 2) = 0;
colors_index += 3;
@ -470,16 +476,22 @@ static void draw_some_arrows (GLuint *lines_origin, long s, long stx, long sty,
{
site = *(arrows + i * 5 + 1);
x = *(arrows + i * 5 + 2); y = *(arrows + i * 5 + 3); z = *(arrows + i * 5 + 4);
// printf("[%d] site = %d x = %ld y = %ld z = %ld step x = %ld step y = %ld\n", site, i, x, y, z, stx, sty);
draw_a_central_star (lines_origin, s + 1 + 12 * (stx * x + sty * y + stz * z));
if (site < 2) draw_an_arrow_East_or_West (lines_origin, s + 1 + 12 * (stx * x + sty * y + stz * z), 1, site);
if (site > 3) draw_an_arrow_North_or_South (lines_origin, s + 1 + 12 * (stx * x + sty * y + stz * z), 1, site);
else draw_an_arrow_Zenith_or_Nadir (lines_origin, s + 1 + 12 * (stx * x + sty * y + stz * z), 1, site);
if (site >-1 && site < 2) draw_an_arrow_East_or_West (lines_origin, s + 1 + 12 * (stx * x + sty * y + stz * z), 1, site);
if (site > 3 && site < 6) draw_an_arrow_North_or_South (lines_origin, s + 1 + 12 * (stx * x + sty * y + stz * z), 1, site);
if (site > 1 && site < 4) draw_an_arrow_Zenith_or_Nadir (lines_origin, s + 1 + 12 * (stx * x + sty * y + stz * z), 1, site);
}
}
// X - X = EAST - WEST = rouge - cyan
// Y - Y = ZENITH - NADIR = vert - magenta
// Z - Z = NORTH - SOUTH = bleu - jaune
@ -499,21 +511,21 @@ static void show_user_choices(long model_size_x,
GLuint *arrows,
int model_arrows_nb,
int pref_mark_unit_space,
int pref_style_lines_planes,
int pref_style_mix_colors,
// int pref_mark_unit_space,
// int pref_style_lines_planes,
// int pref_style_mix_colors,
int pref_show_grid)
{
printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", model_size_x, model_size_y, model_size_z);
if (model_arrows_nb > 0) printf("[%d] arrows ", model_arrows_nb);
if (pref_mark_unit_space == 0) printf("no unit_space marks ");
if (pref_mark_unit_space == 1) printf("first unit space marked ");
if (pref_mark_unit_space == 2) printf("last unit_space marked ");
if (pref_mark_unit_space == 3) printf("first and last units space marked ");
if (! pref_style_lines_planes) printf("no style_lines_planes ");
if (pref_style_lines_planes > 0) printf("style_lines_planes = %d ", pref_style_lines_planes);
if (! pref_style_mix_colors) printf("no style_mix_colors ");
if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
// if (pref_mark_unit_space == 0) printf("no unit_space marks ");
// if (pref_mark_unit_space == 1) printf("first unit space marked ");
// if (pref_mark_unit_space == 2) printf("last unit_space marked ");
// if (pref_mark_unit_space == 3) printf("first and last units space marked ");
// if (! pref_style_lines_planes) printf("no style_lines_planes ");
// if (pref_style_lines_planes > 0) printf("style_lines_planes = %d ", pref_style_lines_planes);
// if (! pref_style_mix_colors) printf("no style_mix_colors ");
// if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
if (pref_show_grid == 1) printf("pref_show_grid = %d <> show no grid ", pref_show_grid);
if (pref_show_grid == 0) printf("pref_show_grid = %d <> show all grids ", pref_show_grid);
if (pref_show_grid == 2) printf("pref_show_grid = %d <> show grid xy ", pref_show_grid);
@ -528,7 +540,12 @@ static void show_user_choices(long model_size_x,
for (int i = 0; i < model_arrows_nb; i++)
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));
printf("\n");
printf("NB If you play : 'draw_some_arrows_demo(...)',\
1) don't forget to set model_arrows_nb to 6 (line 573 in graphics.c) and \
2) nombre_de_cases_contenant_des_fleches to 6 (line 576) ( ;- ))\n");
printf("NB The same is true if you play : 'draw_some_arrows(...)',\
and modify the number of arrows described above the line 555.\n");
}
@ -543,8 +560,8 @@ bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_s
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_test_diagonal,
// int pref_mark_unit_space, int pref_style_lines_planes, int pref_style_mix_colors,
int pref_show_grid, int pref_test_diagonal,
GLfloat *vertex_origin, GLfloat *colors_origin,
GLuint *lines_origin, GLuint *plans_origin)
@ -552,8 +569,8 @@ bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_s
{
show_user_choices(model_size_x, model_size_y, model_size_z,
arrows, model_arrows_nb,
pref_mark_unit_space, pref_style_lines_planes,
pref_style_mix_colors, pref_show_grid);
// pref_mark_unit_space, pref_style_lines_planes, 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);
@ -569,10 +586,14 @@ bool compute_space_and_arrows(long model_size_x, long model_size_y, long model_s
long s = step_z * model_size_z + step_y * model_size_y + step_x * model_size_x;
if (0) draw_some_arrows_demo (lines_origin, s, model_size_x, model_size_y, model_size_z, arrows, model_arrows_nb);
draw_some_arrows (lines_origin, s, model_size_z * model_size_y, model_size_z, arrows, model_arrows_nb);
if (1) draw_some_arrows (lines_origin, s, model_size_z * model_size_y, model_size_z, arrows, model_arrows_nb);
// draw_a_cube_at(1, 1, 1, lines_origin, model_size_x, model_size_y, model_size_z, 0);
return 0;
}
// X - X = EAST - WEST = rouge - cyan
// Y - Y = ZENITH - NADIR = vert - magenta
// Z - Z = NORTH - SOUTH = bleu - jaune

View File

@ -60,9 +60,9 @@ GLuint *buffer_plans_origin = NULL;
//int pref_3D_xor_2D_space = 0; // default view == 0 == 3D
//int pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
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_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, 1, 2, 3, 5, 6, 10, 15, 30, etc
int pref_test_diagonal = 0; // diagonal test
@ -553,38 +553,34 @@ bool graphics_init_shaders(const void *gl_area)
GLuint arrows[] = {
1, 1, 1, 1, 0,
1, 0, 0, 1, 0,
// 1, 4, 1, 2, 0,
// 1, 5, 1, 2, 1,
/* 1, 0, 3, 0, 0, */
/* 1, 1, 3, 0, 0, */
/* 1, 0, 2, 2, 0, */
/* 1, 1, 2, 2, 0, */
/* 1, 2, 2, 2, 0, */
/* 1, 3, 2, 2, 0, */
1, 0, 0, 0, 0,
1, 1, 1, 0, 0,
1, 2, 2, 1, 1,
1, 3, 2, 2, 1,
1, 4, 3, 0, 1,
1, 5, 3, 0, 2
// load, site, x, y, z
};
static void get_model_data_and_user_preferences(){
model_space_size_x = 3; // 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_z = 3; // 0 < model_space_size_z
// XXX ONLY space drawed, no arrows
model_arrows_nb = 2; // assert : l'emplacement des flèches est contraint
// XXX ONLY space drawed, no arrows yet
model_arrows_nb = 6; // assert : l'emplacement des flèches est contraint
// par model_space_size_x, y, z et le nombre de sites
// OLD ARROWS (DEPRECATED)
nombre_de_cases_contenant_des_fleches = 2; // à calculer TODO
nombre_de_cases_contenant_des_fleches = 6; // à calculer TODO
// pref_1D_shown_as_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D
// pref_1D_shown_as_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D
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_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 = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
// xyz, 0, x, y, z, xy, xz, yz, xyz
pref_test_diagonal = 0;
@ -601,9 +597,9 @@ static void compute_buffers_sizes(int model_space_size_x,
int model_arrows_nb,
int pref_mark_unit_space,
int pref_style_lines_planes,
int pref_style_mix_colors,
// int pref_mark_unit_space,
// int pref_style_lines_planes,
// int pref_style_mix_colors,
int pref_test_diagonal)
{
// XXX ONLY space and no arrows
@ -648,6 +644,7 @@ static void compute_buffers_sizes(int model_space_size_x,
// buffer_lines_size += 16 + 20; // draw a small cube with diagonals
// buffer_lines_size -= 2;
// buffer_lines_size += 30;
if (1) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",
@ -702,9 +699,9 @@ void graphics_init_buffers(const void *gl_area)
model_arrows_nb,
pref_mark_unit_space,
pref_style_lines_planes,
pref_style_mix_colors,
// pref_mark_unit_space,
// pref_style_lines_planes,
// pref_style_mix_colors,
pref_test_diagonal);
buffer_vertex_origin = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
@ -719,9 +716,9 @@ void graphics_init_buffers(const void *gl_area)
arrows,
model_arrows_nb,
pref_mark_unit_space,
pref_style_lines_planes,
pref_style_mix_colors,
// pref_mark_unit_space,
// pref_style_lines_planes,
// pref_style_mix_colors,
pref_show_grid,
pref_test_diagonal,
@ -790,7 +787,8 @@ void graphics_draw(const void *gl_area)
/* Use our shaders */
glUseProgram(entry->program);
if (pref_style_mix_colors == 0) glClearColor(0, 0, 0, 0.4f);
// if (pref_style_mix_colors == 0)
glClearColor(0, 0, 0, 0.4f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);