diff --git a/src/manif.c b/src/manif.c index 32984c8..761f4b5 100644 --- a/src/manif.c +++ b/src/manif.c @@ -2,11 +2,19 @@ static GLuint _pId = 0; static GLuint _planId = 0; -static GLuint _herosId = 0; -static const char matrix_proj[] = "proj"; -static const char matrix_model[] = "model"; -static const char matrix_view[] = "view"; +struct manifestant { + GLuint corps, tete; + // Offsets + GLfloat ox, oz; +}; + +#define HEROS_NUMBER 70 +static struct manifestant _herosId[HEROS_NUMBER]; + +static const char *matrix_proj = "proj"; +static const char *matrix_model = "model"; +static const char *matrix_view = "view"; static void init(void); static void draw(void); @@ -28,7 +36,17 @@ void manif(int state) { static void init(void) { _planId = gl4dgGenQuadf(); - _herosId = gl4dgGenConef(3, GL_FALSE); + + // Last Offset X and Z + for (int i = 0; i < HEROS_NUMBER; ++i) { + _herosId[i].corps = gl4dgGenCubef(); + _herosId[i].tete = gl4dgGenSpheref(20, 20); + _herosId[i].ox = ((GLfloat)rand() / (GLfloat)RAND_MAX) * -7; + _herosId[i].oz = ((GLfloat)rand() / (GLfloat)RAND_MAX) * 10; + + /* printf("Generating #%d\t=> %f:%f\n", _herosId[i].corps, + (double)_herosId[i].ox, (double)_herosId[i].oz); */ + } _pId = gl4duCreateProgram("shaders/manif.vs", "shaders/manif.fs", NULL); @@ -73,13 +91,29 @@ static void draw(void) { glUniform4fv(couleur_gpu, 1, couleur_plan); gl4dgDraw(_planId); - bindAndLoadf(matrix_model); - gl4duScalef(1, 1.5, 1); - gl4duRotatef((GLfloat)(180 * deplacement / M_PI), 0, 1, 0); + for (int i = 0; i < HEROS_NUMBER; ++i) { + bindAndLoadf(matrix_model); + gl4duTranslatef(0, 1, -1); + gl4duScalef(0.1f, 0.7f, 0.2f); + + // Apply hero position + move(_herosId[i].ox + (float)deplacement, 0, _herosId[i].oz, CORPS); + + // Draw corps + gl4duSendMatrices(); + glUniform4fv(couleur_gpu, 1, couleur_heros); + gl4dgDraw(_herosId[i].corps); + + bindAndLoadf(matrix_model); + move(_herosId[i].ox + (float)deplacement, 0, _herosId[i].oz, TETE); + gl4duTranslatef(0, 1.9f, -1); + gl4duScalef(0.1f, 0.2f, 0.2f); + + gl4duSendMatrices(); + glUniform4fv(couleur_gpu, 1, couleur_heros); + gl4dgDraw(_herosId[i].tete); + } - gl4duSendMatrices(); - glUniform4fv(couleur_gpu, 1, couleur_heros); - gl4dgDraw(_herosId); deplacement += 0.4 * M_PI * dt; glUseProgram(0); }