idk? rotate lights so it move

This commit is contained in:
Mylloon 2023-05-19 11:13:37 +02:00
parent 1df635eb15
commit be76a975de
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
3 changed files with 17 additions and 2 deletions

View file

@ -25,4 +25,7 @@ void bindAndLoadf(const char *name);
* `-z` => move away */
void move(GLfloat x, GLfloat y, GLfloat z);
/* Rotate a vector XYZ */
void rotate_vec(GLfloat *, GLfloat);
#endif

View file

@ -101,8 +101,9 @@ static void draw(void) {
for (int i = 0; i < HEROS_NUMBER; ++i) {
// Torchs
// Position
const GLfloat lumpos_i[] = {(_herosId[i].ox / 10) + (deplacement / 10), 1,
(_herosId[i].oz / 20) - 1, 0};
GLfloat lumpos_i[] = {(_herosId[i].ox / 10) + (deplacement / 10), 1,
((_herosId[i].oz / 20) - 1)};
rotate_vec(lumpos_i, 2 * ((float)sin(deplacement) + 1) / 2);
memcpy(lumpos[i], lumpos_i, sizeof(lumpos_i));
// Color

View file

@ -15,3 +15,14 @@ void bindAndLoadf(const char *name) {
}
void move(GLfloat x, GLfloat y, GLfloat z) { gl4duTranslatef(x, y, z); }
void rotate_vec(GLfloat *vec, GLfloat angle) {
GLfloat y = vec[1];
GLfloat z = vec[2];
GLfloat cosTheta = (GLfloat)cos(angle);
GLfloat sinTheta = (GLfloat)sin(angle);
vec[1] = y * cosTheta - z * sinTheta;
vec[2] = y * sinTheta + z * cosTheta;
}