idk? rotate lights so it move
This commit is contained in:
parent
1df635eb15
commit
be76a975de
3 changed files with 17 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
11
src/utils.c
11
src/utils.c
|
@ -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;
|
||||
}
|
||||
|
|
Reference in a new issue