-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActor.cpp
More file actions
57 lines (51 loc) · 1.35 KB
/
Copy pathActor.cpp
File metadata and controls
57 lines (51 loc) · 1.35 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
#include "Actor.h"
void Actor::InitCity()
{
float vertices[30] = {
0.0f, 0.0f, 0.8f, 0.0f, 0.0f,
0.0f, 0.8f, 0.0f, 0.0f, 0.0f,
0.8f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, -0.8f, 0.0f, 0.0f, 0.0f,
-0.8f, 0.0f, 0.0f, 0.0f, 0.0f,
};
unsigned int indices[] = {
0, 1, 2,
0, 2, 3,
0, 3, 4,
0, 4, 1,
};
texture.InitRGBA(255, 0, 0, 255);
vertexArray.Init(vertices, 5, indices, 12);
distance = 1.0001f;
}
void Actor::InitShip()
{
float vertices[] = {
0.0f, 0.5f, 0.0f, 0.0f, 0.0f,
0.3f, -0.5f, 0.0f, 0.0f, 0.0f,
-0.3f, -0.5f, 0.0f, 0.0f, 0.0f,
};
unsigned int indices[] = {
0, 1, 2,
};
texture.InitRGBA(255, 255, 0, 255);
vertexArray.Init(vertices, 3, indices, 3);
distance = 1.0002f;
}
void Actor::SetPosition(Vector3d position, Vector3d direction)
{
Vector3d side = cross(position, direction);
Matrix4d rotation = {
side.x, direction.x, position.x, 0,
side.y, direction.y, position.y, 0,
side.z, direction.z, position.z, 0,
0, 0, 0, 1,
};
matrix = Matrix4d::move(distance * position) * Matrix4d::scale(0.01f) * rotation;
}
void Actor::Render(Shader& shader)
{
shader.SetWorldTransform(matrix);
texture.SetActive();
vertexArray.Render();
}