-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.cpp
More file actions
48 lines (38 loc) · 1.18 KB
/
Copy pathobject.cpp
File metadata and controls
48 lines (38 loc) · 1.18 KB
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
#include "object.h"
//######################################
//########## Abstract Object class #####
//######################################
Object::Object(glm::vec3 position, std::string modelRelativePath) :
pos{position},
scale{glm::vec3(1.0f, 1.0f, 1.0f)},
rotation{glm::mat4(1.0f)},
transformation{glm::translate(rotation, position)}
{
// Set model
std::string sourcePath = __FILE__;
std::string dirPath = sourcePath.substr(0, sourcePath.rfind("/"));
std::string modelPath = std::string(dirPath);
modelPath.append("/").append(modelRelativePath);
objectModel = new Model(modelPath);
}
Object::~Object()
{
delete objectModel;
}
// Updates the transformation matrix based on position, rotation, scale.
void Object::updateTransformation()
{
transformation = glm::translate(rotation, pos);
transformation = glm::scale(transformation, scale);
}
void Object::draw(Shader shader)
{
objectModel->Draw(shader);
}
//######################################
//########## Sphere class ##############
//######################################
Sphere::Sphere(glm::vec3 position, std::string modelRelativePath) :
Object(position, modelRelativePath)
{
}