From 6ccb196b3baf80d823df53fb6c59bb0226418dac Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Thu, 24 Apr 2014 01:20:13 +0200 Subject: [PATCH] Jeep physics --- src/Components/Wheel.h | 1 + src/GameWorld.cpp | 253 ++++++++++++++++++++++------------ src/GameWorld.cpp.orig | 172 +++++++++++++++-------- src/Shaders/Fragment.glsl | 4 +- src/Systems/PhysicsSystem.cpp | 4 +- 5 files changed, 287 insertions(+), 147 deletions(-) diff --git a/src/Components/Wheel.h b/src/Components/Wheel.h index 212aad5..5c005c7 100644 --- a/src/Components/Wheel.h +++ b/src/Components/Wheel.h @@ -33,6 +33,7 @@ struct Wheel : Component private: int ID; + glm::quat OriginalOrientation; }; } diff --git a/src/GameWorld.cpp b/src/GameWorld.cpp index f40ac63..06b965f 100755 --- a/src/GameWorld.cpp +++ b/src/GameWorld.cpp @@ -41,100 +41,183 @@ void GameWorld::Initialize() } - for (int i = 0; i < 1; i++) { - auto car = CreateEntity(); - auto transform = AddComponent(car, "Transform"); - transform->Position = glm::vec3(0, (i+1)*5, 0); - transform->Scale = glm::vec3(3, 1, 5); - transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); - auto model = AddComponent(car, "Model"); - model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; - auto physics = AddComponent(car, "Physics"); + auto jeep = CreateEntity(); + auto transform = AddComponent(jeep, "Transform"); + transform->Position = glm::vec3(0, 2, 0); + + auto physics = AddComponent(jeep, "Physics"); physics->Mass = 1200; - auto box = AddComponent(car, "Box"); - box->Width = 1.5f; - box->Height = 0.5f; - box->Depth = 2.5f; - auto vehicle = AddComponent(car, "Vehicle"); + auto box = AddComponent(jeep, "Box"); + box->Width = 1.487f; + box->Height = 0.727f; + box->Depth = 2.594f; + auto vehicle = AddComponent(jeep, "Vehicle"); vehicle->TopSpeed = 500.f; vehicle->MaxTorque = 1000.f; - AddComponent(car, "Input"); - + AddComponent(jeep, "Input"); + { - // Front Right Wheel - auto ent = CreateEntity(car); - auto transform = AddComponent(ent, "Transform"); - transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); - transform->Position = glm::vec3(1.1f, -1.5f, -1.3f); - auto Wheel = AddComponent(ent, "Wheel"); - Wheel->Hardpoint = glm::vec3(1.1f, 0.f, -1.3f);// HACK: make into component - Wheel->AxleID = 0; - Wheel->Mass = 10; - Wheel->Radius = 0.5f; - Wheel->Steering = true; - Wheel->SuspensionStrength = 20.f; - auto model = AddComponent(ent, "Model"); - model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; - CommitEntity(ent); - } - { - // Front Left Wheel - auto ent = CreateEntity(car); - auto transform = AddComponent(ent, "Transform"); - transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); - transform->Position = glm::vec3(-1.1f, -1.5f, -1.3f); - auto Wheel = AddComponent(ent, "Wheel"); - Wheel->Hardpoint = glm::vec3(-1.1f, 0.f, -1.3f); - Wheel->AxleID = 0; - Wheel->Mass = 10; - Wheel->Radius = 0.5f; - Wheel->Steering = true; - Wheel->SuspensionStrength = 20.f; - auto model = AddComponent(ent, "Model"); - model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; - CommitEntity(ent); - } - { - // Back Right Wheel - auto ent = CreateEntity(car); - auto transform = AddComponent(ent, "Transform"); - transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); - transform->Position = glm::vec3(1.1f, -1.5f, 1.3f); - auto Wheel = AddComponent(ent, "Wheel"); - Wheel->Hardpoint = glm::vec3(1.1f, 0.f, 1.3f); - Wheel->AxleID = 1; - Wheel->Mass = 10; - Wheel->Radius = 0.5f; - Wheel->Steering = false; - Wheel->ConnectedToHandbrake = true; - Wheel->SuspensionStrength = 20.f; - auto model = AddComponent(ent, "Model"); - model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; - CommitEntity(ent); - } - { - // Back Left Wheel - auto ent = CreateEntity(car); - auto transform = AddComponent(ent, "Transform"); - transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); - transform->Position = glm::vec3(-1.1f, -1.5f, 1.3f); - auto Wheel = AddComponent(ent, "Wheel"); - Wheel->Hardpoint = glm::vec3(-1.1f, 0.f, 1.3f); - Wheel->AxleID = 1; - Wheel->Mass = 10; - Wheel->Radius = 0.5f; - Wheel->Steering = false; - Wheel->ConnectedToHandbrake = true; - Wheel->SuspensionStrength = 20.f; - auto model = AddComponent(ent, "Model"); - model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; - CommitEntity(ent); + auto chassis = CreateEntity(jeep); + auto transform = AddComponent(chassis, "Transform"); + transform->Position = glm::vec3(0, -0.6577f, 0); + auto model = AddComponent(chassis, "Model"); + model->ModelFile = "Models/JeepV2/Chassi/chassi.OBJ"; } - CommitEntity(car); + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(1.4f, 0.5546f - 0.6577f - 0.2, -0.9242f); + transform->Scale = glm::vec3(1.0f); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj"; + auto Wheel = AddComponent(wheel, "Wheel"); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f); + Wheel->AxleID = 0; + Wheel->Mass = 10; + Wheel->Radius = 0.837f; + Wheel->Steering = true; + Wheel->SuspensionStrength = 50.f; + Wheel->Friction = 4.0f; + Wheel->ConnectedToHandbrake = true; + CommitEntity(wheel); + } + + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(-1.4f, 0.5546f - 0.6577f - 0.2, -0.9242f); + transform->Scale = glm::vec3(1.0f); + transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj"; + auto Wheel = AddComponent(wheel, "Wheel"); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f); + Wheel->AxleID = 0; + Wheel->Mass = 10; + Wheel->Radius = 0.837f; + Wheel->Steering = true; + Wheel->SuspensionStrength = 50.f; + Wheel->Friction = 4.0f; + Wheel->ConnectedToHandbrake = true; + CommitEntity(wheel); + } + + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(0.2726f, 0.2805f - 0.6577f, 1.9307f); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj"; + auto Wheel = AddComponent(wheel, "Wheel"); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f); + Wheel->AxleID = 1; + Wheel->Mass = 10; + Wheel->Radius = 0.737f; + Wheel->Steering = false; + Wheel->SuspensionStrength = 50.f; + Wheel->Friction = 4.0f; + CommitEntity(wheel); + } + + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(-0.2726f, 0.2805f - 0.6577f, 1.9307f); + transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj"; + auto Wheel = AddComponent(wheel, "Wheel"); + Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f); + Wheel->AxleID = 1; + Wheel->Mass = 10; + Wheel->Radius = 0.737f; + Wheel->Steering = false; + Wheel->SuspensionStrength = 50.f; + Wheel->Friction = 4.0f; + CommitEntity(wheel); + } + CommitEntity(jeep); } +/* + + { + // Front Right Wheel + auto ent = CreateEntity(car); + auto transform = AddComponent(ent, "Transform"); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(1.1f, -1.5f, -1.3f); + auto Wheel = AddComponent(ent, "Wheel"); + Wheel->Hardpoint = glm::vec3(1.1f, 0.f, -1.3f);// HACK: make into component + Wheel->AxleID = 0; + Wheel->Mass = 10; + Wheel->Radius = 0.5f; + Wheel->Steering = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); + } + { + // Front Left Wheel + auto ent = CreateEntity(car); + auto transform = AddComponent(ent, "Transform"); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(-1.1f, -1.5f, -1.3f); + auto Wheel = AddComponent(ent, "Wheel"); + Wheel->Hardpoint = glm::vec3(-1.1f, 0.f, -1.3f); + Wheel->AxleID = 0; + Wheel->Mass = 10; + Wheel->Radius = 0.5f; + Wheel->Steering = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); + } + { + // Back Right Wheel + auto ent = CreateEntity(car); + auto transform = AddComponent(ent, "Transform"); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(1.1f, -1.5f, 1.3f); + auto Wheel = AddComponent(ent, "Wheel"); + Wheel->Hardpoint = glm::vec3(1.1f, 0.f, 1.3f); + Wheel->AxleID = 1; + Wheel->Mass = 10; + Wheel->Radius = 0.5f; + Wheel->Steering = false; + Wheel->ConnectedToHandbrake = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); + } + { + // Back Left Wheel + auto ent = CreateEntity(car); + auto transform = AddComponent(ent, "Transform"); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(-1.1f, -1.5f, 1.3f); + auto Wheel = AddComponent(ent, "Wheel"); + Wheel->Hardpoint = glm::vec3(-1.1f, 0.f, 1.3f); + Wheel->AxleID = 1; + Wheel->Mass = 10; + Wheel->Radius = 0.5f; + Wheel->Steering = false; + Wheel->ConnectedToHandbrake = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); + } + + CommitEntity(car); + } +*/ + for(int i = 0; i < 10; i++) diff --git a/src/GameWorld.cpp.orig b/src/GameWorld.cpp.orig index 73aac8b..34dc849 100644 --- a/src/GameWorld.cpp.orig +++ b/src/GameWorld.cpp.orig @@ -24,29 +24,88 @@ void GameWorld::Initialize() auto ground = CreateEntity(); auto transform = AddComponent(ground, "Transform"); transform->Position = glm::vec3(0, -5, 0); - transform->Scale = glm::vec3(1000.0f, 10.0f, 1000.0f); + 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(ground, "Model"); model->ModelFile = "Models/Placeholders/PhysicsTest/Cube.obj"; auto box = AddComponent(ground, "Box"); - box->Width = 500; + box->Width = 200; box->Height = 5; - box->Depth = 500; + box->Depth = 200; auto physics = AddComponent(ground, "Physics"); physics->Mass = 10; -<<<<<<< HEAD physics->Static = true; -======= + CommitEntity(ground); ->>>>>>> 84d6911... Barebones entity component commit events } +<<<<<<< HEAD +======= + { + auto jeep = CreateEntity(); + auto transform = AddComponent(jeep, "Transform"); + transform->Position = glm::vec3(0, 1, 0); + auto model = AddComponent(jeep, "Model"); + model->ModelFile = "Models/JeepV2/Chassi/chassi.OBJ"; + CommitEntity(jeep); + + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(1.4f, 0.5546f, -0.9242f); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj"; + CommitEntity(wheel); + } + + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(-1.4f, 0.5546f, -0.9242f); + transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj"; + CommitEntity(wheel); + } + + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(0.2726f, 0.2805f, 1.9307f); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj"; + CommitEntity(wheel); + } + + { + auto wheel = CreateEntity(jeep); + auto transform = AddComponent(wheel, "Transform"); + transform->Position = glm::vec3(-0.2726f, 0.2805f, 1.9307f); + transform->Orientation = glm::angleAxis(glm::pi(), glm::vec3(0, 0, 1)); + auto model = AddComponent(wheel, "Model"); + model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj"; + CommitEntity(wheel); + } + } + + { + auto TankTest = CreateEntity(); + auto transform = AddComponent(TankTest, "Transform"); + transform->Position = glm::vec3(1.5f, 0.7f, 5.f); + + auto model = AddComponent(TankTest, "Model"); + model->ModelFile = "Models/Placeholders/tank/Chassi.obj"; + CommitEntity(TankTest); + } +>>>>>>> 3412fa4... Jeep entity setup. + + for (int i = 0; i < 1; i++) { auto car = CreateEntity(); auto transform = AddComponent(car, "Transform"); - transform->Position = glm::vec3(0, 5, 0); + transform->Position = glm::vec3(0, (i+1)*5, 0); transform->Scale = glm::vec3(3, 1, 5); transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); auto model = AddComponent(car, "Model"); @@ -58,107 +117,103 @@ void GameWorld::Initialize() box->Height = 0.5f; box->Depth = 2.5f; auto vehicle = AddComponent(car, "Vehicle"); + vehicle->TopSpeed = 500.f; + vehicle->MaxTorque = 1000.f; AddComponent(car, "Input"); { // Front Right Wheel auto ent = CreateEntity(car); auto transform = AddComponent(ent, "Transform"); - transform->Position = glm::vec3(1.1f, -0.5f, -1.3f); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(1.1f, -1.5f, -1.3f); auto Wheel = AddComponent(ent, "Wheel"); Wheel->Hardpoint = glm::vec3(1.1f, 0.f, -1.3f);// HACK: make into component Wheel->AxleID = 0; Wheel->Mass = 10; - Wheel->Radius = 0.6f; + Wheel->Radius = 0.5f; Wheel->Steering = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); } { // Front Left Wheel auto ent = CreateEntity(car); auto transform = AddComponent(ent, "Transform"); - transform->Position = glm::vec3(-1.1f, -0.5f, -1.3f); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(-1.1f, -1.5f, -1.3f); auto Wheel = AddComponent(ent, "Wheel"); Wheel->Hardpoint = glm::vec3(-1.1f, 0.f, -1.3f); Wheel->AxleID = 0; Wheel->Mass = 10; - Wheel->Radius = 0.6f; + Wheel->Radius = 0.5f; Wheel->Steering = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); } { // Back Right Wheel auto ent = CreateEntity(car); auto transform = AddComponent(ent, "Transform"); - transform->Position = glm::vec3(1.1f, -0.5f, 1.3f); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(1.1f, -1.5f, 1.3f); auto Wheel = AddComponent(ent, "Wheel"); Wheel->Hardpoint = glm::vec3(1.1f, 0.f, 1.3f); Wheel->AxleID = 1; Wheel->Mass = 10; - Wheel->Radius = 0.6f; + Wheel->Radius = 0.5f; Wheel->Steering = false; + Wheel->ConnectedToHandbrake = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); } { // Back Left Wheel auto ent = CreateEntity(car); auto transform = AddComponent(ent, "Transform"); - transform->Position = glm::vec3(-1.1f, -0.5f, 1.3f); + transform->Scale = glm::vec3(1)/glm::vec3(3, 1, 5); + transform->Position = glm::vec3(-1.1f, -1.5f, 1.3f); auto Wheel = AddComponent(ent, "Wheel"); Wheel->Hardpoint = glm::vec3(-1.1f, 0.f, 1.3f); Wheel->AxleID = 1; Wheel->Mass = 10; - Wheel->Radius = 0.6f; + Wheel->Radius = 0.5f; Wheel->Steering = false; + Wheel->ConnectedToHandbrake = true; + Wheel->SuspensionStrength = 20.f; + auto model = AddComponent(ent, "Model"); + model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; + CommitEntity(ent); } -<<<<<<< HEAD + CommitEntity(car); } -======= - auto model = AddComponent(TankTest, "Model"); - model->ModelFile = "Models/Placeholders/tank/Chassi.obj"; - CommitEntity(TankTest); - } - for(int i = 0; i < 83; i++) + + for(int i = 0; i < 10; i++) { - auto light = CreateEntity(); - auto transform = AddComponent(light, "Transform"); - transform->Position = glm::vec3((float)(2*i)*glm::sin((float)i), 3, (float)(2*i)*glm::cos((float)i)); - - auto pointLight = AddComponent(light, "PointLight"); - pointLight->Specular = glm::vec3(0.1f, 0.1f, 0.1f); - pointLight->Diffuse = glm::vec3(0.05f, 0.36f, 1.f); - pointLight->constantAttenuation = 0.03f; - pointLight->linearAttenuation = 0.009f; - pointLight->quadraticAttenuation = 0.07f; - pointLight->spotExponent = 0.0f; - - auto model = AddComponent(light, "Model"); - model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj"; - CommitEntity(light); - } ->>>>>>> 84d6911... Barebones entity component commit events - - - for(int i = 0; i < 50; i++) - { - auto ball = CreateEntity(); - auto transform = AddComponent(ball, "Transform"); - transform->Position = glm::vec3(243, 10 + i*10, 0); - transform->Scale = glm::vec3(10); + auto cube = CreateEntity(); + auto transform = AddComponent(cube, "Transform"); + transform->Position = glm::vec3(20, 10 + i*2, 0); + transform->Scale = glm::vec3(1); transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)); - auto model = AddComponent(ball, "Model"); + auto model = AddComponent(cube, "Model"); model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj"; - auto physics = AddComponent(ball, "Physics"); -<<<<<<< HEAD + + auto physics = AddComponent(cube, "Physics"); physics->Mass = 100; - auto box = AddComponent(ball, "Box"); - box->Width = 5.f; - box->Height = 5.f; - box->Depth = 5.f; -======= - physics->Mass = 1; - CommitEntity(ball); ->>>>>>> 84d6911... Barebones entity component commit events + auto box = AddComponent(cube, "Box"); + box->Width = 0.5f; + box->Height = 0.5f; + box->Depth = 0.5f; + CommitEntity(cube); } { @@ -168,6 +223,7 @@ void GameWorld::Initialize() emitter->Path = "Sounds/korvring.wav"; emitter->Loop = true; GetSystem("SoundSystem")->PlaySound(emitter); + CommitEntity(entity); } } diff --git a/src/Shaders/Fragment.glsl b/src/Shaders/Fragment.glsl index 11a43ab..1909e84 100755 --- a/src/Shaders/Fragment.glsl +++ b/src/Shaders/Fragment.glsl @@ -52,7 +52,7 @@ void main() //float bias = 0.001 * tan(acos(cosTheta)); // cosTheta is dot( n,l ), clamped between 0 and 1 //bias = clamp(bias, 0.0, 0.01); float visibility = 1.0; - if (Input.ShadowCoord.x >= 0.0 && Input.ShadowCoord.x <= 1.0 && Input.ShadowCoord.y >= 0.0 && Input.ShadowCoord.y <= 1.0) + /*if (Input.ShadowCoord.x >= 0.0 && Input.ShadowCoord.x <= 1.0 && Input.ShadowCoord.y >= 0.0 && Input.ShadowCoord.y <= 1.0) { float bias = 0.00005; vec4 shadowMapValue = texture(shadowMap, Input.ShadowCoord.xy); @@ -60,7 +60,7 @@ void main() { visibility = 0.3; } - } + }*/ vec3 totalLighting = La * Ka * visibility; diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index 837ed5a..9fc476d 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -123,7 +123,7 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p hkQuaternion steeringOrientation = m_Vehicles[car]->m_wheelsInfo[wheelComponent->ID].m_steeringOrientationChassisSpace; hkReal spinAngle = -m_Vehicles[car]->m_wheelsInfo[wheelComponent->ID].m_spinAngle; glm::quat orientation = glm::quat(steeringOrientation(3), steeringOrientation(0), steeringOrientation(1), steeringOrientation(2)) * glm::angleAxis(spinAngle, glm::vec3(1, 0, 0)); - transformComponent->Orientation = orientation; + transformComponent->Orientation = orientation * wheelComponent->OriginalOrientation; } } else @@ -164,6 +164,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity ) if (wheelComponent) { wheelComponent->ID = m_Wheels.size(); + wheelComponent->OriginalOrientation = transformComponent->Orientation; m_Wheels.push_back(entity); } @@ -179,7 +180,6 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity ) hkpRigidBodyCinfo rigidBodyInfo; hkMassProperties massProperties; - if (sphereComponent) { shape = new hkpSphereShape(sphereComponent->Radius);