WIP: Voisinage 3D de rayon > 2 (mise en place)
This commit is contained in:
parent
ba7ebcbe2b
commit
734045a50f
|
@ -69,18 +69,25 @@ static bool grids_intersections (long x, long y, long z,
|
|||
|
||||
vertex_index += 3;
|
||||
|
||||
if ((i == 0 || i == x) && (j == 0 || j == y) && (k == 0 || k == z)) {
|
||||
*(colors_origin + colors_index + 0) = 0.5f;// 3 * vx / 2;
|
||||
*(colors_origin + colors_index + 1) = 0.5f;// 3 * vy / 2;
|
||||
*(colors_origin + colors_index + 2) = 0.5f;// 3 * vz / 2;
|
||||
} else {
|
||||
*(colors_origin + colors_index + 0) = 0.64f;// 3 * vx / 2;
|
||||
*(colors_origin + colors_index + 1) = 0.64f;// 3 * vy / 2;
|
||||
*(colors_origin + colors_index + 2) = 0.64f;// 3 * vz / 2;
|
||||
|
||||
}
|
||||
colors_index += 3;
|
||||
|
||||
|
||||
};
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static bool arrows_anchors (long x, long y, long z,
|
||||
static bool central_stars (long x, long y, long z,
|
||||
GLfloat *vertex_origin, GLfloat *colors_origin)
|
||||
{
|
||||
|
||||
|
@ -99,7 +106,7 @@ static bool arrows_anchors (long x, long y, long z,
|
|||
// pour qu'elles n'aillent pas jusqu'aux faces des cubes
|
||||
|
||||
|
||||
if (0) printf("arrows_anchors 1 / max = %5.2f max / 2 = %5.2f\n", ad, max / 2);
|
||||
if (0) printf("central_stars 1 / max = %5.2f max / 2 = %5.2f\n", ad, max / 2);
|
||||
|
||||
for (i = 0; i < x; i++)
|
||||
for (j = 0; j < y; j++)
|
||||
|
@ -123,13 +130,13 @@ static bool arrows_anchors (long x, long y, long z,
|
|||
|
||||
vertex_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0.3f;
|
||||
*(colors_origin + colors_index + 0) = 1.0f;
|
||||
*(colors_origin + colors_index + 1) = 0.3f;
|
||||
*(colors_origin + colors_index + 2) = 0.3f;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0.3f;
|
||||
*(colors_origin + colors_index + 0) = 1.0f;
|
||||
*(colors_origin + colors_index + 1) = 0.3f;
|
||||
*(colors_origin + colors_index + 2) = 0.3f;
|
||||
|
||||
|
@ -150,14 +157,14 @@ static bool arrows_anchors (long x, long y, long z,
|
|||
|
||||
vertex_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0.3f;
|
||||
*(colors_origin + colors_index + 1) = 0.3f;
|
||||
*(colors_origin + colors_index + 0) = 1.0f;
|
||||
*(colors_origin + colors_index + 1) = 1.3f;
|
||||
*(colors_origin + colors_index + 2) = 0.3f;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0.3f;
|
||||
*(colors_origin + colors_index + 1) = 0.3f;
|
||||
*(colors_origin + colors_index + 0) = 1.0f;
|
||||
*(colors_origin + colors_index + 1) = 1.3f;
|
||||
*(colors_origin + colors_index + 2) = 0.3f;
|
||||
|
||||
colors_index += 3;
|
||||
|
@ -178,100 +185,71 @@ static bool arrows_anchors (long x, long y, long z,
|
|||
vertex_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0.3f;
|
||||
*(colors_origin + colors_index + 1) = 0.3f;
|
||||
*(colors_origin + colors_index + 1) = 1.3f;
|
||||
*(colors_origin + colors_index + 2) = 0.3f;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0.3f;
|
||||
*(colors_origin + colors_index + 1) = 0.3f;
|
||||
*(colors_origin + colors_index + 1) = 1.3f;
|
||||
*(colors_origin + colors_index + 2) = 0.3f;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
//--------------------------------------------------------------
|
||||
};
|
||||
|
||||
// X - X axis arrows tips near the faces centers EAST - WEST
|
||||
|
||||
*(vertex_origin + vertex_index + 0) = vx + ad - eps;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static bool centers (long x, long y, long z,
|
||||
GLfloat *vertex_origin, GLfloat *colors_origin)
|
||||
{
|
||||
float max = fmax(x, y);
|
||||
max = fmax(max, z);
|
||||
|
||||
float i, j, k, vx, vy, vz,
|
||||
ad = 1 / max,
|
||||
eps = 0.1 * ad; // eps(ilon) servira à décaler légèrement les deux vertex centraux
|
||||
// l'un source, l'autre cible, de couleurs différentes
|
||||
|
||||
|
||||
if (0) printf("centers eps(ilon) = %5.2f\n", eps);
|
||||
|
||||
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 + eps;
|
||||
*(vertex_origin + vertex_index + 1) = vy;
|
||||
*(vertex_origin + vertex_index + 2) = vz;
|
||||
|
||||
vertex_index += 3;
|
||||
|
||||
*(vertex_origin + vertex_index + 0) = vx - ad + eps;
|
||||
*(colors_origin + colors_index + 0) = 0.0f;
|
||||
*(colors_origin + colors_index + 1) = 0.0f;
|
||||
*(colors_origin + colors_index + 2) = 0.0f;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
|
||||
|
||||
*(vertex_origin + vertex_index + 0) = vx - eps;
|
||||
*(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_origin + colors_index + 0) = 1.0f;
|
||||
*(colors_origin + colors_index + 1) = 1.0f;
|
||||
*(colors_origin + colors_index + 2) = 1.0f;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0;
|
||||
*(colors_origin + colors_index + 1) = 1;
|
||||
*(colors_origin + colors_index + 2) = 1;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
|
||||
// Y - Y axis arrows tips near the faces centers ZENITH - NADIR
|
||||
|
||||
*(vertex_origin + vertex_index + 0) = vx;
|
||||
*(vertex_origin + vertex_index + 1) = vy + ad - eps;
|
||||
*(vertex_origin + vertex_index + 2) = vz;
|
||||
|
||||
vertex_index += 3;
|
||||
|
||||
*(vertex_origin + vertex_index + 0) = vx;
|
||||
*(vertex_origin + vertex_index + 1) = vy - ad + eps;
|
||||
*(vertex_origin + vertex_index + 2) = vz;
|
||||
|
||||
vertex_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0;
|
||||
*(colors_origin + colors_index + 1) = 1;
|
||||
*(colors_origin + colors_index + 2) = 0;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 1;
|
||||
*(colors_origin + colors_index + 1) = 0;
|
||||
*(colors_origin + colors_index + 2) = 1;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
|
||||
// Z - Z axis arrows tips near the faces centers NORTH - SOUTH
|
||||
|
||||
*(vertex_origin + vertex_index + 0) = vx;
|
||||
*(vertex_origin + vertex_index + 1) = vy;
|
||||
*(vertex_origin + vertex_index + 2) = vz + ad - eps;
|
||||
|
||||
vertex_index += 3;
|
||||
|
||||
*(vertex_origin + vertex_index + 0) = vx;
|
||||
*(vertex_origin + vertex_index + 1) = vy;
|
||||
*(vertex_origin + vertex_index + 2) = vz - ad + eps;
|
||||
|
||||
vertex_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 0;
|
||||
*(colors_origin + colors_index + 1) = 0;
|
||||
*(colors_origin + colors_index + 2) = 1;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
*(colors_origin + colors_index + 0) = 1;
|
||||
*(colors_origin + colors_index + 1) = 1;
|
||||
*(colors_origin + colors_index + 2) = 0;
|
||||
|
||||
colors_index += 3;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -285,41 +263,6 @@ static void draw_line (GLuint *lines_origin, int a, int b)
|
|||
*(lines_origin + lines_index) = b; lines_index ++;
|
||||
}
|
||||
|
||||
static void draw_a_cube_at(long u, long v, long w, GLuint *lines_origin,
|
||||
long size_x, long size_y, long size_z, bool diagonals)
|
||||
{
|
||||
long step_z = 1, step_y = size_z, step_x = size_y * size_z, x = u + 1, y = v + 1, z = w + 1;
|
||||
|
||||
// draw_line (lines_origin, 0,21); draw_line (lines_origin, 21,42);
|
||||
// ce qui suit ne vaut que dans un espace 3 x 3 x 3 (le reste est à corriger - ou à oublier ?)
|
||||
draw_line (lines_origin, 21,22); draw_line (lines_origin, 21,25);
|
||||
draw_line (lines_origin, 25,26); draw_line (lines_origin, 22,26);
|
||||
draw_line (lines_origin, 37,41); draw_line (lines_origin, 41,42);
|
||||
draw_line (lines_origin, 38,42); draw_line (lines_origin, 37,38);
|
||||
draw_line (lines_origin, 25,41); draw_line (lines_origin, 21,37);
|
||||
draw_line (lines_origin, 26,42); draw_line (lines_origin, 22,38);
|
||||
|
||||
/* draw_line (lines_origin, step_z * w + step_y * v + step_x * u, step_z * (w + 0) + step_y * (v + 0) + step_x * (u + 1)); */
|
||||
/* draw_line (lines_origin, step_z * w + step_y * v + step_x * u, step_z * (w + 0) + step_y * (v + 1) + step_x * (u + 0)); */
|
||||
/* draw_line (lines_origin, step_z * w + step_y * v + step_x * u, step_z * (w + 1) + step_y * (v + 1) + step_x * (u + 0)); */
|
||||
/* draw_line (lines_origin, step_z * z + step_y * y + step_x * x, step_z * (w + 1) + step_y * (v + 1) + step_x * (u + 0)); */
|
||||
/* draw_line (lines_origin, step_z * z + step_y * y + step_x * x, step_z * (w + 1) + step_y * (v + 0) + step_x * (u + 1)); */
|
||||
/* draw_line (lines_origin, step_z * z + step_y * y + step_x * x, step_z * (w + 0) + step_y * (v + 1) + step_x * (u + 1)); */
|
||||
/* draw_line (lines_origin, step_z * w + step_y * v + step_x * x, step_z * (w + 1) + step_y * (v + 0) + step_x * (u + 1)); */
|
||||
/* draw_line (lines_origin, step_z * w + step_y * v + step_x * x, step_z * (w + 0) + step_y * (v + 1) + step_x * (u + 1)); */
|
||||
/* draw_line (lines_origin, step_z * w + step_y * y + step_x * u, step_z * (w + 0) + step_y * (v + 1) + step_x * (u + 1)); */
|
||||
/* draw_line (lines_origin, step_z * z + step_y * v + step_x * u, step_z * (w + 1) + step_y * (v + 1) + step_x * (u + 0)); */
|
||||
/* draw_line (lines_origin, step_z * z + step_y * v + step_x * u, step_z * (w + 1) + step_y * (v + 0) + step_x * (u + 1)); */
|
||||
/* draw_line (lines_origin, step_z * z + step_y * y + step_x * u, step_z * (w + 0) + step_y * (v + 1) + step_x * (u + 0)); */
|
||||
|
||||
if (diagonals){
|
||||
draw_line (lines_origin, step_z * w + step_y * v + step_x * u, step_z * (w + 1) + step_y * (v + 1) + step_x * (u + 1));
|
||||
draw_line (lines_origin, step_z * w + step_y * v + step_x * x, step_z * (w + 1) + step_y * (v + 1) + step_x * (u + 0));
|
||||
draw_line (lines_origin, step_z * z + step_y * v + step_x * u, step_z * (w + 0) + step_y * (v + 1) + step_x * (u + 1));
|
||||
draw_line (lines_origin, step_z * w + step_y * y + step_x * u, step_z * (w + 1) + step_y * (v + 0) + step_x * (u + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void draw_ridges_3D (long x, long y, long z,
|
||||
long step_x, long step_y, long step_z,
|
||||
|
@ -352,10 +295,6 @@ static bool draw_grids_3D (long x, long y, long z,
|
|||
for (int u = 0; u < y; u ++){
|
||||
for (int w = 0; w < x; w ++){
|
||||
calcul = step_x * w + step_y * u;
|
||||
// écriture plus concise en utilisant la fonction "draw_line(...){...}"
|
||||
// mais probablement plus lente.
|
||||
// Je commente donc la ligne "draw_line" et laisse les deux lignes suivantes actives
|
||||
// draw_line (lines_origin, calcul, calcul + step_y - step_z);
|
||||
*(lines_origin + lines_index) = calcul; lines_index ++;
|
||||
*(lines_origin + lines_index) = calcul + step_y - step_z; lines_index ++;
|
||||
}
|
||||
|
@ -395,32 +334,6 @@ static void diagonal_test(long x, long y, long z,
|
|||
|
||||
|
||||
|
||||
static void draw_an_arrow_East_or_West (GLuint *lines_origin, long s, int weight, int site)
|
||||
{
|
||||
draw_line (lines_origin, s + 2, s + 6 + site % 2);
|
||||
draw_line (lines_origin, s + 3, s + 6 + site % 2);
|
||||
|
||||
draw_line (lines_origin, s + 4, s + 6 + site % 2);
|
||||
draw_line (lines_origin, s + 5, s + 6 + site % 2);
|
||||
}
|
||||
|
||||
static void draw_an_arrow_Zenith_or_Nadir (GLuint *lines_origin, long s, int weight, int site)
|
||||
{
|
||||
draw_line (lines_origin, s + 0, s + 8 + site % 2);
|
||||
draw_line (lines_origin, s + 1, s + 8 + site % 2);
|
||||
|
||||
draw_line (lines_origin, s + 4, s + 8 + site % 2);
|
||||
draw_line (lines_origin, s + 5, s + 8 + site % 2);
|
||||
}
|
||||
|
||||
static void draw_an_arrow_North_or_South (GLuint *lines_origin, long s, int weight, int site)
|
||||
{
|
||||
draw_line (lines_origin, s + 0, s + 10 + site % 2);
|
||||
draw_line (lines_origin, s + 1, s + 10 + site % 2);
|
||||
|
||||
draw_line (lines_origin, s + 2, s + 10 + site % 2);
|
||||
draw_line (lines_origin, s + 3, s + 10 + site % 2);
|
||||
}
|
||||
|
||||
|
||||
static void draw_a_central_star(GLuint *lines_origin, long n)
|
||||
|
@ -441,123 +354,127 @@ static void draw_a_central_star(GLuint *lines_origin, long n)
|
|||
#define NORTH 5 // - z bleu
|
||||
|
||||
bool draw_some_arrows (GLuint *lines_origin, long s, long stx, long sty,
|
||||
GLuint *arrows, int arrows_nb)
|
||||
{
|
||||
long stz = 1;
|
||||
long site = 0, x = 0, y = 0, z = 0;
|
||||
GLuint *arrows, int arrows_nb) {return 1;}
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
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 >-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);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// X - X = EAST - WEST = rouge - cyan
|
||||
// Y - Y = ZENITH - NADIR = vert - magenta
|
||||
// Z - Z = SOUTH - NORTH = jaune - bleu
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void show_user_choices(long model_size_x, long model_size_y, long model_size_z,
|
||||
GLuint *arrows, int model_arrows_nb, int pref_show_grid)
|
||||
{
|
||||
printf("\nmodel + 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_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);
|
||||
if (pref_show_grid == 3) printf("pref_show_grid = %d <> show grid xz ", pref_show_grid);
|
||||
if (pref_show_grid == 5) printf("pref_show_grid = %d <> show grid yz ", 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 == 15) printf("pref_show_grid = %d <> show grids xz & yz ", pref_show_grid);
|
||||
if (model_arrows_nb > 0) printf("\n[ n] load site x y z ---- < arrows array >\
|
||||
------------------------------------------------------------\n");
|
||||
// (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++)
|
||||
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));
|
||||
|
||||
if (0) printf("NB If you play : 'draw_some_arrows(...)' and add some more arrows (in graphics.c below line 571),\
|
||||
you must also increase the number of arrows (line 555) \n\
|
||||
The 'central_stars_nb' is automatically set equal to the number_of_arrows (line 559).\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool compute_space(long model_size_x, long model_size_y, long model_size_z,
|
||||
|
||||
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,
|
||||
|
||||
GLfloat *vertex_origin, GLfloat *colors_origin,
|
||||
GLuint *lines_origin, GLuint *plans_origin)
|
||||
bool compute_space(long space_x, long space_y, long 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)
|
||||
|
||||
{
|
||||
if (0) 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);
|
||||
grids_intersections (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);
|
||||
|
||||
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, step_y = space_z + 1, step_x = (space_z + 1) * (space_y + 1);
|
||||
|
||||
long step_z = 1,
|
||||
step_y = model_size_z + 1,
|
||||
step_x = (model_size_z + 1) * (model_size_y + 1);
|
||||
draw_grids_3D (space_x, space_y, space_z, step_x, step_y, step_z, lines_origin, pref_show_grid);
|
||||
if (pref_show_grid > 0) draw_ridges_3D (space_x, space_y, space_z, step_x, step_y, step_z, lines_origin);
|
||||
long s = step_z * space_z + step_y * space_y + step_x * space_x;
|
||||
draw_a_central_star (lines_origin, s + 1 + 171 * 6);
|
||||
|
||||
draw_grids_3D (model_size_x, model_size_y, model_size_z, step_x, step_y, step_z, lines_origin, pref_show_grid);
|
||||
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);
|
||||
if (pref_test_diagonal) diagonal_test (model_size_x, model_size_y, model_size_z, step_x, step_y, step_z, lines_origin);
|
||||
|
||||
// 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);
|
||||
// if (0) 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);
|
||||
|
||||
|
||||
draw_line (lines_origin, 2800, 3500);
|
||||
draw_line (lines_origin, 3500, 2422);//
|
||||
draw_line (lines_origin, 3500, 2606);
|
||||
|
||||
|
||||
|
||||
|
||||
if (pref_test_diagonal) diagonal_test (space_x, space_y, space_z, step_x, step_y, step_z, lines_origin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// S C O R I E S --------------------------------------------------------
|
||||
|
||||
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (29 * 2 * 6)); // OK NORTH 58
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 3 * 6)); // CENTRE 57
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * ( 7 * 8 * 6)); // OK SOUTH 56
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (106 * 6 )); // Ok EAST 19 x 3 + 7 x 7 (57 + 49)
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (8 * 6)); // OK WEST 19 x 3 - 7 x 7 (57 - 49)
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (15 * 6)); // W Z
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (1 * 6)); // W A
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (49 * 6)); // S A
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (7 * 6)); // W S
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (9 * 6)); // W N
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (105 * 6)); // E S
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 6 - 12)); // E A S
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (49 * 2 * 6)); // E A S
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 6)); // E Z S << Last One
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 6 - 6)); // E A
|
||||
|
||||
|
||||
// draw_a_central_star (lines_origin, s + 1 + 3 * (19 * 6 * 4)); //
|
||||
|
||||
// draw_a_central_star (lines_origin, s + 1 + 171 * 6);
|
||||
// 4 x 6 = W 10 x 6 = A 14 x 6 = N
|
||||
// 1 x 6 = WA 3 x 6 = WS 9 x 6 = AS 15 x 6 = ZS 21 x 6 = ES
|
||||
// 0 x 6 = WAS 2 x 6 = WAN 6 x 6 = WZS 8 x 6 = WZN 12 x 6 = EZS
|
||||
// 27 x 6 > out
|
||||
|
||||
// if (0) draw_some_arrows_demo (lines_origin, s, space_x, space_y, space_z, arrows, model_arrows_nb);
|
||||
// if (0) draw_some_arrows (lines_origin, s, space_z * space_y, space_z, arrows, model_arrows_nb);
|
||||
|
||||
|
||||
// X - X = EAST - WEST = rouge - cyan
|
||||
// Y - Y = ZENITH - NADIR = vert - magenta
|
||||
// Z - Z = SOUTH - NORTH = jaune - bleu
|
||||
|
||||
|
||||
/* static void draw_an_arrow_East_or_West (GLuint *lines_origin, long s, int weight, int site) */
|
||||
/* { */
|
||||
/* draw_line (lines_origin, s + 2, s + 6 + site % 2); */
|
||||
/* draw_line (lines_origin, s + 3, s + 6 + site % 2); */
|
||||
|
||||
/* draw_line (lines_origin, s + 4, s + 6 + site % 2); */
|
||||
/* draw_line (lines_origin, s + 5, s + 6 + site % 2); */
|
||||
/* } */
|
||||
|
||||
/* static void draw_an_arrow_Zenith_or_Nadir (GLuint *lines_origin, long s, int weight, int site) */
|
||||
/* { */
|
||||
/* draw_line (lines_origin, s + 0, s + 8 + site % 2); */
|
||||
/* draw_line (lines_origin, s + 1, s + 8 + site % 2); */
|
||||
|
||||
/* draw_line (lines_origin, s + 4, s + 8 + site % 2); */
|
||||
/* draw_line (lines_origin, s + 5, s + 8 + site % 2); */
|
||||
/* } */
|
||||
|
||||
/* static void draw_an_arrow_North_or_South (GLuint *lines_origin, long s, int weight, int site) */
|
||||
/* { */
|
||||
/* draw_line (lines_origin, s + 0, s + 10 + site % 2); */
|
||||
/* draw_line (lines_origin, s + 1, s + 10 + site % 2); */
|
||||
|
||||
/* draw_line (lines_origin, s + 2, s + 10 + site % 2); */
|
||||
/* draw_line (lines_origin, s + 3, s + 10 + site % 2); */
|
||||
/* } */
|
||||
|
||||
|
|
|
@ -548,18 +548,7 @@ bool graphics_init_shaders(const void *gl_area)
|
|||
#define c_est_idiot__ce_nombre_est_donné_à_la_lecture_du_fichier_XML 0
|
||||
#define ça_me_sert_juste_à_éviter_des_erreurs_pendant_le_débuguage 0
|
||||
GLuint arrows[] = {
|
||||
/* 1, 0, 0, 0, 0, */
|
||||
/* 1, 1, 1, 0, 0, */
|
||||
/* 1, 2, 2, 1, 1, */
|
||||
/* 1, 3, 2, 2, 1, */
|
||||
// 1, 4, 3, 0, 0,
|
||||
// 1, 5, 3, 0, 1,
|
||||
/* 1, 1, 3, 0, 0, */
|
||||
/* 1, 0, 2, 0, 0, */
|
||||
/* 1, 5, 2, 1, 1, */
|
||||
/* 1, 4, 2, 1, 0, */
|
||||
/* 1, 4, 0, 1, 0, */
|
||||
/* 1, 5, 0, 1, 1, */
|
||||
// 1, 0, 0, 0, 0,
|
||||
un_nombre_ad_hoc_que_je_mets_a_la_fin_du_tableau_pour_en_mesurer_la_taille
|
||||
// load, site, x, y, z
|
||||
};
|
||||
|
@ -567,31 +556,22 @@ GLuint arrows[] = {
|
|||
static void get_model_data_and_user_preferences(){
|
||||
|
||||
|
||||
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 yet
|
||||
model_space_size_x = 7; // 0 < model_space_size_x
|
||||
model_space_size_y = 7; // 0 < model_space_size_y
|
||||
model_space_size_z = 7; // 0 < model_space_size_z
|
||||
|
||||
long arrows_array_size = 0;
|
||||
while (*(arrows + arrows_array_size) != un_nombre_ad_hoc_que_je_mets_a_la_fin_du_tableau_pour_en_mesurer_la_taille)
|
||||
arrows_array_size ++;
|
||||
printf("get_model_data_and_user_preferences (579) arrows_array_size = %ld (arrows_nb = %ld)\n", arrows_array_size, arrows_array_size / 5);
|
||||
printf("get_model_data_and_user_preferences (566) arrows_array_size = %ld (arrows_nb = %ld)\n", arrows_array_size, arrows_array_size / 5);
|
||||
|
||||
arrows_nb = arrows_array_size / 5; // assert : l'emplacement des flèches est contraint
|
||||
// par model_space_size_x, y, z et le nombre de sites
|
||||
arrows_nb = arrows_array_size / 5;
|
||||
// assert : l'emplacement des flèches est contraint par space_size_x, y, z et le nombre de sites
|
||||
|
||||
// central_stars_nb sera à calculer pour éviter de redessiner les central_stars TODO
|
||||
central_stars_nb = arrows_nb; // ! WARNING ! Pour l'instant égal au nombre de flèches !
|
||||
// (les "central stars" sont donc systématiquement redessinées
|
||||
// s'il y a plusieurs flèches dans le même cube)
|
||||
|
||||
// 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
|
||||
central_stars_nb = 1;
|
||||
pref_show_grid = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||
pref_test_diagonal = 0;
|
||||
pref_test_diagonal = 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -602,12 +582,6 @@ static void get_model_data_and_user_preferences(){
|
|||
static void compute_buffers_sizes(int model_space_size_x,
|
||||
int model_space_size_y,
|
||||
int model_space_size_z,
|
||||
|
||||
// int arrows_nb,
|
||||
|
||||
// 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
|
||||
|
@ -615,24 +589,23 @@ static void compute_buffers_sizes(int model_space_size_x,
|
|||
* (model_space_size_y + 1)
|
||||
* (model_space_size_z + 1);
|
||||
|
||||
long arrows_anchors = (model_space_size_x)
|
||||
long central_stars = (model_space_size_x)
|
||||
* (model_space_size_y)
|
||||
* (model_space_size_z)
|
||||
* (6 + 6); // 6 is to draw the small central star
|
||||
// 6 is for the six faces centers
|
||||
|
||||
// long cubes_nb = model_space_size_x * model_space_size_y * model_space_size_z;
|
||||
* 6; // 6 is to draw the small central star
|
||||
long centers = (model_space_size_x)
|
||||
* (model_space_size_y)
|
||||
* (model_space_size_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 ?)
|
||||
// NB In this git branch, I forget the six faces centers
|
||||
|
||||
buffer_vertex_size = grids_intersections * 3; // 3 numbers per vertex
|
||||
// + cubes_nb * (8 + 6) + 15 * arrows_nb;// OLD ARROWS (DEPRECATED)
|
||||
buffer_vertex_size += arrows_anchors * 3;
|
||||
|
||||
buffer_vertex_size += 8 * 3; // draw a small cube
|
||||
|
||||
|
||||
buffer_vertex_size += central_stars * 3;
|
||||
buffer_vertex_size += centers * 3;
|
||||
buffer_colors_size = buffer_vertex_size;
|
||||
|
||||
buffer_plans_size = 3;
|
||||
buffer_plans_size = 0;
|
||||
|
||||
long grids_lines =
|
||||
(pref_show_grid % 2 == 0) * (model_space_size_x + 1) * (model_space_size_y + 1)
|
||||
|
@ -647,9 +620,7 @@ static void compute_buffers_sizes(int model_space_size_x,
|
|||
|
||||
buffer_lines_size += 6 * central_stars_nb; // test central stars
|
||||
|
||||
buffer_lines_size += 8 * arrows_nb; // flèches
|
||||
|
||||
// buffer_lines_size += 16 + 20; // draw a small cube with diagonals
|
||||
buffer_lines_size += 6;
|
||||
|
||||
// buffer_lines_size -= 2; // == TEST LINES BUFFER SIZE
|
||||
|
||||
|
@ -662,128 +633,6 @@ static void compute_buffers_sizes(int model_space_size_x,
|
|||
}
|
||||
|
||||
|
||||
#define DETAIL 0
|
||||
static bool rewrite_arrow (GLuint *arrows, long address, long weight,
|
||||
long site, long x, long y, long z)
|
||||
{
|
||||
if (DETAIL) printf("write the arrow weight to %ld at (%ld, %ld, %ld, %ld)\n",\
|
||||
weight, site, x, y, z);
|
||||
|
||||
*(arrows + address + 0) = weight;
|
||||
|
||||
return 1; /* replaces the load of the existing arrow by the load 'weight' */
|
||||
}
|
||||
|
||||
static bool create_arrow (GLuint *arrows, long weight, long site, long x, long y, long z)
|
||||
{
|
||||
if (1) printf("create a new arrow with weight = %ld at (%ld, %ld, %ld, %ld)\n",\
|
||||
weight, site, x, y, z);
|
||||
|
||||
arrows_nb ++;
|
||||
if (arrows_nb == 1) arrows = g_malloc(arrows_nb * 5 * sizeof(GLuint) * 2);
|
||||
else arrows = g_realloc(arrows, arrows_nb * 5 * sizeof(GLuint) * 2);
|
||||
|
||||
buffer_lines_size += 14;
|
||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2);
|
||||
|
||||
*(arrows + arrows_nb * 5 + 0) = weight;
|
||||
*(arrows + arrows_nb * 5 + 1) = site;
|
||||
*(arrows + arrows_nb * 5 + 2) = x;
|
||||
*(arrows + arrows_nb * 5 + 3) = y;
|
||||
*(arrows + arrows_nb * 5 + 4) = z;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool erase_arrow (GLuint *arrows, long address,
|
||||
long site, long x, long y, long z)
|
||||
{
|
||||
if (DETAIL) printf("erase arrow at address %ld with values (%ld, %ld, %ld, %ld)",\
|
||||
address / 5, site, x, y, z);
|
||||
if (DETAIL) printf(" last arrow is %d, %d, %d, %d, %d\n",
|
||||
*(arrows + (arrows_nb - 1) * 5 + 0),
|
||||
*(arrows + (arrows_nb - 1) * 5 + 1),
|
||||
*(arrows + (arrows_nb - 1) * 5 + 2),
|
||||
*(arrows + (arrows_nb - 1) * 5 + 3),
|
||||
*(arrows + (arrows_nb - 1) * 5 + 4));
|
||||
|
||||
*(arrows + address + 0) = *(arrows + (arrows_nb - 1) * 5 + 0);
|
||||
*(arrows + address + 1) = *(arrows + (arrows_nb - 1) * 5 + 1);
|
||||
*(arrows + address + 2) = *(arrows + (arrows_nb - 1) * 5 + 2);
|
||||
*(arrows + address + 3) = *(arrows + (arrows_nb - 1) * 5 + 3);
|
||||
*(arrows + address + 4) = *(arrows + (arrows_nb - 1) * 5 + 4);
|
||||
|
||||
arrows_nb --;
|
||||
buffer_lines_size -= 14;
|
||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z)
|
||||
{
|
||||
if (arrows_nb <= 1) return -1;
|
||||
printf("check_for_arrow (723) arrows_nb = %ld\n", arrows_nb);
|
||||
|
||||
long address = -1, f_weight = -1, f_site = -1, f_x = -1, f_y = -1, f_z = -1;
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
f_weight = *(arrows + i * 5 + 0);
|
||||
f_site = *(arrows + i * 5 + 1);
|
||||
f_x = *(arrows + i * 5 + 2);
|
||||
f_y = *(arrows + i * 5 + 3);
|
||||
f_z = *(arrows + i * 5 + 4);
|
||||
|
||||
if (f_site == site && f_x == x && f_y == y && f_z == z) {
|
||||
address = i * 5;
|
||||
if (DETAIL) printf("arrows_nb = %ld checked arrow (%ld,%ld,%ld,%ld) found at address %ld (line %ld)",\
|
||||
arrows_nb, site, x, y, z, address, address / 5);
|
||||
if (DETAIL && f_weight > 1) printf(" weight = %ld", f_weight);
|
||||
if (DETAIL) printf("\n");
|
||||
}
|
||||
}
|
||||
return address; /* returns the address of the arrow if there is one
|
||||
* or (-1) if there is none */
|
||||
}
|
||||
|
||||
|
||||
static void show_arrows_array (GLuint *arrows, long address, long weight, long site, long x, long y, long z)
|
||||
{
|
||||
printf("\n[ n] load | site x y z ----- < arrows_nb = %ld > ------", arrows_nb);
|
||||
if (arrows_nb == 0) printf("--------------------------- no arrows\n");
|
||||
else if (address == -1) printf("--------------------------- create new arrow\n");
|
||||
else printf("--------------------------- erase arrow at address = %ld / 5\n", address);
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
printf("[%2d] = %2d | %2d, %2d, %2d, %2d ",\
|
||||
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
|
||||
if (weight == 0 && i == address / 5) printf(" <<<| < - > (%d, %d, %d, %d) @ [%ld]",\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||
if (weight > 0 && i == arrows_nb - 1) printf(" <<< < + > (%d, %d, %d, %d) @ [%ld]",\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||
if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |");
|
||||
if (weight == 0 && i == arrows_nb - 1 && i != address / 5) printf(" >>>|");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static bool set_arrow (GLuint *arrows, long weight, long site, long x, long y, long z)
|
||||
{
|
||||
long address = (check_for_arrow (arrows, site, x, y, z));
|
||||
show_arrows_array(arrows, address, weight, site, x, y, z);
|
||||
|
||||
if (address == -1 && weight == 0) return 0;
|
||||
if (address == -1 && weight > 0) return create_arrow (arrows, weight, site, x, y, z);
|
||||
if (address >= 0 && weight == 0) return erase_arrow (arrows, address, site, x, y, z);
|
||||
if (address >= 0 && weight > 0) return rewrite_arrow (arrows, address, weight, site, x, y, z);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -817,12 +666,6 @@ void graphics_init_buffers(const void *gl_area)
|
|||
compute_buffers_sizes (model_space_size_x,
|
||||
model_space_size_y,
|
||||
model_space_size_z,
|
||||
|
||||
// arrows_nb,
|
||||
|
||||
// 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);
|
||||
|
@ -837,9 +680,6 @@ void graphics_init_buffers(const void *gl_area)
|
|||
arrows,
|
||||
arrows_nb,
|
||||
|
||||
// pref_mark_unit_space,
|
||||
// pref_style_lines_planes,
|
||||
// pref_style_mix_colors,
|
||||
pref_show_grid,
|
||||
pref_test_diagonal,
|
||||
|
||||
|
@ -858,41 +698,6 @@ void graphics_init_buffers(const void *gl_area)
|
|||
model_space_size_z * model_space_size_y, model_space_size_z,
|
||||
arrows, arrows_nb);
|
||||
|
||||
// sleep(0);
|
||||
|
||||
// set_arrow(arrows, 0, 4, 3, 0, 0);
|
||||
// set_arrow(arrows, 0, 5, 3, 0, 1);
|
||||
/* set_arrow(arrows, 0, 5, 2, 1, 1); */
|
||||
/* set_arrow(arrows, 0, 4, 2, 1, 0); */
|
||||
/* set_arrow(arrows, 0, 2, 2, 1, 1); */
|
||||
/* set_arrow(arrows, 0, 3, 2, 2, 1); */
|
||||
/* set_arrow(arrows, 0, 0, 0, 0, 0); */
|
||||
/* set_arrow(arrows, 0, 1, 1, 0, 0); */
|
||||
/* set_arrow(arrows, 0, 1, 3, 0, 0); */
|
||||
/* set_arrow(arrows, 0, 0, 2, 0, 0); */
|
||||
/* set_arrow(arrows, 0, 4, 0, 1, 0); */
|
||||
/* set_arrow(arrows, 0, 5, 0, 1, 1); */
|
||||
|
||||
// sleep(0);
|
||||
|
||||
// set_arrow(arrows, 1, 0, 0, 0, 2);
|
||||
set_arrow(arrows, 4, 1, 1, 0, 2);
|
||||
|
||||
// set_arrow(arrows, 0, 0, 0, 0, 2);
|
||||
// set_arrow(arrows, 0, 1, 1, 0, 2);
|
||||
// set_arrow(arrows, 1, 2, 0, 0, 2);
|
||||
// set_arrow(arrows, 1, 3, 0, 1, 2);
|
||||
|
||||
// set_arrow(arrows, 3, 1, 1, 0, 2);
|
||||
|
||||
if (1) set_arrow(arrows, -1, -1, -1, -1, -1); // I use this to fprint the variables state
|
||||
// before "drawing_some_arrows"
|
||||
|
||||
draw_some_arrows (buffer_lines_origin, s,
|
||||
model_space_size_z * model_space_size_y, model_space_size_z,
|
||||
arrows, arrows_nb);
|
||||
|
||||
|
||||
GLuint vao, vertex_buffer, color_buffer;
|
||||
|
||||
glGenBuffers(1, &vertex_buffer);
|
||||
|
@ -995,3 +800,182 @@ void graphics_draw(const void *gl_area)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* #define DETAIL 0 */
|
||||
/* static bool rewrite_arrow (GLuint *arrows, long address, long weight, */
|
||||
/* long site, long x, long y, long z) */
|
||||
/* { */
|
||||
/* if (DETAIL) printf("write the arrow weight to %ld at (%ld, %ld, %ld, %ld)\n",\ */
|
||||
/* weight, site, x, y, z); */
|
||||
|
||||
/* *(arrows + address + 0) = weight; */
|
||||
|
||||
/* return 1; */ /* replaces the load of the existing arrow by the load 'weight' */
|
||||
/* } */
|
||||
|
||||
/* static bool create_arrow (GLuint *arrows, long weight, long site, long x, long y, long z) */
|
||||
/* { */
|
||||
/* if (1) printf("create a new arrow with weight = %ld at (%ld, %ld, %ld, %ld)\n",\ */
|
||||
/* weight, site, x, y, z); */
|
||||
|
||||
/* arrows_nb ++; */
|
||||
/* if (arrows_nb == 1) arrows = g_malloc(arrows_nb * 5 * sizeof(GLuint) * 2); */
|
||||
/* else arrows = g_realloc(arrows, arrows_nb * 5 * sizeof(GLuint) * 2); */
|
||||
|
||||
/* buffer_lines_size += 14; */
|
||||
/* buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2); */
|
||||
|
||||
/* *(arrows + arrows_nb * 5 + 0) = weight; */
|
||||
/* *(arrows + arrows_nb * 5 + 1) = site; */
|
||||
/* *(arrows + arrows_nb * 5 + 2) = x; */
|
||||
/* *(arrows + arrows_nb * 5 + 3) = y; */
|
||||
/* *(arrows + arrows_nb * 5 + 4) = z; */
|
||||
|
||||
/* return 1; */
|
||||
/* } */
|
||||
|
||||
/* static bool erase_arrow (GLuint *arrows, long address, */
|
||||
/* long site, long x, long y, long z) */
|
||||
/* { */
|
||||
/* if (DETAIL) printf("erase arrow at address %ld with values (%ld, %ld, %ld, %ld)",\ */
|
||||
/* address / 5, site, x, y, z); */
|
||||
/* if (DETAIL) printf(" last arrow is %d, %d, %d, %d, %d\n", */
|
||||
/* *(arrows + (arrows_nb - 1) * 5 + 0), */
|
||||
/* *(arrows + (arrows_nb - 1) * 5 + 1), */
|
||||
/* *(arrows + (arrows_nb - 1) * 5 + 2), */
|
||||
/* *(arrows + (arrows_nb - 1) * 5 + 3), */
|
||||
/* *(arrows + (arrows_nb - 1) * 5 + 4)); */
|
||||
|
||||
/* *(arrows + address + 0) = *(arrows + (arrows_nb - 1) * 5 + 0); */
|
||||
/* *(arrows + address + 1) = *(arrows + (arrows_nb - 1) * 5 + 1); */
|
||||
/* *(arrows + address + 2) = *(arrows + (arrows_nb - 1) * 5 + 2); */
|
||||
/* *(arrows + address + 3) = *(arrows + (arrows_nb - 1) * 5 + 3); */
|
||||
/* *(arrows + address + 4) = *(arrows + (arrows_nb - 1) * 5 + 4); */
|
||||
|
||||
/* arrows_nb --; */
|
||||
/* buffer_lines_size -= 14; */
|
||||
/* buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint) * 2); */
|
||||
|
||||
/* return 1; */
|
||||
/* } */
|
||||
|
||||
/* static long check_for_arrow (GLuint *arrows, long site, long x, long y, long z) */
|
||||
/* { */
|
||||
/* if (arrows_nb <= 1) return -1; */
|
||||
/* printf("check_for_arrow (723) arrows_nb = %ld\n", arrows_nb); */
|
||||
|
||||
/* long address = -1, f_weight = -1, f_site = -1, f_x = -1, f_y = -1, f_z = -1; */
|
||||
/* for (int i = 0; i < arrows_nb; i++) */
|
||||
/* { */
|
||||
/* f_weight = *(arrows + i * 5 + 0); */
|
||||
/* f_site = *(arrows + i * 5 + 1); */
|
||||
/* f_x = *(arrows + i * 5 + 2); */
|
||||
/* f_y = *(arrows + i * 5 + 3); */
|
||||
/* f_z = *(arrows + i * 5 + 4); */
|
||||
|
||||
/* if (f_site == site && f_x == x && f_y == y && f_z == z) { */
|
||||
/* address = i * 5; */
|
||||
/* if (DETAIL) printf("arrows_nb = %ld checked arrow (%ld,%ld,%ld,%ld) found at address %ld (line %ld)",\ */
|
||||
/* arrows_nb, site, x, y, z, address, address / 5); */
|
||||
/* if (DETAIL && f_weight > 1) printf(" weight = %ld", f_weight); */
|
||||
/* if (DETAIL) printf("\n"); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return address; returns the address of the arrow if there is one
|
||||
/* or (-1) if there is none */
|
||||
/* } */
|
||||
|
||||
|
||||
/* static void show_arrows_array (GLuint *arrows, long address, long weight, long site, long x, long y, long z) */
|
||||
/* { */
|
||||
/* printf("\n[ n] load | site x y z ----- < arrows_nb = %ld > ------", arrows_nb); */
|
||||
/* if (arrows_nb == 0) printf("--------------------------- no arrows\n"); */
|
||||
/* else if (address == -1) printf("--------------------------- create new arrow\n"); */
|
||||
/* else printf("--------------------------- erase arrow at address = %ld / 5\n", address); */
|
||||
|
||||
/* for (int i = 0; i < arrows_nb; i++) */
|
||||
/* { */
|
||||
/* printf("[%2d] = %2d | %2d, %2d, %2d, %2d ",\ */
|
||||
/* i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
|
||||
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4)); */
|
||||
/* if (weight == 0 && i == address / 5) printf(" <<<| < - > (%d, %d, %d, %d) @ [%ld]",\ */
|
||||
/* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
|
||||
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */
|
||||
/* if (weight > 0 && i == arrows_nb - 1) printf(" <<< < + > (%d, %d, %d, %d) @ [%ld]",\ */
|
||||
/* *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ */
|
||||
/* *(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5); */
|
||||
/* if (weight == 0 && i > address / 5 && i < arrows_nb - 1) printf(" |"); */
|
||||
/* if (weight == 0 && i == arrows_nb - 1 && i != address / 5) printf(" >>>|"); */
|
||||
/* printf("\n"); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
/* static bool set_arrow (GLuint *arrows, long weight, long site, long x, long y, long z) */
|
||||
/* { */
|
||||
/* long address = (check_for_arrow (arrows, site, x, y, z)); */
|
||||
/* show_arrows_array(arrows, address, weight, site, x, y, z); */
|
||||
|
||||
/* if (address == -1 && weight == 0) return 0; */
|
||||
/* if (address == -1 && weight > 0) return create_arrow (arrows, weight, site, x, y, z); */
|
||||
/* if (address >= 0 && weight == 0) return erase_arrow (arrows, address, site, x, y, z); */
|
||||
/* if (address >= 0 && weight > 0) return rewrite_arrow (arrows, address, weight, site, x, y, z); */
|
||||
|
||||
/* return 0; */
|
||||
/* } */
|
||||
|
||||
|
|
Loading…
Reference in New Issue