-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorbitLight.cpp
More file actions
36 lines (29 loc) · 791 Bytes
/
orbitLight.cpp
File metadata and controls
36 lines (29 loc) · 791 Bytes
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
#include "orbitLight.h"
orbitLight::orbitLight()
{
orbitLocation = glm::vec3(0, 0, 0);
axis = glm::vec3(0, 1, 0);
orbitSpeed = 0.5f;
orbitDistance = 1000.0f;
currentRotation = 0.0f;
}
orbitLight::orbitLight(glm::vec3 _origin, glm::vec3 _axis, float _speed, float _radius)
{
orbitLocation = _origin;
axis = _axis;
orbitSpeed = _speed;
orbitDistance = _radius;
currentRotation = 0.0f;
}
void orbitLight::update(float _deltaTime)
{
currentRotation += orbitSpeed * _deltaTime;
glm::mat4 tmpMatrix = glm::mat4(1.0f);
tmpMatrix = glm::rotate(tmpMatrix, glm::radians(currentRotation), axis);
tmpMatrix = glm::translate(tmpMatrix, glm::vec3(orbitDistance, 0.0f, 0.0f));
position = glm::vec4(position, 1.0f) * tmpMatrix;
}
glm::vec3 orbitLight::getPos()
{
return position;
}