Merge branch 'master' into havok

Conflicts:
	assets
	src/GameWorld.cpp
	vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
2014-05-17 21:23:46 +02:00
40 changed files with 1394 additions and 883 deletions
+196 -216
View File
@@ -13,20 +13,20 @@ void GameWorld::Initialize()
BindKey(GLFW_KEY_A, "horizontal", -1.f);
BindKey(GLFW_KEY_D, "horizontal", 1.f);
BindGamepadAxis(Gamepad::Axis::LeftX, "horizontal", 1.f);
BindGamepadAxis(Gamepad::Axis::RightTrigger, "vertical", 1.f);
BindGamepadAxis(Gamepad::Axis::LeftTrigger, "vertical", -1.f);
BindGamepadAxis(Gamepad::Axis::LeftY, "vertical", 1.f);
BindKey(GLFW_KEY_UP, "barrel_rotation", 1.f);
BindKey(GLFW_KEY_DOWN, "barrel_rotation", -1.f);
BindKey(GLFW_KEY_LEFT, "tower_rotation", -1.f);
BindKey(GLFW_KEY_RIGHT, "tower_rotation", 1.f);
BindGamepadAxis(Gamepad::Axis::RightX, "tower_rotation", 1.f);
BindGamepadAxis(Gamepad::Axis::RightY, "barrel_rotation", 1.f);
BindKey(GLFW_KEY_SPACE, "handbrake", 1.f);
BindGamepadButton(Gamepad::Button::A, "handbrake", 1.f);
BindKey(GLFW_KEY_Z, "shoot", 1.f);
BindGamepadAxis(Gamepad::Axis::RightTrigger, "shoot", 1.f);
//BindGamepadButton(Gamepad::Button::Up, "Gamepad::Button::Up", 1.f);
//BindGamepadButton(Gamepad::Button::Down, "Gamepad::Button::Down", 1.f);
@@ -42,62 +42,40 @@ void GameWorld::Initialize()
//BindGamepadButton(Gamepad::Button::B, "Gamepad::Button::B", 1.f);
//BindGamepadButton(Gamepad::Button::X, "Gamepad::Button::X", 1.f);
//BindGamepadButton(Gamepad::Button::Y, "Gamepad::Button::Y", 1.f);
//
// BindKey(GLFW_KEY_UP, "vertical", -1.f);
// BindKey(GLFW_KEY_DOWN, "vertical", 1.f);
// BindKey(GLFW_KEY_LEFT, "horizontal", -1.f);
// BindKey(GLFW_KEY_RIGHT, "horizontal", 1.f);
/*
BindKey(GLFW_KEY_Q, "+tower_right");
BindKey(GLFW_KEY_E, "+tower_left");
BindKey(GLFW_KEY_Q, "+up");
BindKey(GLFW_KEY_LEFT_CONTROL, "+down");
BindKey(GLFW_KEY_LEFT_ALT, "+slow");
BindKey(GLFW_KEY_LEFT_SHIFT, "+fast");
BindMouseButton(GLFW_MOUSE_BUTTON_1, "+attack");
BindMouseButton(GLFW_MOUSE_BUTTON_2, "+attack2");
BindMouseButton(GLFW_MOUSE_BUTTON_3, "+attack3");
BindKey(GLFW_KEY_UP, "+cam_forward");
BindKey(GLFW_KEY_DOWN, "+cam_backward");
BindKey(GLFW_KEY_LEFT, "+cam_left");
BindKey(GLFW_KEY_RIGHT, "+cam_right");*/
RegisterComponents();
{
auto camera = CreateEntity();
auto transform = AddComponent<Components::Transform>(camera, "Transform");
transform->Position.z = 20.f;
transform->Position.y = 20.f;
//transform->Orientation = glm::quat(glm::vec3(glm::pi<float>() / 8.f, 0.f, 0.f));
auto cameraComp = AddComponent<Components::Camera>(camera, "Camera");
cameraComp->FarClip = 2000.f;
auto freeSteering = AddComponent<Components::FreeSteering>(camera, "FreeSteering");
CommitEntity(camera);
}
//{
// auto camera = CreateEntity();
// auto transform = AddComponent<Components::Transform>(camera);
// transform->Position.z = 20.f;
// transform->Position.y = 20.f;
// //transform->Orientation = glm::quat(glm::vec3(glm::pi<float>() / 8.f, 0.f, 0.f));
// auto cameraComp = AddComponent<Components::Camera>(camera);
// cameraComp->FarClip = 2000.f;
// auto freeSteering = AddComponent<Components::FreeSteering>(camera);
// CommitEntity(camera);
//}
{
auto ground = CreateEntity();
auto transform = AddComponent<Components::Transform>(ground, "Transform");
auto transform = AddComponent<Components::Transform>(ground);
transform->Position = glm::vec3(0, 0, 0);
//transform->Scale = glm::vec3(400.0f, 10.0f, 400.0f);
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
auto model = AddComponent<Components::Model>(ground, "Model");
auto model = AddComponent<Components::Model>(ground);
//model->ModelFile = "Models/TestScene/testScene.obj";
model->ModelFile = "Models/Placeholders/Terrain/Terrain2.obj";
auto physics = AddComponent<Components::Physics>(ground, "Physics");
auto physics = AddComponent<Components::Physics>(ground);
physics->Mass = 10;
physics->Static = true;
auto groundshape = CreateEntity(ground);
auto transformshape = AddComponent<Components::Transform>(groundshape, "Transform");
auto meshShape = AddComponent<Components::MeshShape>(groundshape, "MeshShape");
auto transformshape = AddComponent<Components::Transform>(groundshape);
auto meshShape = AddComponent<Components::MeshShape>(groundshape);
meshShape->ResourceName = "Models/Placeholders/Terrain/Terrain2.obj";
//meshShape->ResourceName = "Models/TestScene/testScene.obj";
@@ -110,23 +88,23 @@ void GameWorld::Initialize()
/*{
auto jeep = CreateEntity();
auto transform = AddComponent<Components::Transform>(jeep, "Transform");
auto transform = AddComponent<Components::Transform>(jeep);
transform->Position = glm::vec3(0, 5, 0);
transform->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(0, 1, 0));
auto physics = AddComponent<Components::Physics>(jeep, "Physics");
auto physics = AddComponent<Components::Physics>(jeep);
physics->Mass = 1800;
physics->Static = false;
auto vehicle = AddComponent<Components::Vehicle>(jeep, "Vehicle");
AddComponent<Components::Input>(jeep, "Input");
auto vehicle = AddComponent<Components::Vehicle>(jeep);
AddComponent<Components::Input>(jeep);
{
auto shape = CreateEntity(jeep);
auto transform = AddComponent<Components::Transform>(shape, "Transform");
auto meshShape = AddComponent<Components::MeshShape>(shape, "MeshShape");
auto transform = AddComponent<Components::Transform>(shape);
auto meshShape = AddComponent<Components::MeshShape>(shape);
meshShape->ResourceName = "Models/Jeep/Chassi/ChassiCollision.obj";
CommitEntity(shape);
// auto box = AddComponent<Components::Box>(jeep, "Box");
// auto box = AddComponent<Components::Box>(jeep);
// box->Width = 1.487f;
// box->Height = 0.727f;
// box->Depth = 2.594f;
@@ -135,17 +113,17 @@ void GameWorld::Initialize()
{
auto chassis = CreateEntity(jeep);
auto transform = AddComponent<Components::Transform>(chassis, "Transform");
auto transform = AddComponent<Components::Transform>(chassis);
transform->Position = glm::vec3(0, 0, 0); // 0.6577f
auto model = AddComponent<Components::Model>(chassis, "Model");
auto model = AddComponent<Components::Model>(chassis);
model->ModelFile = "Models/Jeep/Chassi/chassi.obj";
}
{
auto lightentity = CreateEntity(jeep);
auto transform = AddComponent<Components::Transform>(lightentity, "Transform");
auto transform = AddComponent<Components::Transform>(lightentity);
transform->Position = glm::vec3(0, 15, 0);
auto light = AddComponent<Components::PointLight>(lightentity, "PointLight");
auto light = AddComponent<Components::PointLight>(lightentity);
light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
light->Specular = glm::vec3(1.f);
light->constantAttenuation = 0.3f;
@@ -160,12 +138,12 @@ void GameWorld::Initialize()
float suspensionStrength = 35.f;
{
auto wheel = CreateEntity(jeep);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(1.9f, 0.5546f - wheelOffset, -0.9242f);
transform->Scale = glm::vec3(1.0f);
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 0;
Wheel->Mass = 50;
@@ -179,13 +157,13 @@ void GameWorld::Initialize()
{
auto wheel = CreateEntity(jeep);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(-1.9f, 0.5546f - wheelOffset, -0.9242f);
transform->Scale = glm::vec3(1.0f);
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 0;
Wheel->Mass = 50;
@@ -199,11 +177,11 @@ void GameWorld::Initialize()
{
auto wheel = CreateEntity(jeep);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(0.2726f, 0.2805f - wheelOffset, 1.9307f);
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 1;
Wheel->Mass = 50;
@@ -217,12 +195,12 @@ void GameWorld::Initialize()
{
auto wheel = CreateEntity(jeep);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(-0.2726f, 0.2805f - wheelOffset, 1.9307f);
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 1;
Wheel->Mass = 50;
@@ -240,26 +218,26 @@ void GameWorld::Initialize()
{
auto tank = CreateEntity();
auto transform = AddComponent<Components::Transform>(tank, "Transform");
auto transform = AddComponent<Components::Transform>(tank);
transform->Position = glm::vec3(0, 5, 0);
//transform->Orientation = glm::angleAxis(0.f, glm::vec3(0, 1, 0));
auto physics = AddComponent<Components::Physics>(tank, "Physics");
auto physics = AddComponent<Components::Physics>(tank);
physics->Mass = 45000;
physics->Static = false;
auto vehicle = AddComponent<Components::Vehicle>(tank, "Vehicle");
auto vehicle = AddComponent<Components::Vehicle>(tank);
vehicle->MaxTorque = 5200.f;
vehicle->MaxSteeringAngle = 90.f;
AddComponent<Components::TankSteering>(tank, "TankSteering");
AddComponent<Components::Input>(tank, "Input");
AddComponent<Components::TankSteering>(tank);
AddComponent<Components::Input>(tank);
{
auto shape = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(shape, "Transform");
auto meshShape = AddComponent<Components::MeshShape>(shape, "MeshShape");
auto transform = AddComponent<Components::Transform>(shape);
auto meshShape = AddComponent<Components::MeshShape>(shape);
meshShape->ResourceName = "Models/Tank/Fix/ChassiCollision.obj";
CommitEntity(shape);
// auto box = AddComponent<Components::Box>(jeep, "Box");
// auto box = AddComponent<Components::Box>(jeep);
// box->Width = 1.487f;
// box->Height = 0.727f;
// box->Depth = 2.594f;
@@ -268,48 +246,48 @@ void GameWorld::Initialize()
{
auto chassis = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(chassis, "Transform");
auto transform = AddComponent<Components::Transform>(chassis);
transform->Position = glm::vec3(0, 0, 0);
auto model = AddComponent<Components::Model>(chassis, "Model");
auto model = AddComponent<Components::Model>(chassis);
model->ModelFile = "Models/Tank/Fix/Chassi.obj";
}
{
auto tower = CreateEntity(tank);
SetProperty(tower, "Name", "tower");
auto transform = AddComponent<Components::Transform>(tower, "Transform");
auto transform = AddComponent<Components::Transform>(tower);
transform->Position = glm::vec3(0.f, 1.2f, 1.8f);
auto model = AddComponent<Components::Model>(tower, "Model");
auto model = AddComponent<Components::Model>(tower);
model->ModelFile = "Models/Tank/Fix/Top.obj";
auto towerSteering = AddComponent<Components::TowerSteering>(tower, "TowerSteering");
auto towerSteering = AddComponent<Components::TowerSteering>(tower);
towerSteering->Axis = glm::vec3(0.f, 1.f, 0.f);
towerSteering->TurnSpeed = glm::pi<float>()/4.f;
{
auto barrel = CreateEntity(tower);
auto transform = AddComponent<Components::Transform>(barrel, "Transform");
auto transform = AddComponent<Components::Transform>(barrel);
transform->Position = glm::vec3(-0.018f, -0.2, -1.3f);
auto model = AddComponent<Components::Model>(barrel, "Model");
auto model = AddComponent<Components::Model>(barrel);
model->ModelFile = "Models/Tank/Fix/Barrel.obj";
auto barrelSteering = AddComponent<Components::BarrelSteering>(barrel, "BarrelSteering");
auto barrelSteering = AddComponent<Components::BarrelSteering>(barrel);
barrelSteering->Axis = glm::vec3(1.f, 0.f, 0.f);
barrelSteering->TurnSpeed = glm::pi<float>()/4.f;
barrelSteering->ShotSpeed = 70.f;
{
auto shot = CreateEntity(barrel);
auto transform = AddComponent<Components::Transform>(shot, "Transform");
auto transform = AddComponent<Components::Transform>(shot);
transform->Position = glm::vec3(0.35f, 0.f, -2.f);
transform->Orientation = glm::angleAxis(-glm::pi<float>()/2.f, glm::vec3(1, 0, 0));
transform->Scale = glm::vec3(3.f);
AddComponent(shot, "Template");
auto physics = AddComponent<Components::Physics>(shot, "Physics");
AddComponent<Components::Template>(shot);
auto physics = AddComponent<Components::Physics>(shot);
physics->Mass = 10.f;
physics->Static = false;
auto modelComponent = AddComponent<Components::Model>(shot, "Model");
auto modelComponent = AddComponent<Components::Model>(shot);
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
{
auto shape = CreateEntity(shot);
auto transform = AddComponent<Components::Transform>(shape, "Transform");
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto transform = AddComponent<Components::Transform>(shape);
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.5f;
boxShape->Height = 0.5f;
boxShape->Depth = 0.5f;
@@ -320,18 +298,32 @@ void GameWorld::Initialize()
}
CommitEntity(barrel);
}
{
auto camera = CreateEntity(tower);
auto transform = AddComponent<Components::Transform>(camera);
transform->Position.z = 30.f;
transform->Position.y = 5.f;
//transform->Orientation = glm::quat(glm::vec3(-glm::pi<float>() / 8.f, 0.f, 0.f));
transform->Orientation = glm::angleAxis(glm::pi<float>() / 100, glm::vec3(1, 0, 0));
auto cameraComp = AddComponent<Components::Camera>(camera);
cameraComp->FarClip = 2000.f;
AddComponent<Components::Input>(camera);
//auto freeSteering = AddComponent<Components::FreeSteering>(camera);
CommitEntity(camera);
}
}
{
auto lightentity = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(lightentity, "Transform");
transform->Position = glm::vec3(0, 15, 0);
auto light = AddComponent<Components::PointLight>(lightentity, "PointLight");
light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
light->Specular = glm::vec3(1.f);
light->constantAttenuation = 0.3f;
light->linearAttenuation = 0.003f;
light->quadraticAttenuation = 0.002f;
auto transform = AddComponent<Components::Transform>(lightentity);
transform->Position = glm::vec3(0, 0, 0);
auto light = AddComponent<Components::PointLight>(lightentity);
//light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
//light->Specular = glm::vec3(1.f);
/*light->ConstantAttenuation = 0.3f;
light->LinearAttenuation = 0.003f;
light->QuadraticAttenuation = 0.002f;*/
}
// auto wheelpair = CreateEntity(tank);
@@ -345,12 +337,12 @@ void GameWorld::Initialize()
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(1.68f, -0.83f - wheelOffset, -2.6f);
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 0;
Wheel->Mass = 2000;
@@ -363,9 +355,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -375,12 +367,12 @@ void GameWorld::Initialize()
}
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(1.68f, -0.83f - wheelOffset, -0.83f);
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 0;
Wheel->Mass = 2000;
@@ -393,9 +385,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -406,12 +398,12 @@ void GameWorld::Initialize()
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(-1.68f, -0.83f - wheelOffset, -2.6f);
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 0;
Wheel->Mass = 2000;
@@ -424,9 +416,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -436,12 +428,12 @@ void GameWorld::Initialize()
}
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(-1.68f, -0.83f - wheelOffset, -0.83f);
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 0;
Wheel->Mass = 2000;
@@ -454,9 +446,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -469,11 +461,11 @@ void GameWorld::Initialize()
//Back
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(1.68f, -0.83f - wheelOffset, 1.f);
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 1;
Wheel->Mass = 2000;
@@ -486,9 +478,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -498,11 +490,11 @@ void GameWorld::Initialize()
}
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(1.68f, -0.83f - wheelOffset, 2.95f);
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 1;
Wheel->Mass = 2000;
@@ -515,9 +507,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -525,12 +517,12 @@ void GameWorld::Initialize()
}
CommitEntity(wheel);
/*auto entity = CreateEntity(tank);
auto transformComponent = AddComponent<Components::Transform>(entity, "Transform");
auto entity = CreateEntity(tank);
auto transformComponent = AddComponent<Components::Transform>(entity);
transformComponent->Position = glm::vec3(2,-1.7,2.0);
transformComponent->Scale = glm::vec3(3,3,3);
transformComponent->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0));
auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity, "ParticleEmitter");
auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity);
emitterComponent->SpawnCount = 2;
emitterComponent->SpawnFrequency = 0.005;
emitterComponent->SpreadAngle = glm::pi<float>();
@@ -541,23 +533,23 @@ void GameWorld::Initialize()
CommitEntity(entity);
auto particleEntity = CreateEntity(entity);
auto TEMP = AddComponent<Components::Transform>(particleEntity, "Transform");
auto TEMP = AddComponent<Components::Transform>(particleEntity);
TEMP->Scale = glm::vec3(0);
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity, "Sprite");
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
emitterComponent->ParticleTemplate = particleEntity;
CommitEntity(particleEntity);*/
CommitEntity(particleEntity);
}
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(-1.68f, -0.83f - wheelOffset, 1.f);
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 1;
Wheel->Mass = 2000;
@@ -570,9 +562,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -582,11 +574,11 @@ void GameWorld::Initialize()
}
{
auto wheel = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
auto transform = AddComponent<Components::Transform>(wheel);
transform->Position = glm::vec3(-1.68f, -0.83f - wheelOffset, 2.95f);
auto model = AddComponent<Components::Model>(wheel, "Model");
auto model = AddComponent<Components::Model>(wheel);
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
auto Wheel = AddComponent<Components::Wheel>(wheel);
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
Wheel->AxleID = 1;
Wheel->Mass = 2000;
@@ -599,9 +591,9 @@ void GameWorld::Initialize()
Wheel->Width = 0.6f;
{
auto shape = CreateEntity(wheel);
auto shapetransform = AddComponent<Components::Transform>(shape, "Transform");
auto shapetransform = AddComponent<Components::Transform>(shape);
shapetransform->Position = glm::vec3(0.f, 0.32f, 0.f) + transform->Position;
auto boxShape = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto boxShape = AddComponent<Components::BoxShape>(shape);
boxShape->Width = 0.7f;
boxShape->Height = 0.34f;
boxShape->Depth = 0.7f;
@@ -609,45 +601,32 @@ void GameWorld::Initialize()
}
CommitEntity(wheel);
//auto entity = CreateEntity(tank);
//auto transformComponent = AddComponent<Components::Transform>(entity, "Transform");
//transformComponent->Position = glm::vec3(-2,-1.7,2.0);
//transformComponent->Scale = glm::vec3(3,3,3);
//transformComponent->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0));
//auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity, "ParticleEmitter");
//emitterComponent->SpawnCount = 2;
//emitterComponent->SpawnFrequency = 0.005;
//emitterComponent->SpreadAngle = glm::pi<float>();
//emitterComponent->UseGoalVelocity = false;
//emitterComponent->LifeTime = 0.5;
////emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
//emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
//CommitEntity(entity);
auto entity = CreateEntity(tank);
auto transformComponent = AddComponent<Components::Transform>(entity);
transformComponent->Position = glm::vec3(-2,-1.7,2.0);
transformComponent->Scale = glm::vec3(3,3,3);
transformComponent->Orientation = glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0));
auto emitterComponent = AddComponent<Components::ParticleEmitter>(entity);
emitterComponent->SpawnCount = 2;
emitterComponent->SpawnFrequency = 0.005;
emitterComponent->SpreadAngle = glm::pi<float>();
emitterComponent->UseGoalVelocity = false;
emitterComponent->LifeTime = 0.5;
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
CommitEntity(entity);
//auto particleEntity = CreateEntity(entity);
//auto TEMP = AddComponent<Components::Transform>(particleEntity, "Transform");
//TEMP->Scale = glm::vec3(0);
//auto spriteComponent = AddComponent<Components::Sprite>(particleEntity, "Sprite");
//spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
//emitterComponent->ParticleTemplate = particleEntity;
auto particleEntity = CreateEntity(entity);
auto TEMP = AddComponent<Components::Transform>(particleEntity);
TEMP->Scale = glm::vec3(0);
auto spriteComponent = AddComponent<Components::Sprite>(particleEntity);
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
emitterComponent->ParticleTemplate = particleEntity;
//CommitEntity(particleEntity);
CommitEntity(particleEntity);
}
CommitEntity(tank);
{
auto camera = CreateEntity(tank);
auto transform = AddComponent<Components::Transform>(camera, "Transform");
transform->Position.z = 20.f;
transform->Position.y = 7.f;
//transform->Orientation = glm::quat(glm::vec3(-glm::pi<float>() / 8.f, 0.f, 0.f));
transform->Orientation = glm::angleAxis(glm::pi<float>() / 100, glm::vec3(1,0,0));
auto cameraComp = AddComponent<Components::Camera>(camera, "Camera");
cameraComp->FarClip = 2000.f;
AddComponent(camera, "Input");
auto freeSteering = AddComponent<Components::FreeSteering>(camera, "FreeSteering");
CommitEntity(camera);
}
}
@@ -656,7 +635,7 @@ void GameWorld::Initialize()
for(int i = 0; i < 10; i++)
{
auto entity = CreateEntity();
auto transform = AddComponent<Components::Transform>(entity, "Transform");
auto transform = AddComponent<Components::Transform>(entity);
transform->Position = glm::vec3(30 + i*0.1f, 0 + i*0.1f, 10 + i*0.1f);
transform->Scale = glm::vec3(0);
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
@@ -664,13 +643,13 @@ void GameWorld::Initialize()
std::stringstream ss;
ss << "Models/Placeholders/ShatterTest/" << i+1 << ".obj";
auto model = AddComponent<Components::Model>(entity, "Model");
auto model = AddComponent<Components::Model>(entity);
model->ModelFile = ss.str();
auto physics = AddComponent<Components::Physics>(entity, "Physics");
auto physics = AddComponent<Components::Physics>(entity);
physics->Mass = 100;
physics->Static = true;
auto meshShape = AddComponent<Components::MeshShape>(entity, "MeshShape");
auto meshShape = AddComponent<Components::MeshShape>(entity);
meshShape->ResourceName = ss.str();
CommitEntity(entity);
@@ -683,22 +662,22 @@ void GameWorld::Initialize()
for (int x = -5; x < 5; x++)
{
auto brick = CreateEntity();
auto transform = AddComponent<Components::Transform>(brick, "Transform");
auto transform = AddComponent<Components::Transform>(brick);
transform->Position = glm::vec3(x + 0.01f, y * 0.3f + 0.01f, -20);
transform->Position.x += (y % 2)*0.5f;
transform->Scale = glm::vec3(1, 0.3f, 0.4f);
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
auto model = AddComponent<Components::Model>(brick, "Model");
auto model = AddComponent<Components::Model>(brick);
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj";
auto physics = AddComponent<Components::Physics>(brick, "Physics");
auto physics = AddComponent<Components::Physics>(brick);
physics->Mass = 3;
auto shape = CreateEntity(brick);
auto transformshape = AddComponent<Components::Transform>(shape, "Transform");
auto box = AddComponent<Components::BoxShape>(shape, "BoxShape");
auto transformshape = AddComponent<Components::Transform>(shape);
auto box = AddComponent<Components::BoxShape>(shape);
box->Width = 0.5f;
box->Height = 0.15f;
box->Depth = 0.3f;
@@ -712,16 +691,16 @@ void GameWorld::Initialize()
for (int y = 0; y < 5; y++)
{
auto cube = CreateEntity();
auto transform = AddComponent<Components::Transform>(cube, "Transform");
auto transform = AddComponent<Components::Transform>(cube);
transform->Position = glm::vec3(3 * x + 0.1f + -20.f, 3 * y + 0.1f + 1.f, 0);
transform->Scale = glm::vec3(3);
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
auto model = AddComponent<Components::Model>(cube, "Model");
auto model = AddComponent<Components::Model>(cube);
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj";
auto physics = AddComponent<Components::Physics>(cube, "Physics");
auto physics = AddComponent<Components::Physics>(cube);
physics->Mass = 100;
auto box = AddComponent<Components::BoxShape>(cube, "BoxShape");
auto box = AddComponent<Components::BoxShape>(cube);
box->Width = 1.5f;
box->Height = 1.5f;
box->Depth = 1.5f;
@@ -733,7 +712,7 @@ void GameWorld::Initialize()
/*{
auto entity = CreateEntity();
AddComponent(entity, "Transform");
auto emitter = AddComponent<Components::SoundEmitter>(entity, "SoundEmitter");
auto emitter = AddComponent<Components::SoundEmitter>(entity);
emitter->Path = "Sounds/korvring.wav";
emitter->Loop = true;
GetSystem<Systems::SoundSystem>("SoundSystem")->PlaySound(emitter);
@@ -749,40 +728,40 @@ void GameWorld::Update(double dt)
void GameWorld::RegisterComponents()
{
m_ComponentFactory.Register("Transform", []() { return new Components::Transform(); });
m_ComponentFactory.Register("Template", []() { return new Components::Template(); });
m_ComponentFactory.Register<Components::Transform>([]() { return new Components::Transform(); });
m_ComponentFactory.Register<Components::Template>([]() { return new Components::Template(); });
}
void GameWorld::RegisterSystems()
{
m_SystemFactory.Register("TransformSystem", [this]() { return new Systems::TransformSystem(this, m_EventBroker); });
//m_SystemFactory.Register("LevelGenerationSystem", [this]() { return new Systems::LevelGenerationSystem(this); });
m_SystemFactory.Register("InputSystem", [this]() { return new Systems::InputSystem(this, m_EventBroker); });
m_SystemFactory.Register("DebugSystem", [this]() { return new Systems::DebugSystem(this, m_EventBroker); });
//m_SystemFactory.Register("CollisionSystem", [this]() { return new Systems::CollisionSystem(this); });
m_SystemFactory.Register("ParticleSystem", [this]() { return new Systems::ParticleSystem(this, m_EventBroker); });
//m_SystemFactory.Register("PlayerSystem", [this]() { return new Systems::PlayerSystem(this); });
m_SystemFactory.Register("FreeSteeringSystem", [this]() { return new Systems::FreeSteeringSystem(this, m_EventBroker); });
m_SystemFactory.Register("TankSteeringSystem", [this]() { return new Systems::TankSteeringSystem(this, m_EventBroker); });
m_SystemFactory.Register("SoundSystem", [this]() { return new Systems::SoundSystem(this, m_EventBroker); });
m_SystemFactory.Register("PhysicsSystem", [this]() { return new Systems::PhysicsSystem(this, m_EventBroker); });
m_SystemFactory.Register("RenderSystem", [this]() { return new Systems::RenderSystem(this, m_EventBroker, m_Renderer); });
m_SystemFactory.Register<Systems::TransformSystem>([this]() { return new Systems::TransformSystem(this, m_EventBroker); });
//m_SystemFactory.Register<Systems::LevelGenerationSystem>([this]() { return new Systems::LevelGenerationSystem(this); });
m_SystemFactory.Register<Systems::InputSystem>([this]() { return new Systems::InputSystem(this, m_EventBroker); });
m_SystemFactory.Register<Systems::DebugSystem>([this]() { return new Systems::DebugSystem(this, m_EventBroker); });
//m_SystemFactory.Register<Systems::CollisionSystem>([this]() { return new Systems::CollisionSystem(this); });
m_SystemFactory.Register<Systems::ParticleSystem>([this]() { return new Systems::ParticleSystem(this, m_EventBroker); });
//m_SystemFactory.Register<Systems::PlayerSystem>([this]() { return new Systems::PlayerSystem(this); });
m_SystemFactory.Register<Systems::FreeSteeringSystem>([this]() { return new Systems::FreeSteeringSystem(this, m_EventBroker); });
m_SystemFactory.Register<Systems::TankSteeringSystem>([this]() { return new Systems::TankSteeringSystem(this, m_EventBroker); });
m_SystemFactory.Register<Systems::SoundSystem>([this]() { return new Systems::SoundSystem(this, m_EventBroker); });
m_SystemFactory.Register<Systems::PhysicsSystem>([this]() { return new Systems::PhysicsSystem(this, m_EventBroker); });
m_SystemFactory.Register<Systems::RenderSystem>([this]() { return new Systems::RenderSystem(this, m_EventBroker, m_Renderer); });
}
void GameWorld::AddSystems()
{
AddSystem("TransformSystem");
//AddSystem("LevelGenerationSystem");
AddSystem("InputSystem");
AddSystem("DebugSystem");
//AddSystem("CollisionSystem");
AddSystem("ParticleSystem");
//AddSystem("PlayerSystem");
AddSystem("FreeSteeringSystem");
AddSystem("TankSteeringSystem");
AddSystem("SoundSystem");
AddSystem("PhysicsSystem");
AddSystem("RenderSystem");
AddSystem<Systems::TransformSystem>();
//AddSystem<Systems::LevelGenerationSystem>();
AddSystem<Systems::InputSystem>();
AddSystem<Systems::DebugSystem>();
//AddSystem<Systems::CollisionSystem>();
AddSystem<Systems::ParticleSystem>();
//AddSystem<Systems::PlayerSystem>();
AddSystem<Systems::FreeSteeringSystem>();
AddSystem<Systems::TankSteeringSystem>();
AddSystem<Systems::SoundSystem>();
AddSystem<Systems::PhysicsSystem>();
AddSystem<Systems::RenderSystem>();
}
void GameWorld::BindKey(int keyCode, std::string command, float value)
@@ -794,11 +773,12 @@ void GameWorld::BindKey(int keyCode, std::string command, float value)
m_EventBroker->Publish(e);
}
void GameWorld::BindMouseButton(int button, std::string command)
void GameWorld::BindMouseButton(int button, std::string command, float value)
{
Events::BindMouseButton e;
e.Button = button;
e.Command = command;
e.Value = value;
m_EventBroker->Publish(e);
}