-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangle.cpp
42 lines (36 loc) · 1.03 KB
/
Rectangle.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
#include "Rectangle.h"
Rectangle::Rectangle(
const Primitives& primitives,
float width,
float height ) :
primitives( primitives ),
width( width ),
height( height ) {
this->scale.x = width / 2;
this->scale.y = height / 2;
this->UpdateBounds();
}
void Rectangle::UpdateBounds() {
this->minBound.x = this->translation.x - this->width / 2;
this->minBound.y = this->translation.y - this->height / 2;
this->maxBound.x = this->translation.x + this->width / 2;
this->maxBound.y = this->translation.y + this->height / 2;
}
void Rectangle::Draw( Shader& shader, Camera& camera ) {
this->primitives.DrawRectangle(
shader,
camera,
this->matrix,
this->translation,
this->rotation,
this->scale
);
}
void Rectangle::Translate( glm::vec3 displacementVec ) {
this->translation += displacementVec;
this->UpdateBounds();
}
void Rectangle::MoveTo( glm::vec3 newPosition ) {
this->translation = newPosition;
this->UpdateBounds();
}