-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpropeller.cpp
57 lines (44 loc) · 1.13 KB
/
propeller.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* File: propeller.cpp
* Author: 2019202344
*
* Created on 6 de Dezembro de 2019, 20:15
*/
#include <cstdio>
#include "propeller.h"
#include "cube.h"
wf_object_t* propeller_t::sModel = NULL;
propeller_t::propeller_t(vector3f offset) :
offset(offset) {
}
void propeller_t::init(wf_object_loader_t& loader) {
sModel = loader.loadRes("helice");
}
void propeller_t::transformAndDraw(float s) const {
glPushMatrix();
{
glTranslatef(offset.x, offset.y, offset.z);
glRotatef(90, 0.0f, 0.0f, 1);
glRotatef(angle * 180 / M_PI, 0.0f, 1.0f, 0.0f);
glScalef(s, s, s);
// printf("angle = %f\n", angle);
// drawAxis(1);
if (sModel == NULL) {
glScalef(10, 1, 1);
drawCube();
} else {
sModel->draw();
}
}
glPopMatrix();
}
void propeller_t::setMagnitude(float v) {
angularVelocity = v * factor;
}
void propeller_t::setScaleFactor(float scale) {
this->factor = scale * 2 * M_PI;
}
void propeller_t::update(int millis) {
angle += angularVelocity * millis / 1000.0f;
angle = clampAngle(angle);
}