WIP: Suffisament propre pour mériter un commit.

This commit is contained in:
Jean Sirmai 2023-10-12 09:30:13 +02:00
parent 36ecfb7041
commit f223dd4433
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 44 additions and 16 deletions

View File

@ -872,7 +872,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
int rand(void);
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
int arbitrary = 13;
int arbitrary = 20;
int space_X = 1 + rand() % arbitrary,
space_Y = 1 + rand() % arbitrary,
space_Z = 1 + rand() % arbitrary;

View File

@ -52,29 +52,57 @@ void write_space_ridges (long offset_vertex, long offset_lines, long x, long y,
void write_space_faces_grids (long offset_vertex, long offset_lines, long x, long y, long z)
{
float i, j, k, vx, vy, vz, max = fmax(x, y);
max = fmax(max, z);
float i, max = fmax(x, y); max = fmax(max, z);
for (i = 1; i < x; i++) {
vx = (2 * i / x - 1) * x / max; vy = - y / max; vz = - z / max;
graphics_write_vertex (vx, vy, vz);
vx = (2 * i / x - 1) * x / max; vy = - y / max; vz = + z / max;
graphics_write_vertex (vx, vy, vz);
vx = (2 * i / x - 1) * x / max; vy = + y / max; vz = + z / max;
graphics_write_vertex (vx, vy, vz);
vx = (2 * i / x - 1) * x / max; vy = + y / max; vz = - z / max;
graphics_write_vertex (vx, vy, vz);
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max);
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, z / max);
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, z / max);
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, - z / max);
}
for (i = 0; i < x; i ++) {
/* for (i = 0; i < x; i ++) { */
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); */
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); */
/* graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); */
/* } */
offset_vertex += (x - 1) * 4;
for (i = 1; i < y; i++) {
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max);
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, z / max);
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, z / max);
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max);
}
for (i = 0; i < y - 1; i ++) {
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
}
offset_vertex += (y - 1) * 4;
for (i = 1; i < z; i++) {
graphics_write_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max);
graphics_write_vertex (- x / max, y / max, (2 * i / z - 1) * z / max);
graphics_write_vertex ( x / max, y / max, (2 * i / z - 1) * z / max);
graphics_write_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max);
}
for (i = 0; i <= z; i ++) {
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); */
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
}
}