WIP: Bon. Quelque chose se dessine... Pas ce que je voudrais, mais...
This commit is contained in:
parent
a017c91699
commit
03982e911c
|
@ -52,11 +52,11 @@ int plans_ndx = 0;
|
||||||
#define EDGE 0.999999
|
#define EDGE 0.999999
|
||||||
|
|
||||||
#define S 0
|
#define S 0
|
||||||
#define S3 0
|
#define S3 1
|
||||||
#define SA 1
|
#define SA 1
|
||||||
#define A3 0
|
#define A3 0
|
||||||
|
|
||||||
#define L 0
|
#define L 1
|
||||||
#define V 0
|
#define V 0
|
||||||
#define C 0
|
#define C 0
|
||||||
#define P 0
|
#define P 0
|
||||||
|
@ -259,6 +259,13 @@ static int compute_arrow_2D(int space_size_x,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* x = - ((space_size_x % 2) * (space_size_x / 2 - i) */
|
||||||
|
/* - (space_size_x % 2 - 1) * (i + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE; */
|
||||||
|
/* y = - ((space_size_y % 2) * (space_size_y / 2 - j) */
|
||||||
|
/* - (space_size_y % 2 - 1) * (j + 0.5f - space_size_y / 2)) / space_size_y * 2 * EDGE; */
|
||||||
|
/* z = - ((space_size_z % 2) * (space_size_z / 2 - k) */
|
||||||
|
/* - (space_size_z % 2 - 1) * (k + 0.5f - space_size_z / 2)) / space_size_z * 2 * EDGE; */
|
||||||
|
|
||||||
static bool compute_space_3D (int space_size_x,
|
static bool compute_space_3D (int space_size_x,
|
||||||
int space_size_y,
|
int space_size_y,
|
||||||
int space_size_z,
|
int space_size_z,
|
||||||
|
@ -272,142 +279,49 @@ static bool compute_space_3D (int space_size_x,
|
||||||
GLubyte *line_origin,
|
GLubyte *line_origin,
|
||||||
GLubyte *plan_origin)
|
GLubyte *plan_origin)
|
||||||
{
|
{
|
||||||
|
printf("\n");
|
||||||
float x = 0, y = 0, z = 0;
|
float x = 0, y = 0, z = 0;
|
||||||
|
|
||||||
for (int i = 0; i < space_size_x; i++)
|
for (int i = 0; i < space_size_x; i++)
|
||||||
for (int j = 0; j < space_size_y; j++)
|
for (int j = 0; j < space_size_y; j++)
|
||||||
for (int k = 0; k < space_size_z; k++)
|
for (int k = 0; k < space_size_z; k++){
|
||||||
{
|
|
||||||
|
|
||||||
x = - ((space_size_x % 2) * (space_size_x / 2 - i)
|
printf("[%d*%d*%d] ", i, j, k);
|
||||||
- (space_size_x % 2 - 1) * (i + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE;
|
|
||||||
y = - ((space_size_x % 2) * (space_size_x / 2 - j)
|
|
||||||
- (space_size_x % 2 - 1) * (j + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE;
|
|
||||||
z = - ((space_size_x % 2) * (space_size_x / 2 - k)
|
|
||||||
- (space_size_x % 2 - 1) * (k + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE;
|
|
||||||
// x = (i - space_size_x / 2) * EDGE / 2;
|
|
||||||
// y = (j - space_size_y / 2) * EDGE / 2;
|
|
||||||
// z = (k - space_size_z / 2) * EDGE / 2;
|
|
||||||
|
|
||||||
if (S3) printf("[%1.1f * %1.1f * %1.1f] ", x, y, z);
|
x = (i * 2 - space_size_x / 2) * EDGE / 2;
|
||||||
if (S3 && i == space_size_x - 1) printf("\n");
|
y = (j * 2 - space_size_y / 2) * EDGE / 2;
|
||||||
|
z = (k * 2 - space_size_z / 2) * EDGE / 2;
|
||||||
|
|
||||||
/* *(vertex_origin + i + j + k + 0) = x; */
|
*(vertex_origin + vertex_ndx + 0) = x;
|
||||||
/* *(vertex_origin + i + j + k + 1) = y; */
|
*(vertex_origin + vertex_ndx + 1) = y;
|
||||||
/* *(vertex_origin + i + j + k + 2) = z; */
|
*(vertex_origin + vertex_ndx + 2) = z;
|
||||||
|
|
||||||
/* vertex_ndx += 3; // if (V) printf(" => vertex_ndx = %3d space_3D\n", vertex_ndx); */
|
vertex_ndx += 3; // if (V) printf(" => vertex_ndx = %3d space_3D\n", vertex_ndx);
|
||||||
|
|
||||||
*(color_origin + k * 12 + 9) = 0;
|
*(color_origin + colors_ndx + 0) = 0.6f * x ;
|
||||||
*(color_origin + k * 12 + 10) = 0;
|
*(color_origin + colors_ndx + 1) = 0.1f * y;
|
||||||
*(color_origin + k * 12 + 11) = 1;
|
*(color_origin + colors_ndx + 2) = 0.1f * z;
|
||||||
|
|
||||||
colors_ndx += 3; // if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
colors_ndx += 3; // if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
||||||
|
};
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
for (int i = 0; i < space_size_x; i++){
|
||||||
|
*(line_origin + lines_ndx + 0) = i * 2 + 0;
|
||||||
|
*(line_origin + lines_ndx + 1) = i * 2 + 1;
|
||||||
|
lines_ndx += 2; if (L) printf("|=> lines_ndx = %3d space 3D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < space_size_y; i++){
|
||||||
|
*(line_origin + lines_ndx + 0) = i * 2 + 0;
|
||||||
|
*(line_origin + lines_ndx + 1) = i * 2 + 1;
|
||||||
|
lines_ndx += 2; if (L) printf("|=> lines_ndx = %3d space 3D\n", lines_ndx);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < space_size_z; i++){
|
||||||
|
*(line_origin + lines_ndx + 0) = i * 2 + 0;
|
||||||
|
*(line_origin + lines_ndx + 1) = i * 2 + 1;
|
||||||
|
lines_ndx += 2; if (L) printf("|=> lines_ndx = %3d space 3D\n", lines_ndx);
|
||||||
}
|
}
|
||||||
|
|
||||||
*(color_origin + 0) = 0;
|
|
||||||
*(color_origin + 1) = 0;
|
|
||||||
*(color_origin + 2) = 0;
|
|
||||||
|
|
||||||
*(color_origin + 3) = 1;
|
|
||||||
*(color_origin + 4) = 1;
|
|
||||||
*(color_origin + 5) = 1;
|
|
||||||
|
|
||||||
*(color_origin + 6) = 0;
|
|
||||||
*(color_origin + 7) = 0;
|
|
||||||
*(color_origin + 8) = 0;
|
|
||||||
|
|
||||||
*(color_origin + 9) = 1;
|
|
||||||
*(color_origin + 10) = 1;
|
|
||||||
*(color_origin + 11) = 1;
|
|
||||||
|
|
||||||
colors_ndx += 12; if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
|
||||||
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 0) = 1;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 1) = 1;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 2) = 1;
|
|
||||||
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 3) = 0;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 4) = 0;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 5) = 0;
|
|
||||||
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 6) = 0;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 7) = 0;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 8) = 0;
|
|
||||||
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 9) = 1;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 10) = 1;
|
|
||||||
*(color_origin + (space_size_x - 1) * 12 + 11) = 1;
|
|
||||||
|
|
||||||
colors_ndx += 12; if (C) printf(" => colors_ndx = %d\n", colors_ndx);
|
|
||||||
|
|
||||||
if (S3) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x);
|
|
||||||
|
|
||||||
// pourquoi je ne vois pas la ligne suivante ???
|
|
||||||
// *(line_origin + 4) = 0;
|
|
||||||
// *(line_origin + 5) = space_size_x * 4 - 4; // barre horizontale du bas arr
|
|
||||||
|
|
||||||
*(line_origin + 6) = 1;
|
|
||||||
*(line_origin + 7) = space_size_x * 4 - 3; // barre horizontale du haut arr
|
|
||||||
|
|
||||||
*(line_origin + 0) = 2;
|
|
||||||
*(line_origin + 1) = space_size_x * 4 - 2; // barre horizontale du bas av
|
|
||||||
|
|
||||||
*(line_origin + 2) = 3;
|
|
||||||
*(line_origin + 3) = space_size_x * 4 - 1; // barre horizontale du haut av
|
|
||||||
|
|
||||||
lines_ndx += 8; if (L) printf("|=> lines_ndx = %3d space 3D\n", lines_ndx);
|
|
||||||
|
|
||||||
/* *(plan_origin + 0) = 0; */
|
|
||||||
/* *(plan_origin + 1) = 1; */
|
|
||||||
/* *(plan_origin + 2) = 2; */
|
|
||||||
|
|
||||||
/* *(plan_origin + 3) = 0; */
|
|
||||||
/* *(plan_origin + 4) = 1; */
|
|
||||||
/* *(plan_origin + 5) = 3; */
|
|
||||||
// plans_ndx += 6; if (P) printf("|=> plans_ndx = %d\n", plans_ndx);
|
|
||||||
|
|
||||||
|
|
||||||
/* for (int k = 8; k <= space_size_x * 8; k += 8){ // for (int k = 8; k < space_size_x * 8; k += 8){ */
|
|
||||||
|
|
||||||
|
|
||||||
/* *(line_origin + k + 0) = k / 2 - 4; // + 0; */
|
|
||||||
/* *(line_origin + k + 1) = k / 2 - 2; // + 2; */
|
|
||||||
|
|
||||||
/* *(line_origin + k + 2) = k / 2 - 3; // + 1; */
|
|
||||||
/* *(line_origin + k + 3) = k / 2 - 1; // + 3; */
|
|
||||||
|
|
||||||
/* *(line_origin + k + 4) = k / 2 - 4; // + 0; */
|
|
||||||
/* *(line_origin + k + 5) = k / 2 - 1; // + 3; */
|
|
||||||
|
|
||||||
/* *(line_origin + k + 6) = k / 2 - 3; // + 1; */
|
|
||||||
/* *(line_origin + k + 7) = k / 2 - 2; // + 2; */
|
|
||||||
|
|
||||||
/* lines_ndx += 8; if (L) printf("|=> lines_ndx = %3d space_3D\n", lines_ndx); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) { */
|
|
||||||
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro */
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 3) = 0 + 1; */
|
|
||||||
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 2) = 0 + 2; // diagonales pour marquer la case zéro */
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 1) = 0 + 3; */
|
|
||||||
|
|
||||||
/* lines_ndx += 4; if (L) printf("|=> lines_ndx = %3d space_3D\n", lines_ndx); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
/* if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) { */
|
|
||||||
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 8) = (space_size_x - 1) * 4 + 0; // diagonales pour marquer la case finale */
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 7) = (space_size_x - 1) * 4 + 1; */
|
|
||||||
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 6) = (space_size_x - 1) * 4 + 2; // diagonales pour marquer la case finale */
|
|
||||||
/* *(line_origin + (2 + space_size_x) * 8 - 5) = (space_size_x - 1) * 4 + 3; */
|
|
||||||
|
|
||||||
/* lines_ndx += 4; if (L) printf("|=> lines_ndx = %3d space_3D\n", lines_ndx); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
if (S3) printf("space 3D buffer_lines (from-to) ");
|
if (S3) printf("space 3D buffer_lines (from-to) ");
|
||||||
for (int v = 0; v < space_size_x + 2; v++) {
|
for (int v = 0; v < space_size_x + 2; v++) {
|
||||||
|
@ -531,15 +445,15 @@ static void show_user_choices(int model_space_size_x,
|
||||||
int pref_style_lines_planes,
|
int pref_style_lines_planes,
|
||||||
int pref_style_mix_colors)
|
int pref_style_mix_colors)
|
||||||
{
|
{
|
||||||
printf("model + user constraints : x,y,z = (%d, %d, %d) ", model_space_size_x, model_space_size_y, model_space_size_z);
|
printf("model + user constraints : space size x,y,z = %d,%d,%d ", model_space_size_x, model_space_size_y, model_space_size_z);
|
||||||
if (model_arrows_nb > 0) printf("[%d] arrows ", model_arrows_nb);
|
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 == 0) printf("no unit_space marks ");
|
||||||
if (pref_mark_unit_space == 1) printf("first unit space marked ");
|
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 == 2) printf("last unit_space marked ");
|
||||||
if (pref_mark_unit_space == 3) printf("first and last units space marked ");
|
if (pref_mark_unit_space == 3) printf("first and last units space marked ");
|
||||||
if (! pref_style_lines_planes) printf("style_lines_planes = 0 ");
|
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_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes);
|
||||||
if (! pref_style_mix_colors) printf("style_mix_colors = 0 ");
|
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_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
|
||||||
if (model_arrows_nb > 0) printf("\n[ n] load site x y z ---- < arrows array >\
|
if (model_arrows_nb > 0) printf("\n[ n] load site x y z ---- < arrows array >\
|
||||||
------------------------------------------------------------\n");
|
------------------------------------------------------------\n");
|
||||||
|
@ -577,7 +491,7 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
pref_style_lines_planes,
|
pref_style_lines_planes,
|
||||||
pref_style_mix_colors);
|
pref_style_mix_colors);
|
||||||
|
|
||||||
compute_space_2D (model_space_size_x,
|
compute_space_3D (model_space_size_x,
|
||||||
model_space_size_y,
|
model_space_size_y,
|
||||||
model_space_size_z,
|
model_space_size_z,
|
||||||
|
|
||||||
|
@ -591,15 +505,15 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
plan_origin);
|
plan_origin);
|
||||||
|
|
||||||
for (int i = 0; i < model_arrows_nb; i++)
|
for (int i = 0; i < model_arrows_nb; i++)
|
||||||
compute_arrow_2D (model_space_size_x,
|
compute_arrow_3D (model_space_size_x,
|
||||||
model_space_size_y,
|
model_space_size_y,
|
||||||
model_space_size_z,
|
model_space_size_z,
|
||||||
|
|
||||||
*(arrows + i * 5 + 0), // weight (load)
|
*(arrows + i * 5 + 0), // weight (load)
|
||||||
*(arrows + i * 5 + 1), // site
|
*(arrows + i * 5 + 1), // site
|
||||||
*(arrows + i * 5 + 2), // x
|
*(arrows + i * 5 + 2), // x
|
||||||
*(arrows + i * 5 + 2), // y
|
*(arrows + i * 5 + 3), // y
|
||||||
*(arrows + i * 5 + 2), // z
|
*(arrows + i * 5 + 4), // z
|
||||||
|
|
||||||
pref_style_lines_planes,
|
pref_style_lines_planes,
|
||||||
pref_style_mix_colors,
|
pref_style_mix_colors,
|
||||||
|
|
|
@ -540,9 +540,9 @@ GLubyte arrows[] = {
|
||||||
static void get_model_data_and_user_preferences(){
|
static void get_model_data_and_user_preferences(){
|
||||||
|
|
||||||
model_space_size_x = 3; // 1 < model_space_size_x
|
model_space_size_x = 3; // 1 < model_space_size_x
|
||||||
model_space_size_y = 0; // 1 < model_space_size_y
|
model_space_size_y = 2; // 1 < model_space_size_y
|
||||||
model_space_size_z = 0; // 1 < model_space_size_z
|
model_space_size_z = 1; // 1 < model_space_size_z
|
||||||
model_arrows_nb = 2; // assert : l'emplacement des flèches est contraint
|
model_arrows_nb = 1; // 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
|
||||||
|
|
||||||
// pref_1D_shown_as_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D
|
// pref_1D_shown_as_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D
|
||||||
|
@ -613,22 +613,21 @@ static void compute_buffers_sizes(int model_space_size_x,
|
||||||
- model_space_size_x
|
- model_space_size_x
|
||||||
- model_space_size_y
|
- model_space_size_y
|
||||||
- model_space_size_z
|
- model_space_size_z
|
||||||
+ 2; // je suis en 2D
|
+ 3; // je suis en 2D
|
||||||
// pourquoi est-ce possible ?
|
// pourquoi est-ce possible ?
|
||||||
buffer_lines_size += 8 * pref_mark_unit_space; // 8 because 4 diagonal lines
|
buffer_lines_size += 8 * pref_mark_unit_space; // 8 because 4 diagonal lines
|
||||||
|
|
||||||
buffer_vertex_size += model_arrows_nb * 9; // je suis en 2D
|
// buffer_vertex_size += model_arrows_nb * 9; // je suis en 2D
|
||||||
// buffer_vertex_size += model_arrows_nb * 15 - 3; // - 2, + 3 ou -8 == Ad Hoc !
|
buffer_vertex_size += model_arrows_nb * 15;
|
||||||
buffer_colors_size += model_arrows_nb * 15;
|
buffer_colors_size += model_arrows_nb * 15;
|
||||||
buffer_plans_size += 0;
|
buffer_plans_size += 0;
|
||||||
buffer_lines_size += model_arrows_nb * 6; // je suis en 2D
|
// buffer_lines_size += model_arrows_nb * 6; // je suis en 2D
|
||||||
// buffer_lines_size += model_arrows_nb * 16;
|
buffer_lines_size += model_arrows_nb * 16;
|
||||||
|
|
||||||
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
|
||||||
%4d/2 = %3d lines, %4d/3 = %3d plans. (space size = %d x %d x %d)\n",\
|
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",\
|
||||||
buffer_vertex_size, buffer_vertex_size / 3, buffer_colors_size, buffer_colors_size / 3,
|
buffer_vertex_size, buffer_vertex_size / 3, buffer_colors_size, buffer_colors_size / 3,
|
||||||
buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3,
|
buffer_lines_size, buffer_lines_size / 2, buffer_plans_size, buffer_plans_size / 3);
|
||||||
model_space_size_x, model_space_size_y, model_space_size_z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue