-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathworld.cpp
More file actions
68 lines (49 loc) · 1.11 KB
/
world.cpp
File metadata and controls
68 lines (49 loc) · 1.11 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
#include "stdafx.h"
#include "world.h"
#include "quaternion.h"
World::World()
{
temp_camera = nullptr;
}
void World::frame(Camera* camera)
{
camera->generateMatrix();
(*mesh)[0].rotate(math::Quaternion().fromAxisRotation(math::vec3(0,1,0),0.008f));
m_renderList.draw(camera);
}
bool World::initialise()
{
DirectionalLight* sun = new DirectionalLight();
sun->intensity = 5;
sun->colour = math::vec3(1.f, 1.f, 1.f);
sun->vector = math::vec3(0.f, 0.4f, 0.5f);
m_lights.push_back(sun);
initialiseObjects();
return true;
}
bool World::initialiseObjects()
{
temp_camera = new Camera(math::vec3(0, 0, 5));
if (!temp_camera)
return false;
if (!mesh->load("Game/Models/building.obj", Enum::GPU))
return false;
Texture* marble = new Texture();
if (!marble->load("Game/Textures/building.dds", Enum::GPU))
return false;
mesh->createInstance(Transformable(), *marble);
(*mesh)[0].setScale(0.4f);
m_renderList.addObject3D(mesh);
return true;
}
void World::shutdown()
{
for (Light* l : m_lights)
delete l;
if (temp_camera)
delete temp_camera;
}
Camera* World::getCamera()
{
return temp_camera;
}