From 8f7ee02cdd761920f756da02a93ac1291b96cf9e Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Mon, 16 Oct 2023 11:17:46 +0200 Subject: [PATCH] OK (space & arrows) pour de petits nombres. Nettoyage en cours. --- include/arrows.h | 53 +------------ include/grid.h | 46 +---------- src/graphics/arrows.c | 100 ++++------------------- src/graphics/graphics.c | 115 ++++++++------------------- src/graphics/grid.c | 171 ---------------------------------------- 5 files changed, 54 insertions(+), 431 deletions(-) diff --git a/include/arrows.h b/include/arrows.h index a1f35ae..dd289d4 100644 --- a/include/arrows.h +++ b/include/arrows.h @@ -38,58 +38,7 @@ typedef struct arrow_t { GLuint z; }; -/* - * Writes basis and tip for all arrows into vertex and color buffers - * - * @param dimensions (x,y,z) - * - * @return void - */ -void arrows_write_terminations (long x, long y, long z); - -/* - * Writes lines for arrow oriented to the east or west into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_east_west (long s, int weight, int site); - -/* - * Writes lines for arrow oriented to the zenith or nadir into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_zenith_nadir (long s, int weight, int site); - -/* - * Writes lines for arrow oriented to the south or north into lines buffer - * - * @param s, - * weight, - * site - * - * @return void - */ -void write_arrow_lines_south_north (long s, int weight, int site); - -/* - * Writes three lines that draw arrow basis (central star) into lines buffer - * - * @param n - * - * @return void - */ -void arrows_write_basis (long n); - -int write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, +int write_one_arrow(int offset_vertex, int space_X, int space_Y, int space_Z, int weight, int site, int x, int y, int z); diff --git a/include/grid.h b/include/grid.h index bd3f45a..ae7f021 100644 --- a/include/grid.h +++ b/include/grid.h @@ -27,19 +27,6 @@ #include #include -int write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z); - -long write_grids_on_space_faces (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style); - -/* - * Writes grid lines intersections to vertex and color buffers - * - * @param coords long (x,y,z) - * - * @return void - */ -void grid_write_intersections (long x, long y, long z); - /* * Writes grid ridges to vertex and color buffers * @@ -47,41 +34,14 @@ void grid_write_intersections (long x, long y, long z); * * @return void */ -void grid_write_ridges (long x, long y, long z); +int write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z); /* - * Writes marks (each space unit) along space ridges - * - * @param coords long (x,y,z) // , step_x, step_y, step_z - * - * @return void - */ -void grid_write_marks (long x, long y, long z); - - -/* - * Writes grid lines for x axis to vertex and color buffers + * Writes grid lines on space faces * * @param coords long (x,y,z) * * @return void */ -void grid_write_x (long x, long y, long z); +long write_grids_on_space_faces (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style); -/* - * Writes grid lines for y axis to vertex and color buffers - * - * @param coords long (x,y,z) - * - * @return void - */ -void grid_write_y (long x, long y, long z); - -/* - * Writes grid lines for z axis to vertex and color buffers - * - * @param coords long (x,y,z) - * - * @return void - */ -void grid_write_z (long x, long y, long z); diff --git a/src/graphics/arrows.c b/src/graphics/arrows.c index f7dda51..90e1507 100644 --- a/src/graphics/arrows.c +++ b/src/graphics/arrows.c @@ -19,7 +19,7 @@ * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License - * aint with this program. If not, see . + * along with this program. If not, see . */ #include "../../include/base.h" @@ -40,64 +40,7 @@ * * @return void */ -void arrows_write_terminations (long x, long y, long z) -{ - float max, i, j, k, vx, vy, vz, arrow_basis_width, arrow_tip_padding, nuance = 0.24f; - max = fmax(x, y); max = fmax(max, z); - - // arrow_basis_width donne la dimension de l'étoile centrale - arrow_basis_width = 0.3f * (1 / max), - - // décale légèrement les pointes des flèches - // pour qu'elles n'aillent pas jusqu'aux faces des cubes - arrow_tip_padding = 0.1 * (1 / max); - - 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 + (1 / max); - vy = (2 * j / y - 1) * y / max + (1 / max); - vz = (2 * k / z - 1) * z / max + (1 / max); - - // X - X axis - central star (basis) - graphics_write_vertex(vx + arrow_basis_width, vy, vz); - graphics_write_vertex(vx - arrow_basis_width, vy, vz); - graphics_write_color(0.3f, 0.3f, 0.3f); - graphics_write_color(0.3f, 0.3f, 0.3f); - - // Y - Y axis - central star (basis) - graphics_write_vertex(vx, vy + arrow_basis_width, vz); - graphics_write_vertex(vx, vy - arrow_basis_width, vz); - graphics_write_color(0.3f, 0.3f, 0.3f); - graphics_write_color(0.3f, 0.3f, 0.3f); - - // Z - Z axis - central star (basis) - graphics_write_vertex(vx, vy, vz + arrow_basis_width); - graphics_write_vertex(vx, vy, vz - arrow_basis_width); - graphics_write_color(0.3f, 0.3f, 0.3f); - graphics_write_color(0.3f, 0.3f, 0.3f); - - // X - X (EAST - WEST) axis - arrows tips (red - green) - graphics_write_vertex (vx + (1 / max) - arrow_tip_padding, vy, vz); - graphics_write_vertex (vx - (1 / max) + arrow_tip_padding, vy, vz); - graphics_write_color(1.0f - nuance / 3, 0.0f + nuance, 0.0f + nuance); - graphics_write_color(0.0f + nuance, 1.0f - nuance, 1.0f - nuance); - - // Y - Y (ZENITH - NADIR) axis - arrows tips (cyan - magenta) - graphics_write_vertex (vx, vy + (1 / max) - arrow_tip_padding, vz); - graphics_write_vertex (vx, vy - (1 / max) + arrow_tip_padding, vz); - graphics_write_color(0.0f + nuance, 1.0f - nuance / 3, 0.0f + nuance); - graphics_write_color(1.0f - nuance, 0.0f + nuance, 1.0f - nuance); - - // Z - Z (NORTH - SOUTH) axis - arrows tips (blue - yellow) - graphics_write_vertex (vx, vy, vz + (1 / max) - arrow_tip_padding); - graphics_write_vertex (vx, vy, vz - (1 / max) + arrow_tip_padding); - graphics_write_color(0.0f + nuance, 0.0f + nuance, 1.0f - nuance / 4); - graphics_write_color(1.0f - nuance / 3, 1.0f - nuance / 3, 0.0f + nuance); - }; -} /* * Writes lines for arrow oriented towards east or west into lines buffer @@ -108,7 +51,7 @@ void arrows_write_terminations (long x, long y, long z) * * @return void */ -void write_arrow_lines_east_west (long offset, int weight, int site) +static void write_arrow_lines_east_west (long offset, int weight, int site) { graphics_write_line (offset + 2, offset + 6 + site % 2); graphics_write_line (offset + 3, offset + 6 + site % 2); @@ -125,7 +68,7 @@ void write_arrow_lines_east_west (long offset, int weight, int site) * * @return void */ -void write_arrow_lines_zenith_nadir (long offset, int weight, int site) +static void write_arrow_lines_zenith_nadir (long offset, int weight, int site) { graphics_write_line (offset + 0, offset + 8 + site % 2); graphics_write_line (offset + 1, offset + 8 + site % 2); @@ -142,7 +85,7 @@ void write_arrow_lines_zenith_nadir (long offset, int weight, int site) * * @return void */ -void write_arrow_lines_south_north (long offset, int weight, int site) +static void write_arrow_lines_south_north (long offset, int weight, int site) { graphics_write_line (offset + 0, offset + 10 + site % 2); graphics_write_line (offset + 1, offset + 10 + site % 2); @@ -157,7 +100,7 @@ void write_arrow_lines_south_north (long offset, int weight, int site) * * @return void */ -void arrows_write_basis(long offset) +static void arrows_write_basis(long offset) { graphics_write_line (offset + 0, offset + 1); graphics_write_line (offset + 2, offset + 3); @@ -167,27 +110,26 @@ void arrows_write_basis(long offset) /******************************************************************************/ -int write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, - int space_X_int, int space_Y_int, int space_Z_int, - int weight, int site, int arrow_x, int arrow_y, int arrow_z) +int write_one_arrow(int offset_vertex, + int space_X_int, int space_Y_int, int space_Z_int, + int weight, int site, int arrow_x, int arrow_y, int arrow_z) { - float space_X = space_X_int, space_Y = space_Y_int, space_Z = space_Z_int; - float max = fmax(space_X, space_Y); - max = fmax(max, space_Z); + float max = fmax(space_X_int, space_Y_int); + max = fmax(max, space_Z_int); float i = arrow_x, j = arrow_y, k = arrow_z; - float vx = (2 * i / space_X - 1) * space_X / max + (1 / max), - vy = (2 * j / space_Y - 1) * space_Y / max + (1 / max), - vz = (2 * k / space_Z - 1) * space_Z / max + (1 / max); + float vx = (2 * i / space_X_int - 1) * space_X_int / max + (1 / max), + vy = (2 * j / space_Y_int - 1) * space_Y_int / max + (1 / max), + vz = (2 * k / space_Z_int - 1) * space_Z_int / max + (1 / max); // arrow_basis_width donne la dimension de l'étoile centrale - GLfloat arrow_basis_width = 0.3f * (1 / max), + GLfloat arrow_basis_width = (1 / max) / 5; // décale légèrement les pointes des flèches // pour qu'elles n'aillent pas jusqu'aux faces des cubes - arrow_tip_padding = 0.1 * (1 / max); + GLfloat arrow_tip_padding = (1 / max) / 10; // X - X axis - central star (basis) graphics_write_vertex(vx + arrow_basis_width, vy, vz); @@ -207,16 +149,10 @@ int write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, graphics_write_color(0.3f, 0.3f, 0.3f); graphics_write_color(0.3f, 0.3f, 0.3f); - /* offset_vertex += 6; */ - /* offset_colors += 6; */ - graphics_write_line (offset_vertex + 0, offset_vertex + 1); graphics_write_line (offset_vertex + 2, offset_vertex + 3); graphics_write_line (offset_vertex + 4, offset_vertex + 5); - /* offset_lines += 3; // inutile... */ - - GLfloat nuance = 0.24f; @@ -235,11 +171,9 @@ int write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, // Z - Z (NORTH - SOUTH) axis - arrows tips (blue - yellow) graphics_write_vertex (vx, vy, vz + (1 / max) - arrow_tip_padding); graphics_write_vertex (vx, vy, vz - (1 / max) + arrow_tip_padding); - graphics_write_color(0.0f + nuance, 0.0f + nuance, 1.0f - nuance / 4); - graphics_write_color(1.0f - nuance / 4, 1.0f - nuance / 4, 0.0f + nuance); + graphics_write_color(0.0f + nuance * 2, 0.0f + nuance * 2, 1.0f - nuance); + graphics_write_color(1.0f - nuance / 3, 1.0f - nuance / 3, 0.0f + nuance); - /* offset_vertex += 6; */ - /* offset_colors += 6; */ switch(site){ case EAST: case WEST: write_arrow_lines_east_west (offset_vertex, weight, site); break; diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 0ccecca..e2492f2 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -379,7 +379,7 @@ void graphics_draw(const void *gl_area) /* Use our shaders */ glUseProgram(entry->program); -// if (pref_style_mix_colors == 0) +// if (pref_show_space_design_mix_colors == 0) glClearColor(0, 0, 0, 0.4f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -564,10 +564,10 @@ bool graphics_shutdown(const void *gl_area) * * For each arrow the following parameters are displayed : * - rank in the array - * - weight (or load) + * - load (or weight) * - coordinates in space (site, x, y, z) */ -static void show_arrows_array (struct arrow_t *arrows, int arrows_nb) +static void print_arrows_array (struct arrow_t *arrows, int arrows_nb) { printf(" [rank] load | site x y z"); for (int i = 0; i < arrows_nb; i++) @@ -584,61 +584,17 @@ static void show_arrows_array (struct arrow_t *arrows, int arrows_nb) * NB The space may be empty or saturated with arrows or any value in between * Only one arrow per possible coordinates with a load max equal to ? TODO */ -static void show_user_choices(struct arrow_t *arrows, int arrows_nb, +static void print_user_choices(struct arrow_t *arrows, int arrows_nb, int space_size_x, int space_size_y, int space_size_z, - int prefer, int show_all, int show_array, int style) + int show_array, int show_space_design) { - if (show_array) printf("\n"); - printf("model + user constraints :\tspace size x,y,z = %d,%d,%d\t", space_size_x, space_size_y, space_size_z); - if (show_all && prefer == 0) printf("prefer = %d <> show all grids", prefer); - if (show_all && prefer == 1) printf("prefer = %d <> show no grid", prefer); - if (show_all && prefer > 1) printf("show grids according rule (%d)", prefer); - if (style) printf("orientations grilles alternées"); + printf("model + user constraints :\tspace size x,y,z = %d,%d,%d\tarrows nb = %d\t",\ + space_size_x, space_size_y, space_size_z, arrows_nb); + if (show_space_design) printf("orientations grilles alternées"); printf("\n"); - if (show_all) printf("\ - initial arrows data with arrows_nb = %d\n", arrows_nb); - if (show_array) show_arrows_array (arrows, arrows_nb); -} - -/* - * Prints vertex and lines buffers_states (sizes) at major steps and at the end of a session. - * Major steps are creation of grids and creation of arrows - * Arithmetic verification is provided at each step - */ -static void show_buffers_states(int space_X, int space_Y, int space_Z, int arrows_nb, - int offset_after_grids, int buffer_vertex_size, - int buffer_lines_size_after_cubes, int buffer_lines_size) -{ - int offset_after_arrows = buffer_vertex_size / 3, difference = offset_after_arrows - offset_after_grids; - - printf("\n - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); - printf("\n buffer_vertex_offset_after grids = %6d\t%6d = (x+1)*(y+1)*(z+1); <--> (x,y,z = %d,%d,%d)",\ - offset_after_grids, (space_X + 1)*(space_Y + 1)*(space_Z + 1), space_X, space_Y, space_Z); - - printf("\n buffer_vertex_offset_after arrows = %6d\t%6d = %d + %d; <--> %d = 12 x %d (there are %d cubes)",\ - offset_after_arrows, offset_after_arrows, offset_after_grids,\ - difference, difference, difference / 12, difference / 12); - - printf("\n buffer_lines_offset after cubes = %6d\t%6d = 2 * (%dx%d + %dx%d + %dx%d); <--> 2 * (x*y + x*z + y*z)",\ - buffer_lines_size_after_cubes, ((space_X+1) * (space_Y+1) + (space_X+1) * (space_Z+1) + (space_Y+1) * (space_Z+1)) * 2, - space_X+1, space_Y+1, space_X+1, space_Z+1, space_Y+1, space_Z+1); - - printf("\n buffer_lines_offset after arrows = %6d\t%6d = %d + %d; <--> %d = (3 + 4) x 2 x %d (arrows_nb = %d)",\ - buffer_lines_size, buffer_lines_size, buffer_lines_size_after_cubes,\ - buffer_lines_size - buffer_lines_size_after_cubes, arrows_nb * 14, arrows_nb, arrows_nb); - - if (arrows_nb < 0) // LOL ! This error no more exists ! - printf("\n ERR : %d - %d = %d %d = %d x %d\n",\ - arrows_nb * 14, buffer_lines_size - buffer_lines_size_after_cubes,\ - arrows_nb * 14 - (buffer_lines_size - buffer_lines_size_after_cubes),\ - arrows_nb * 14 - (buffer_lines_size - buffer_lines_size_after_cubes),\ - (arrows_nb * 14 - (buffer_lines_size - buffer_lines_size_after_cubes)) / arrows_nb, arrows_nb); - - if (arrows_nb > 1) - printf("\n WARNING In this test, it may happens that some arrows (whatever their weights) are drawn superimposed (check the list).\n"); - else printf("\n"); + if (show_array) print_arrows_array (arrows, arrows_nb); } @@ -662,14 +618,14 @@ static void show_buffers_states(int space_X, int space_Y, int space_Z, int arrow /* - * Assigns a new weight to the arrow at address (address) + * Assigns a new load to the arrow at address (address) */ -static int rewrite_arrow (int arrows_nb, int address, int weight, int site, int x, int y, int z) +static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z) { - arrows[address].load = weight; + arrows[address].load = load; // if (! TEST) - // show_arrows_array (arrows, arrows_nb); + // print_arrows_array (arrows, arrows_nb); return arrows_nb; } @@ -678,7 +634,7 @@ static int rewrite_arrow (int arrows_nb, int address, int weight, int site, int * Creates a new arrow at address (address) * NB Weights (or loads) are NOT added */ -static inline int create_arrow (int arrows_nb, int weight, int site, int x, int y, int z) +static inline int create_arrow (int arrows_nb, int load, int site, int x, int y, int z) { void *newptr = g_realloc(arrows, (arrows_nb + 1) * sizeof(struct arrow_t)); @@ -687,7 +643,7 @@ static inline int create_arrow (int arrows_nb, int weight, int site, int x, int else perror("Can't allocate new arrow buffer!\n"); - arrows[arrows_nb].load = weight; + arrows[arrows_nb].load = load; arrows[arrows_nb].site = site; arrows[arrows_nb].x = x; arrows[arrows_nb].y = y; @@ -696,7 +652,7 @@ static inline int create_arrow (int arrows_nb, int weight, int site, int x, int arrows_nb ++; // if (! TEST) - // show_arrows_array (arrows, arrows_nb); + // print_arrows_array (arrows, arrows_nb); return arrows_nb; } @@ -725,7 +681,7 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int perror("Can't allocate new arrow buffer!\n"); // if (! TEST) - // show_arrows_array (arrows, arrows_nb); + // print_arrows_array (arrows, arrows_nb); return arrows_nb; } @@ -769,9 +725,9 @@ static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requeste if (address >= 0 && current_weight != requested_weight) return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z); -// if (! TEST && address >= 0 && current_weight == requested_weight) show_arrows_array(arrows, arrows_nb, x, y, z); +// if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(arrows, arrows_nb, x, y, z); -// if (! TEST && address == -1 && requested_weight == 0) show_arrows_array(arrows, arrows_nb, x, y, z); +// if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(arrows, arrows_nb, x, y, z); return arrows_nb; } @@ -879,11 +835,10 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) space_Z = 1 + rand() % arbitrary; int density_max = space_X * space_Y * space_Z; int max = fmax(space_X, space_Y); max = fmax(max, space_Z); - int pref_show_grids = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc - // xyz, 0, x, y, z, xy, xz, yz, xyz - int weight = 0, site = 0, x = 0, y = 0, z = 0;// stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0; - int style = 0; + int show_space_design = 0, print_arrows_array = 0; + + int load = 0, site = 0, x = 0, y = 0, z = 0; int specif_arrows_nb = rand() % density_max / 3; int arrows_nb = 0; @@ -896,8 +851,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) rand() % space_Z); // z } - show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1, 0, style); - if (0) show_arrows_array (arrows, arrows_nb); + print_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, print_arrows_array, show_space_design); /* DATA ARE NOW ALL SPECIFIED - DRAWING CAN START */ @@ -906,30 +860,27 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void) offset_vertex += write_space_ridges (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z); offset_colors = offset_vertex; - offset_vertex += write_grids_on_space_faces (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, style); + offset_vertex += write_grids_on_space_faces (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design); offset_colors = offset_vertex; /* ARROWS */ for (int i = 0; i < arrows_nb; i++) { - weight = arrows[i].load; - site = arrows[i].site; - x = arrows[i].x; - y = arrows[i].y; - z = arrows[i].z; + load = arrows[i].load; + site = arrows[i].site; + x = arrows[i].x; + y = arrows[i].y; + z = arrows[i].z; - offset_vertex += write_one_arrow(offset_vertex, offset_colors, offset_lines, + offset_vertex += write_one_arrow(offset_vertex, space_X, space_Y, space_Z, - weight, site, x, y, z); + load, site, x, y, z); offset_colors = offset_vertex; } - free(arrows); // ? free (space) +// ? free (space) TODO + free(arrows); arrows = NULL; arrows_nb = 0; - - /* show_buffers_states(space_X, space_Y, space_Z, arrows_nb, */ - /* offset_after_grids, buffer_vertex_size, */ - /* buffer_lines_size_after_cubes, buffer_lines_size); */ } diff --git a/src/graphics/grid.c b/src/graphics/grid.c index a6144f1..8c88042 100644 --- a/src/graphics/grid.c +++ b/src/graphics/grid.c @@ -25,16 +25,6 @@ #include "../../include/base.h" #include "../../include/graphics.h" -/* void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z) { */ -/* buffer_vertex_origin = g_realloc (buffer_vertex_origin, (buffer_vertex_size + 3) * sizeof(GLfloat)); */ -/* buffer_vertex_origin[buffer_vertex_size + 0] = x; */ -/* buffer_vertex_origin[buffer_vertex_size + 1] = y; */ -/* buffer_vertex_origin[buffer_vertex_size + 2] = z; */ -/* buffer_vertex_size += 3; */ -/* //printf("Created vertex (%f,%f,%f), size is %d\n", x,y,z, buffer_vertex_size); */ -/* } */ - - int write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z) { float max = fmax(x, y); max = fmax(max, z); @@ -158,164 +148,3 @@ long write_grids_on_space_faces (long offset_vertex, long offset_colors, long of } - - - - - - - - - - - - - - - - - - - - -/* - * Writes grid lines intersections to vertex and color buffers - * - * @param coords long (x,y,z) - * - * @return void - */ -void grid_write_intersections (long x, long y, long z) -{ - - float i, j, k, vx, vy, vz, max = fmax(x, y); - max = fmax(max, z); - - 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; - vy = (2 * j / y - 1) * y / max; - vz = (2 * k / z - 1) * z / max; - - graphics_write_vertex (vx, vy, vz); - // graphics_write_color (0.64f,0.64f,0.64f); - }; -} - -/* - * Writes grid ridges to vertex and color buffers - * - * @param coords long (x,y,z), step_x, step_y, step_z - * - * @return void - */ -void grid_write_marks (long x, long y, long z) -{ - long step_z = 1; // step_x = (z + 1) * (y + 1), step_y = z + 1; - //int delta = 1.0f; - for (int i=1; i < z; i ++) { - // graphics_write_vertex (delta, delta, i); graphics_write_vertex (delta, - delta, i); - // graphics_write_color (0.3f,0.3f,0.3f); graphics_write_color (0.3f,0.3f,0.3f); - // graphics_write_line (0, step_z * z + step_y * y + step_x * x); - graphics_write_line ( i * step_z, i * step_z + x); - // graphics_write_line ( i * step_z, i * step_z + y); - } -} - -void grid_write_ridges (long x, long y, long z) -{ - long step_x = (z + 1) * (y + 1), - step_y = z + 1, - step_z = 1; - long r_000 = step_z * 0 + step_y * 0 + step_x * 0, - r_100 = step_z * 0 + step_y * 0 + step_x * x, - r_010 = step_z * 0 + step_y * y + step_x * 0, - r_001 = step_z * z + step_y * 0 + step_x * 0, - r_011 = step_z * z + step_y * y + step_x * 0, - r_101 = step_z * z + step_y * 0 + step_x * x, - r_110 = step_z * 0 + step_y * y + step_x * x, - r_111 = step_z * z + step_y * y + step_x * x; - - graphics_write_line (r_000, r_100); graphics_write_line (r_111, r_011); - graphics_write_line (r_000, r_010); graphics_write_line (r_111, r_101); - graphics_write_line (r_000, r_001); graphics_write_line (r_111, r_110); - graphics_write_line (r_100, r_110); graphics_write_line (r_011, r_001); - graphics_write_line (r_100, r_101); graphics_write_line (r_011, r_010); - graphics_write_line (r_010, r_110); graphics_write_line (r_101, r_001); -} - -/* - * Writes grid lines for x axis to vertex and color buffers - * - * @param coords long (x,y,z) - * - * @return void - */ -void grid_write_x (long x, long y, long z) -{ - long step_z = 1, - step_y = z + 1, - step_x = (z + 1) * (y + 1); - - x ++; y ++; z ++; - float calcul = 0; - - for (int u = 0; u < y; u ++){ - for (int w = 0; w < x; w ++){ - calcul = step_x * w + step_y * u; - graphics_write_line (calcul, calcul + step_y - step_z); - } - } -} - -/* - * Writes grid lines for y axis to vertex and color buffers - * - * @param coords long (x,y,z) - * - * @return void - */ -void grid_write_y (long x, long y, long z) -{ - long step_z = 1, - step_y = z + 1, - step_x = (z + 1) * (y + 1); - - x ++; y ++; z ++; - float calcul = 0; - - for (int u = 0; u < z; u++) { - for (int w = 0; w < x; w ++){ - calcul = step_x * w + step_z * u; - graphics_write_line (calcul, calcul + step_x - step_y); - } - } -} - -/* - * Writes grid lines for z axis to vertex and color buffers - * - * @param coords long (x,y,z) - * - * @return void - */ -void grid_write_z (long x, long y, long z) -{ - long step_z = 1, - step_y = z + 1, - step_x = (z + 1) * (y + 1); - - x ++; y ++; z ++; - float calcul = 0; - - for (int u = 0; u < z; u ++){ - for (int w = 0; w < y; w ++){ - calcul = step_y * w + step_z * u; - graphics_write_line (calcul, calcul + step_x * (x - 1)); - } - } -} - -