-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlane.cpp
More file actions
82 lines (71 loc) · 2.17 KB
/
Plane.cpp
File metadata and controls
82 lines (71 loc) · 2.17 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "Plane.h"
#include "GraphicsEngine.h"
#include "ShaderLibrary.h"
Plane::Plane(String name) : Cube(name)
{
ShaderNames shaderNames;
void* shaderByteCode = NULL;
size_t sizeShader = 0;
ShaderLibrary::getInstance()->requestVertexShaderData(shaderNames.BASE_VERTEX_SHADER_NAME, &shaderByteCode, &sizeShader);
//override cube constructor with different renderer
//create buffers for drawing. vertex data that needs to be drawn are temporarily placed here.
Vertex quadList[] = {
//X, Y, Z
//FRONT FACE
{Vector3D(-0.5f,-0.5f,-0.5f), Vector3D(1,1,1), Vector3D(0.2f,0,0) },
{Vector3D(-0.5f,0.5f,-0.5f), Vector3D(1,1,1), Vector3D(0.2f,0.2f,0) },
{Vector3D(0.5f,0.5f,-0.5f), Vector3D(1,1,1), Vector3D(0.2f,0.2f,0) },
{Vector3D(0.5f,-0.5f,-0.5f), Vector3D(1,1,1), Vector3D(0.2f,0,0) },
//BACK FACE
{Vector3D(0.5f,-0.5f,0.5f), Vector3D(1,1,1), Vector3D(0,0.2f,0) },
{Vector3D(0.5f,0.5f,0.5f), Vector3D(1,1,1), Vector3D(0,0.2f,0.2f) },
{Vector3D(-0.5f,0.5f,0.5f), Vector3D(1,1,1), Vector3D(0,0.2f,0.2f) },
{Vector3D(-0.5f,-0.5f,0.5f), Vector3D(1,1,1), Vector3D(0,0.2f,0) },
};
this->vertexBuffer->release();
this->vertexBuffer = GraphicsEngine::get()->createVertexBuffer();
this->vertexBuffer->load(quadList, sizeof(Vertex), ARRAYSIZE(quadList), shaderByteCode, sizeShader);
unsigned int indexList[] =
{
//FRONT SIDE
0,1,2, //FIRST TRIANGLE
2,3,0, //SECOND TRIANGLE
//BACK SIDE
4,5,6,
6,7,4,
//TOP SIDE
1,6,5,
5,2,1,
//BOTTOM SIDE
7,0,3,
3,4,7,
//RIGHT SIDE
3,2,5,
5,4,3,
//LEFT SIDE
7,6,1,
1,0,7
};
this->indexBuffer->release();
this->indexBuffer = GraphicsEngine::get()->createIndexBuffer();
this->indexBuffer->load(indexList, ARRAYSIZE(indexList));
this->constantBuffer->release();
//create constant buffer
CBData cbData = {};
cbData.time = 0;
this->constantBuffer = GraphicsEngine::get()->createConstantBuffer();
this->constantBuffer->load(&cbData, sizeof(CBData));
this->setScale(8.0f, 8.0f, 0.1f);
this->setRotation(90, 0.0f, 0.0f);
}
Plane::~Plane()
{
}
void Plane::update(float deltaTime)
{
Cube::update(deltaTime);
}
void Plane::draw(int width, int height)
{
Cube::draw(width, height);
}