Merge branch 'master' of github.com:sippeangelo/Escape-the-Dawn
Conflicts: Escape-the-Dawn/GameWorld.cpp
This commit is contained in:
@@ -5,7 +5,7 @@ void GameWorld::Initialize()
|
|||||||
{
|
{
|
||||||
World::Initialize();
|
World::Initialize();
|
||||||
|
|
||||||
//AddSystem("LevelGenerationSystem");
|
AddSystem("LevelGenerationSystem");
|
||||||
AddSystem("InputSystem");
|
AddSystem("InputSystem");
|
||||||
AddSystem("CollisionSystem");
|
AddSystem("CollisionSystem");
|
||||||
//AddSystem("ParticleSystem");
|
//AddSystem("ParticleSystem");
|
||||||
@@ -26,12 +26,12 @@ void GameWorld::Initialize()
|
|||||||
SetProperty(entcamera, "Name", std::string("Camera"));
|
SetProperty(entcamera, "Name", std::string("Camera"));
|
||||||
transform = AddComponent<Components::Transform>(entcamera, "Transform");
|
transform = AddComponent<Components::Transform>(entcamera, "Transform");
|
||||||
AddComponent<Components::Input>(entcamera, "Input");
|
AddComponent<Components::Input>(entcamera, "Input");
|
||||||
transform->Position = glm::vec3(0.f, 2.f, 10.f);
|
transform->Position = glm::vec3(0.f, 10.f, 14.f);
|
||||||
camera = AddComponent<Components::Camera>(entcamera, "Camera");
|
camera = AddComponent<Components::Camera>(entcamera, "Camera");
|
||||||
camera->FOV = 45.f;
|
camera->FOV = 45.f;
|
||||||
camera->FarClip = 1000.f;
|
camera->FarClip = 1000.f;
|
||||||
camera->NearClip = 0.01f;
|
camera->NearClip = 0.01f;
|
||||||
transform->Orientation = glm::angleAxis<float>(glm::radians(25.0f),glm::vec3(1,0,0));
|
transform->Orientation = glm::angleAxis<float>(glm::radians(15.0f),glm::vec3(1,0,0));
|
||||||
collision = AddComponent<Components::Collision>(entcamera, "Collision");
|
collision = AddComponent<Components::Collision>(entcamera, "Collision");
|
||||||
collision->Phantom = false;
|
collision->Phantom = false;
|
||||||
bounds = AddComponent<Components::Bounds>(entcamera, "Bounds");
|
bounds = AddComponent<Components::Bounds>(entcamera, "Bounds");
|
||||||
@@ -51,7 +51,7 @@ void GameWorld::Initialize()
|
|||||||
pointLight->quadraticAttenuation = 0.f;
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
pointLight->spotExponent = 0.0f;
|
pointLight->spotExponent = 0.0f;
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
model->ModelFile = "sphere.obj";
|
model->ModelFile = "Models/sphere.obj";
|
||||||
ent = CreateEntity();
|
ent = CreateEntity();
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
transform->Position = glm::vec3(10.f, 4.f, 0.f);
|
transform->Position = glm::vec3(10.f, 4.f, 0.f);
|
||||||
@@ -66,7 +66,7 @@ void GameWorld::Initialize()
|
|||||||
pointLight->quadraticAttenuation = 0.f;
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
pointLight->spotExponent = 0.0f;
|
pointLight->spotExponent = 0.0f;
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
model->ModelFile = "sphere.obj";
|
model->ModelFile = "Models/sphere.obj";
|
||||||
ent = CreateEntity();
|
ent = CreateEntity();
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
transform->Position = glm::vec3(0.f, -4.f, 0.f);
|
transform->Position = glm::vec3(0.f, -4.f, 0.f);
|
||||||
@@ -80,23 +80,23 @@ void GameWorld::Initialize()
|
|||||||
pointLight->quadraticAttenuation = 0.f;
|
pointLight->quadraticAttenuation = 0.f;
|
||||||
pointLight->spotExponent = 0.0f;
|
pointLight->spotExponent = 0.0f;
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
model->ModelFile = "sphere.obj";
|
model->ModelFile = "Models/sphere.obj";
|
||||||
|
|
||||||
//ground
|
//ground
|
||||||
ent = CreateEntity();
|
ent = CreateEntity();
|
||||||
transform = AddComponent<Components::Transform>(ent, "Transform");
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
model = AddComponent<Components::Model>(ent, "Model");
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
model->ModelFile = "plane.obj";
|
model->ModelFile = "Models/plane.obj";
|
||||||
|
|
||||||
// Player
|
// Player
|
||||||
m_Player = CreateEntity();
|
m_Player = CreateEntity();
|
||||||
SetProperty(m_Player, "Name", std::string("PlayerShip"));
|
SetProperty(m_Player, "Name", std::string("PlayerShip"));
|
||||||
transform = AddComponent<Components::Transform>(m_Player, "Transform");
|
transform = AddComponent<Components::Transform>(m_Player, "Transform");
|
||||||
transform->Position = glm::vec3(0.f, 4.f, -5.f);
|
transform->Position = glm::vec3(0.f, 4.f, -5.f);
|
||||||
transform->Scale = glm::vec3(2.0f);
|
transform->Scale = glm::vec3(1.0f);
|
||||||
model = AddComponent<Components::Model>(m_Player, "Model");
|
model = AddComponent<Components::Model>(m_Player, "Model");
|
||||||
model->ModelFile = "ship.obj";
|
model->ModelFile = "Models/ship.obj";
|
||||||
AddComponent<Components::Input>(m_Player, "Input");
|
AddComponent<Components::Input>(m_Player, "Input");
|
||||||
collision = AddComponent<Components::Collision>(m_Player, "Collision");
|
collision = AddComponent<Components::Collision>(m_Player, "Collision");
|
||||||
collision->Phantom = false;
|
collision->Phantom = false;
|
||||||
@@ -104,12 +104,11 @@ void GameWorld::Initialize()
|
|||||||
bounds->Origin = glm::vec3(transform->Position.x, transform->Position.y - 4, transform->Position.z + 3);
|
bounds->Origin = glm::vec3(transform->Position.x, transform->Position.y - 4, transform->Position.z + 3);
|
||||||
bounds->VolumeVector = glm::vec3(4.f,0.7f,4);
|
bounds->VolumeVector = glm::vec3(4.f,0.7f,4);
|
||||||
|
|
||||||
|
ent = CreateEntity();
|
||||||
player2 = CreateEntity();
|
transform = AddComponent<Components::Transform>(ent, "Transform");
|
||||||
transform = AddComponent<Components::Transform>(player2, "Transform");
|
transform->Position = glm::vec3(10.f, 4.f, 0.f);
|
||||||
transform->Position = glm::vec3(10.f, 0.f, 0.f);
|
model = AddComponent<Components::Model>(ent, "Model");
|
||||||
model = AddComponent<Components::Model>(player2, "Model");
|
model->ModelFile = "Models/ship.obj";
|
||||||
model->ModelFile = "ship.obj";
|
|
||||||
collision = AddComponent<Components::Collision>(player2, "Collision");
|
collision = AddComponent<Components::Collision>(player2, "Collision");
|
||||||
collision->Phantom = false;
|
collision->Phantom = false;
|
||||||
bounds = AddComponent<Components::Bounds>(player2, "Bounds");
|
bounds = AddComponent<Components::Bounds>(player2, "Bounds");
|
||||||
@@ -120,8 +119,6 @@ void GameWorld::Initialize()
|
|||||||
void GameWorld::Update(double dt)
|
void GameWorld::Update(double dt)
|
||||||
{
|
{
|
||||||
World::Update(dt);
|
World::Update(dt);
|
||||||
/*if(GetSystem<Systems::CollisionSystem>("CollisionSystem")->Intersects(m_Player, entcamera))
|
|
||||||
assert(false);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWorld::RegisterComponents()
|
void GameWorld::RegisterComponents()
|
||||||
@@ -144,7 +141,7 @@ void GameWorld::RegisterComponents()
|
|||||||
|
|
||||||
void GameWorld::RegisterSystems()
|
void GameWorld::RegisterSystems()
|
||||||
{
|
{
|
||||||
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
|
m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
|
||||||
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
|
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_Renderer); });
|
||||||
m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
|
||||||
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
|
//m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this); });
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
@@ -0,0 +1,36 @@
|
|||||||
|
# Blender v2.69 (sub 0) OBJ File: 'obstaclesandstuff.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib obstacle_cube_1.mtl
|
||||||
|
o Cube.001_Cube.018
|
||||||
|
v -1.000000 -0.019077 1.000000
|
||||||
|
v -1.000000 -0.019077 -1.000000
|
||||||
|
v 1.000000 -0.019077 -1.000000
|
||||||
|
v 1.000000 -0.019077 1.000000
|
||||||
|
v -1.000000 1.980923 1.000000
|
||||||
|
v -1.000000 1.980923 -1.000000
|
||||||
|
v 1.000000 1.980923 -1.000000
|
||||||
|
v 1.000000 1.980923 1.000000
|
||||||
|
vt 0.000000 0.000000
|
||||||
|
vt 1.000000 0.000000
|
||||||
|
vt 0.000000 1.000000
|
||||||
|
vt 1.000000 1.000000
|
||||||
|
vn -1.000000 0.000000 0.000000
|
||||||
|
vn 0.000000 0.000000 -1.000000
|
||||||
|
vn 1.000000 0.000000 0.000000
|
||||||
|
vn 0.000000 0.000000 1.000000
|
||||||
|
vn 0.000000 -1.000000 0.000000
|
||||||
|
vn 0.000000 1.000000 0.000000
|
||||||
|
usemtl Material.001
|
||||||
|
s off
|
||||||
|
f 5/1/1 6/2/1 1/3/1
|
||||||
|
f 6/1/2 7/2/2 2/3/2
|
||||||
|
f 7/1/3 8/2/3 3/3/3
|
||||||
|
f 8/1/4 5/2/4 4/3/4
|
||||||
|
f 1/1/5 2/2/5 4/3/5
|
||||||
|
f 8/1/6 7/2/6 5/3/6
|
||||||
|
f 6/2/1 2/4/1 1/3/1
|
||||||
|
f 7/2/2 3/4/2 2/3/2
|
||||||
|
f 8/2/3 4/4/3 3/3/3
|
||||||
|
f 5/2/4 1/4/4 4/3/4
|
||||||
|
f 2/2/5 3/4/5 4/3/5
|
||||||
|
f 7/2/6 6/4/6 5/3/6
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Blender MTL File: 'obstaclesandstuff.blend'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.559600 0.559600 0.559600
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd ObstacleTexture.png
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
# Blender v2.69 (sub 0) OBJ File: 'obstaclesandstuff.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib obstacle_mountain_1.mtl
|
||||||
|
o Cube.004
|
||||||
|
v 1.698819 0.000000 2.036847
|
||||||
|
v 1.698819 0.000000 5.330842
|
||||||
|
v -1.595176 0.000000 5.330841
|
||||||
|
v -1.595175 0.000000 2.036846
|
||||||
|
v 0.051821 8.843084 3.683845
|
||||||
|
v 1.278842 0.000000 4.358418
|
||||||
|
v 10.046223 0.000000 4.358419
|
||||||
|
v 10.046223 0.000000 -4.408960
|
||||||
|
v 1.278844 0.000000 -4.408961
|
||||||
|
v 5.662531 17.390135 -0.025270
|
||||||
|
v -6.655907 0.000000 1.637957
|
||||||
|
v 2.108382 0.000000 1.637958
|
||||||
|
v 2.108382 0.000000 -7.126330
|
||||||
|
v -6.655905 0.000000 -7.126331
|
||||||
|
v -2.273763 25.648932 -2.744185
|
||||||
|
v -0.900829 0.000000 0.659354
|
||||||
|
v 5.318377 0.000000 0.659354
|
||||||
|
v 5.318377 0.000000 -5.559852
|
||||||
|
v -0.900827 0.000000 -5.559853
|
||||||
|
v 2.208774 24.324408 -2.450248
|
||||||
|
v -2.753737 0.000000 -1.359767
|
||||||
|
v -2.753737 0.000000 4.431494
|
||||||
|
v -8.544997 0.000000 4.431493
|
||||||
|
v -8.544996 0.000000 -1.359768
|
||||||
|
v -5.649367 18.211798 1.535864
|
||||||
|
vt 0.465364 0.552468
|
||||||
|
vt 0.391639 0.552468
|
||||||
|
vt 0.465364 0.478743
|
||||||
|
vt 0.239247 0.239247
|
||||||
|
vt 0.000250 0.000250
|
||||||
|
vt 0.478243 0.000250
|
||||||
|
vt 0.677193 0.198700
|
||||||
|
vt 0.478743 0.000250
|
||||||
|
vt 0.875642 0.000250
|
||||||
|
vt 0.875643 0.397149
|
||||||
|
vt 0.478743 0.397149
|
||||||
|
vt 0.674971 0.725248
|
||||||
|
vt 0.674971 0.921475
|
||||||
|
vt 0.478743 0.725248
|
||||||
|
vt 0.806342 0.397649
|
||||||
|
vt 0.892489 0.483796
|
||||||
|
vt 0.806342 0.569944
|
||||||
|
vt 0.978636 0.569944
|
||||||
|
vt 0.978636 0.397649
|
||||||
|
vt 0.478243 0.478243
|
||||||
|
vt 0.000250 0.478243
|
||||||
|
vt 0.871629 0.921406
|
||||||
|
vt 0.675471 0.921406
|
||||||
|
vt 0.871629 0.725248
|
||||||
|
vt 0.195695 0.674188
|
||||||
|
vt 0.000250 0.478743
|
||||||
|
vt 0.391139 0.478743
|
||||||
|
vt 0.391139 0.869632
|
||||||
|
vt 0.000250 0.869633
|
||||||
|
vt 0.945537 0.724748
|
||||||
|
vt 0.806342 0.724748
|
||||||
|
vt 0.945537 0.585552
|
||||||
|
vt 0.129867 0.999750
|
||||||
|
vt 0.000250 0.999750
|
||||||
|
vt 0.129867 0.870133
|
||||||
|
vt 0.805842 0.397649
|
||||||
|
vt 0.642293 0.561199
|
||||||
|
vt 0.478743 0.397649
|
||||||
|
vt 0.478743 0.724748
|
||||||
|
vt 0.805842 0.724748
|
||||||
|
vt 0.391639 0.478743
|
||||||
|
vt 0.478743 0.921475
|
||||||
|
vt 0.675471 0.725248
|
||||||
|
vt 0.806342 0.585552
|
||||||
|
vt 0.000250 0.870133
|
||||||
|
vn 0.000000 -1.000000 0.000000
|
||||||
|
vn 0.000000 0.168411 -0.985717
|
||||||
|
vn 0.000000 0.244433 -0.969666
|
||||||
|
vn -0.969666 0.244432 -0.000000
|
||||||
|
vn -0.000000 0.244433 0.969666
|
||||||
|
vn 0.969666 0.244433 0.000000
|
||||||
|
vn 0.983095 0.183098 0.000000
|
||||||
|
vn -0.000001 0.183098 0.983095
|
||||||
|
vn -0.983095 0.183098 -0.000000
|
||||||
|
vn 0.000000 0.183098 -0.983095
|
||||||
|
vn -0.985717 0.168411 -0.000000
|
||||||
|
vn -0.000000 0.168411 0.985717
|
||||||
|
vn 0.985717 0.168411 0.000000
|
||||||
|
vn 0.000000 0.126807 -0.991927
|
||||||
|
vn -0.991927 0.126807 -0.000000
|
||||||
|
vn -0.000000 0.126807 0.991928
|
||||||
|
vn 0.991928 0.126807 0.000000
|
||||||
|
vn 0.987595 0.157025 0.000000
|
||||||
|
vn -0.000000 0.157025 0.987595
|
||||||
|
vn -0.987595 0.157025 -0.000000
|
||||||
|
vn 0.000000 0.157025 -0.987595
|
||||||
|
usemtl Material
|
||||||
|
s off
|
||||||
|
f 1/1/1 2/2/1 4/3/1
|
||||||
|
f 15/4/2 13/5/2 14/6/2
|
||||||
|
f 10/7/3 8/8/3 9/9/3
|
||||||
|
f 6/10/4 10/7/4 9/9/4
|
||||||
|
f 7/11/5 10/7/5 6/10/5
|
||||||
|
f 8/8/6 10/7/6 7/11/6
|
||||||
|
f 8/12/1 7/13/1 9/14/1
|
||||||
|
f 1/15/7 5/16/7 2/17/7
|
||||||
|
f 2/17/8 5/16/8 3/18/8
|
||||||
|
f 3/18/9 5/16/9 4/19/9
|
||||||
|
f 5/16/10 1/15/10 4/19/10
|
||||||
|
f 11/20/11 15/4/11 14/6/11
|
||||||
|
f 12/21/12 15/4/12 11/20/12
|
||||||
|
f 13/5/13 15/4/13 12/21/13
|
||||||
|
f 13/22/1 12/23/1 14/24/1
|
||||||
|
f 20/25/14 18/26/14 19/27/14
|
||||||
|
f 16/28/15 20/25/15 19/27/15
|
||||||
|
f 17/29/16 20/25/16 16/28/16
|
||||||
|
f 18/26/17 20/25/17 17/29/17
|
||||||
|
f 18/30/1 17/31/1 19/32/1
|
||||||
|
f 21/33/1 22/34/1 24/35/1
|
||||||
|
f 21/36/18 25/37/18 22/38/18
|
||||||
|
f 22/38/19 25/37/19 23/39/19
|
||||||
|
f 23/39/20 25/37/20 24/40/20
|
||||||
|
f 25/37/21 21/36/21 24/40/21
|
||||||
|
f 2/2/1 3/41/1 4/3/1
|
||||||
|
f 7/13/1 6/42/1 9/14/1
|
||||||
|
f 12/23/1 11/43/1 14/24/1
|
||||||
|
f 17/31/1 16/44/1 19/32/1
|
||||||
|
f 22/34/1 23/45/1 24/35/1
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Blender MTL File: 'obstaclesandstuff.blend'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.559600 0.559600 0.559600
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd ObstacleTexture.png
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Blender v2.69 (sub 0) OBJ File: 'obstaclesandstuff.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib obstacle_mountain_2.mtl
|
||||||
|
o Cube.011_Cube.026
|
||||||
|
v -3.450152 0.000000 3.450150
|
||||||
|
v 3.450150 0.000000 3.450151
|
||||||
|
v 3.450150 0.000000 -3.450150
|
||||||
|
v -3.450150 0.000000 -3.450152
|
||||||
|
v -0.000001 15.531238 0.000001
|
||||||
|
vt 0.341102 0.341102
|
||||||
|
vt 0.682105 0.000100
|
||||||
|
vt 0.682105 0.682105
|
||||||
|
vt 0.000100 0.682105
|
||||||
|
vt 0.000100 0.000100
|
||||||
|
vt 0.999900 0.317695
|
||||||
|
vt 0.682305 0.317695
|
||||||
|
vt 0.999900 0.000100
|
||||||
|
vt 0.682305 0.000100
|
||||||
|
vn 0.000000 0.216857 -0.976204
|
||||||
|
vn -0.976204 0.216856 -0.000000
|
||||||
|
vn -0.000000 0.216856 0.976204
|
||||||
|
vn 0.976204 0.216856 0.000000
|
||||||
|
vn 0.000000 -1.000000 0.000000
|
||||||
|
usemtl Material
|
||||||
|
s off
|
||||||
|
f 5/1/1 3/2/1 4/3/1
|
||||||
|
f 1/4/2 5/1/2 4/3/2
|
||||||
|
f 2/5/3 5/1/3 1/4/3
|
||||||
|
f 3/2/4 5/1/4 2/5/4
|
||||||
|
f 3/6/5 2/7/5 4/8/5
|
||||||
|
f 2/7/5 1/9/5 4/8/5
|
||||||
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
@@ -0,0 +1,12 @@
|
|||||||
|
# Blender MTL File: 'obstaclesandstuff.blend'
|
||||||
|
# Material Count: 1
|
||||||
|
|
||||||
|
newmtl Material.001
|
||||||
|
Ns 96.078431
|
||||||
|
Ka 0.000000 0.000000 0.000000
|
||||||
|
Kd 0.640000 0.640000 0.640000
|
||||||
|
Ks 0.500000 0.500000 0.500000
|
||||||
|
Ni 1.000000
|
||||||
|
d 1.000000
|
||||||
|
illum 2
|
||||||
|
map_Kd ObstacleTexture.png
|
||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,93 @@
|
|||||||
|
#include "LevelGenerationSystem.h"
|
||||||
|
|
||||||
|
Systems::LevelGenerationSystem::LevelGenerationSystem( World* world )
|
||||||
|
: System(world)
|
||||||
|
{
|
||||||
|
elapsedtime = 0;
|
||||||
|
startyz = glm::vec2(0, -1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::LevelGenerationSystem::SpawnObstacle()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typeRandom = 0 + (rand() % 3);
|
||||||
|
|
||||||
|
|
||||||
|
EntityID ent;
|
||||||
|
|
||||||
|
ent = m_World->CreateEntity();
|
||||||
|
obstacles.push_back(ent);
|
||||||
|
m_World->SetProperty(ent, "Name", std::string("Obstacle"));
|
||||||
|
transform = m_World->AddComponent<Components::Transform>(ent, "Transform");
|
||||||
|
bounds = m_World->AddComponent<Components::Bounds>(ent, "Bounds");
|
||||||
|
collision = m_World->AddComponent<Components::Collision>(ent, "Collision");
|
||||||
|
model = m_World->AddComponent<Components::Model>(ent, "Model");
|
||||||
|
|
||||||
|
positionRandom = -500 + (rand() % 1000);
|
||||||
|
|
||||||
|
switch (typeRandom)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||||
|
bounds->VolumeVector = glm::vec3(9, 12, 7);
|
||||||
|
bounds->Origin = glm::vec3(1,11,-1);
|
||||||
|
model->ModelFile = "Models/obstacle_mountain_1.obj";
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||||
|
bounds->VolumeVector = glm::vec3(3.5f, 7.5f, 3.5f);
|
||||||
|
bounds->Origin = glm::vec3(0,7.5f,0);
|
||||||
|
model->ModelFile = "Models/obstacle_mountain_2.obj";
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
transform->Position = glm::vec3( positionRandom, startyz); // fix position
|
||||||
|
bounds->VolumeVector = glm::vec3(1, 1, 1);
|
||||||
|
bounds->Origin = glm::vec3(0,1,0);
|
||||||
|
model->ModelFile = "Models/obstacle_cube_1.obj";
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::LevelGenerationSystem::Update( double dt )
|
||||||
|
{
|
||||||
|
|
||||||
|
elapsedtime += dt;
|
||||||
|
|
||||||
|
if(elapsedtime > 0.1){
|
||||||
|
SpawnObstacle();
|
||||||
|
elapsedtime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<EntityID> removethis;
|
||||||
|
|
||||||
|
for(auto ent : obstacles)
|
||||||
|
{
|
||||||
|
auto transformComponent = m_World->GetComponent<Components::Transform>(ent, "Transform");
|
||||||
|
transformComponent->Position.z += 100.f * dt;
|
||||||
|
|
||||||
|
if(transformComponent->Position.z > 100)
|
||||||
|
{
|
||||||
|
removethis.push_back(ent);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(auto ent : removethis)
|
||||||
|
{
|
||||||
|
m_World->RemoveEntity(ent);
|
||||||
|
obstacles.remove(ent);
|
||||||
|
}
|
||||||
|
removethis.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef LevelGenerationSystem_h__
|
||||||
|
#define LevelGenerationSystem_h__
|
||||||
|
|
||||||
|
#include "System.h"
|
||||||
|
#include "World.h"
|
||||||
|
#include "Components/Transform.h"
|
||||||
|
#include "Components/Bounds.h"
|
||||||
|
#include "Components/Collision.h"
|
||||||
|
#include "Components/Model.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Systems
|
||||||
|
{
|
||||||
|
class LevelGenerationSystem : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LevelGenerationSystem(World* world);
|
||||||
|
|
||||||
|
|
||||||
|
void SpawnObstacle();
|
||||||
|
|
||||||
|
void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int typeRandom;
|
||||||
|
int positionRandom;
|
||||||
|
glm::vec2 startyz;
|
||||||
|
double elapsedtime;
|
||||||
|
|
||||||
|
std::list<EntityID> obstacles;
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<Components::Transform> transform;
|
||||||
|
std::shared_ptr<Components::Bounds> bounds;
|
||||||
|
std::shared_ptr<Components::Collision> collision;
|
||||||
|
std::shared_ptr<Components::Model> model;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // LevelGenerationSystem_h__
|
||||||
@@ -18,7 +18,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
if (input == nullptr)
|
if (input == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float speed = 10.0f;
|
float speed = 20.0f;
|
||||||
|
|
||||||
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
auto name = m_World->GetProperty<std::string>(entity, "Name");
|
||||||
if (name == "Camera") {
|
if (name == "Camera") {
|
||||||
@@ -26,7 +26,6 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
glm::vec3 Camera_Right = glm::vec3(glm::vec4(1, 0, 0, 0) * transform->Orientation);
|
||||||
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
glm::vec3 Camera_Forward = glm::vec3(glm::vec4(0, 0, 1, 0) * transform->Orientation);
|
||||||
|
|
||||||
|
|
||||||
if(input->KeyState[GLFW_KEY_LEFT_SHIFT]) {
|
if(input->KeyState[GLFW_KEY_LEFT_SHIFT]) {
|
||||||
speed *= 4.0f;
|
speed *= 4.0f;
|
||||||
}
|
}
|
||||||
@@ -36,7 +35,7 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
if(input->KeyState[GLFW_KEY_A] || input->KeyState[GLFW_KEY_LEFT]) {
|
if(input->KeyState[GLFW_KEY_A] || input->KeyState[GLFW_KEY_LEFT]) {
|
||||||
transform->Position -= Camera_Right * (float)dt * speed;
|
transform->Position -= Camera_Right * (float)dt * speed;
|
||||||
}
|
}
|
||||||
if(input->KeyState[GLFW_KEY_D] || input->KeyState[GLFW_KEY_RIGHT]) {
|
else if(input->KeyState[GLFW_KEY_D] || input->KeyState[GLFW_KEY_RIGHT]) {
|
||||||
transform->Position += Camera_Right * (float)dt * speed;
|
transform->Position += Camera_Right * (float)dt * speed;
|
||||||
}
|
}
|
||||||
if(input->KeyState[GLFW_KEY_W]) {
|
if(input->KeyState[GLFW_KEY_W]) {
|
||||||
@@ -77,27 +76,42 @@ void Systems::PlayerSystem::UpdateEntity(double dt, EntityID entity, EntityID pa
|
|||||||
|
|
||||||
float TurnSpeed = 2.0f;
|
float TurnSpeed = 2.0f;
|
||||||
glm::vec3 Euler = glm::eulerAngles(transform->Orientation);
|
glm::vec3 Euler = glm::eulerAngles(transform->Orientation);
|
||||||
LOG_DEBUG("Euler: %f", Euler.z);
|
|
||||||
|
|
||||||
if(input->KeyState[GLFW_KEY_LEFT]) {
|
if(input->KeyState[GLFW_KEY_LEFT]) {
|
||||||
transform->Position -= Ship_Right * (float)dt * speed;
|
transform->Position -= Ship_Right * (float)dt * speed;
|
||||||
|
|
||||||
if(Euler.z < 25.f)
|
if(Euler.z < 10.f)
|
||||||
{
|
{
|
||||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed,glm::vec3(0,0,1));
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed,glm::vec3(0,0,1));
|
||||||
|
}
|
||||||
|
else if(Euler.z < 20.f)
|
||||||
|
{
|
||||||
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed/2,glm::vec3(0,0,1));
|
||||||
|
}
|
||||||
|
else if (Euler.z < 25.f)
|
||||||
|
{
|
||||||
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed/4,glm::vec3(0,0,1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(input->KeyState[GLFW_KEY_RIGHT]) {
|
else if(input->KeyState[GLFW_KEY_RIGHT]) {
|
||||||
transform->Position += Ship_Right * (float)dt * speed;
|
transform->Position += Ship_Right * (float)dt * speed;
|
||||||
|
|
||||||
if(Euler.z > -25.f)
|
if(Euler.z > -10.f)
|
||||||
{
|
{
|
||||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed,glm::vec3(0,0,-1));
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed,glm::vec3(0,0,-1));
|
||||||
}
|
}
|
||||||
|
else if(Euler.z > -20.f)
|
||||||
|
{
|
||||||
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed/2,glm::vec3(0,0,-1));
|
||||||
|
}
|
||||||
|
else if (Euler.z > -25.f)
|
||||||
|
{
|
||||||
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt * TurnSpeed/4,glm::vec3(0,0,-1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(Euler.z < 0.5f && Euler.z > -0.5f)
|
if(Euler.z < 1.5f && Euler.z > -1.5f)
|
||||||
transform->Orientation = glm::angleAxis<float>(0,glm::vec3(0,0,1));
|
transform->Orientation = glm::angleAxis<float>(0,glm::vec3(0,0,1));
|
||||||
else if(Euler.z < 0.f)
|
else if(Euler.z < 0.f)
|
||||||
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt,glm::vec3(0,0,1));
|
transform->Orientation = transform->Orientation * glm::angleAxis<float>((float)dt,glm::vec3(0,0,1));
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void Systems::RenderSystem::UpdateEntity( double dt, EntityID entity, EntityID p
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
auto bounds = m_World->GetComponent<Components::Bounds>(entity, "Bounds");
|
auto bounds = m_World->GetComponent<Components::Bounds>(entity, "Bounds");
|
||||||
if (bounds != nullptr) {
|
if (bounds != nullptr) {
|
||||||
glm::vec3 origin = transformComponent->Position + bounds->Origin;
|
glm::vec3 origin = transformComponent->Scale * (transformComponent->Position + bounds->Origin);
|
||||||
glm::vec3 volumeVector = transformComponent->Scale * bounds->VolumeVector;
|
glm::vec3 volumeVector = transformComponent->Scale * bounds->VolumeVector;
|
||||||
m_Renderer->AddAABBToDraw(origin, volumeVector);
|
m_Renderer->AddAABBToDraw(origin, volumeVector);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Systems
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderSystem(World* world, std::shared_ptr<Renderer> renderer)
|
RenderSystem(World* world, std::shared_ptr<Renderer> renderer)
|
||||||
: System(world), m_Renderer(renderer) {}
|
: System(world), m_Renderer(renderer){ }
|
||||||
|
|
||||||
std::unordered_map<std::string, std::shared_ptr<Model>> m_CachedModels;
|
std::unordered_map<std::string, std::shared_ptr<Model>> m_CachedModels;
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,12 @@ bool World::ValidEntity(EntityID entity)
|
|||||||
void World::RemoveEntity(EntityID entity)
|
void World::RemoveEntity(EntityID entity)
|
||||||
{
|
{
|
||||||
m_EntityParents.erase(entity);
|
m_EntityParents.erase(entity);
|
||||||
|
m_EntityComponents.erase(entity);
|
||||||
|
for (auto pair : m_EntityComponents[entity]) {
|
||||||
|
auto type = pair.first;
|
||||||
|
auto component = pair.second;
|
||||||
|
m_ComponentsOfType[type].remove(component);
|
||||||
|
}
|
||||||
RecycleEntityID(entity);
|
RecycleEntityID(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ protected:
|
|||||||
std::unordered_map<EntityID, EntityID> m_EntityParents ;
|
std::unordered_map<EntityID, EntityID> m_EntityParents ;
|
||||||
std::unordered_map<EntityID, std::unordered_map<std::string, boost::any>> m_EntityProperties;
|
std::unordered_map<EntityID, std::unordered_map<std::string, boost::any>> m_EntityProperties;
|
||||||
|
|
||||||
std::unordered_map<std::string, std::vector<std::shared_ptr<Component>>> m_ComponentsOfType;
|
std::unordered_map<std::string, std::list<std::shared_ptr<Component>>> m_ComponentsOfType;
|
||||||
std::unordered_map<EntityID, std::map<std::string, std::shared_ptr<Component>>> m_EntityComponents;
|
std::unordered_map<EntityID, std::map<std::string, std::shared_ptr<Component>>> m_EntityComponents;
|
||||||
|
|
||||||
EntityID GenerateEntityID();
|
EntityID GenerateEntityID();
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
# Max2Mtl Version 4.0 Mar 10th, 2001
|
|
||||||
#
|
|
||||||
# Multi/Sub Material__10791 (9) to come
|
|
||||||
#
|
|
||||||
newmtl Material__46
|
|
||||||
Ka 0.1 0.1 0.1
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.5
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__47
|
|
||||||
Ka 0.1 0.1 0.1
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.5
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__48
|
|
||||||
Ka 0.1 0.1 0.1
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.5
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__49
|
|
||||||
Ka 0.1 0.1 0.1
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.5
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__50
|
|
||||||
Ka 0.1 0.1 0.1
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.5
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__51
|
|
||||||
Ka 0.1 0.1 0.1
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.5
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__52
|
|
||||||
Ka 0.1 0.1 0.1
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.5
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__10657
|
|
||||||
Ka 0.6 0.6 0.6
|
|
||||||
Kd 0.6 0.6 0.6
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.0
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__10658
|
|
||||||
Ka 0.6 0.6 0.6
|
|
||||||
Kd 0.6 0.6 0.6
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.0
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
# Multi/Sub Material__10791 done
|
|
||||||
#
|
|
||||||
# Multi/Sub Material__10737 (3) to come
|
|
||||||
#
|
|
||||||
newmtl Material__10678
|
|
||||||
Ka 1.0 1.0 1.0
|
|
||||||
Kd 1.0 1.0 1.0
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.0
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__69
|
|
||||||
Ka 0.6 0.6 0.6
|
|
||||||
Kd 0.6 0.6 0.6
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.0
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
newmtl Material__10677
|
|
||||||
Ka 0.6 0.6 0.6
|
|
||||||
Kd 0.6 0.6 0.6
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.0
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
# Multi/Sub Material__10737 done
|
|
||||||
#
|
|
||||||
newmtl 03_-_Default
|
|
||||||
Ka 0.5 0.5 0.5
|
|
||||||
Kd 0.5 0.5 0.5
|
|
||||||
Ks 0.9 0.9 0.9
|
|
||||||
d 1.0
|
|
||||||
Ns 0.0
|
|
||||||
illum 2
|
|
||||||
#
|
|
||||||
# EOF
|
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user