Merge remote-tracking branch 'origin/master' into Sound+Particles

Conflicts:
	src/GameWorld.cpp
This commit is contained in:
Stiffly
2014-06-04 05:30:42 +02:00
10 changed files with 326 additions and 232 deletions
+1 -1
Submodule assets updated: a6e3f120fd...637f866e2d
+2
View File
@@ -8,6 +8,8 @@ namespace Components
struct SpawnPoint : Component
{
EntityID Player;
virtual SpawnPoint* Clone() const override { return new SpawnPoint(*this); }
};
+4
View File
@@ -132,7 +132,11 @@ public:
Rectangle AbsoluteRectangle()
{
int left = Left();
if (m_Parent)
left = std::max(left, m_Parent->Left());
int top = Top();
if (m_Parent)
top = std::max(top, m_Parent->Top());
int width = Right() - left;
int height = Bottom() - top;
return Rectangle(left, top, width, height);
+330 -268
View File
@@ -91,7 +91,7 @@ void GameWorld::Initialize()
EventBroker->Publish(e);
}
//CreateTerrain();
CreateTerrain();
#pragma region Wall_Debris_Template
@@ -301,8 +301,7 @@ void GameWorld::Initialize()
EventBroker->Publish(e);
}*/
CreateGarage(glm::vec3(323.2f, 41.4f, -10.2f), glm::quat(), 1); // glm::vec3(0, glm::pi<float>()/2.f, 0)
CreateGarage(glm::vec3(-323.2f, 41.4f, -10.2f), glm::quat(), 2); // glm::vec3(0, -glm::pi<float>()/2.f, 0)
{
auto flag = CreateEntity();
@@ -790,14 +789,335 @@ EntityID GameWorld::CreateJeep(int playerID)
return jeep;
}
EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int playerID)
void GameWorld::CreateTerrain()
{
auto garage = CreateEntity();
auto transform = AddComponent<Components::Transform>(garage);
transform->Position = position;
{
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;
auto player = AddComponent<Components::Player>(garage);
player->ID = playerID;
{
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/MiddleBridge.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);
}
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);
transform->Position = Position;
transform->Orientation = orientation;
auto player = CreateEntity(garage);
auto playerComponent = AddComponent<Components::Player>(player);
playerComponent->ID = playerID;
auto ElevatorBase = CreateEntity(garage);
{
@@ -910,6 +1230,7 @@ EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int
auto transform = AddComponent<Components::Transform>(spawnPoint);
transform->Position.y = 1.f;
auto spawnPointComponent = AddComponent<Components::SpawnPoint>(spawnPoint);
spawnPointComponent->Player = player;
}
CommitEntity(spawnPoint);
}
@@ -961,262 +1282,3 @@ EntityID GameWorld::CreateGarage(glm::vec3 position, glm::quat orientation, int
return garage;
}
void GameWorld::CreateTerrain()
{
{
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());
CreateBase(glm::quat(glm::vec3(0, glm::pi<float>()/2.f, 0)));
{
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)
{
{
auto ground_small = CreateEntity();
auto transform = AddComponent<Components::Transform>(ground_small);
transform->Orientation = orientation;
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_base = CreateEntity();
auto transform = AddComponent<Components::Transform>(ground_base);
transform->Orientation = orientation;
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 road_base = CreateEntity();
auto transform = AddComponent<Components::Transform>(road_base);
transform->Orientation = orientation;
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_small = CreateEntity();
auto transform = AddComponent<Components::Transform>(road_small);
transform->Orientation = orientation;
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);
}
}
+2 -2
View File
@@ -82,9 +82,9 @@ private:
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
EntityID CreateJeep(int playerID);
EntityID CreateWall(glm::vec3 pos, glm::quat orientation);
EntityID CreateGarage(glm::vec3 Position, glm::quat orientation, int playerID);
EntityID CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int playerID);
void CreateTerrain();
void CreateBase(glm::quat orientation);
void CreateBase(glm::quat orientation, int playerID);
std::vector<EntityID> m_WallDebrisTemplates;
};
+1
View File
@@ -276,6 +276,7 @@ void Renderer::DrawFrame(RenderQueuePair &rq)
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
glEnable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
+26 -4
View File
@@ -180,6 +180,12 @@ void Systems::PhysicsSystem::Update(double dt)
rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation);
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_RigidBodies[entity]->setPositionAndRotation(position, rotation);
@@ -266,19 +272,35 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
}
}
else if(m_RigidBodies.find(entity) != m_RigidBodies.end())
{
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());
// TODO: No support for Scale, MIGHT be possible
}*/
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());
// HACK: WTF IS THIS?
if (transformComponentParent)
{
transformComponent->Position -= transformComponentParent->Position;
transformComponent->Position = transformComponent->Position * transformComponentParent->Orientation;
transformComponent->Orientation = transformComponent->Orientation * glm::inverse(transformComponentParent->Orientation);
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
transformComponent->Position -= absoluteTransformParent.Position;
transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation;
transformComponent->Orientation = glm::inverse(absoluteTransformParent.Orientation) * transformComponent->Orientation;
}
}
+15 -14
View File
@@ -128,11 +128,11 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
}
{
// Events::PlaySFX e;
// e.Resource = "Sounds/SFX/TankShot.mp3";
// e.Position = absoluteTransform.Position;
// e.Loop = false;
// 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);
@@ -256,11 +256,11 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
EventBroker->Publish(e);
}
{
// Events::PlaySFX e;
// e.MinDistance = 150.f;
// e.Position = shellTransform->Position;
// e.Resource = "Sounds/SFX/Explosion.wav";
// 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)
@@ -383,11 +383,11 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve
return false;
}
for (auto &spawnPointComponent : *spawnPointComponents)
for (auto &component : *spawnPointComponents)
{
auto spawnPoint = spawnPointComponent->Entity;
auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint);
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointBaseParent);
auto spawnPoint = component->Entity;
auto spawnPointComponent = std::dynamic_pointer_cast<Components::SpawnPoint>(component);
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointComponent->Player);
if (!playerComponent || playerComponent->ID != event.PlayerID)
continue;
@@ -430,6 +430,7 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
m_World->AddComponent<Components::Input>(tank);
auto health = m_World->AddComponent<Components::Health>(tank);
health->Amount = 100.f;
m_World->AddComponent<Components::Listener>(tank);
{
auto shape = m_World->CreateEntity(tank);
+1
View File
@@ -22,6 +22,7 @@
#include "Components/Health.h"
#include "Components/TankShell.h"
#include "Components/SphereShape.h"
#include "Components/Listener.h"
#include "Events/EnableCollisions.h"
#include "Events/DisableCollisions.h"
+1
View File
@@ -54,6 +54,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
if(m_RotationItems.find(entity) != m_RotationItems.end())
{
auto transform = m_World->GetComponent<Components::Transform>(entity);
auto absolutetransform = AbsoluteTransform(entity);
float percentage = dt/m_RotationItems[entity].Time;
m_RotationItems[entity].Time -= dt;