Merge remote-tracking branch 'origin/master' into deffered_rendering
Conflicts: assets src/GameWorld.cpp
This commit is contained in:
+1
-1
Submodule assets updated: 664f55cd71...e09ebf5a29
@@ -10,13 +10,14 @@ namespace Components
|
|||||||
|
|
||||||
struct SoundEmitter : Component
|
struct SoundEmitter : Component
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class SoundType
|
enum class SoundType
|
||||||
{
|
{
|
||||||
SOUND_3D,
|
SOUND_3D,
|
||||||
SOUND_2D
|
SOUND_2D
|
||||||
};
|
};
|
||||||
|
|
||||||
SoundEmitter() : Gain(1.f), MaxDistance(1.f), MinDistance(1.f), Pitch(1.f), Loop(false) {}
|
SoundEmitter() : Gain(1.f), MaxDistance(10000.f), MinDistance(1.f), Pitch(1.f), Loop(false) {}
|
||||||
float Gain;
|
float Gain;
|
||||||
float MaxDistance;
|
float MaxDistance;
|
||||||
float MinDistance;
|
float MinDistance;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ namespace Components
|
|||||||
|
|
||||||
struct SpawnPoint : Component
|
struct SpawnPoint : Component
|
||||||
{
|
{
|
||||||
|
EntityID Player;
|
||||||
|
|
||||||
virtual SpawnPoint* Clone() const override { return new SpawnPoint(*this); }
|
virtual SpawnPoint* Clone() const override { return new SpawnPoint(*this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+10
-1
@@ -9,8 +9,17 @@ namespace Events
|
|||||||
|
|
||||||
struct PlaySFX : Event
|
struct PlaySFX : Event
|
||||||
{
|
{
|
||||||
EntityID Emitter;
|
PlaySFX() :
|
||||||
|
MinDistance(100.f),
|
||||||
|
MaxDistance(10000.f),
|
||||||
|
Volume(1.f),
|
||||||
|
Loop (false) {}
|
||||||
|
//EntityID Emitter;
|
||||||
|
glm::vec3 Position;
|
||||||
std::string Resource;
|
std::string Resource;
|
||||||
|
float MinDistance;
|
||||||
|
float MaxDistance;
|
||||||
|
float Volume;
|
||||||
bool Loop;
|
bool Loop;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,11 @@ public:
|
|||||||
Rectangle AbsoluteRectangle()
|
Rectangle AbsoluteRectangle()
|
||||||
{
|
{
|
||||||
int left = Left();
|
int left = Left();
|
||||||
|
if (m_Parent)
|
||||||
|
left = std::max(left, m_Parent->Left());
|
||||||
int top = Top();
|
int top = Top();
|
||||||
|
if (m_Parent)
|
||||||
|
top = std::max(top, m_Parent->Top());
|
||||||
int width = Right() - left;
|
int width = Right() - left;
|
||||||
int height = Bottom() - top;
|
int height = Bottom() - top;
|
||||||
return Rectangle(left, top, width, height);
|
return Rectangle(left, top, width, height);
|
||||||
|
|||||||
+3
-1
@@ -26,12 +26,14 @@ public:
|
|||||||
vp1->X = 0;
|
vp1->X = 0;
|
||||||
vp1->Width = this->Width / 2.f;
|
vp1->Width = this->Width / 2.f;
|
||||||
//new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
//new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||||
auto vehicleSelection = new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
|
new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
|
||||||
|
|
||||||
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
||||||
vp2->X = vp1->Right();
|
vp2->X = vp1->Right();
|
||||||
vp2->Width = this->Width / 2.f;
|
vp2->Width = this->Width / 2.f;
|
||||||
//new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
//new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||||
|
new VehicleSelection(vp2, "VehicleSelection", m_World, 2);
|
||||||
|
|
||||||
|
|
||||||
m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
||||||
m_FreeCamViewport->Hide();
|
m_FreeCamViewport->Hide();
|
||||||
|
|||||||
+360
-380
@@ -91,353 +91,7 @@ void GameWorld::Initialize()
|
|||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CreateTerrain();
|
||||||
#pragma region Lights
|
|
||||||
{
|
|
||||||
auto light = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(light);
|
|
||||||
auto model = AddComponent<Components::Model>(light);
|
|
||||||
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
|
||||||
auto pointLight = AddComponent<Components::PointLight>(light);
|
|
||||||
pointLight->Radius = 40.f;
|
|
||||||
pointLight->Diffuse = glm::vec3(1.0f, 0.5f, 0.3f);
|
|
||||||
pointLight->Specular = glm::vec3(1.0f, 1.0f, 1.0f);
|
|
||||||
pointLight->specularExponent = 100.f;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion Region for world lights
|
|
||||||
|
|
||||||
#pragma region Ground and roads
|
|
||||||
{
|
|
||||||
auto road_base = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(road_base);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
auto model = AddComponent<Components::Model>(road_base);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
|
||||||
auto physics = AddComponent<Components::Physics>(road_base);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(road_base);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(road_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto road_middle = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(road_middle);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
auto model = AddComponent<Components::Model>(road_middle);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj";
|
|
||||||
auto physics = AddComponent<Components::Physics>(road_middle);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(road_middle);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(road_middle);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto road_small = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(road_small);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
auto model = AddComponent<Components::Model>(road_small);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Roads/SmallRoad.obj";
|
|
||||||
auto physics = AddComponent<Components::Physics>(road_small);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(road_small);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/SmallRoad.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(road_small);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
auto water = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(water);
|
|
||||||
transform->Position = glm::vec3(0, -35, 0);
|
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
|
||||||
transform->Scale = glm::vec3(5000.f, 10.f, 5000.f);
|
|
||||||
auto model = AddComponent<Components::Model>(water);
|
|
||||||
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj";
|
|
||||||
auto blendmap = AddComponent<Components::BlendMap>(water);
|
|
||||||
blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg";
|
|
||||||
blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg";
|
|
||||||
blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg";
|
|
||||||
blendmap->TextureRepeats = 1.f;
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(water);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
{
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(water);
|
|
||||||
auto box = AddComponent<Components::BoxShape>(groundshape);
|
|
||||||
box->Depth = 250.f;
|
|
||||||
box->Height = 5.f;
|
|
||||||
box->Width = 250.f;
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
}
|
|
||||||
CommitEntity(water);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto ground_middle = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(ground_middle);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
|
||||||
auto model = AddComponent<Components::Model>(ground_middle);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Middle.obj";
|
|
||||||
auto blendmap = AddComponent<Components::BlendMap>(ground_middle);
|
|
||||||
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
|
||||||
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
|
||||||
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
|
||||||
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
|
||||||
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
|
||||||
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
|
||||||
blendmap->TextureRepeats = 30.f;
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_middle);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_middle);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Middle.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(ground_middle);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto ground_small = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(ground_small);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
|
||||||
auto model = AddComponent<Components::Model>(ground_small);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Small.obj";
|
|
||||||
auto blendmap = AddComponent<Components::BlendMap>(ground_small);
|
|
||||||
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
|
||||||
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
|
||||||
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
|
||||||
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
|
||||||
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
|
||||||
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
|
||||||
blendmap->TextureRepeats = 30.f;
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_small);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_small);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(ground_small);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto ground_small_mirrored = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(ground_small_mirrored);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
transform->Orientation = glm::angleAxis(glm::radians(180.f), glm::vec3(0, 1, 0));
|
|
||||||
auto model = AddComponent<Components::Model>(ground_small_mirrored);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Small.obj";
|
|
||||||
auto blendmap = AddComponent<Components::BlendMap>(ground_small_mirrored);
|
|
||||||
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
|
||||||
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
|
||||||
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
|
||||||
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
|
||||||
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
|
||||||
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
|
||||||
blendmap->TextureRepeats = 30.f;
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_small_mirrored);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_small_mirrored);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(ground_small_mirrored);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto ground_base = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(ground_base);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
|
||||||
auto model = AddComponent<Components::Model>(ground_base);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Base.obj";
|
|
||||||
auto blendmap = AddComponent<Components::BlendMap>(ground_base);
|
|
||||||
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
|
||||||
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
|
||||||
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
|
||||||
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
|
||||||
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
|
||||||
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
|
||||||
blendmap->TextureRepeats = 30.f;
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_base);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_base);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Base.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(ground_base);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto ground_base_mirrored = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(ground_base_mirrored);
|
|
||||||
transform->Position = glm::vec3(0, -50, 0);
|
|
||||||
transform->Orientation = glm::angleAxis(glm::radians(180.f), glm::vec3(0, 1, 0));
|
|
||||||
auto model = AddComponent<Components::Model>(ground_base_mirrored);
|
|
||||||
model->ModelFile = "Models/TerrainFiveIstles/Base.obj";
|
|
||||||
auto blendmap = AddComponent<Components::BlendMap>(ground_base_mirrored);
|
|
||||||
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
|
||||||
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
|
||||||
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
|
||||||
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
|
||||||
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
|
||||||
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
|
||||||
blendmap->TextureRepeats = 30.f;
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground_base_mirrored);
|
|
||||||
physics->Mass = 10;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
|
||||||
physics->CollisionLayer = 1;
|
|
||||||
|
|
||||||
auto groundshape = CreateEntity(ground_base_mirrored);
|
|
||||||
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
meshShape->ResourceName = "Models/TerrainFiveIstles/Base.obj";
|
|
||||||
|
|
||||||
|
|
||||||
CommitEntity(groundshape);
|
|
||||||
CommitEntity(ground_base_mirrored);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma endregion Region for ground and roads
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
auto tree = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(tree);
|
|
||||||
transform->Position = glm::vec3(0, -10, 0);
|
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(tree);
|
|
||||||
physics->Mass = 100.f;
|
|
||||||
physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed;
|
|
||||||
physics->CollisionEvent = false;
|
|
||||||
//physics->LinearDamping = 3.f;
|
|
||||||
physics->CalculateCenterOfMass = true;
|
|
||||||
|
|
||||||
{
|
|
||||||
auto stem = CreateEntity(tree);
|
|
||||||
auto transform = AddComponent<Components::Transform>(stem);
|
|
||||||
transform->Position = glm::vec3(0, -2.40906f, 0);
|
|
||||||
auto model = AddComponent<Components::Model>(stem);
|
|
||||||
model->ModelFile = "Models/Tree/Stem/Stem.obj";
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto leafs = CreateEntity(tree);
|
|
||||||
auto transform = AddComponent<Components::Transform>(leafs);
|
|
||||||
transform->Position = glm::vec3(0, -2.45511f, 0);
|
|
||||||
auto model = AddComponent<Components::Model>(leafs);
|
|
||||||
model->ModelFile = "Models/Tree/Leafs/Leafs.obj";
|
|
||||||
model->Transparent = true;
|
|
||||||
CommitEntity(leafs);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto shape = CreateEntity(tree);
|
|
||||||
auto transform = AddComponent<Components::Transform>(shape);
|
|
||||||
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
|
||||||
auto mesh = AddComponent<Components::MeshShape>(shape);
|
|
||||||
mesh->ResourceName = "Models/Tree/Collision/Collision.obj";
|
|
||||||
|
|
||||||
CommitEntity(shape);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*{
|
|
||||||
auto shape = CreateEntity(tree);
|
|
||||||
auto transform = AddComponent<Components::Transform>(shape);
|
|
||||||
auto box = AddComponent<Components::BoxShape>(shape);
|
|
||||||
transform->Position = glm::vec3(0.f, 0, 0.f);
|
|
||||||
box->Width = 0.296f;
|
|
||||||
box->Height = 2.511f;
|
|
||||||
box->Depth = 0.296f;
|
|
||||||
|
|
||||||
CommitEntity(shape);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto shape = CreateEntity(tree);
|
|
||||||
auto transform = AddComponent<Components::Transform>(shape);
|
|
||||||
auto sphere = AddComponent<Components::SphereShape>(shape);
|
|
||||||
transform->Position = glm::vec3(0, 2.04506f, 0.f);
|
|
||||||
sphere->Radius = 1.389f;
|
|
||||||
|
|
||||||
CommitEntity(shape);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
CommitEntity(tree);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
auto leafs = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(leafs);
|
|
||||||
transform->Position = glm::vec3(0, 0, 0);
|
|
||||||
auto model = AddComponent<Components::Model>(leafs);
|
|
||||||
model->ModelFile = "Models/Tree/Leafs/Leafs.obj";
|
|
||||||
model->Transparent = true;
|
|
||||||
CommitEntity(leafs);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma region Wall_Debris_Template
|
#pragma region Wall_Debris_Template
|
||||||
|
|
||||||
@@ -647,7 +301,7 @@ void GameWorld::Initialize()
|
|||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
CreateGarage(glm::vec3(-3.93076, 10, 0), 1);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto flag = CreateEntity();
|
auto flag = CreateEntity();
|
||||||
@@ -859,12 +513,15 @@ void GameWorld::BindGamepadButton(Gamepad::Button button, std::string command, f
|
|||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameWorld::CreateGate(glm::vec3 Position)
|
void GameWorld::CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation)
|
||||||
{
|
{
|
||||||
|
auto gateParent = CreateEntity(parent);
|
||||||
|
auto transform = AddComponent<Components::Transform>(gateParent);
|
||||||
|
transform->Position = position;
|
||||||
|
transform->Orientation = orientation;
|
||||||
{
|
{
|
||||||
auto gateBase = CreateEntity();
|
auto gateBase = CreateEntity(gateParent);
|
||||||
auto transform = AddComponent<Components::Transform>(gateBase);
|
auto transform = AddComponent<Components::Transform>(gateBase);
|
||||||
transform->Position = Position;
|
|
||||||
auto model = AddComponent<Components::Model>(gateBase);
|
auto model = AddComponent<Components::Model>(gateBase);
|
||||||
model->ModelFile = "Models/Gate/Lift/Lift.obj";
|
model->ModelFile = "Models/Gate/Lift/Lift.obj";
|
||||||
auto physics = AddComponent<Components::Physics>(gateBase);
|
auto physics = AddComponent<Components::Physics>(gateBase);
|
||||||
@@ -923,10 +580,9 @@ void GameWorld::CreateGate(glm::vec3 Position)
|
|||||||
CommitEntity(gateBase);
|
CommitEntity(gateBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto gate = CreateEntity(gateParent);
|
||||||
{
|
{
|
||||||
auto gate = CreateEntity();
|
|
||||||
auto transform = AddComponent<Components::Transform>(gate);
|
auto transform = AddComponent<Components::Transform>(gate);
|
||||||
transform->Position = Position;
|
|
||||||
auto model = AddComponent<Components::Model>(gate);
|
auto model = AddComponent<Components::Model>(gate);
|
||||||
model->ModelFile = "Models/Gate/Gate/Gate.obj";
|
model->ModelFile = "Models/Gate/Gate/Gate.obj";
|
||||||
auto physics = AddComponent<Components::Physics>(gate);
|
auto physics = AddComponent<Components::Physics>(gate);
|
||||||
@@ -934,8 +590,8 @@ void GameWorld::CreateGate(glm::vec3 Position)
|
|||||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||||
auto move = AddComponent<Components::Move>(gate);
|
auto move = AddComponent<Components::Move>(gate);
|
||||||
move->Speed = 5.f;
|
move->Speed = 5.f;
|
||||||
move->GoalPosition = glm::vec3(Position.x, Position.y + 9.02345f, Position.z);
|
move->GoalPosition = glm::vec3(0, 9.02345f, 0);
|
||||||
move->StartPosition = glm::vec3(Position.x, Position.y, Position.z);
|
move->StartPosition = glm::vec3(0, 0, 0);
|
||||||
{
|
{
|
||||||
auto mainShape = CreateEntity(gate);
|
auto mainShape = CreateEntity(gate);
|
||||||
auto transform = AddComponent<Components::Transform>(mainShape);
|
auto transform = AddComponent<Components::Transform>(mainShape);
|
||||||
@@ -957,29 +613,27 @@ void GameWorld::CreateGate(glm::vec3 Position)
|
|||||||
CommitEntity(lowerShape);
|
CommitEntity(lowerShape);
|
||||||
}
|
}
|
||||||
CommitEntity(gate);
|
CommitEntity(gate);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto gateTrigger = CreateEntity(gateParent);
|
||||||
|
auto transform = AddComponent<Components::Transform>(gateTrigger);
|
||||||
|
transform->Position = glm::vec3(0, 2.8241, 0);
|
||||||
|
auto trigger = AddComponent<Components::Trigger>(gateTrigger);
|
||||||
|
auto triggerMove = AddComponent<Components::TriggerMove>(gateTrigger);
|
||||||
|
triggerMove->Entity = gate;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto gateTrigger = CreateEntity();
|
auto shape = CreateEntity(gateTrigger);
|
||||||
auto transform = AddComponent<Components::Transform>(gateTrigger);
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
transform->Position = glm::vec3(Position.x, Position.y + 2.8241, Position.z);
|
transform->Position = glm::vec3(0.f, 2.8241f, 0.f);
|
||||||
auto trigger = AddComponent<Components::Trigger>(gateTrigger);
|
auto box = AddComponent<Components::BoxShape>(shape);
|
||||||
auto triggerMove = AddComponent<Components::TriggerMove>(gateTrigger);
|
box->Width = 6.963f;
|
||||||
triggerMove->Entity = gate;
|
box->Height = 3.104f;
|
||||||
|
box->Depth = 10.356f;
|
||||||
|
CommitEntity(shape);
|
||||||
{
|
|
||||||
auto shape = CreateEntity(gateTrigger);
|
|
||||||
auto transform = AddComponent<Components::Transform>(shape);
|
|
||||||
transform->Position = glm::vec3(0.f, 2.8241f, 0.f);
|
|
||||||
auto box = AddComponent<Components::BoxShape>(shape);
|
|
||||||
box->Width = 6.963f;
|
|
||||||
box->Height = 3.104f;
|
|
||||||
box->Depth = 10.356f;
|
|
||||||
CommitEntity(shape);
|
|
||||||
}
|
|
||||||
CommitEntity(gateTrigger);
|
|
||||||
}
|
}
|
||||||
|
CommitEntity(gateTrigger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1135,13 +789,338 @@ EntityID GameWorld::CreateJeep(int playerID)
|
|||||||
return jeep;
|
return jeep;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityID GameWorld::CreateGarage(glm::vec3 Position, int playerID)
|
void GameWorld::CreateTerrain()
|
||||||
{
|
{
|
||||||
auto garage = CreateEntity();
|
{
|
||||||
|
auto road_middle = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(road_middle);
|
||||||
|
auto model = AddComponent<Components::Model>(road_middle);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(road_middle);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
auto groundshape = CreateEntity(road_middle);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/MiddleRoad.obj";
|
||||||
|
|
||||||
|
|
||||||
|
CommitEntity(groundshape);
|
||||||
|
CommitEntity(road_middle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
/*auto water = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(water);
|
||||||
|
transform->Position = glm::vec3(0, -35, 0);
|
||||||
|
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
||||||
|
transform->Scale = glm::vec3(5000.f, 10.f, 5000.f);
|
||||||
|
auto model = AddComponent<Components::Model>(water);
|
||||||
|
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj";
|
||||||
|
auto blendmap = AddComponent<Components::BlendMap>(water);
|
||||||
|
blendmap->TextureRed = "Textures/Skybox/Sky34/bottom.jpg";
|
||||||
|
blendmap->TextureGreen = "Textures/Skybox/Sky34/bottom.jpg";
|
||||||
|
blendmap->TextureBlue = "Textures/Skybox/Sky34/bottom.jpg";
|
||||||
|
blendmap->TextureRepeats = 1.f;
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(water);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
{
|
||||||
|
|
||||||
|
auto groundshape = CreateEntity(water);
|
||||||
|
auto box = AddComponent<Components::BoxShape>(groundshape);
|
||||||
|
box->Depth = 250.f;
|
||||||
|
box->Height = 5.f;
|
||||||
|
box->Width = 250.f;
|
||||||
|
|
||||||
|
|
||||||
|
CommitEntity(groundshape);
|
||||||
|
}
|
||||||
|
CommitEntity(water);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto ground_middle = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(ground_middle);
|
||||||
|
auto model = AddComponent<Components::Model>(ground_middle);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Middle.obj";
|
||||||
|
auto blendmap = AddComponent<Components::BlendMap>(ground_middle);
|
||||||
|
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
||||||
|
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
||||||
|
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
||||||
|
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
||||||
|
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
||||||
|
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
||||||
|
blendmap->TextureRepeats = 30.f;
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(ground_middle);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
auto groundshape = CreateEntity(ground_middle);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Middle.obj";
|
||||||
|
|
||||||
|
|
||||||
|
CommitEntity(groundshape);
|
||||||
|
CommitEntity(ground_middle);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateBase(glm::quat(), 1);
|
||||||
|
CreateBase(glm::quat(glm::vec3(0, glm::pi<float>(), 0)), 2);
|
||||||
|
|
||||||
|
{
|
||||||
|
auto tree = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(tree);
|
||||||
|
transform->Position = glm::vec3(0, -10, 0);
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(tree);
|
||||||
|
physics->Mass = 100.f;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed;
|
||||||
|
physics->CollisionEvent = false;
|
||||||
|
//physics->LinearDamping = 3.f;
|
||||||
|
physics->CalculateCenterOfMass = true;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto stem = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(stem);
|
||||||
|
transform->Position = glm::vec3(0, -2.40906f, 0);
|
||||||
|
auto model = AddComponent<Components::Model>(stem);
|
||||||
|
model->ModelFile = "Models/Tree/Stem/Stem.obj";
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto leafs = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(leafs);
|
||||||
|
transform->Position = glm::vec3(0, -2.45511f, 0);
|
||||||
|
auto model = AddComponent<Components::Model>(leafs);
|
||||||
|
model->ModelFile = "Models/Tree/Leafs/Leafs.obj";
|
||||||
|
model->Transparent = true;
|
||||||
|
CommitEntity(leafs);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto shape = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
|
transform->Position = glm::vec3(0.f, 0.f, 0.f);
|
||||||
|
auto mesh = AddComponent<Components::MeshShape>(shape);
|
||||||
|
mesh->ResourceName = "Models/Tree/Collision/Collision.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*{
|
||||||
|
auto shape = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto box = AddComponent<Components::BoxShape>(shape);
|
||||||
|
transform->Position = glm::vec3(0.f, 0, 0.f);
|
||||||
|
box->Width = 0.296f;
|
||||||
|
box->Height = 2.511f;
|
||||||
|
box->Depth = 0.296f;
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto shape = CreateEntity(tree);
|
||||||
|
auto transform = AddComponent<Components::Transform>(shape);
|
||||||
|
auto sphere = AddComponent<Components::SphereShape>(shape);
|
||||||
|
transform->Position = glm::vec3(0, 2.04506f, 0.f);
|
||||||
|
sphere->Radius = 1.389f;
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
CommitEntity(tree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameWorld::CreateBase(glm::quat orientation, int playerID)
|
||||||
|
{
|
||||||
|
auto base = CreateEntity();
|
||||||
|
auto transform = AddComponent<Components::Transform>(base);
|
||||||
|
transform->Orientation = orientation;
|
||||||
|
#pragma region Terrain
|
||||||
|
{
|
||||||
|
auto ground_small = CreateEntity(base);
|
||||||
|
auto transform = AddComponent<Components::Transform>(ground_small);
|
||||||
|
auto model = AddComponent<Components::Model>(ground_small);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Small.obj";
|
||||||
|
auto blendmap = AddComponent<Components::BlendMap>(ground_small);
|
||||||
|
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
||||||
|
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
||||||
|
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
||||||
|
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
||||||
|
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
||||||
|
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
||||||
|
blendmap->TextureRepeats = 30.f;
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(ground_small);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
auto groundshape = CreateEntity(ground_small);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Small.obj";
|
||||||
|
CommitEntity(groundshape);
|
||||||
|
|
||||||
|
CommitEntity(ground_small);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto road_small = CreateEntity(base);
|
||||||
|
auto transform = AddComponent<Components::Transform>(road_small);
|
||||||
|
auto model = AddComponent<Components::Model>(road_small);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Roads/SmallRoad.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(road_small);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
auto groundshape = CreateEntity(road_small);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/SmallRoad.obj";
|
||||||
|
|
||||||
|
|
||||||
|
CommitEntity(groundshape);
|
||||||
|
CommitEntity(road_small);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bridge_middle = CreateEntity(base);
|
||||||
|
auto transform = AddComponent<Components::Transform>(bridge_middle);
|
||||||
|
auto model = AddComponent<Components::Model>(bridge_middle);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Bridges/MiddleBridge.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(bridge_middle);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto shape = CreateEntity(bridge_middle);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(shape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(shape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/MiddleBridgeCollision.obj";
|
||||||
|
CommitEntity(shape);
|
||||||
|
}
|
||||||
|
CommitEntity(bridge_middle);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto terrain_base = CreateEntity(base);
|
||||||
|
auto transform = AddComponent<Components::Transform>(terrain_base);
|
||||||
|
auto model = AddComponent<Components::Model>(terrain_base);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Base.obj";
|
||||||
|
auto blendmap = AddComponent<Components::BlendMap>(terrain_base);
|
||||||
|
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
||||||
|
blendmap->TextureRedNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
||||||
|
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
||||||
|
blendmap->TextureGreenNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
||||||
|
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
||||||
|
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
||||||
|
blendmap->TextureRepeats = 30.f;
|
||||||
|
|
||||||
|
auto physics = AddComponent<Components::Physics>(terrain_base);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(terrain_base);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(shape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(shape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Base.obj";
|
||||||
|
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(terrain_base);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto ground_base = CreateEntity(base);
|
||||||
|
auto transform = AddComponent<Components::Transform>(ground_base);
|
||||||
|
auto model = AddComponent<Components::Model>(ground_base);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/BaseGround.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(ground_base);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
auto shape = CreateEntity(ground_base);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(shape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(shape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/BaseGround.obj";
|
||||||
|
|
||||||
|
CommitEntity(shape);
|
||||||
|
CommitEntity(ground_base);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto road_base = CreateEntity(base);
|
||||||
|
auto transform = AddComponent<Components::Transform>(road_base);
|
||||||
|
auto model = AddComponent<Components::Model>(road_base);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(road_base);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
auto groundshape = CreateEntity(road_base);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(groundshape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Roads/BaseRoad.obj";
|
||||||
|
|
||||||
|
|
||||||
|
CommitEntity(groundshape);
|
||||||
|
CommitEntity(road_base);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto bridge_base = CreateEntity(base);
|
||||||
|
auto transform = AddComponent<Components::Transform>(bridge_base);
|
||||||
|
auto model = AddComponent<Components::Model>(bridge_base);
|
||||||
|
model->ModelFile = "Models/TerrainFiveIstles/Bridges/BaseBridge.obj";
|
||||||
|
auto physics = AddComponent<Components::Physics>(bridge_base);
|
||||||
|
physics->Mass = 10;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Fixed;
|
||||||
|
physics->CollisionLayer = 1;
|
||||||
|
|
||||||
|
{
|
||||||
|
auto shape = CreateEntity(bridge_base);
|
||||||
|
auto transformshape = AddComponent<Components::Transform>(shape);
|
||||||
|
auto meshShape = AddComponent<Components::MeshShape>(shape);
|
||||||
|
meshShape->ResourceName = "Models/TerrainFiveIstles/Bridges/BaseBridge.obj";
|
||||||
|
CommitEntity(shape);
|
||||||
|
}
|
||||||
|
CommitEntity(bridge_base);
|
||||||
|
}
|
||||||
|
#pragma endregion Terrain
|
||||||
|
|
||||||
|
CreateGate(base, glm::vec3(273.f, 40.185f, 0.06f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)));
|
||||||
|
|
||||||
|
CreateGarage(base, glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(glm::vec3(0, glm::pi<float>() / 2.f, 0)), playerID);
|
||||||
|
}
|
||||||
|
EntityID GameWorld::CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID)
|
||||||
|
{
|
||||||
|
auto garage = CreateEntity(parent);
|
||||||
auto transform = AddComponent<Components::Transform>(garage);
|
auto transform = AddComponent<Components::Transform>(garage);
|
||||||
transform->Position = Position;
|
transform->Position = Position;
|
||||||
auto player = AddComponent<Components::Player>(garage);
|
transform->Orientation = orientation;
|
||||||
player->ID = playerID;
|
|
||||||
|
auto player = CreateEntity(garage);
|
||||||
|
auto playerComponent = AddComponent<Components::Player>(player);
|
||||||
|
playerComponent->ID = playerID;
|
||||||
|
|
||||||
auto ElevatorBase = CreateEntity(garage);
|
auto ElevatorBase = CreateEntity(garage);
|
||||||
{
|
{
|
||||||
@@ -1210,7 +1189,7 @@ EntityID GameWorld::CreateGarage(glm::vec3 Position, int playerID)
|
|||||||
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
physics->CollisionLayer = (int)Components::Physics::CollisionLayer::STATIC;
|
||||||
auto rotate = AddComponent<Components::Rotate>(rightHatch);
|
auto rotate = AddComponent<Components::Rotate>(rightHatch);
|
||||||
rotate->StartRotation = transform->Orientation;
|
rotate->StartRotation = transform->Orientation;
|
||||||
rotate->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1));
|
rotate->GoalRotation = transform->Orientation * glm::angleAxis(glm::radians(110.f), glm::vec3(0, 0, 1));
|
||||||
rotate->Time = 5.f;
|
rotate->Time = 5.f;
|
||||||
{
|
{
|
||||||
auto shape = CreateEntity(rightHatch);
|
auto shape = CreateEntity(rightHatch);
|
||||||
@@ -1254,6 +1233,7 @@ EntityID GameWorld::CreateGarage(glm::vec3 Position, int playerID)
|
|||||||
auto transform = AddComponent<Components::Transform>(spawnPoint);
|
auto transform = AddComponent<Components::Transform>(spawnPoint);
|
||||||
transform->Position.y = 1.f;
|
transform->Position.y = 1.f;
|
||||||
auto spawnPointComponent = AddComponent<Components::SpawnPoint>(spawnPoint);
|
auto spawnPointComponent = AddComponent<Components::SpawnPoint>(spawnPoint);
|
||||||
|
spawnPointComponent->Player = player;
|
||||||
}
|
}
|
||||||
CommitEntity(spawnPoint);
|
CommitEntity(spawnPoint);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -78,11 +78,13 @@ private:
|
|||||||
void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value);
|
void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value);
|
||||||
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
||||||
|
|
||||||
void CreateGate(glm::vec3 Position);
|
void CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation);
|
||||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
||||||
EntityID CreateJeep(int playerID);
|
EntityID CreateJeep(int playerID);
|
||||||
EntityID CreateWall(glm::vec3 pos, glm::quat orientation);
|
EntityID CreateWall(glm::vec3 pos, glm::quat orientation);
|
||||||
EntityID CreateGarage(glm::vec3 Position, int playerID);
|
EntityID CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID);
|
||||||
|
void CreateTerrain();
|
||||||
|
void CreateBase(glm::quat orientation, int playerID);
|
||||||
std::vector<EntityID> m_WallDebrisTemplates;
|
std::vector<EntityID> m_WallDebrisTemplates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -279,6 +279,7 @@ void Renderer::DrawFrame(RenderQueuePair &rq)
|
|||||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
//glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
|
//glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
@@ -531,7 +532,8 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
|||||||
if (spriteJob)
|
if (spriteJob)
|
||||||
{
|
{
|
||||||
glm::mat4 modelMatrix = spriteJob->ModelMatrix;
|
glm::mat4 modelMatrix = spriteJob->ModelMatrix;
|
||||||
MVP = cameraMatrix * modelMatrix;
|
glm::mat4 billboardingMatrix = glm::inverse(glm::toMat4(glm::inverse(m_Camera->Orientation())));
|
||||||
|
MVP = cameraMatrix * modelMatrix * billboardingMatrix;
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4(MVP)));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4(MVP)));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4(modelMatrix)));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4(modelMatrix)));
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ bool Systems::DebugSystem::OnKeyDown(const Events::KeyDown &event)
|
|||||||
if (event.KeyCode == GLFW_KEY_ENTER)
|
if (event.KeyCode == GLFW_KEY_ENTER)
|
||||||
{
|
{
|
||||||
Events::PlaySFX e;
|
Events::PlaySFX e;
|
||||||
e.Emitter = 0;
|
e.Position = glm::vec3(0);
|
||||||
e.Resource = "Sounds/korvring.wav";
|
e.Resource = "Sounds/korvring.wav";
|
||||||
EventBroker->Publish<Events::PlaySFX>(e);
|
EventBroker->Publish<Events::PlaySFX>(e);
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ void Systems::PhysicsSystem::Initialize()
|
|||||||
worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;
|
worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;
|
||||||
|
|
||||||
// You must specify the size of the broad phase - objects should not be simulated outside this region
|
// You must specify the size of the broad phase - objects should not be simulated outside this region
|
||||||
worldInfo.setBroadPhaseWorldSize(500.0f);
|
worldInfo.setBroadPhaseWorldSize(1000.0f);
|
||||||
m_PhysicsWorld = new hkpWorld(worldInfo);
|
m_PhysicsWorld = new hkpWorld(worldInfo);
|
||||||
|
|
||||||
// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
|
// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
|
||||||
@@ -180,6 +180,12 @@ void Systems::PhysicsSystem::Update(double dt)
|
|||||||
rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation);
|
rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation);
|
||||||
velocity = GLMVEC3_TO_HKVECTOR4(transformComponent->Velocity);
|
velocity = GLMVEC3_TO_HKVECTOR4(transformComponent->Velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
||||||
|
position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position);
|
||||||
|
rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation);
|
||||||
|
velocity = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Velocity);*/
|
||||||
|
|
||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
m_RigidBodies[entity]->setPositionAndRotation(position, rotation);
|
m_RigidBodies[entity]->setPositionAndRotation(position, rotation);
|
||||||
|
|
||||||
@@ -268,17 +274,33 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
else if(m_RigidBodies.find(entity) != m_RigidBodies.end())
|
else if(m_RigidBodies.find(entity) != m_RigidBodies.end())
|
||||||
{
|
{
|
||||||
auto transformComponentParent = m_World->GetComponent<Components::Transform>(parent);
|
auto transformComponentParent = m_World->GetComponent<Components::Transform>(parent);
|
||||||
|
|
||||||
|
/* if(transformComponentParent)
|
||||||
|
{
|
||||||
|
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
|
||||||
|
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||||
|
transformComponent->Orientation = glm::inverse(HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation())) * absoluteTransformParent.Orientation;
|
||||||
|
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto transformComponentParent = m_World->GetComponent<Components::Transform>(parent);
|
||||||
|
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||||
|
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
||||||
|
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||||
|
}*/
|
||||||
|
|
||||||
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||||
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
||||||
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||||
// TODO: No support for Scale, MIGHT be possible
|
|
||||||
|
|
||||||
// HACK: WTF IS THIS?
|
// HACK: WTF IS THIS?
|
||||||
if (transformComponentParent)
|
if (transformComponentParent)
|
||||||
{
|
{
|
||||||
transformComponent->Position -= transformComponentParent->Position;
|
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
|
||||||
transformComponent->Position = transformComponent->Position * transformComponentParent->Orientation;
|
transformComponent->Position -= absoluteTransformParent.Position;
|
||||||
transformComponent->Orientation = transformComponent->Orientation * glm::inverse(transformComponentParent->Orientation);
|
transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation;
|
||||||
|
transformComponent->Orientation = glm::inverse(absoluteTransformParent.Orientation) * transformComponent->Orientation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+33
-28
@@ -20,7 +20,7 @@ void Systems::SoundSystem::Initialize()
|
|||||||
{
|
{
|
||||||
LOG_INFO("FMOD initialized successfully");
|
LOG_INFO("FMOD initialized successfully");
|
||||||
}
|
}
|
||||||
FMOD_System_Set3DSettings(m_System, 1.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale
|
FMOD_System_Set3DSettings(m_System, 0.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,20 +44,31 @@ void Systems::SoundSystem::Update(double dt)
|
|||||||
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
||||||
for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();)
|
for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();)
|
||||||
{
|
{
|
||||||
FMOD_BOOL *isPlaying = false;
|
FMOD_BOOL isPlaying = false;
|
||||||
FMOD_Channel_IsPlaying(it->second, isPlaying);
|
FMOD_Channel_IsPlaying(it->second, &isPlaying);
|
||||||
if(isPlaying)
|
if(isPlaying)
|
||||||
{
|
{
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
// FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
||||||
m_DeleteSounds.erase(it->first);
|
// m_DeleteSounds.erase(it->first);
|
||||||
it = m_DeleteChannels.erase(it);
|
it = m_DeleteChannels.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//LOG_INFO("Antal emitters i listan: %i", m_Channels.size());
|
||||||
|
for (auto channel : m_Channels)
|
||||||
|
{
|
||||||
|
FMOD_BOOL isPlaying = false;
|
||||||
|
FMOD_Channel_IsPlaying(channel.second, &isPlaying);
|
||||||
|
if(!isPlaying)
|
||||||
|
{
|
||||||
|
m_Channels.erase(channel.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
@@ -86,7 +97,7 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
|
|||||||
if(emitter)
|
if(emitter)
|
||||||
{
|
{
|
||||||
FMOD_CHANNEL* channel = m_Channels[entity];
|
FMOD_CHANNEL* channel = m_Channels[entity];
|
||||||
FMOD_SOUND* sound = m_Sounds[entity];
|
//FMOD_SOUND* sound = m_Sounds[entity];
|
||||||
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
|
||||||
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
||||||
@@ -121,34 +132,28 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev
|
|||||||
float pitch = emitter->Pitch;
|
float pitch = emitter->Pitch;
|
||||||
//LoadSound(sound, path, maxDist, minDist);
|
//LoadSound(sound, path, maxDist, minDist);
|
||||||
m_Channels.insert(std::make_pair(emitter->Entity, channel));
|
m_Channels.insert(std::make_pair(emitter->Entity, channel));
|
||||||
m_Sounds.insert(std::make_pair(emitter->Entity, sound));
|
// m_Sounds.insert(std::make_pair(emitter->Entity, sound));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
||||||
{
|
{
|
||||||
auto emitter = m_World->GetComponent<Components::SoundEmitter>(event.Emitter);
|
auto eEntity = m_World->CreateEntity();
|
||||||
if(!emitter)
|
auto eTransform = m_World->AddComponent<Components::Transform>(eEntity);
|
||||||
{
|
eTransform->Position = event.Position;
|
||||||
LOG_ERROR("FMOD: The Entity %i does not have a SoundEmitter-component, but is trying to play a sound", event.Emitter);FMOD_CHANNEL* channel = m_Channels[event.Emitter];
|
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(eEntity);
|
||||||
return false;
|
eComponent->MinDistance = event.MinDistance;
|
||||||
}
|
eComponent->MaxDistance= event.MaxDistance;
|
||||||
|
eComponent->Loop = event.Loop;
|
||||||
|
eComponent->Gain = event.Volume;
|
||||||
|
|
||||||
emitter->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||||
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
|
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
|
||||||
m_Sounds[event.Emitter] = *sound;
|
//m_Sounds[eEntity] = *sound;
|
||||||
FMOD_Sound_Set3DMinMaxDistance(*sound, emitter->MinDistance, emitter->MaxDistance);
|
FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance);
|
||||||
|
|
||||||
PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop);
|
PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop);
|
||||||
FMOD_System_Update(m_System);
|
|
||||||
|
|
||||||
FMOD_BOOL isPlaying = false;
|
|
||||||
FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying);
|
|
||||||
if(!isPlaying)
|
|
||||||
LOG_ERROR("FMOD: File %s is not playing", event.Resource.c_str());
|
|
||||||
else
|
|
||||||
LOG_INFO("Now playing sound %s", event.Resource.c_str());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +165,7 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
|||||||
m_Channels[emitter] = m_BGMChannel;
|
m_Channels[emitter] = m_BGMChannel;
|
||||||
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||||
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
|
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
|
||||||
m_Sounds[emitter] = *sound;
|
//m_Sounds[emitter] = *sound;
|
||||||
|
|
||||||
FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_Channels[emitter]);
|
FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_Channels[emitter]);
|
||||||
return true;
|
return true;
|
||||||
@@ -199,8 +204,8 @@ void Systems::SoundSystem::OnComponentRemoved(EntityID entity, std::string type,
|
|||||||
if(emitter)
|
if(emitter)
|
||||||
{
|
{
|
||||||
m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity]));
|
m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity]));
|
||||||
m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
|
//m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
|
||||||
m_Channels.erase(entity);
|
m_Channels.erase(entity);
|
||||||
m_Sounds.erase(entity);
|
//m_Sounds.erase(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ private:
|
|||||||
std::vector<EntityID> m_Listeners;
|
std::vector<EntityID> m_Listeners;
|
||||||
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
|
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
|
||||||
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
|
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
|
||||||
std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
//std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
||||||
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
|
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
|
||||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||||
|
|
||||||
|
|||||||
@@ -90,12 +90,48 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
auto cloneTransform = m_World->GetComponent<Components::Transform>(clone);
|
auto cloneTransform = m_World->GetComponent<Components::Transform>(clone);
|
||||||
cloneTransform->Position = templateAbsoluteTransform.Position;
|
cloneTransform->Position = templateAbsoluteTransform.Position;
|
||||||
cloneTransform->Orientation = absoluteTransform.Orientation * cloneTransform->Orientation;
|
cloneTransform->Orientation = absoluteTransform.Orientation * cloneTransform->Orientation;
|
||||||
|
|
||||||
Events::SetVelocity eSetVelocity;
|
Events::SetVelocity eSetVelocity;
|
||||||
eSetVelocity.Entity = clone;
|
eSetVelocity.Entity = clone;
|
||||||
eSetVelocity.Velocity = tankTransform->Velocity + absoluteTransform.Orientation * (glm::vec3(0.f, 0.f, -1.f) * barrelSteeringComponent->ShotSpeed);
|
eSetVelocity.Velocity = tankTransform->Velocity + absoluteTransform.Orientation * (glm::vec3(0.f, 0.f, -1.f) * barrelSteeringComponent->ShotSpeed);
|
||||||
EventBroker->Publish(eSetVelocity);
|
EventBroker->Publish(eSetVelocity);
|
||||||
m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0;
|
m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 1.5;
|
||||||
|
e.ParticleScale.push_back(0.6);
|
||||||
|
e.ParticleScale.push_back(1.8);
|
||||||
|
e.ParticlesToSpawn = 5;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 1.7;
|
||||||
|
e.SpreadAngle = glm::pi<float>()/10;
|
||||||
|
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||||
|
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 0.2;
|
||||||
|
e.ParticleScale.push_back(1);
|
||||||
|
//e.ParticleScale.push_back(2);
|
||||||
|
e.ParticlesToSpawn = 1;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.Speed = 0;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/MuzzleFlash.png";
|
||||||
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::PlaySFX e;
|
||||||
|
e.Resource = "Sounds/SFX/TankShot.mp3";
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.Loop = false;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
auto clonePhysicsComponent = m_World->GetComponent<Components::Physics>(clone);
|
auto clonePhysicsComponent = m_World->GetComponent<Components::Physics>(clone);
|
||||||
//1,670m/s
|
//1,670m/s
|
||||||
@@ -109,6 +145,15 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
|
|
||||||
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
|
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// auto shot = m_World->GetComponent<Components::TankShell>(entity);
|
||||||
|
// if(shot)
|
||||||
|
// {
|
||||||
|
// if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||||
@@ -179,6 +224,13 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
|||||||
e.Color = glm::vec4(2, 2, 2, 0.2);
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
Events::PlaySFX e;
|
||||||
|
e.MinDistance = 150.f;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.Resource = "Sounds/SFX/Explosion.wav";
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &physComponent : *physicsComponents)
|
for (auto &physComponent : *physicsComponents)
|
||||||
{
|
{
|
||||||
@@ -300,11 +352,11 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &spawnPointComponent : *spawnPointComponents)
|
for (auto &component : *spawnPointComponents)
|
||||||
{
|
{
|
||||||
auto spawnPoint = spawnPointComponent->Entity;
|
auto spawnPoint = component->Entity;
|
||||||
auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint);
|
auto spawnPointComponent = std::dynamic_pointer_cast<Components::SpawnPoint>(component);
|
||||||
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointBaseParent);
|
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointComponent->Player);
|
||||||
if (!playerComponent || playerComponent->ID != event.PlayerID)
|
if (!playerComponent || playerComponent->ID != event.PlayerID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -347,6 +399,7 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
m_World->AddComponent<Components::Input>(tank);
|
m_World->AddComponent<Components::Input>(tank);
|
||||||
auto health = m_World->AddComponent<Components::Health>(tank);
|
auto health = m_World->AddComponent<Components::Health>(tank);
|
||||||
health->Amount = 100.f;
|
health->Amount = 100.f;
|
||||||
|
m_World->AddComponent<Components::Listener>(tank);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = m_World->CreateEntity(tank);
|
auto shape = m_World->CreateEntity(tank);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "Components/Health.h"
|
#include "Components/Health.h"
|
||||||
#include "Components/TankShell.h"
|
#include "Components/TankShell.h"
|
||||||
#include "Components/SphereShape.h"
|
#include "Components/SphereShape.h"
|
||||||
|
#include "Components/Listener.h"
|
||||||
|
|
||||||
#include "Events/EnableCollisions.h"
|
#include "Events/EnableCollisions.h"
|
||||||
#include "Events/DisableCollisions.h"
|
#include "Events/DisableCollisions.h"
|
||||||
@@ -29,6 +30,9 @@
|
|||||||
#include "Components/TriggerExplosion.h"
|
#include "Components/TriggerExplosion.h"
|
||||||
#include "Components/FrameTimer.h"
|
#include "Components/FrameTimer.h"
|
||||||
|
|
||||||
|
#include "Events/PlaySFX.h"
|
||||||
|
#include "Events/PlayBGM.h"
|
||||||
|
|
||||||
#include "Events/Damage.h"
|
#include "Events/Damage.h"
|
||||||
#include "Components/Vehicle.h"
|
#include "Components/Vehicle.h"
|
||||||
#include "Components/Player.h"
|
#include "Components/Player.h"
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
|||||||
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
||||||
{
|
{
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
auto absolutetransform = AbsoluteTransform(entity);
|
||||||
|
|
||||||
float percentage = dt/m_RotationItems[entity].Time;
|
float percentage = dt/m_RotationItems[entity].Time;
|
||||||
m_RotationItems[entity].Time -= dt;
|
m_RotationItems[entity].Time -= dt;
|
||||||
|
|||||||
@@ -194,6 +194,9 @@
|
|||||||
<Filter Include="Base\Events">
|
<Filter Include="Base\Events">
|
||||||
<UniqueIdentifier>{3cbe68d9-2446-45ee-8637-ffb805997dcd}</UniqueIdentifier>
|
<UniqueIdentifier>{3cbe68d9-2446-45ee-8637-ffb805997dcd}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Rendering\Events">
|
||||||
|
<UniqueIdentifier>{a025d51e-594d-4844-983b-f683726bf1bf}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
<Filter Include="Game\Events">
|
<Filter Include="Game\Events">
|
||||||
<UniqueIdentifier>{9702064a-02a2-4b3c-a2ab-47c23a9cf49c}</UniqueIdentifier>
|
<UniqueIdentifier>{9702064a-02a2-4b3c-a2ab-47c23a9cf49c}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -556,6 +559,9 @@
|
|||||||
<ClInclude Include="..\..\src\Components\Rotate.h">
|
<ClInclude Include="..\..\src\Components\Rotate.h">
|
||||||
<Filter>Base\Components</Filter>
|
<Filter>Base\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
||||||
|
<Filter>Rendering\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\GUI\VehicleSelection.h">
|
<ClInclude Include="..\..\src\GUI\VehicleSelection.h">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
Reference in New Issue
Block a user