-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisibleobject.cpp
More file actions
36 lines (30 loc) · 816 Bytes
/
Copy pathvisibleobject.cpp
File metadata and controls
36 lines (30 loc) · 816 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 "visibleobject.h"
#include <glm/fwd.hpp>
#include <glm/ext/matrix_transform.hpp>
#include <utility>
VisibleObject::VisibleObject
(
Model model,
Shader shader,
const glm::vec3& position,
const glm::vec3& size,
const glm::vec3& offset,
const glm::vec3& scale
)
: GameObject{position, size},
model_{std::move(model)},
scale_{scale},
offset_{offset},
shader_{shader}
{
}
// Calculate transform for the model and then render it using the provided shader
void VisibleObject::draw() const
{
auto transform{glm::mat4{1.0f}};
transform = translate(transform, position_);
// Offset models slightly on X and Y to line up with collision box -- may be necessary if model is scaled
transform = translate(transform, offset_);
transform = scale(transform, scale_);
model_.draw(shader_, transform);
}