WIP: une ébauche 2D avec plusieurs flèches
This commit is contained in:
parent
02bc747ad3
commit
1104459617
|
@ -50,6 +50,8 @@ int plans_ndx = 0;
|
||||||
#define EDGE 0.999999
|
#define EDGE 0.999999
|
||||||
|
|
||||||
#define S2 0
|
#define S2 0
|
||||||
|
#define L 0
|
||||||
|
#define V 1
|
||||||
static bool compute_space_2D(int space_size_x,
|
static bool compute_space_2D(int space_size_x,
|
||||||
int space_size_y,
|
int space_size_y,
|
||||||
int space_size_z,
|
int space_size_z,
|
||||||
|
@ -86,6 +88,7 @@ static bool compute_space_2D(int space_size_x,
|
||||||
*(vertex_origin + k * 6 + 5) = 0.0f;
|
*(vertex_origin + k * 6 + 5) = 0.0f;
|
||||||
|
|
||||||
vertex_ndx += 6;
|
vertex_ndx += 6;
|
||||||
|
if (V) printf(" => vertex_ndx = %d\n", vertex_ndx);
|
||||||
|
|
||||||
*(color_origin + k * 6 + 0) = 1;
|
*(color_origin + k * 6 + 0) = 1;
|
||||||
*(color_origin + k * 6 + 1) = 0;
|
*(color_origin + k * 6 + 1) = 0;
|
||||||
|
@ -101,6 +104,7 @@ static bool compute_space_2D(int space_size_x,
|
||||||
*(line_origin + k * 2 + 1) = k * 2 + 1;
|
*(line_origin + k * 2 + 1) = k * 2 + 1;
|
||||||
|
|
||||||
lines_ndx += 2;
|
lines_ndx += 2;
|
||||||
|
if (L) printf(" => lines_ndx = %d\n", lines_ndx);
|
||||||
}
|
}
|
||||||
|
|
||||||
*(color_origin + 0) = 0;
|
*(color_origin + 0) = 0;
|
||||||
|
@ -128,25 +132,32 @@ static bool compute_space_2D(int space_size_x,
|
||||||
*(line_origin + lines_ndx + 3) = space_size_x * 2 - 1; // barre horizontale du haut
|
*(line_origin + lines_ndx + 3) = space_size_x * 2 - 1; // barre horizontale du haut
|
||||||
|
|
||||||
lines_ndx += 4;
|
lines_ndx += 4;
|
||||||
|
if (L) printf("H=> lines_ndx = %d\n", lines_ndx);
|
||||||
|
|
||||||
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) // diagonales to mark first space unit
|
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) // diagonales to mark first space unit
|
||||||
{
|
{
|
||||||
*(line_origin + lines_ndx + 0) = 0;
|
*(line_origin + lines_ndx + 0) = 0;
|
||||||
*(line_origin + lines_ndx + 1) = 3;
|
*(line_origin + lines_ndx + 1) = 3;
|
||||||
|
|
||||||
*(line_origin + lines_ndx + 2) = 1;
|
*(line_origin + lines_ndx + 2) = 1;
|
||||||
*(line_origin + lines_ndx + 3) = 2;
|
*(line_origin + lines_ndx + 3) = 2;
|
||||||
|
|
||||||
lines_ndx += 4;
|
lines_ndx += 4;
|
||||||
|
if (L) printf("X=> lines_ndx = %d\n", lines_ndx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) // diagonales to mark last space unit
|
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) // diagonales to mark last space unit
|
||||||
{
|
{
|
||||||
*(line_origin + lines_ndx + 0) = (space_size_x - 2) * 2 + 0;
|
*(line_origin + lines_ndx + 0) = (space_size_x - 2) * 2 + 0;
|
||||||
*(line_origin + lines_ndx + 1) = (space_size_x - 2) * 2 + 3;
|
*(line_origin + lines_ndx + 1) = (space_size_x - 2) * 2 + 3;
|
||||||
|
|
||||||
*(line_origin + lines_ndx + 2) = (space_size_x - 2) * 2 + 1;
|
*(line_origin + lines_ndx + 2) = (space_size_x - 2) * 2 + 1;
|
||||||
*(line_origin + lines_ndx + 3) = (space_size_x - 2) * 2 + 2;
|
*(line_origin + lines_ndx + 3) = (space_size_x - 2) * 2 + 2;
|
||||||
|
|
||||||
lines_ndx +=4;
|
lines_ndx +=4;
|
||||||
|
if (L) printf("X=> lines_ndx = %d\n", lines_ndx);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S2) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x);
|
if (S2) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x);
|
||||||
|
@ -182,12 +193,14 @@ static int compute_arrow_2D(int space_size_x,
|
||||||
int buffer_lines_size,
|
int buffer_lines_size,
|
||||||
int buffer_plans_size)
|
int buffer_plans_size)
|
||||||
{
|
{
|
||||||
|
printf("compute_arrow_2D load = %d site = %d x = %d\n", weight, site, x);
|
||||||
float zero = 0.0f;
|
float zero = 0.0f;
|
||||||
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
||||||
// float tip = center + (2 * site - 1) * (1.0f / space_size_x);
|
float tip = center + (2 * site - 1) * (1.0f / space_size_x);
|
||||||
|
tip = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
||||||
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
||||||
|
|
||||||
*(vertex_origin + vertex_ndx + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
*(vertex_origin + vertex_ndx + 0) = tip;
|
||||||
*(vertex_origin + vertex_ndx + 1) = zero;
|
*(vertex_origin + vertex_ndx + 1) = zero;
|
||||||
*(vertex_origin + vertex_ndx + 2) = zero;
|
*(vertex_origin + vertex_ndx + 2) = zero;
|
||||||
|
|
||||||
|
@ -200,19 +213,23 @@ static int compute_arrow_2D(int space_size_x,
|
||||||
*(vertex_origin + vertex_ndx + 8) = zero;
|
*(vertex_origin + vertex_ndx + 8) = zero;
|
||||||
|
|
||||||
vertex_ndx += 9;
|
vertex_ndx += 9;
|
||||||
|
if (V) printf(" => vertex_ndx = %d\n", vertex_ndx);
|
||||||
|
|
||||||
if (pref_style_lines_planes == 0) {
|
if (pref_style_lines_planes == 0) {
|
||||||
|
|
||||||
*(line_origin + lines_ndx + 0) = vertex_ndx / 3 + 0;
|
if (V) printf("0=> lines_ndx = %d\n", lines_ndx);
|
||||||
*(line_origin + lines_ndx + 1) = vertex_ndx / 3 + 1;
|
|
||||||
|
|
||||||
*(line_origin + lines_ndx + 2) = vertex_ndx / 3 + 0;
|
*(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 3;
|
||||||
*(line_origin + lines_ndx + 3) = vertex_ndx / 3 + 2;
|
*(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 2;
|
||||||
|
|
||||||
*(line_origin + lines_ndx + 4) = vertex_ndx / 3 + 1;
|
*(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 3;
|
||||||
*(line_origin + lines_ndx + 5) = vertex_ndx / 3 + 2;
|
*(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 1;
|
||||||
|
|
||||||
|
*(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 2;
|
||||||
|
*(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 1;
|
||||||
|
|
||||||
lines_ndx += 6;
|
lines_ndx += 6;
|
||||||
|
if (V) printf("|=> lines_ndx = %d\n", lines_ndx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,6 +291,9 @@ static bool compute_space_3D (int space_size_x,
|
||||||
*(vertex_origin + k * 12 + 10) = - 1.0f / space_size_x;
|
*(vertex_origin + k * 12 + 10) = - 1.0f / space_size_x;
|
||||||
*(vertex_origin + k * 12 + 11) = 1.0f / space_size_x;
|
*(vertex_origin + k * 12 + 11) = 1.0f / space_size_x;
|
||||||
|
|
||||||
|
vertex_ndx += 12;
|
||||||
|
if (V) printf(" => vertex_ndx = %d\n", vertex_ndx);
|
||||||
|
|
||||||
*(color_origin + k * 12 + 0) = 1; // 1 - (k / space_size_x);
|
*(color_origin + k * 12 + 0) = 1; // 1 - (k / space_size_x);
|
||||||
*(color_origin + k * 12 + 1) = 0;
|
*(color_origin + k * 12 + 1) = 0;
|
||||||
*(color_origin + k * 12 + 2) = 0;
|
*(color_origin + k * 12 + 2) = 0;
|
||||||
|
@ -453,6 +473,9 @@ static bool compute_arrow_3D(int space_size_x,
|
||||||
*(vertex_origin + vgap + 13) = - 0.4f / space_size_x;
|
*(vertex_origin + vgap + 13) = - 0.4f / space_size_x;
|
||||||
*(vertex_origin + vgap + 14) = 0.4f / space_size_x;
|
*(vertex_origin + vgap + 14) = 0.4f / space_size_x;
|
||||||
|
|
||||||
|
vertex_ndx += 15;
|
||||||
|
if (V) printf(" => vertex_ndx = %d\n", vertex_ndx);
|
||||||
|
|
||||||
if (A3) printf("center = %f tip = %f base = %f\n",\
|
if (A3) printf("center = %f tip = %f base = %f\n",\
|
||||||
center, tip, base); // vgap=%d igap=%d
|
center, tip, base); // vgap=%d igap=%d
|
||||||
|
|
||||||
|
@ -619,11 +642,11 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
|
|
||||||
|
|
||||||
// arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
// arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
|
||||||
if (SA) for (int i = 0; i < model_arrows_nb; i++) {
|
if (SA) for (int i = 0; i < model_arrows_nb; i++)
|
||||||
printf("[%2d] = %2d, %2d, %2d \n",\
|
printf("[%2d] = %2d, %2d, %2d \n",\
|
||||||
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
||||||
|
|
||||||
if (pref_3D_xor_2D_arrows) compute_arrow_2D(model_space_size_x,
|
for (int i = 0; i < model_arrows_nb; i++) if (pref_3D_xor_2D_arrows) compute_arrow_2D(model_space_size_x,
|
||||||
model_space_size_y,
|
model_space_size_y,
|
||||||
model_space_size_z,
|
model_space_size_z,
|
||||||
|
|
||||||
|
@ -682,7 +705,7 @@ bool compute_space_and_arrows(int model_space_size_x,
|
||||||
/* compute_arrow_3D(entry, model_space_size_x, vgap, igap, 1, 0, model_space_size_x - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */
|
/* compute_arrow_3D(entry, model_space_size_x, vgap, igap, 1, 0, model_space_size_x - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */
|
||||||
/* compute_arrow_3D(entry, model_space_size_x, vgap, igap, 1, 1, model_space_size_x - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */
|
/* compute_arrow_3D(entry, model_space_size_x, vgap, igap, 1, 1, model_space_size_x - 2, 0, 0); vgap += 15; igap += 16; cgap += 15; ++model_arrows_nb; */
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,8 +525,8 @@ bool graphics_init_shaders(const void *gl_area)
|
||||||
|
|
||||||
static void get_model_data_and_user_preferences(){
|
static void get_model_data_and_user_preferences(){
|
||||||
|
|
||||||
model_space_size_x = 6; // 2 < model_space_size_x < 32
|
model_space_size_x = 8; // 2 < model_space_size_x < 32
|
||||||
model_arrows_nb = 1; // assert : l'emplacement des flèches est contraint
|
model_arrows_nb = 6; // 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_3D_xor_2D_space = 1; // 0 = 3D 1 = 2D
|
pref_3D_xor_2D_space = 1; // 0 = 3D 1 = 2D
|
||||||
pref_3D_xor_2D_arrows = 1; // 0 = 3D 1 = 2D
|
pref_3D_xor_2D_arrows = 1; // 0 = 3D 1 = 2D
|
||||||
|
|
Loading…
Reference in New Issue