create_arrow(): fonctionnel mais quelques bugs
This commit is contained in:
parent
d4c7e1bba5
commit
0ebd025bd8
|
@ -37,7 +37,7 @@
|
|||
void arrows_write_terminations (long x, long y, long z);
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the east into lines buffer
|
||||
* Writes lines for arrow oriented to the east or west into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* weight,
|
||||
|
@ -45,10 +45,10 @@ void arrows_write_terminations (long x, long y, long z);
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_east (long s, int weight, int site);
|
||||
void write_arrow_lines_east_west (long s, int weight, int site);
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the west into lines buffer
|
||||
* Writes lines for arrow oriented to the zenith or nadir into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* weight,
|
||||
|
@ -56,10 +56,10 @@ void write_arrow_lines_east (long s, int weight, int site);
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_west (long s, int weight, int site);
|
||||
void write_arrow_lines_zenith_nadir (long s, int weight, int site);
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the zenith into lines buffer
|
||||
* Writes lines for arrow oriented to the south or north into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* weight,
|
||||
|
@ -67,47 +67,12 @@ void write_arrow_lines_west (long s, int weight, int site);
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_zenith (long s, int weight, int site);
|
||||
void write_arrow_lines_south_north (long s, int weight, int site);
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the nadir into lines buffer
|
||||
* Writes three lines that draw arrow basis (central star) into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_nadir (long s, int weight, int site);
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the south into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_south (long s, int weight, int site);
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the north into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_north (long s, int weight, int site);
|
||||
|
||||
/*
|
||||
* Writes lines for arrow basis into lines buffer
|
||||
*
|
||||
* @param n,
|
||||
* weight,
|
||||
* site
|
||||
* @param n
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -91,7 +91,7 @@ void arrows_write_terminations (long x, long y, long z)
|
|||
graphics_write_color(0.0f, 1.0f, 0.0f);
|
||||
graphics_write_color(1.0f, 0.0f, 1.0f);
|
||||
|
||||
// Z - Z axis arrows tips near the faces centers NORTH - SOUTH
|
||||
// Z - Z (NORTH - SOUTH) axis - arrows tips
|
||||
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, 0.0f, 1.0f);
|
||||
|
@ -100,69 +100,67 @@ void arrows_write_terminations (long x, long y, long z)
|
|||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the east or west into lines buffer
|
||||
* Writes lines for arrow oriented towards east or west into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_east_west (long s, int weight, int site)
|
||||
void write_arrow_lines_east_west (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (s + 2, s + 6 + site % 2);
|
||||
graphics_write_line (s + 3, s + 6 + site % 2);
|
||||
graphics_write_line (s + 4, s + 6 + site % 2);
|
||||
graphics_write_line (s + 5, s + 6 + site % 2);
|
||||
graphics_write_line (offset + 2, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 3, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 4, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 5, offset + 6 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the zenith or nadir into lines buffer
|
||||
* Writes lines for arrow oriented towards zenith or nadir into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_zenith_nadir (long s, int weight, int site)
|
||||
void write_arrow_lines_zenith_nadir (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (s + 0, s + 8 + site % 2);
|
||||
graphics_write_line (s + 1, s + 8 + site % 2);
|
||||
graphics_write_line (s + 4, s + 8 + site % 2);
|
||||
graphics_write_line (s + 5, s + 8 + site % 2);
|
||||
graphics_write_line (offset + 0, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 1, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 4, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 5, offset + 8 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented to the south or north into lines buffer
|
||||
* Writes lines for arrow oriented towards south or north into lines buffer
|
||||
*
|
||||
* @param s,
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void write_arrow_lines_south_north (long s, int weight, int site)
|
||||
void write_arrow_lines_south_north (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (s + 0, s + 10 + site % 2);
|
||||
graphics_write_line (s + 1, s + 10 + site % 2);
|
||||
graphics_write_line (s + 2, s + 10 + site % 2);
|
||||
graphics_write_line (s + 3, s + 10 + site % 2);
|
||||
graphics_write_line (offset + 0, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 1, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 2, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 3, offset + 10 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow basis into lines buffer
|
||||
*
|
||||
* @param n,
|
||||
* weight,
|
||||
* site
|
||||
* @param offset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
void arrows_write_basis(long n)
|
||||
void arrows_write_basis(long offset)
|
||||
{
|
||||
graphics_write_line (n + 0, n + 1);
|
||||
graphics_write_line (n + 2, n + 3);
|
||||
graphics_write_line (n + 4, n + 5);
|
||||
graphics_write_line (offset + 0, offset + 1);
|
||||
graphics_write_line (offset + 2, offset + 3);
|
||||
graphics_write_line (offset + 4, offset + 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,40 +32,300 @@
|
|||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
|
||||
static GLuint arrows[] = {
|
||||
1, 0, 3, 2, 1,
|
||||
1, 1, 3, 2, 1,
|
||||
1, 2, 3, 2, 1,
|
||||
1, 3, 3, 2, 1,
|
||||
1, 4, 3, 2, 1,
|
||||
1, 5, 3, 2, 1,
|
||||
// load, site, x, y, z
|
||||
};
|
||||
|
||||
static int model_space_size_x = 0;
|
||||
static int model_space_size_y = 0;
|
||||
static int model_space_size_z = 0;
|
||||
static int central_stars_nb = 0;
|
||||
|
||||
static GLfloat *buffer_vertex_origin = NULL;
|
||||
static GLfloat *buffer_colors_origin = NULL;
|
||||
static GLuint *buffer_lines_origin = NULL;
|
||||
static GLuint *buffer_plans_origin = NULL;
|
||||
|
||||
static int pref_show_grids = 0;
|
||||
|
||||
static volatile int buffer_vertex_size = 0;
|
||||
static int buffer_colors_size = 0;
|
||||
static int buffer_lines_size = 0;
|
||||
static int buffer_plans_size = 0;
|
||||
static volatile int buffer_lines_size = 0;
|
||||
static volatile int buffer_colors_size = 0;
|
||||
static volatile int buffer_plans_size = 0;
|
||||
|
||||
|
||||
// model_data_and_user_preferences :
|
||||
|
||||
static int pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||
static int space_X = 0;
|
||||
static int space_Y = 0;
|
||||
static int space_Z = 0;
|
||||
|
||||
static void show_user_choices(GLuint *arrows, int arrows_nb,
|
||||
int space_size_x, int space_size_y, int space_size_z,
|
||||
int prefer, int show_all)
|
||||
{
|
||||
printf("model + user constraints :\tspace size x,y,z = %d,%d,%d\t", space_size_x, space_size_y, space_size_z);
|
||||
if (prefer == 0) printf("prefer = %d <> show all grids", prefer);
|
||||
if (prefer == 1) printf("prefer = %d <> show no grid", prefer);
|
||||
if (prefer > 1) printf("pref_show_grids = %d", prefer);
|
||||
if (show_all) {
|
||||
printf("\n\t\t\t\t\t buffer_vertex_size = %d\t buffer_lines_size = %d", buffer_vertex_size, buffer_lines_size);
|
||||
if (arrows_nb > 0) printf("\n [%2d] load | site x y z\
|
||||
< initial data\n -------------------------------", arrows_nb);
|
||||
for (int i = 0; i < arrows_nb; i++) printf("\n [%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 (arrows_nb > 0) printf("\n -------------------------------\n");}
|
||||
}
|
||||
|
||||
static void get_model_data_and_user_preferences(GLuint *arrows, int arrows_nb)
|
||||
{
|
||||
space_X = 4; // 0 < model_space_size_x
|
||||
space_Y = 1; // 0 < model_space_size_y
|
||||
space_Z = 1; // 0 < model_space_size_z
|
||||
pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||
show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int current_weigh, int weight, int site, int x, int y, int z);
|
||||
|
||||
static bool rewrite_arrow (GLuint *arrows, int arrows_nb, int address, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
show_arrows_array(arrows, arrows_nb, address, *(arrows + address + 0), weight, site, x, y, z);
|
||||
|
||||
*(arrows + address + 0) = weight;
|
||||
|
||||
if (1) printf("the new arrow weight is %d at (%d, %d, %d, %d)\n", weight, site, x, y, z);
|
||||
|
||||
return 1; /* replaces the load of the existing arrow by the new load 'weight' */
|
||||
}
|
||||
|
||||
static bool create_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
if (0) printf("\ncreating the new arrow (%d, %d, %d, %d, %d)",\
|
||||
weight, site, x, y, z);
|
||||
|
||||
buffer_lines_size += (3 + 4) * 2;
|
||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLuint));
|
||||
|
||||
*(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;
|
||||
|
||||
show_arrows_array(arrows, arrows_nb + 1, -1, -1, weight, site, x, y, z);
|
||||
|
||||
printf("buffer_lines_size = %d\tarrow (%d, %d, %d, %d, %d) was created",\
|
||||
buffer_lines_size, weight, site, x, y, z);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool erase_arrow (GLuint *arrows, int arrows_nb, int address, int site, int x, int y, int z)
|
||||
{
|
||||
arrows_nb --;
|
||||
|
||||
if (arrows_nb > 0) {
|
||||
*(arrows + address + 0) = *(arrows + arrows_nb * 5 + 0);
|
||||
*(arrows + address + 1) = *(arrows + arrows_nb * 5 + 1);
|
||||
*(arrows + address + 2) = *(arrows + arrows_nb * 5 + 2);
|
||||
*(arrows + address + 3) = *(arrows + arrows_nb * 5 + 3);
|
||||
*(arrows + address + 4) = *(arrows + arrows_nb * 5 + 4);
|
||||
}
|
||||
buffer_lines_size -= (3 + 4) * 2;
|
||||
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * sizeof(GLuint));
|
||||
|
||||
show_arrows_array(arrows, arrows_nb, address, -1, 0, site, x, y, z);
|
||||
|
||||
if (1) printf("arrow previously at address (%d) with values (%d, %d, %d, %d) was erased;\
|
||||
last arrow is now : (%d, %d, %d, %d, %d)\n", address / 5, site, x, y, z, *(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));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void show_arrows_array (GLuint *arrows, int arrows_nb, int address, int current_weigh, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
printf("\nset_arrow (%d | %2d %2d %2d %2d) <> ", weight, site, x, y, z);
|
||||
|
||||
if (arrows_nb == 0 && weight == 0) printf("buffer_lines_size = %d\tno arrow in space + no arrows to be created > end function set_arrow()\n", buffer_lines_size);
|
||||
if (address == -1 && weight == 0) printf("buffer_lines_size = %d\tarrow not found + no arrows to be created > end function set_arrow()\n", buffer_lines_size);
|
||||
if (address == -1 && weight > 0) printf("buffer_lines_size = %d\tarrow (%d, %d, %d, %d, %d) not found > new arrow will be created at line [%d]\n",\
|
||||
buffer_lines_size, arrows_nb, weight, site, x, y, z);
|
||||
if (address >= 0 && weight == 0) printf("buffer_lines_size = %d\tarrow found at line [%d] > will be erased\n", buffer_lines_size, address / 5);
|
||||
if (address >= 0 && weight > 0) {
|
||||
if (current_weigh != weight) printf("buffer_lines_size = %d\tarrow found at line [%d] > will be modified\n", buffer_lines_size, address / 5);
|
||||
if (current_weigh == weight) printf("buffer_lines_size = %d\tarrow found at line [%d] > will not be modified\n", buffer_lines_size, address / 5);
|
||||
}
|
||||
|
||||
printf(" [rank] load | site x y z\n");
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
{
|
||||
printf(" [%4d] = %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) moved at [%2d]",\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||
if (weight > 0 && current_weigh != weight && i == arrows_nb - 1 && address >= 0)
|
||||
printf(" <<< < + > (%d, %d, %d, %d) added at [%2d]",\
|
||||
*(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
|
||||
*(arrows + i * 5 + 3), *(arrows + i * 5 + 4), address / 5);
|
||||
if (weight > 0 && current_weigh == weight && i == address / 5) printf(" <");
|
||||
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 int set_arrow (GLuint *arrows, int arrows_nb, int weight, int site, int x, int y, int z)
|
||||
{
|
||||
// assert pas de doublons flèche(s)
|
||||
|
||||
int address = -1, current_weight = -1;
|
||||
|
||||
if (arrows_nb > 0)
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
if ((site == *(arrows + i * 5 + 1))
|
||||
&& (x == *(arrows + i * 5 + 2))
|
||||
&& (y == *(arrows + i * 5 + 3))
|
||||
&& (z == *(arrows + i * 5 + 4)))
|
||||
{
|
||||
address = i * 5;
|
||||
current_weight = *(arrows + i * 5 + 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (address == -1 && weight == 0) return 0;
|
||||
if (address == -1 && weight > 0) return create_arrow (arrows, arrows_nb, weight, site, x, y, z);
|
||||
if (address >= 0 && weight == 0) return erase_arrow (arrows, arrows_nb, address, site, x, y, z);
|
||||
if (address >= 0 && current_weight != weight) return rewrite_arrow (arrows, arrows_nb, address, weight, site, x, y, z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Dynamic array of ptrs to dynamically allocated gl_area_entry
|
||||
*/
|
||||
struct gl_area_entry **gl_area_array = NULL;
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Prints verbose human-readable debug messages
|
||||
*
|
||||
|
@ -127,59 +387,6 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
|
|||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* DEBUG
|
||||
*
|
||||
*/
|
||||
static void show_user_choices(long space_size_x,
|
||||
long space_size_y,
|
||||
long space_size_z,
|
||||
GLuint *arrows,
|
||||
int prefer)
|
||||
{
|
||||
int arrows_nb = 3 * sizeof(arrows) / sizeof(arrows[0]);
|
||||
printf("model + user constraints : space size x,y,z = %ld,%ld,%ld ", space_size_x, space_size_y, space_size_z);
|
||||
if (arrows_nb > 0) printf("[%d] arrows ", arrows_nb);
|
||||
if (prefer == 1) printf("prefer = %d <> show no grid ", prefer);
|
||||
if (prefer == 0) printf("prefer = %d <> show all grids ", prefer);
|
||||
if (prefer == 2) printf("prefer = %d <> show grid xy ", prefer);
|
||||
if (prefer == 3) printf("prefer = %d <> show grid xz ", prefer);
|
||||
if (prefer == 5) printf("prefer = %d <> show grid yz ", prefer);
|
||||
if (prefer == 6) printf("prefer = %d <> show grids xy & xz ", prefer);
|
||||
if (prefer == 10) printf("prefer = %d <> show grids xy & yz ", prefer);
|
||||
if (prefer == 15) printf("prefer = %d <> show grids xz & yz ", prefer);
|
||||
if (arrows_nb == 0) printf("\tbuffer_vertex_size = %d\t lines = %d\n",\
|
||||
buffer_vertex_size, buffer_lines_size);
|
||||
if (arrows_nb > 0) printf("\n--- < arrows array >\
|
||||
---\n[ n] load site x y z \n-----------------------------\n");
|
||||
for (int i = 0; i < 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));
|
||||
}
|
||||
|
||||
static void get_model_data_and_user_preferences()
|
||||
{
|
||||
model_space_size_x = 7; // 0 < model_space_size_x
|
||||
model_space_size_y = 5; // 0 < model_space_size_y
|
||||
model_space_size_z = 3; // 0 < model_space_size_z
|
||||
// assert : l'emplacement des flèches est contraint
|
||||
// par model_space_size_x, y, z et le nombre de sites
|
||||
|
||||
central_stars_nb = 0; // à calculer TODO
|
||||
// ! WARNING ! Pour l'instant égal au nombre de flèches ! (central stars réécrites)
|
||||
central_stars_nb = sizeof(arrows) / sizeof(arrows[0]);
|
||||
|
||||
pref_show_grids = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
|
||||
// xyz, 0, x, y, z, xy, xz, yz, xyz
|
||||
|
||||
show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z,
|
||||
arrows, pref_show_grids);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
* Writes values to describe a line from a to b into the line buffer
|
||||
*
|
||||
|
@ -275,8 +482,6 @@ void graphics_init_buffers(const void *gl_area)
|
|||
struct gl_area_entry *entry;
|
||||
entry = graphics_find_glarea_from_ptr(gl_area);
|
||||
|
||||
get_model_data_and_user_preferences();
|
||||
|
||||
//XXX
|
||||
main_test_graphics ();
|
||||
|
||||
|
@ -616,55 +821,92 @@ bool graphics_shutdown(const void *gl_area)
|
|||
|
||||
void main_test_graphics (void)
|
||||
{
|
||||
long site = 0,
|
||||
x = model_space_size_x,
|
||||
y = model_space_size_y,
|
||||
z = model_space_size_z;
|
||||
long stx = z * y,
|
||||
sty = z,
|
||||
stz = 1;
|
||||
long arrow_offset = 0;
|
||||
if (0) printf("buffer_vertex_offset_before_grid = %d\n", buffer_vertex_size / 3);
|
||||
|
||||
printf("offset_before_grid = %d\n", buffer_vertex_size / 3);
|
||||
// assert : l'emplacement des flèches est contraint
|
||||
// par model_space_size_x, y, z et le nombre de sites. TODO
|
||||
// assert : pas de doublons (une seule flèche max par site). TODO
|
||||
|
||||
GLuint arrows[] = {
|
||||
1, 0, 0, 0, 0,
|
||||
// 1, 1, 0, 0, 0,
|
||||
// 1, 0, 1, 0, 0,
|
||||
// 1, 1, 1, 0, 0,
|
||||
1, 0, 2, 0, 0,
|
||||
1, 1, 2, 0, 0,
|
||||
// 1, 0, 3, 0, 0,
|
||||
1, 1, 3, 0, 0,
|
||||
// load, site, x, y, z
|
||||
};
|
||||
|
||||
int arrows_nb = sizeof(arrows) / sizeof(arrows[0]) / 5;
|
||||
|
||||
get_model_data_and_user_preferences(arrows, arrows_nb);
|
||||
long weight = 0, site = 0,
|
||||
stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0;
|
||||
|
||||
/* GRID */
|
||||
grid_write_intersections (space_X, space_Y, space_Z);
|
||||
|
||||
grid_write_intersections (x, y, z);
|
||||
if (pref_show_grids % 2 == 0) grid_write_x (space_X, space_Y, space_Z);
|
||||
if (pref_show_grids % 3 == 0) grid_write_y (space_X, space_Y, space_Z);
|
||||
if (pref_show_grids % 5 == 0) grid_write_z (space_X, space_Y, space_Z);
|
||||
|
||||
if (pref_show_grids % 2 == 0) grid_write_x (x, y, z);
|
||||
if (pref_show_grids % 3 == 0) grid_write_y (x, y, z);
|
||||
if (pref_show_grids % 5 == 0) grid_write_z (x, y, z);
|
||||
if (pref_show_grids > 0) grid_write_ridges (space_X, space_Y, space_Z);
|
||||
|
||||
if (pref_show_grids > 0) grid_write_ridges (x, y, z);
|
||||
int offset_after_grids = buffer_vertex_size / 3;
|
||||
int buffer_lines_size_after_cubes = buffer_lines_size;
|
||||
|
||||
int offset_after_grid = buffer_vertex_size / 3;
|
||||
|
||||
printf("offset_after_ grid = %d\n", offset_after_grid);
|
||||
int offset_up_to_this_cube_coords = 0, x, y, z;
|
||||
|
||||
/* ARROWS */
|
||||
arrows_write_terminations (x, y, z);
|
||||
|
||||
int arrows_nb_ad_hoc = 6; // 3 * sizeof(arrows) / sizeof(arrows[0]) ???
|
||||
arrows_write_terminations (space_X, space_Y, space_Z); // Independent of the number of arrows
|
||||
|
||||
for (int i = 0; i < arrows_nb_ad_hoc; i++) {
|
||||
set_arrow (arrows, arrows_nb, 0, 1, 2, 0, 0); arrows_nb --;
|
||||
set_arrow (arrows, arrows_nb, 1, 1, 2, 0, 0); arrows_nb ++;
|
||||
// set_arrow (arrows, arrows_nb, 0, 1, 1, 0, 0); arrows_nb --;
|
||||
// set_arrow (arrows, arrows_nb, 0, 1, 0, 0, 0); arrows_nb --;
|
||||
|
||||
// set_arrow (arrows, arrows_nb, 1, 0, 5, 0, 0); arrows_nb ++;
|
||||
// set_arrow (arrows, arrows_nb, 1, 1, 1, 0, 0); arrows_nb ++;
|
||||
// set_arrow (arrows, arrows_nb, 1, 0, 0, 0, 0); arrows_nb ++;
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
weight = arrows[i * 5 + 0];
|
||||
site = arrows[i * 5 + 1];
|
||||
x = arrows[i * 5 + 2];
|
||||
y = arrows[i * 5 + 3];
|
||||
z = arrows[i * 5 + 4];
|
||||
|
||||
// cube coordinates = 12 * (stx * x + sty * y + stz * z);
|
||||
arrow_offset = offset_after_grid + 12 * (stx * x + sty * y + stz * z);
|
||||
offset_up_to_this_cube_coords = 12 * (stx * x + sty * y + stz * z);
|
||||
arrow_offset = offset_after_grids + offset_up_to_this_cube_coords;
|
||||
arrows_write_basis (arrow_offset);
|
||||
|
||||
switch(site){
|
||||
case EAST: case WEST: write_arrow_lines_east_west (arrow_offset, 1, site); break;
|
||||
case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (arrow_offset, 1, site); break;
|
||||
case SOUTH: case NORTH: write_arrow_lines_south_north (arrow_offset, 1, site); break;
|
||||
case EAST: case WEST: write_arrow_lines_east_west (arrow_offset, weight, site); break;
|
||||
case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (arrow_offset, weight, site); break;
|
||||
case SOUTH: case NORTH: write_arrow_lines_south_north (arrow_offset, weight, site); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("main_test_graphics [ok]\n");
|
||||
int offset_after_arrows = buffer_vertex_size / 3, difference = offset_after_arrows - offset_after_grids;
|
||||
|
||||
if (1) 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);
|
||||
if (1) 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);
|
||||
if (1) 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);
|
||||
if (1) printf("\n buffer_lines_offset after arrows = %6d\t%6d = %d + %d; <--> %d = (3 + 4) x 2 x %d (arrows_nb = %d)\n", 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 (0) printf("main_test_graphics [ok]\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue