WIP: content ! premiere réorganisation OK (ajustements, réglages,...)
This commit is contained in:
parent
d8494dc956
commit
3f59e99ba1
|
@ -40,15 +40,17 @@
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
bool compute_space(int model_space_size_x,
|
bool compute_space_and_arrows(int model_space_size_x,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_origin, GLubyte *plan_origin,
|
GLubyte *line_origin, GLubyte *plan_origin,
|
||||||
GLubyte *arrows,
|
GLubyte *arrows, int model_arrows_nb,
|
||||||
|
int vgap, int cgap, int lgap, int pgap,
|
||||||
bool pref_3D_xor_2D_space,
|
bool pref_3D_xor_2D_space,
|
||||||
bool pref_lines_planes_or_mix,
|
bool pref_lines_planes_or_mix,
|
||||||
bool pref_mark_unit_space_first,
|
bool pref_mark_unit_space_first,
|
||||||
bool pref_mark_unit_space_last);
|
bool pref_mark_unit_space_last);
|
||||||
|
|
||||||
|
|
||||||
// bool compute_arrow(int state_size,
|
// bool compute_arrow(int state_size,
|
||||||
// GLfloat *vertex_base, GLfloat *color_base,
|
// GLfloat *vertex_base, GLfloat *color_base,
|
||||||
// GLubyte *line_ndx, GLubyte *plan_ndx,
|
// GLubyte *line_ndx, GLubyte *plan_ndx,
|
||||||
|
|
|
@ -46,9 +46,9 @@
|
||||||
int line_ndx = 0;
|
int line_ndx = 0;
|
||||||
|
|
||||||
#define V 1
|
#define V 1
|
||||||
#define I 0
|
#define I 1
|
||||||
#define EDGE 0.999999
|
#define EDGE 0.999999
|
||||||
static bool compute_space_2D(int state_size,
|
static bool compute_space_2D(int space_size_x,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_origin, GLubyte *plan_origin,
|
GLubyte *line_origin, GLubyte *plan_origin,
|
||||||
bool pref_lines_planes_or_mix,
|
bool pref_lines_planes_or_mix,
|
||||||
|
@ -57,24 +57,24 @@ static bool compute_space_2D(int state_size,
|
||||||
{
|
{
|
||||||
|
|
||||||
float x = 0;
|
float x = 0;
|
||||||
// for (int k = 0; k < state_size + 1; k++) <=> + 1
|
// for (int k = 0; k < space_size_x + 1; k++) <=> + 1
|
||||||
// car on passe du nombre de cases = (n)
|
// car on passe du nombre de cases = (n)
|
||||||
// au nombre de séparations entre les cases + les deux bords = (n + 1)
|
// au nombre de séparations entre les cases + les deux bords = (n + 1)
|
||||||
|
|
||||||
if (V) printf("vertices ");
|
if (V) printf("vertex ");
|
||||||
for (int k = 0; k < state_size; k++){ // barres verticales
|
for (int k = 0; k < space_size_x; k++){ // barres verticales
|
||||||
//
|
//
|
||||||
x = ((state_size % 2) * (state_size / 2 - k)
|
x = ((space_size_x % 2) * (space_size_x / 2 - k)
|
||||||
+ (state_size % 2 - 1) * (k + 0.5f - state_size / 2)) / state_size * 2 * EDGE;
|
+ (space_size_x % 2 - 1) * (k + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE;
|
||||||
|
|
||||||
if (V) printf("[%1.1f] ", x);
|
if (V) printf("[%1.1f] ", x);
|
||||||
|
|
||||||
*(vertex_base + k * 6 + 0) = - x;
|
*(vertex_base + k * 6 + 0) = - x;
|
||||||
*(vertex_base + k * 6 + 1) = 1.0f / state_size;
|
*(vertex_base + k * 6 + 1) = 1.0f / space_size_x;
|
||||||
*(vertex_base + k * 6 + 2) = 0.0f;
|
*(vertex_base + k * 6 + 2) = 0.0f;
|
||||||
|
|
||||||
*(vertex_base + k * 6 + 3) = - x;
|
*(vertex_base + k * 6 + 3) = - x;
|
||||||
*(vertex_base + k * 6 + 4) = - 1.0f / state_size;
|
*(vertex_base + k * 6 + 4) = - 1.0f / space_size_x;
|
||||||
*(vertex_base + k * 6 + 5) = 0.0f;
|
*(vertex_base + k * 6 + 5) = 0.0f;
|
||||||
|
|
||||||
*(color_base + k * 6 + 0) = 1;
|
*(color_base + k * 6 + 0) = 1;
|
||||||
|
@ -94,28 +94,28 @@ static bool compute_space_2D(int state_size,
|
||||||
*(color_base + 4) = 1;
|
*(color_base + 4) = 1;
|
||||||
*(color_base + 5) = 1;
|
*(color_base + 5) = 1;
|
||||||
|
|
||||||
*(color_base + (state_size - 1) * 6 + 0) = 1;
|
*(color_base + (space_size_x - 1) * 6 + 0) = 1;
|
||||||
*(color_base + (state_size - 1) * 6 + 1) = 1;
|
*(color_base + (space_size_x - 1) * 6 + 1) = 1;
|
||||||
*(color_base + (state_size - 1) * 6 + 2) = 1;
|
*(color_base + (space_size_x - 1) * 6 + 2) = 1;
|
||||||
|
|
||||||
*(color_base + (state_size - 1) * 6 + 3) = 0;
|
*(color_base + (space_size_x - 1) * 6 + 3) = 0;
|
||||||
*(color_base + (state_size - 1) * 6 + 4) = 0;
|
*(color_base + (space_size_x - 1) * 6 + 4) = 0;
|
||||||
*(color_base + (state_size - 1) * 6 + 5) = 0;
|
*(color_base + (space_size_x - 1) * 6 + 5) = 0;
|
||||||
|
|
||||||
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
|
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x);
|
||||||
|
|
||||||
for (int k = 0; k < state_size * 2; k++) *(line_origin + k) = k;
|
for (int k = 0; k < space_size_x * 2; k++) *(line_origin + k) = k;
|
||||||
line_ndx += state_size * 2;
|
line_ndx += space_size_x * 2;
|
||||||
|
|
||||||
*(line_origin + line_ndx + 0) = 0;
|
*(line_origin + line_ndx + 0) = 0;
|
||||||
*(line_origin + line_ndx + 1) = state_size * 2 - 2; // barre horizontale du bas
|
*(line_origin + line_ndx + 1) = space_size_x * 2 - 2; // barre horizontale du bas
|
||||||
|
|
||||||
*(line_origin + line_ndx + 2) = 1;
|
*(line_origin + line_ndx + 2) = 1;
|
||||||
*(line_origin + line_ndx + 3) = state_size * 2 - 1; // barre horizontale du haut
|
*(line_origin + line_ndx + 3) = space_size_x * 2 - 1; // barre horizontale du haut
|
||||||
|
|
||||||
if (I) printf("line_origin (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1);
|
if (I) printf("line_origin (%d - space_size_x(0)) x (%d - space_size_x(1)) ", 0, 1);
|
||||||
|
|
||||||
for (int v = 0; v < state_size + 2; v++)
|
for (int v = 0; v < space_size_x + 2; v++)
|
||||||
if (I) printf("(%d-%d) ", *(line_origin + v), *(line_origin + v + 1));
|
if (I) printf("(%d-%d) ", *(line_origin + v), *(line_origin + v + 1));
|
||||||
|
|
||||||
if (pref_mark_unit_space_first) { // diagonales to mark first space unit
|
if (pref_mark_unit_space_first) { // diagonales to mark first space unit
|
||||||
|
@ -128,98 +128,109 @@ static bool compute_space_2D(int state_size,
|
||||||
|
|
||||||
if (pref_mark_unit_space_last) { // diagonales to mark last space unit
|
if (pref_mark_unit_space_last) { // diagonales to mark last space unit
|
||||||
line_ndx +=4;
|
line_ndx +=4;
|
||||||
*(line_origin + line_ndx + 0) = (state_size - 2) * 2 + 0;
|
*(line_origin + line_ndx + 0) = (space_size_x - 2) * 2 + 0;
|
||||||
*(line_origin + line_ndx + 1) = (state_size - 2) * 2 + 3;
|
*(line_origin + line_ndx + 1) = (space_size_x - 2) * 2 + 3;
|
||||||
*(line_origin + line_ndx + 2) = (state_size - 2) * 2 + 1;
|
*(line_origin + line_ndx + 2) = (space_size_x - 2) * 2 + 1;
|
||||||
*(line_origin + line_ndx + 3) = (state_size - 2) * 2 + 2;
|
*(line_origin + line_ndx + 3) = (space_size_x - 2) * 2 + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
|
if (I) printf(" n = 4 + (%d x 2)\n", space_size_x + 2);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compute_arrow_2D(int state_size,
|
static bool compute_arrow_2D(int space_size_x,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base,
|
||||||
GLubyte *line_origin, GLubyte *plan_ndx,
|
GLfloat *color_base,
|
||||||
int vgap, int igap, int cgap,
|
GLubyte *line_origin,
|
||||||
|
GLubyte *plan_origin,
|
||||||
|
bool pref_lines_planes_or_mix,
|
||||||
|
int vgap, int cgap, int lgap, int pgap,
|
||||||
int weight, int site, int x, int y, int z)
|
int weight, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
|
||||||
float zero = 0.0f;
|
float zero = 0.0f;
|
||||||
float center = (1.0f / state_size) * (2 * x - state_size + 2);
|
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
||||||
// float tip = center + (2 * site - 1) * (1.0f / state_size);
|
// float tip = center + (2 * site - 1) * (1.0f / space_size_x);
|
||||||
float base = center + (2 * site - 1) * (0.1f / state_size);
|
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
||||||
|
|
||||||
*(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / state_size - 0.01f);
|
vgap = space_size_x * 6;
|
||||||
|
|
||||||
|
*(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
||||||
*(vertex_base + vgap + 1) = zero;
|
*(vertex_base + vgap + 1) = zero;
|
||||||
*(vertex_base + vgap + 2) = zero;
|
*(vertex_base + vgap + 2) = zero;
|
||||||
|
|
||||||
*(vertex_base + vgap + 3) = base;
|
*(vertex_base + vgap + 3) = base;
|
||||||
*(vertex_base + vgap + 4) = 0.4f / state_size;
|
*(vertex_base + vgap + 4) = 0.4f / space_size_x;
|
||||||
*(vertex_base + vgap + 5) = zero;
|
*(vertex_base + vgap + 5) = zero;
|
||||||
|
|
||||||
*(vertex_base + vgap + 6) = base;
|
*(vertex_base + vgap + 6) = base;
|
||||||
*(vertex_base + vgap + 7) = - 0.4f / state_size;
|
*(vertex_base + vgap + 7) = - 0.4f / space_size_x;
|
||||||
*(vertex_base + vgap + 8) = zero;
|
*(vertex_base + vgap + 8) = zero;
|
||||||
|
|
||||||
|
lgap = space_size_x * 4;
|
||||||
|
|
||||||
*(line_origin + igap + 0) = vgap / 3 + 0;
|
if (pref_lines_planes_or_mix == 0) {
|
||||||
*(line_origin + igap + 1) = vgap / 3 + 1;
|
*(line_origin + lgap + 0) = vgap / 3 + 0;
|
||||||
*(line_origin + igap + 2) = vgap / 3 + 0;
|
*(line_origin + lgap + 1) = vgap / 3 + 1;
|
||||||
*(line_origin + igap + 3) = vgap / 3 + 2;
|
*(line_origin + lgap + 2) = vgap / 3 + 0;
|
||||||
*(line_origin + igap + 4) = vgap / 3 + 1;
|
*(line_origin + lgap + 3) = vgap / 3 + 2;
|
||||||
*(line_origin + igap + 5) = vgap / 3 + 2;
|
*(line_origin + lgap + 4) = vgap / 3 + 1;
|
||||||
|
*(line_origin + lgap + 5) = vgap / 3 + 2;
|
||||||
|
}
|
||||||
|
|
||||||
*(plan_ndx + 0) = vgap / 3 + 0;
|
pgap = 0;
|
||||||
*(plan_ndx + 1) = vgap / 3 + 1;
|
|
||||||
*(plan_ndx + 2) = vgap / 3 + 2;
|
|
||||||
|
|
||||||
*(plan_ndx + 3) = vgap / 3 + 0;
|
if (pref_lines_planes_or_mix == 1) {
|
||||||
*(plan_ndx + 4) = vgap / 3 + 1;
|
*(plan_origin + pgap + 0) = vgap / 3 + 0;
|
||||||
*(plan_ndx + 5) = vgap / 3 + 2;
|
*(plan_origin + pgap + 1) = vgap / 3 + 1;
|
||||||
|
*(plan_origin + pgap + 2) = vgap / 3 + 2;
|
||||||
|
|
||||||
return 1;
|
*(plan_origin + pgap + 3) = vgap / 3 + 0;
|
||||||
|
*(plan_origin + pgap + 4) = vgap / 3 + 1;
|
||||||
|
*(plan_origin + pgap + 5) = vgap / 3 + 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool compute_space_3D(int state_size,
|
static bool compute_space_3D(int space_size_x,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_origin,
|
GLubyte *line_origin, GLubyte *plan_origin,
|
||||||
|
bool pref_lines_planes_or_mix,
|
||||||
bool pref_mark_unit_space_first,
|
bool pref_mark_unit_space_first,
|
||||||
bool pref_mark_unit_space_last)
|
bool pref_mark_unit_space_last)
|
||||||
{
|
{
|
||||||
|
|
||||||
float x = 0;
|
float x = 0;
|
||||||
// for (int k = 0; k < state_size + 1; k++) <=> + 1 car
|
// for (int k = 0; k < space_size_x + 1; k++) <=> + 1 car
|
||||||
// on passe du nombre de cases = (n)
|
// on passe du nombre de cases = (n)
|
||||||
// au nombre de séparations entre les cases + les deux bords = (n + 1)
|
// au nombre de séparations entre les cases + les deux bords = (n + 1)
|
||||||
|
|
||||||
if (V) printf("vertices ");
|
if (V) printf("vertex ");
|
||||||
for (int k = 0; k < state_size; k++){ // barres verticales
|
for (int k = 0; k < space_size_x; k++){ // barres verticales
|
||||||
//
|
//
|
||||||
x = ((state_size % 2) * (state_size / 2 - k)
|
x = ((space_size_x % 2) * (space_size_x / 2 - k)
|
||||||
+ (state_size % 2 - 1) * (k + 0.5f - state_size / 2)) / state_size * 2 * EDGE;
|
+ (space_size_x % 2 - 1) * (k + 0.5f - space_size_x / 2)) / space_size_x * 2 * EDGE;
|
||||||
|
|
||||||
if (V) printf("[%1.1f] ", x);
|
if (V) printf("[%1.1f] ", x);
|
||||||
|
|
||||||
*(vertex_base + k * 12 + 0) = - x;
|
*(vertex_base + k * 12 + 0) = - x;
|
||||||
*(vertex_base + k * 12 + 1) = 1.0f / state_size;
|
*(vertex_base + k * 12 + 1) = 1.0f / space_size_x;
|
||||||
*(vertex_base + k * 12 + 2) = 1.0f / state_size;
|
*(vertex_base + k * 12 + 2) = 1.0f / space_size_x;
|
||||||
|
|
||||||
*(vertex_base + k * 12 + 3) = - x;
|
*(vertex_base + k * 12 + 3) = - x;
|
||||||
*(vertex_base + k * 12 + 4) = - 1.0f / state_size;
|
*(vertex_base + k * 12 + 4) = - 1.0f / space_size_x;
|
||||||
*(vertex_base + k * 12 + 5) = - 1.0f / state_size;
|
*(vertex_base + k * 12 + 5) = - 1.0f / space_size_x;
|
||||||
|
|
||||||
*(vertex_base + k * 12 + 6) = - x;
|
*(vertex_base + k * 12 + 6) = - x;
|
||||||
*(vertex_base + k * 12 + 7) = 1.0f / state_size;
|
*(vertex_base + k * 12 + 7) = 1.0f / space_size_x;
|
||||||
*(vertex_base + k * 12 + 8) = - 1.0f / state_size;
|
*(vertex_base + k * 12 + 8) = - 1.0f / space_size_x;
|
||||||
|
|
||||||
*(vertex_base + k * 12 + 9) = - x;
|
*(vertex_base + k * 12 + 9) = - x;
|
||||||
*(vertex_base + k * 12 + 10) = - 1.0f / state_size;
|
*(vertex_base + k * 12 + 10) = - 1.0f / space_size_x;
|
||||||
*(vertex_base + k * 12 + 11) = 1.0f / state_size;
|
*(vertex_base + k * 12 + 11) = 1.0f / space_size_x;
|
||||||
|
|
||||||
*(color_base + k * 12 + 0) = 1; // 1 - (k / state_size);
|
*(color_base + k * 12 + 0) = 1; // 1 - (k / space_size_x);
|
||||||
*(color_base + k * 12 + 1) = 0;
|
*(color_base + k * 12 + 1) = 0;
|
||||||
*(color_base + k * 12 + 2) = 0;
|
*(color_base + k * 12 + 2) = 0;
|
||||||
|
|
||||||
|
@ -252,47 +263,47 @@ static bool compute_space_3D(int state_size,
|
||||||
*(color_base + 10) = 1;
|
*(color_base + 10) = 1;
|
||||||
*(color_base + 11) = 1;
|
*(color_base + 11) = 1;
|
||||||
|
|
||||||
*(color_base + (state_size - 1) * 12 + 0) = 1;
|
*(color_base + (space_size_x - 1) * 12 + 0) = 1;
|
||||||
*(color_base + (state_size - 1) * 12 + 1) = 1;
|
*(color_base + (space_size_x - 1) * 12 + 1) = 1;
|
||||||
*(color_base + (state_size - 1) * 12 + 2) = 1;
|
*(color_base + (space_size_x - 1) * 12 + 2) = 1;
|
||||||
|
|
||||||
*(color_base + (state_size - 1) * 12 + 3) = 0;
|
*(color_base + (space_size_x - 1) * 12 + 3) = 0;
|
||||||
*(color_base + (state_size - 1) * 12 + 4) = 0;
|
*(color_base + (space_size_x - 1) * 12 + 4) = 0;
|
||||||
*(color_base + (state_size - 1) * 12 + 5) = 0;
|
*(color_base + (space_size_x - 1) * 12 + 5) = 0;
|
||||||
|
|
||||||
*(color_base + (state_size - 1) * 12 + 6) = 0;
|
*(color_base + (space_size_x - 1) * 12 + 6) = 0;
|
||||||
*(color_base + (state_size - 1) * 12 + 7) = 0;
|
*(color_base + (space_size_x - 1) * 12 + 7) = 0;
|
||||||
*(color_base + (state_size - 1) * 12 + 8) = 0;
|
*(color_base + (space_size_x - 1) * 12 + 8) = 0;
|
||||||
|
|
||||||
*(color_base + (state_size - 1) * 12 + 9) = 1;
|
*(color_base + (space_size_x - 1) * 12 + 9) = 1;
|
||||||
*(color_base + (state_size - 1) * 12 + 10) = 1;
|
*(color_base + (space_size_x - 1) * 12 + 10) = 1;
|
||||||
*(color_base + (state_size - 1) * 12 + 11) = 1;
|
*(color_base + (space_size_x - 1) * 12 + 11) = 1;
|
||||||
|
|
||||||
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", state_size + 1, 2.0f / state_size);
|
if (V) printf(" n = %d x 2 côté = [%1.1f]\n", space_size_x + 1, 2.0f / space_size_x);
|
||||||
|
|
||||||
*(line_origin + 4) = 0;
|
*(line_origin + 4) = 0;
|
||||||
*(line_origin + 5) = state_size * 4 - 4; // barre horizontale du bas arr
|
*(line_origin + 5) = space_size_x * 4 - 4; // barre horizontale du bas arr
|
||||||
|
|
||||||
*(line_origin + 6) = 1;
|
*(line_origin + 6) = 1;
|
||||||
*(line_origin + 7) = state_size * 4 - 3; // barre horizontale du haut arr
|
*(line_origin + 7) = space_size_x * 4 - 3; // barre horizontale du haut arr
|
||||||
|
|
||||||
*(line_origin + 0) = 2;
|
*(line_origin + 0) = 2;
|
||||||
*(line_origin + 1) = state_size * 4 - 2; // barre horizontale du bas av
|
*(line_origin + 1) = space_size_x * 4 - 2; // barre horizontale du bas av
|
||||||
|
|
||||||
*(line_origin + 2) = 3;
|
*(line_origin + 2) = 3;
|
||||||
*(line_origin + 3) = state_size * 4 - 1; // barre horizontale du haut av
|
*(line_origin + 3) = space_size_x * 4 - 1; // barre horizontale du haut av
|
||||||
|
|
||||||
|
|
||||||
/* *(plan_ndx + 0) = 0; */
|
/* *(plan_origin + 0) = 0; */
|
||||||
/* *(plan_ndx + 1) = 1; */
|
/* *(plan_origin + 1) = 1; */
|
||||||
/* *(plan_ndx + 2) = 2; */
|
/* *(plan_origin + 2) = 2; */
|
||||||
|
|
||||||
/* *(plan_ndx + 3) = 0; */
|
/* *(plan_origin + 3) = 0; */
|
||||||
/* *(plan_ndx + 4) = 1; */
|
/* *(plan_origin + 4) = 1; */
|
||||||
/* *(plan_ndx + 5) = 3; */
|
/* *(plan_origin + 5) = 3; */
|
||||||
|
|
||||||
|
|
||||||
for (int k = 8; k <= state_size * 8; k += 8){ // for (int k = 8; k < state_size * 8; k += 8){
|
for (int k = 8; k <= space_size_x * 8; k += 8){ // for (int k = 8; k < space_size_x * 8; k += 8){
|
||||||
|
|
||||||
|
|
||||||
*(line_origin + k + 0) = k / 2 - 4; // + 0;
|
*(line_origin + k + 0) = k / 2 - 4; // + 0;
|
||||||
|
@ -310,24 +321,24 @@ static bool compute_space_3D(int state_size,
|
||||||
|
|
||||||
if (pref_mark_unit_space_first) {
|
if (pref_mark_unit_space_first) {
|
||||||
|
|
||||||
*(line_origin + (2 + state_size) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
*(line_origin + (2 + space_size_x) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
||||||
*(line_origin + (2 + state_size) * 8 - 3) = 0 + 1;
|
*(line_origin + (2 + space_size_x) * 8 - 3) = 0 + 1;
|
||||||
|
|
||||||
*(line_origin + (2 + state_size) * 8 - 2) = 0 + 2; // diagonales pour marquer la case zéro
|
*(line_origin + (2 + space_size_x) * 8 - 2) = 0 + 2; // diagonales pour marquer la case zéro
|
||||||
*(line_origin + (2 + state_size) * 8 - 1) = 0 + 3;
|
*(line_origin + (2 + space_size_x) * 8 - 1) = 0 + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pref_mark_unit_space_last) {
|
if (pref_mark_unit_space_last) {
|
||||||
|
|
||||||
*(line_origin + (2 + state_size) * 8 - 8) = (state_size - 1) * 4 + 0; // diagonales pour marquer la case finale
|
*(line_origin + (2 + space_size_x) * 8 - 8) = (space_size_x - 1) * 4 + 0; // diagonales pour marquer la case finale
|
||||||
*(line_origin + (2 + state_size) * 8 - 7) = (state_size - 1) * 4 + 1;
|
*(line_origin + (2 + space_size_x) * 8 - 7) = (space_size_x - 1) * 4 + 1;
|
||||||
|
|
||||||
*(line_origin + (2 + state_size) * 8 - 6) = (state_size - 1) * 4 + 2; // diagonales pour marquer la case finale
|
*(line_origin + (2 + space_size_x) * 8 - 6) = (space_size_x - 1) * 4 + 2; // diagonales pour marquer la case finale
|
||||||
*(line_origin + (2 + state_size) * 8 - 5) = (state_size - 1) * 4 + 3;
|
*(line_origin + (2 + space_size_x) * 8 - 5) = (space_size_x - 1) * 4 + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (I) printf("line_origin ");
|
if (I) printf("line_origin ");
|
||||||
for (int v = 0; v < state_size + 2; v++) {
|
for (int v = 0; v < space_size_x + 2; v++) {
|
||||||
if (I) printf("(%d-%d) ", *(line_origin + v), *(line_origin + v + 1));
|
if (I) printf("(%d-%d) ", *(line_origin + v), *(line_origin + v + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,95 +349,117 @@ if (pref_mark_unit_space_last) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool compute_arrow_3D(int state_size,
|
static bool compute_arrow_3D(int space_size_x,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_origin, GLubyte *plan_ndx,
|
GLubyte *line_origin, GLubyte *plan_origin,
|
||||||
int vgap, int igap, int cgap,
|
bool pref_lines_planes_or_mix,
|
||||||
|
int vgap, int cgap, int lgap, int pgap,
|
||||||
int weight, int site, int x, int y, int z)
|
int weight, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
float zero = 0.0f;
|
float zero = 0.0f;
|
||||||
float center = (1.0f / state_size) * (2 * x - state_size + 2);
|
float center = (1.0f / space_size_x) * (2 * x - space_size_x + 2);
|
||||||
float tip = center + (2 * site - 1) * (1.0f / state_size);
|
float tip = center + (2 * site - 1) * (1.0f / space_size_x);
|
||||||
float base = center + (2 * site - 1) * (0.1f / state_size);
|
float base = center + (2 * site - 1) * (0.1f / space_size_x);
|
||||||
|
|
||||||
if (I) printf("compute_arrow_3D vgap = %d\n", vgap);
|
if (I) printf("compute_arrow_3D vgap = %d\n", vgap);
|
||||||
|
|
||||||
*(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / state_size - 0.01f);
|
vgap = space_size_x * 12;
|
||||||
|
|
||||||
|
*(vertex_base + vgap + 0) = center + (2 * site - 1) * (1.0f / space_size_x - 0.01f);
|
||||||
*(vertex_base + vgap + 1) = zero;
|
*(vertex_base + vgap + 1) = zero;
|
||||||
*(vertex_base + vgap + 2) = zero;
|
*(vertex_base + vgap + 2) = zero;
|
||||||
|
|
||||||
*(vertex_base + vgap + 3) = base;
|
*(vertex_base + vgap + 3) = base;
|
||||||
*(vertex_base + vgap + 4) = 0.4f / state_size;
|
*(vertex_base + vgap + 4) = 0.4f / space_size_x;
|
||||||
*(vertex_base + vgap + 5) = 0.4f / state_size;
|
*(vertex_base + vgap + 5) = 0.4f / space_size_x;
|
||||||
|
|
||||||
*(vertex_base + vgap + 6) = base;
|
*(vertex_base + vgap + 6) = base;
|
||||||
*(vertex_base + vgap + 7) = 0.4f / state_size;
|
*(vertex_base + vgap + 7) = 0.4f / space_size_x;
|
||||||
*(vertex_base + vgap + 8) = - 0.4f / state_size;
|
*(vertex_base + vgap + 8) = - 0.4f / space_size_x;
|
||||||
|
|
||||||
*(vertex_base + vgap + 9) = base;
|
*(vertex_base + vgap + 9) = base;
|
||||||
*(vertex_base + vgap + 10) = - 0.4f / state_size;
|
*(vertex_base + vgap + 10) = - 0.4f / space_size_x;
|
||||||
*(vertex_base + vgap + 11) = - 0.4f / state_size;
|
*(vertex_base + vgap + 11) = - 0.4f / space_size_x;
|
||||||
|
|
||||||
*(vertex_base + vgap + 12) = base;
|
*(vertex_base + vgap + 12) = base;
|
||||||
*(vertex_base + vgap + 13) = - 0.4f / state_size;
|
*(vertex_base + vgap + 13) = - 0.4f / space_size_x;
|
||||||
*(vertex_base + vgap + 14) = 0.4f / state_size;
|
*(vertex_base + vgap + 14) = 0.4f / space_size_x;
|
||||||
|
|
||||||
if (I) printf("x = %d site = %d center = %f tip = %f base = %f\n",\
|
if (I) printf("x = %d site = %d center = %f tip = %f base = %f\n",\
|
||||||
x, site, center, tip, base); // vgap=%d igap=%d
|
x, site, center, tip, base); // vgap=%d igap=%d
|
||||||
|
|
||||||
*(line_origin + igap + 0) = vgap / 3 + 0;
|
if (pref_lines_planes_or_mix == 0) {
|
||||||
*(line_origin + igap + 1) = vgap / 3 + 1;
|
|
||||||
|
|
||||||
*(line_origin + igap + 2) = vgap / 3 + 0;
|
lgap = space_size_x * 11;
|
||||||
*(line_origin + igap + 3) = vgap / 3 + 2;
|
|
||||||
|
|
||||||
*(line_origin + igap + 4) = vgap / 3 + 0;
|
*(line_origin + lgap + 0) = vgap / 3 + 0;
|
||||||
*(line_origin + igap + 5) = vgap / 3 + 3;
|
*(line_origin + lgap + 1) = vgap / 3 + 1;
|
||||||
|
|
||||||
*(line_origin + igap + 6) = vgap / 3 + 0;
|
*(line_origin + lgap + 2) = vgap / 3 + 0;
|
||||||
*(line_origin + igap + 7) = vgap / 3 + 4;
|
*(line_origin + lgap + 3) = vgap / 3 + 2;
|
||||||
|
|
||||||
*(line_origin + igap + 8) = vgap / 3 + 1;
|
*(line_origin + lgap + 4) = vgap / 3 + 0;
|
||||||
*(line_origin + igap + 9) = vgap / 3 + 2;
|
*(line_origin + lgap + 5) = vgap / 3 + 3;
|
||||||
|
|
||||||
*(line_origin + igap + 10) = vgap / 3 + 2;
|
*(line_origin + lgap + 6) = vgap / 3 + 0;
|
||||||
*(line_origin + igap + 11) = vgap / 3 + 3;
|
*(line_origin + lgap + 7) = vgap / 3 + 4;
|
||||||
|
|
||||||
*(line_origin + igap + 12) = vgap / 3 + 3;
|
*(line_origin + lgap + 8) = vgap / 3 + 1;
|
||||||
*(line_origin + igap + 13) = vgap / 3 + 4;
|
*(line_origin + lgap + 9) = vgap / 3 + 2;
|
||||||
|
|
||||||
*(line_origin + igap + 14) = vgap / 3 + 4;
|
*(line_origin + lgap + 10) = vgap / 3 + 2;
|
||||||
*(line_origin + igap + 15) = vgap / 3 + 1;
|
*(line_origin + lgap + 11) = vgap / 3 + 3;
|
||||||
|
|
||||||
|
*(line_origin + lgap + 12) = vgap / 3 + 3;
|
||||||
|
*(line_origin + lgap + 13) = vgap / 3 + 4;
|
||||||
|
|
||||||
*(plan_ndx + 0) = vgap / 3 + 0;
|
*(line_origin + lgap + 14) = vgap / 3 + 4;
|
||||||
*(plan_ndx + 1) = vgap / 3 + 1;
|
*(line_origin + lgap + 15) = vgap / 3 + 1;
|
||||||
*(plan_ndx + 2) = vgap / 3 + 2;
|
}
|
||||||
|
|
||||||
*(plan_ndx + 3) = vgap / 3 + 0;
|
if (pref_lines_planes_or_mix == 1) {
|
||||||
*(plan_ndx + 4) = vgap / 3 + 1;
|
|
||||||
*(plan_ndx + 5) = vgap / 3 + 2;
|
pgap = 0;
|
||||||
|
|
||||||
|
*(plan_origin + pgap + 0) = vgap / 3 + 0;
|
||||||
|
*(plan_origin + pgap + 1) = vgap / 3 + 1;
|
||||||
|
*(plan_origin + pgap + 2) = vgap / 3 + 2;
|
||||||
|
|
||||||
|
*(plan_origin + pgap + 3) = vgap / 3 + 0;
|
||||||
|
*(plan_origin + pgap + 4) = vgap / 3 + 3;
|
||||||
|
*(plan_origin + pgap + 5) = vgap / 3 + 4;
|
||||||
|
|
||||||
|
*(plan_origin + pgap + 0) = vgap / 3 + 0;
|
||||||
|
*(plan_origin + pgap + 1) = vgap / 3 + 1;
|
||||||
|
*(plan_origin + pgap + 2) = vgap / 3 + 3;
|
||||||
|
|
||||||
|
*(plan_origin + pgap + 3) = vgap / 3 + 0;
|
||||||
|
*(plan_origin + pgap + 4) = vgap / 3 + 2;
|
||||||
|
*(plan_origin + pgap + 5) = vgap / 3 + 4;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define A 1
|
||||||
bool compute_space(int model_space_size_x,
|
bool compute_space_and_arrows(int model_space_size_x,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_origin, GLubyte *plan_origin,
|
GLubyte *line_origin, GLubyte *plan_origin,
|
||||||
GLubyte *arrows,
|
GLubyte *arrows, int model_arrows_nb,
|
||||||
|
int vgap, int cgap, int lgap, int pgap,
|
||||||
bool pref_3D_xor_2D_space,
|
bool pref_3D_xor_2D_space,
|
||||||
bool pref_lines_planes_or_mix,
|
bool pref_lines_planes_or_mix,
|
||||||
bool pref_mark_unit_space_first,
|
bool pref_mark_unit_space_first,
|
||||||
bool pref_mark_unit_space_last)
|
bool pref_mark_unit_space_last)
|
||||||
{
|
{
|
||||||
printf("Prefer : mark_unit_space_first = %d mark_unit_space_last = %d 3D_xor_2D_space = %d\n",
|
if (A) printf("buffers.compute_space_and_arrows() prefer : mark_unit_space_first = %d\
|
||||||
|
mark_unit_space_last = %d 3D_xor_2D_space = %d (0 is 3D) (1 is 2D)\n",
|
||||||
pref_mark_unit_space_first, pref_mark_unit_space_last, pref_3D_xor_2D_space);
|
pref_mark_unit_space_first, pref_mark_unit_space_last, pref_3D_xor_2D_space);
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) { // 2D
|
printf("buffers.compute_space_and_arrows() vgap %d cgap %d lgap %d pgap %d \n", vgap, cgap, lgap, pgap);
|
||||||
printf("buffers.compute_space() pref_3D_xor_2D_space > 2D \n");
|
|
||||||
|
|
||||||
|
if (pref_3D_xor_2D_space){
|
||||||
compute_space_2D(model_space_size_x,
|
compute_space_2D(model_space_size_x,
|
||||||
vertex_base, color_base,
|
vertex_base, color_base,
|
||||||
line_origin, plan_origin,
|
line_origin, plan_origin,
|
||||||
|
@ -434,9 +467,45 @@ bool compute_space(int model_space_size_x,
|
||||||
pref_mark_unit_space_first,
|
pref_mark_unit_space_first,
|
||||||
pref_mark_unit_space_last);
|
pref_mark_unit_space_last);
|
||||||
|
|
||||||
return 0;
|
// GLubyte arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
||||||
|
if (A) for (int i = 0; i < model_arrows_nb; i++) {
|
||||||
|
printf("[%d] = %2d, %2d, %2d\n",\
|
||||||
|
i, *(arrows + i * 3), *(arrows + i * 3 + 1), *(arrows + i * 3 + 2));
|
||||||
|
}
|
||||||
|
{ // ... on verra demain ...
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
compute_arrow_2D(model_space_size_x,
|
||||||
|
vertex_base, color_base,
|
||||||
|
line_origin, plan_origin,
|
||||||
|
pref_lines_planes_or_mix,
|
||||||
|
vgap, cgap, lgap, pgap,
|
||||||
|
*(arrows + i * 3 + 0),
|
||||||
|
*(arrows + i * 3 + 1),
|
||||||
|
*(arrows + i * 3 + 2),
|
||||||
|
0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
} else { // 3D
|
} else { // 3D
|
||||||
printf("buffers.compute_space() pref_3D_xor_2D_space > 3D \n");
|
|
||||||
|
compute_space_3D(model_space_size_x,
|
||||||
|
vertex_base, color_base,
|
||||||
|
line_origin, plan_origin,
|
||||||
|
pref_lines_planes_or_mix,
|
||||||
|
pref_mark_unit_space_first,
|
||||||
|
pref_mark_unit_space_last);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
compute_arrow_3D(model_space_size_x,
|
||||||
|
vertex_base, color_base,
|
||||||
|
line_origin, plan_origin,
|
||||||
|
pref_lines_planes_or_mix,
|
||||||
|
vgap, cgap, lgap, pgap,
|
||||||
|
*(arrows + i * 3 + 0),
|
||||||
|
*(arrows + i * 3 + 1),
|
||||||
|
*(arrows + i * 3 + 2),
|
||||||
|
0, 0);
|
||||||
|
|
||||||
/* compute_arrow_3D(model_space_size_x, */
|
/* compute_arrow_3D(model_space_size_x, */
|
||||||
/* vertex_base, color_base, */
|
/* vertex_base, color_base, */
|
||||||
|
@ -450,9 +519,7 @@ bool compute_space(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;
|
|
||||||
}
|
}
|
||||||
printf("buffers.compute_space() end.\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -489,12 +489,13 @@ int model_space_size_x = 0;
|
||||||
int model_space_size_y = 0;
|
int model_space_size_y = 0;
|
||||||
int model_space_size_z = 0;
|
int model_space_size_z = 0;
|
||||||
int model_arrows_nb = 0;
|
int model_arrows_nb = 0;
|
||||||
GLubyte *arrows = NULL; //{ 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
GLubyte // arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }; // GLubyte ?
|
||||||
|
arrows[] = { 1, 1, 0, 1, 2, 1, 1, 1, 3, 1, 2, 4, 1, 1, 6, 1, 2, 7 };
|
||||||
|
|
||||||
|
|
||||||
bool pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
bool pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
||||||
bool pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
|
bool pref_3D_xor_2D_arrows = 0; // default view == 0 == 3D
|
||||||
bool pref_lines_planes_or_mix = 0; // default view == 0 == lines only
|
bool pref_lines_planes_or_mix = 0; // arrows as lines = 0, as planes = 1
|
||||||
bool pref_mark_unit_space_first = 0; // default == 0 == no mark
|
bool pref_mark_unit_space_first = 0; // default == 0 == no mark
|
||||||
bool pref_mark_unit_space_last = 0; // default == 0 == no mark
|
bool pref_mark_unit_space_last = 0; // default == 0 == no mark
|
||||||
bool pref_background_color = 0; // don't know yet...
|
bool pref_background_color = 0; // don't know yet...
|
||||||
|
@ -514,15 +515,16 @@ static void get_model_data_and_user_preferences(){
|
||||||
// The model data (arrows) to use (from model.xml)
|
// The model data (arrows) to use (from model.xml)
|
||||||
// int *arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
// int *arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 };
|
||||||
|
|
||||||
model_space_size_x = 6; // 2 < model_space_size_x < 32
|
model_space_size_x = 12; // 2 < model_space_size_x < 32
|
||||||
model_arrows_nb = 0; // assert : leur emplacement est contraint par
|
model_arrows_nb = 6; // assert : leur emplacement est contraint par
|
||||||
// model_space_size_x, y, z et le nombre de sites
|
// model_space_size_x, y, z et le nombre de sites
|
||||||
|
|
||||||
pref_3D_xor_2D_space = 1; // default == 0 == 3D
|
pref_3D_xor_2D_space = 0; // default == 0 == 3D
|
||||||
pref_3D_xor_2D_arrows = 1; // default == 0 == 3D
|
pref_3D_xor_2D_arrows = 0; // default == 0 == 3D
|
||||||
pref_mark_unit_space_first = 1; // default == 0 == no mark
|
pref_mark_unit_space_first = 0; // default == 0 == no mark
|
||||||
pref_mark_unit_space_last = 1; // default == 0 == no mark
|
pref_mark_unit_space_last = 1; // default == 0 == no mark
|
||||||
pref_background_color = 0; // TODO
|
pref_background_color = 0; // TODO
|
||||||
|
pref_lines_planes_or_mix = 1; // arrows as lines = 0, as planes = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_buffers_sizes(int model_space_size_x,
|
static void compute_buffers_sizes(int model_space_size_x,
|
||||||
|
@ -610,7 +612,7 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
entry = find_entry_from_ptr(gl_area);
|
entry = find_entry_from_ptr(gl_area);
|
||||||
|
|
||||||
get_model_data_and_user_preferences();
|
get_model_data_and_user_preferences();
|
||||||
/* une struct en retour pour ne plus utiliser de variables globales ? (facile) */
|
/* une struct en retour pour ne plus utiliser de variables globales ? */
|
||||||
|
|
||||||
compute_buffers_sizes(model_space_size_x,
|
compute_buffers_sizes(model_space_size_x,
|
||||||
model_space_size_y,
|
model_space_size_y,
|
||||||
|
@ -622,16 +624,19 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
pref_mark_unit_space_first,
|
pref_mark_unit_space_first,
|
||||||
pref_mark_unit_space_last);
|
pref_mark_unit_space_last);
|
||||||
|
|
||||||
// g_malloc
|
|
||||||
vertex_base = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
vertex_base = g_malloc0(buffer_vertex_size * sizeof(GLfloat) * 2);
|
||||||
color_base = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
color_base = g_malloc0(buffer_colors_size * sizeof(GLfloat) * 2);
|
||||||
line_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLubyte) * 2);
|
line_origin = g_malloc0(buffer_lines_size * 2 * sizeof(GLubyte) * 2);
|
||||||
plan_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLubyte) * 2);
|
plan_origin = g_malloc0(buffer_plans_size * 3 * sizeof(GLubyte) * 2);
|
||||||
|
|
||||||
compute_space (model_space_size_x,
|
compute_space_and_arrows (model_space_size_x,
|
||||||
vertex_base, color_base,
|
vertex_base, color_base,
|
||||||
line_origin, plan_origin,
|
line_origin, plan_origin,
|
||||||
arrows,
|
arrows, model_arrows_nb,
|
||||||
|
buffer_vertex_size,
|
||||||
|
buffer_colors_size,
|
||||||
|
buffer_lines_size,
|
||||||
|
buffer_plans_size,
|
||||||
pref_3D_xor_2D_space,
|
pref_3D_xor_2D_space,
|
||||||
pref_lines_planes_or_mix,
|
pref_lines_planes_or_mix,
|
||||||
pref_mark_unit_space_first,
|
pref_mark_unit_space_first,
|
||||||
|
|
Loading…
Reference in New Issue