forked from BellCrow/GettingInShapes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rhombus.cpp
54 lines (43 loc) · 864 Bytes
/
Rhombus.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
43
44
45
46
47
48
49
50
51
52
53
54
#include "Rhombus.h"
#include "Vertex.h"
#include <DirectXMath.h>
Rhombus::Rhombus(Point pos, float width, float height, Color color):
AbstractShape(pos,width,height,color)
{
m_triangles = new RenderTriangle[2];
}
Rhombus::~Rhombus(){}
void Rhombus::SetHeight(float a_height)
{
m_height = a_height;
m_isDirty = true;
}
void Rhombus::SetWidth(float a_width)
{
m_width = a_width;
m_isDirty = true;
}
void Rhombus::SetPosition(Point a_position)
{
m_position = a_position;
m_isDirty = true;
}
int Rhombus::GetTriangleCount()
{
return 2;
}
void Rhombus::CalculateRenderData()
{
float w2 = m_width / 2;
float h2 = m_height / 2;
Point a(- 1, 0);
Point b(0, 0.5);
Point c(1, 0);
Point d(0, - 0.5);
m_triangles[0] = RenderTriangle(b, d, a);
m_triangles[1] = RenderTriangle(b, c, d);
}
void Rhombus::SetColor(Color color)
{
m_color = color;
}