move all the striker drawing into animations.c

This commit is contained in:
Mylloon 2023-05-23 12:49:54 +02:00
parent bf0d6f7a05
commit 1bd16eae68
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 70 additions and 60 deletions

View file

@ -33,4 +33,8 @@ struct manifestant {
// Génère un manifestant
void genManifestant(struct manifestant *);
// Dessine un manifestant
void drawManifestant(const char *, const struct manifestant *, const float,
const GLboolean);
#endif

View file

@ -123,3 +123,68 @@ void genManifestant(struct manifestant *hero) {
hero->jambe_g = gl4dgGenCubef();
hero->jambe_d = gl4dgGenCubef();
}
void drawManifestant(const char *matrix_model, const struct manifestant *hero,
const float deplacement, const GLboolean oscillate) {
const GLfloat oscillation = oscillate ? ((float)sin(2 * deplacement) + 1) : 0;
const float x = hero->ox + deplacement;
const float z = hero->oz * 4;
// Draw corps
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.5f, 0.2f);
gl4duTranslatef(0, 3, -1);
move(x, 0, hero->oz);
gl4duSendMatrices();
gl4dgDraw(hero->corps);
// Draw head
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.2f, 0.2f);
gl4duTranslatef(0, 10.9f, -1);
move(x, 0, hero->oz);
gl4duSendMatrices();
gl4dgDraw(hero->tete);
// Draw leg left
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 1, 0.05f);
gl4duTranslatef(0, 0, -1);
move(x, 0, z);
gl4duRotatef(-oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(hero->jambe_g);
// Draw leg right
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 1, 0.05f);
gl4duTranslatef(0, 0, -7);
move(x, 0, z);
gl4duRotatef(oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(hero->jambe_d);
// Draw arm left
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.4f, 0.05f);
gl4duTranslatef(0, 4, 1);
move(x, 0, z);
gl4duRotatef(oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(hero->bras_g);
// Draw arm right
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.4f, 0.05f);
gl4duTranslatef(0, 4, -8);
move(x, 0, z);
gl4duRotatef(-oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(hero->bras_d);
}

View file

@ -80,7 +80,6 @@ static void draw(void) {
GLfloat lumpos[HEROS_NUMBER][4], lumcolor[HEROS_NUMBER][4];
glUniform4fv(couleur_gpu, 1, couleur_heros);
GLfloat part_mult = 4;
for (int i = 0; i < HEROS_NUMBER; ++i) {
// Torchs
// Position
@ -94,65 +93,7 @@ static void draw(void) {
const GLfloat lumcolor_red[] = {1, 0, 0, 1};
memcpy(lumcolor[i], lumcolor_red, sizeof(lumcolor_red));
GLfloat oscillation = ((float)sin(2 * deplacement) + 1);
// Draw corps
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.5f, 0.2f);
gl4duTranslatef(0, 3, -1);
move(_herosId[i].ox + deplacement, 0, _herosId[i].oz);
gl4duSendMatrices();
gl4dgDraw(_herosId[i].corps);
// Draw head
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.2f, 0.2f);
gl4duTranslatef(0, 10.9f, -1);
move(_herosId[i].ox + deplacement, 0, _herosId[i].oz);
gl4duSendMatrices();
gl4dgDraw(_herosId[i].tete);
// Draw leg left
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 1, 0.05f);
gl4duTranslatef(0, 0, -1);
move(_herosId[i].ox + deplacement, 0, _herosId[i].oz * part_mult);
gl4duRotatef(-oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(_herosId[i].jambe_g);
// Draw leg right
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 1, 0.05f);
gl4duTranslatef(0, 0, -7);
move(_herosId[i].ox + deplacement, 0, _herosId[i].oz * part_mult);
gl4duRotatef(oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(_herosId[i].jambe_d);
// Draw arm left
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.4f, 0.05f);
gl4duTranslatef(0, 4, 1);
move(_herosId[i].ox + deplacement, 0, _herosId[i].oz * part_mult);
gl4duRotatef(oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(_herosId[i].bras_g);
// Draw arm right
bindAndLoadf(matrix_model);
gl4duScalef(0.1f, 0.4f, 0.05f);
gl4duTranslatef(0, 4, -8);
move(_herosId[i].ox + deplacement, 0, _herosId[i].oz * part_mult);
gl4duRotatef(-oscillation * 90, 0, 0, 1);
gl4duSendMatrices();
gl4dgDraw(_herosId[i].bras_d);
drawManifestant(matrix_model, &_herosId[i], deplacement, GL_TRUE);
}
int max_gpu = 3; // HEROS_NUMBER;