WIP: pref_3D_xor_2D_space and pref_mark_unit_space_zero seem OK (check)
This commit is contained in:
parent
28c45295c6
commit
a6927dbaa5
|
@ -27,4 +27,6 @@
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
bool compute_space_2D(int state_size,
|
bool compute_space_2D(int state_size,
|
||||||
GLfloat *vertex_base, GLubyte *line_ndx);
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
|
GLubyte *line_ndx,
|
||||||
|
bool pref_mark_unit_space_zero, int dgap);
|
||||||
|
|
|
@ -28,4 +28,5 @@
|
||||||
|
|
||||||
bool compute_space_3D(int state_size,
|
bool compute_space_3D(int state_size,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_ndx, int ad_hoc_diag);
|
GLubyte *line_ndx,
|
||||||
|
bool pref_mark_unit_space_zero, int dgap);
|
||||||
|
|
|
@ -46,14 +46,6 @@
|
||||||
#include "../../include/arrow_2D.h"
|
#include "../../include/arrow_2D.h"
|
||||||
#include "../../include/arrow_3D.h"
|
#include "../../include/arrow_3D.h"
|
||||||
|
|
||||||
/* int dim = 0; */
|
|
||||||
/* int state_size = 0; */
|
|
||||||
/* int vertex_nb = 0; */
|
|
||||||
/* int colors_nb = 0; */
|
|
||||||
/* int lines_nb = 0; */
|
|
||||||
/* int plans_nb = 0; */
|
|
||||||
/* int arrows_nb = 0; */
|
|
||||||
|
|
||||||
#define A 0
|
#define A 0
|
||||||
int graphics_compute_lines(int line_indices_nb,
|
int graphics_compute_lines(int line_indices_nb,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
|
@ -107,7 +99,9 @@ int graphics_compute_lines(int line_indices_nb,
|
||||||
assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
||||||
}
|
}
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, line_ndx, line_indices_nb);
|
compute_space_3D(state_size, vertex_base, color_base, line_ndx,
|
||||||
|
0,4); // patch provisoire
|
||||||
|
// pref_mark_unit_space_zero, dgap){
|
||||||
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
||||||
|
|
||||||
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
||||||
|
@ -261,7 +255,10 @@ int graphics_compute_plans(int plan_indices_nb,
|
||||||
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_nb);
|
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_nb);
|
||||||
// assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
// assert(k + 8 < line_indices_nb); assert(k + 16 < line_indices_nb);
|
||||||
|
|
||||||
compute_space_3D(state_size, vertex_base, color_base, plan_ndx, plan_indices_nb);
|
compute_space_3D(state_size, vertex_base, color_base, plan_ndx,
|
||||||
|
0,4); // patch provisoire
|
||||||
|
//pref_mark_unit_space_zero, dgap){
|
||||||
|
|
||||||
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
||||||
|
|
||||||
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
||||||
|
|
|
@ -550,7 +550,7 @@ int plans_nb = 0;
|
||||||
int arrows_nb = 0;
|
int arrows_nb = 0;
|
||||||
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_mark_unit_space_zero = 0; // default == no mark
|
bool pref_mark_unit_space_zero = 0; // default == 0 == no mark
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -562,9 +562,9 @@ static void get_model_data_and_user_preferences(){
|
||||||
state_size = 8; // 2 < state_size < 32
|
state_size = 8; // 2 < state_size < 32
|
||||||
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
|
arrows_nb = 4; // assert : leur emplacement doit être fonction de state_size
|
||||||
|
|
||||||
pref_3D_xor_2D_space = 1; // default view == 0 == 3D
|
pref_3D_xor_2D_space = 0; // default view == 0 == 3D
|
||||||
pref_3D_xor_2D_arrows = 1; // default view == 0 == 3D
|
pref_3D_xor_2D_arrows = 1; // default view == 0 == 3D
|
||||||
pref_mark_unit_space_zero = 1; // default == 0 == no mark
|
pref_mark_unit_space_zero = 0; // default == 0 == no mark
|
||||||
}
|
}
|
||||||
|
|
||||||
static void compute_vertex_colors_lines_plans_nb(int dim,
|
static void compute_vertex_colors_lines_plans_nb(int dim,
|
||||||
|
@ -579,7 +579,8 @@ static void compute_vertex_colors_lines_plans_nb(int dim,
|
||||||
|
|
||||||
colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO
|
colors_nb = (state_size + 1) * 12 + arrows_nb * 0; // TODO
|
||||||
|
|
||||||
printf("Prefer : mark_unit_space_zero = %d ", pref_mark_unit_space_zero);
|
printf("Prefer : mark_unit_space_zero = %d pref_3D_xor_2D_space = %d state_size = %d\n",
|
||||||
|
pref_mark_unit_space_zero, pref_3D_xor_2D_space, state_size);
|
||||||
|
|
||||||
if (pref_3D_xor_2D_space) lines_nb = (2 + state_size) + (arrows_nb * 3); // case 2D
|
if (pref_3D_xor_2D_space) lines_nb = (2 + state_size) + (arrows_nb * 3); // case 2D
|
||||||
else lines_nb = (4 + state_size * 4) + (arrows_nb * 8); // case 3D
|
else lines_nb = (4 + state_size * 4) + (arrows_nb * 8); // case 3D
|
||||||
|
@ -623,57 +624,27 @@ void graphics_init_buffers(const void *gl_area)
|
||||||
plan_ndx = g_malloc0(plans_nb * 3 * sizeof(GLubyte) * 2);
|
plan_ndx = g_malloc0(plans_nb * 3 * sizeof(GLubyte) * 2);
|
||||||
|
|
||||||
|
|
||||||
compute_space_2D(state_size, vertex_base, line_ndx);
|
|
||||||
|
|
||||||
int vgap = 0, igap = 0, cgap = 0, dgap = 0;
|
int vgap = 0, igap = 0, cgap = 0, dgap = 0;
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) dgap = 4; // 4 vertices for 2 diagonal lines
|
if (pref_mark_unit_space_zero) dgap = 4; // 4 vertices for 2 diagonal lines
|
||||||
//
|
|
||||||
vgap += (6 * state_size);
|
vgap += (6 * state_size);
|
||||||
igap += state_size * 2 + dgap;
|
igap += state_size * 2 + dgap;
|
||||||
cgap += (6 * state_size);
|
cgap += (6 * state_size);
|
||||||
|
|
||||||
if (pref_mark_unit_space_zero) { // diagonales pour marquer la case zéro
|
if (pref_3D_xor_2D_space) compute_space_2D(state_size,
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 0) = 0;
|
vertex_base, color_base,
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 1) = 3;
|
line_ndx,
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 2) = 1;
|
pref_mark_unit_space_zero, dgap);
|
||||||
*(line_ndx + state_size * 2 + 6 + dgap + 3) = 2;
|
else compute_space_3D(state_size,
|
||||||
}
|
vertex_base, color_base,
|
||||||
|
line_ndx,
|
||||||
|
pref_mark_unit_space_zero, dgap);
|
||||||
|
|
||||||
for (int k = 0; k < state_size; k++){
|
for (int k = 0; k < state_size; k++){
|
||||||
assert(k * 12 < vertex_nb); assert(k * 12 + 11 < vertex_nb);
|
assert(k * 12 < vertex_nb); assert(k * 12 + 11 < vertex_nb);
|
||||||
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_nb);
|
assert(k * 12 < colors_nb); assert(k * 12 + 11 < colors_nb);
|
||||||
assert(k + 8 < entry->line_indices_nb); assert(k + 16 < entry->line_indices_nb);
|
assert(k + 8 < entry->line_indices_nb); assert(k + 16 < entry->line_indices_nb);
|
||||||
}
|
}
|
||||||
// compute_space_3D(state_size, vertex_base, color_base, line_ndx, entry->line_indices_nb);
|
|
||||||
// vgap += (12 * state_size); igap += state_size * 8 + 8; cgap += (12 * state_size);
|
|
||||||
|
|
||||||
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
|
||||||
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
|
|
||||||
/* compute_arrow_2D(state_size, vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 0, 0, 0); */
|
|
||||||
/* // if (A) printf("compute_arrow_2D vgap = %d vertex_nb = %d\n", vgap, vertex_nb); */
|
|
||||||
/* // if (A) printf("x = %d site = %d center = %f tip = %f base = %f\n",\ */
|
|
||||||
/* // x, site, center, tip, base); // vgap=%d igap=%d */
|
|
||||||
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
|
||||||
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
|
|
||||||
/* compute_arrow_2D(state_size, vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 1, 2, 0, 0); */
|
|
||||||
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
|
||||||
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
|
|
||||||
/* compute_arrow_2D(state_size, vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 0, 3, 0, 0); */
|
|
||||||
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
/* assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb); */
|
|
||||||
/* assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb); */
|
|
||||||
/* compute_arrow_2D(state_size, vertex_base, color_base, */
|
|
||||||
/* line_ndx, plan_ndx, vgap, igap, cgap, 1, 1, state_size - 2, 0, 0); */
|
|
||||||
/* vgap += 9; igap += 6; cgap += 15; ++arrows_nb; */
|
|
||||||
|
|
||||||
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
|
assert(vgap < vertex_nb); assert(vgap + 9 < vertex_nb);
|
||||||
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
|
assert(igap < entry->line_indices_nb); assert(igap + 5 < entry->line_indices_nb);
|
||||||
|
|
|
@ -28,7 +28,9 @@
|
||||||
#define I 0
|
#define I 0
|
||||||
#define EDGE 0.999999
|
#define EDGE 0.999999
|
||||||
bool compute_space_2D(int state_size,
|
bool compute_space_2D(int state_size,
|
||||||
GLfloat *vertex_base, GLubyte *line_ndx){
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
|
GLubyte *line_ndx,
|
||||||
|
bool pref_mark_unit_space_zero, int dgap){
|
||||||
|
|
||||||
float x = 0;
|
float x = 0;
|
||||||
// for (int k = 0; k < state_size + 1; k++) <=> + 1
|
// for (int k = 0; k < state_size + 1; k++) <=> + 1
|
||||||
|
@ -67,6 +69,13 @@ bool compute_space_2D(int state_size,
|
||||||
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space_zero) { // diagonales pour marquer la case zéro
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 0) = 0;
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 1) = 3;
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 2) = 1;
|
||||||
|
*(line_ndx + state_size * 2 + 6 + dgap + 3) = 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
|
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -25,12 +25,13 @@
|
||||||
#include <epoxy/gl.h>
|
#include <epoxy/gl.h>
|
||||||
|
|
||||||
#define V 1
|
#define V 1
|
||||||
#define I 0
|
#define I 1
|
||||||
#define EDGE 0.999999
|
#define EDGE 0.999999
|
||||||
|
|
||||||
bool compute_space_3D(int state_size,
|
bool compute_space_3D(int state_size,
|
||||||
GLfloat *vertex_base, GLfloat *color_base,
|
GLfloat *vertex_base, GLfloat *color_base,
|
||||||
GLubyte *line_ndx, int ad_hoc_diag){
|
GLubyte *line_ndx,
|
||||||
|
bool pref_mark_unit_space_zero, int dgap){
|
||||||
|
|
||||||
float x = 0;
|
float x = 0;
|
||||||
// for (int k = 0; k < state_size + 1; k++) <=> + 1 car
|
// for (int k = 0; k < state_size + 1; k++) <=> + 1 car
|
||||||
|
@ -128,22 +129,26 @@ bool compute_space_3D(int state_size,
|
||||||
*(line_ndx + k + 7) = k / 2 - 2; // + 2;
|
*(line_ndx + k + 7) = k / 2 - 2; // + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pref_mark_unit_space_zero) {
|
||||||
|
|
||||||
*(line_ndx + ad_hoc_diag - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
*(line_ndx + (2 + state_size) * 8 - 4) = 0 + 0; // diagonales pour marquer la case zéro
|
||||||
*(line_ndx + ad_hoc_diag - 3) = 0 + 1;
|
*(line_ndx + (2 + state_size) * 8 - 3) = 0 + 1;
|
||||||
|
|
||||||
*(line_ndx + ad_hoc_diag - 2) = 0 + 2; // diagonales pour marquer la case zéro
|
*(line_ndx + (2 + state_size) * 8 - 2) = 0 + 2; // diagonales pour marquer la case zéro
|
||||||
*(line_ndx + ad_hoc_diag - 1) = 0 + 3;
|
*(line_ndx + (2 + state_size) * 8 - 1) = 0 + 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (I) printf("line_ndx ");
|
||||||
if (I) printf("line_ndx (%d - state_size(0)) x (%d - state_size(1)) ", 0, 1);
|
|
||||||
for (int v = 0; v < state_size + 2; v++) {
|
for (int v = 0; v < state_size + 2; v++) {
|
||||||
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
if (I) printf("(%d-%d) ", *(line_ndx + v), *(line_ndx + v + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (I) printf(" n = 4 + (%d x 2)\n", state_size + 2);
|
if (I) printf(" n = 4 + (%d x 2) dgap = %d\n", state_size + 2, dgap);
|
||||||
|
if (I) printf("pref_mark_unit_space_zero = %d ", pref_mark_unit_space_zero);
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue