WIP: ébauche 'quadrillage' <> base de travail

This commit is contained in:
Jean Sirmai 2023-07-17 15:47:14 +02:00
parent 0da70e312c
commit 114e2ccef5
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 95 additions and 34 deletions

View File

@ -50,13 +50,14 @@ int lines_ndx = 0;
int plans_ndx = 0;
#define EDGE 0.999999
#define CORRC 1.1
#define S 0
#define S3 1
#define SA 1
#define A3 0
#define L 1
#define L 0
#define V 0
#define C 0
#define P 0
@ -266,6 +267,31 @@ static int compute_arrow_2D(int space_size_x,
/* 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,
int space_size_y,
int space_size_z,
@ -279,18 +305,25 @@ static bool compute_space_3D (int space_size_x,
GLubyte *line_origin,
GLubyte *plan_origin)
{
printf("vertex [x*y*z] > ");
float x = 0, y = 0, z = 0;
int max = 0, c = 0; // TODO max = math.max(max, space_size_x);
for (c = 0; c <= space_size_x; c++) if (c > max) max = c;
for (c = 0; c <= space_size_y; c++) if (c > max) max = c;
for (c = 0; c <= space_size_z; c++) if (c > max) max = c;
printf("max(%d,%d,%d) = %d;\n", space_size_x, space_size_y, space_size_z, max);
for (int i = 0; i <= space_size_x; i++)
float x = 0, y = 0, z = 0, maximum = max * CORRC;
for (int i = 0; i <= space_size_x; i++){
for (int j = 0; j <= space_size_y; j++)
for (int k = 0; k <= space_size_z; k++){
printf("[%d*%d*%d] ", i, j, k);
printf("(%d*%d*%d)<>", i, j, k);
x = (i * 2 - space_size_x / 2) * EDGE / 2;
y = (j * 2 - space_size_y / 2) * EDGE / 2;
z = (k * 2 - space_size_z / 2) * EDGE / 2;
x = (2 * i / space_size_x - 1) * (space_size_x / maximum);
y = (2 * j / space_size_y - 1) * (space_size_y / maximum);
z = (2 * k / space_size_z - 1) * (space_size_z / maximum);
printf("[%0.00f %0.00f %0.00f] ", x, y, z);
*(vertex_origin + vertex_ndx + 0) = x;
*(vertex_origin + vertex_ndx + 1) = y;
@ -298,6 +331,10 @@ static bool compute_space_3D (int space_size_x,
vertex_ndx += 3; // if (V) printf(" => vertex_ndx = %3d space_3D\n", vertex_ndx);
}
printf("\n");
*(color_origin + colors_ndx + 0) = 1.0f * x ;
*(color_origin + colors_ndx + 1) = 0.0f * y;
*(color_origin + colors_ndx + 2) = 0.0f * z;
@ -305,33 +342,55 @@ static bool compute_space_3D (int space_size_x,
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);
}
int u = 3; // '9' marche aussi (je n'ai pas été plus loin)
*(line_origin + lines_ndx + 0) = 1 + u; *(line_origin + lines_ndx + 1) = 2 + u; lines_ndx += 2;
*(line_origin + lines_ndx + 0) = 3 + u; *(line_origin + lines_ndx + 1) = 4 + u; lines_ndx += 2;
*(line_origin + lines_ndx + 0) = 5 + u; *(line_origin + lines_ndx + 1) = 6 + u; lines_ndx += 2;
if (S3) printf("space 3D buffer_lines (from-to) ");
for (int v = 0; v < space_size_x + 2; v++) {
if (S3) printf("(%d-%d) ", *(line_origin + v), *(line_origin + v + 1));
*(line_origin + lines_ndx + 0) = 2 + u; *(line_origin + lines_ndx + 1) = 4 + u; lines_ndx += 2;
*(line_origin + lines_ndx + 0) = 1 + u; *(line_origin + lines_ndx + 1) = 3 + u; lines_ndx += 2;
//if (S3) printf("space 3D buffer_lines (from-to) ");
for (int v = 0; v < lines_ndx / 2; v ++) {
if (S3) printf("(%d-%d) ", *(line_origin + 2 * v), *(line_origin + 2 * v + 1));
}
if (S3) printf("\n");
return 1;
}
static bool compute_arrow_3D(int space_size_x,
int space_size_y,
int space_size_z,

View File

@ -523,10 +523,10 @@ bool graphics_init_shaders(const void *gl_area)
GLubyte arrows[] = {
1, 1, 0, 0, 0,
1, 0, 0, 0, 0,
1, 2, 4, 0, 0,
1, 0, 0, 1, 0,
1, 1, 0, 0, 0,
1, 0, 1, 0, 0,
1, 1, 1, 0, 0,
1, 2, 0, 3, 0,
1, 0, 0, 4, 0,
1, 1, 3, 4, 0,
@ -539,10 +539,10 @@ GLubyte arrows[] = {
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 = 2; // 0 < model_space_size_y
model_space_size_z = 1; // 0 < model_space_size_z
model_arrows_nb = 2; // assert : l'emplacement des flèches est contraint
model_arrows_nb = 4; // assert : l'emplacement des flèches est contraint
// 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
@ -613,7 +613,9 @@ static void compute_buffers_sizes(int model_space_size_x,
- model_space_size_x
- model_space_size_y
- model_space_size_z
+ 3; // je suis en 2D
+ 3
+ 20; // je suis en 2D
// pourquoi est-ce possible ?
buffer_lines_size += 8 * pref_mark_unit_space; // 8 because 4 diagonal lines