13
13
14
14
ColorGenerator* GameObject::color_generator = new ColorGenerator(100000 );
15
15
16
- GameObject::GameObject (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::vec3 & rotation,
16
+ GameObject::GameObject (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::quat & rotation,
17
17
const glm::vec3& scale, const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color) {
18
18
this ->name = name;
19
19
this ->model_name = model_name;
@@ -37,9 +37,7 @@ GameObject::~GameObject() {
37
37
void GameObject::set_model_matrices_standard () {
38
38
model = glm::mat4 (1 .0f );
39
39
model = glm::translate (model, position);
40
- model = glm::rotate (model, glm::radians (rotation.x ), glm::vec3 (1 .0f , 0 .0f , 0 .0f ));
41
- model = glm::rotate (model, glm::radians (rotation.y ), glm::vec3 (0 .0f , 1 .0f , 0 .0f ));
42
- model = glm::rotate (model, glm::radians (rotation.z ), glm::vec3 (0 .0f , 0 .0f , 1 .0f ));
40
+ model *= glm::mat4_cast (rotation);
43
41
model = glm::scale (model, scale);
44
42
45
43
model_inv = glm::inverse (model);
@@ -79,32 +77,32 @@ void GameObject::clean() {
79
77
80
78
// ////////////////////////////// LIGHTS //////////////////////////////////////
81
79
82
- Light::Light (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::vec3& scale , const glm::vec3& rotation , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
80
+ Light::Light (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::quat& rotation , const glm::vec3& scale , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
83
81
const glm::vec3& ambient, const glm::vec3& diffuse, const glm::vec3& specular)
84
- : GameObject(name, model_name, position, scale, rotation , color, is_selected, render_only_ambient, render_one_color) {
82
+ : GameObject(name, model_name, position, rotation, scale , color, is_selected, render_only_ambient, render_one_color) {
85
83
this ->ambient = ambient;
86
84
this ->diffuse = diffuse;
87
85
this ->specular = specular;
88
86
}
89
87
90
- PointLight::PointLight (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::vec3& scale , const glm::vec3& rotation , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
88
+ PointLight::PointLight (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::quat& rotation , const glm::vec3& scale , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
91
89
const glm::vec3& ambient, const glm::vec3& diffuse, const glm::vec3& specular, float constant, float linear, float quadratic)
92
- : Light(name, model_name, position, scale, rotation , color, is_selected, render_only_ambient, render_one_color, ambient, diffuse, specular) {
90
+ : Light(name, model_name, position, rotation, scale , color, is_selected, render_only_ambient, render_one_color, ambient, diffuse, specular) {
93
91
this ->constant = constant;
94
92
this ->linear = linear;
95
93
this ->quadratic = quadratic;
96
94
}
97
95
98
- DirectionalLight::DirectionalLight (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::vec3& scale , const glm::vec3& rotation , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
96
+ DirectionalLight::DirectionalLight (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::quat& rotation , const glm::vec3& scale , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
99
97
const glm::vec3& ambient, const glm::vec3& diffuse, const glm::vec3& specular, const glm::vec3& direction)
100
- : Light(name, model_name, position, scale, rotation , color, is_selected, render_only_ambient, render_one_color, ambient, diffuse, specular) {
98
+ : Light(name, model_name, position, rotation, scale , color, is_selected, render_only_ambient, render_one_color, ambient, diffuse, specular) {
101
99
this ->direction = direction;
102
100
}
103
101
104
- SpotLight::SpotLight (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::vec3& scale , const glm::vec3& rotation , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
102
+ SpotLight::SpotLight (const std::string& name, const std::string& model_name, const glm::vec3& position, const glm::quat& rotation , const glm::vec3& scale , const glm::vec3& color, bool is_selected, bool render_only_ambient, bool render_one_color,
105
103
const glm::vec3& ambient, const glm::vec3& diffuse, const glm::vec3& specular, const glm::vec3& direction, float inner_cut_off, float outer_cut_off,
106
104
float constant, float linear, float quadratic)
107
- : Light(name, model_name, position, scale, rotation , color, is_selected, render_only_ambient, render_one_color, ambient, diffuse, specular) {
105
+ : Light(name, model_name, position, rotation, scale , color, is_selected, render_only_ambient, render_one_color, ambient, diffuse, specular) {
108
106
this ->direction = direction;
109
107
110
108
this ->inner_cut_off = inner_cut_off;
0 commit comments