Vehicle tuning
This commit is contained in:
@@ -19,6 +19,7 @@ struct Vehicle : Component
|
|||||||
float MaxRPM;
|
float MaxRPM;
|
||||||
// Degrees
|
// Degrees
|
||||||
float MaxSteeringAngle;
|
float MaxSteeringAngle;
|
||||||
|
//TopSpeed not working fully yet
|
||||||
float TopSpeed;
|
float TopSpeed;
|
||||||
float MaxSpeedFullSteeringAngle;
|
float MaxSpeedFullSteeringAngle;
|
||||||
};
|
};
|
||||||
|
|||||||
+31
-27
@@ -20,10 +20,11 @@ void GameWorld::Initialize()
|
|||||||
//transform->Scale = glm::vec3(400.0f, 10.0f, 400.0f);
|
//transform->Scale = glm::vec3(400.0f, 10.0f, 400.0f);
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.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");
|
||||||
model->ModelFile = "Models/Placeholders/Terrain/Terrain.obj";
|
model->ModelFile = "Models/TestScene/testScene.obj";
|
||||||
|
//model->ModelFile = "Models/Placeholders/Terrain/Terrain.obj";
|
||||||
auto meshShape = AddComponent<Components::MeshShape>(ground, "MeshShape");
|
auto meshShape = AddComponent<Components::MeshShape>(ground, "MeshShape");
|
||||||
meshShape->ResourceName = "Models/Placeholders/Terrain/Terrain.obj";
|
//meshShape->ResourceName = "Models/Placeholders/Terrain/Terrain.obj";
|
||||||
|
meshShape->ResourceName = "Models/TestScene/testScene.obj";
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(ground, "Physics");
|
auto physics = AddComponent<Components::Physics>(ground, "Physics");
|
||||||
physics->Mass = 10;
|
physics->Mass = 10;
|
||||||
@@ -86,24 +87,26 @@ void GameWorld::Initialize()
|
|||||||
light->quadraticAttenuation = 0.002f;
|
light->quadraticAttenuation = 0.002f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float wheelOffset = -0.2f;
|
|
||||||
float hardPointOffset = 0.0f;
|
|
||||||
|
|
||||||
|
//Create wheels
|
||||||
|
float wheelOffset = 0.4f;
|
||||||
|
float springLength = 0.3f;
|
||||||
|
float suspensionStrength = 20.f;
|
||||||
{
|
{
|
||||||
auto wheel = CreateEntity(jeep);
|
auto wheel = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
transform->Position = glm::vec3(1.9f, 0.5546f - 0.2 + wheelOffset, -0.9242f);
|
transform->Position = glm::vec3(1.9f, 0.5546f - wheelOffset, -0.9242f);
|
||||||
transform->Scale = glm::vec3(1.0f);
|
transform->Scale = glm::vec3(1.0f);
|
||||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||||
model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj";
|
model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj";
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f - hardPointOffset, 0.f);
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
Wheel->AxleID = 0;
|
Wheel->AxleID = 0;
|
||||||
Wheel->Mass = 50;
|
Wheel->Mass = 50;
|
||||||
Wheel->Radius = 0.837f;
|
Wheel->Radius = 0.837f;
|
||||||
Wheel->Steering = true;
|
Wheel->Steering = true;
|
||||||
Wheel->SuspensionStrength = 50.f;
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
Wheel->Friction = 3.5f;
|
Wheel->Friction = 4.f;
|
||||||
Wheel->ConnectedToHandbrake = true;
|
Wheel->ConnectedToHandbrake = true;
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
}
|
}
|
||||||
@@ -111,19 +114,19 @@ void GameWorld::Initialize()
|
|||||||
{
|
{
|
||||||
auto wheel = CreateEntity(jeep);
|
auto wheel = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
transform->Position = glm::vec3(-1.9f, 0.5546f - 0.2 + wheelOffset, -0.9242f);
|
transform->Position = glm::vec3(-1.9f, 0.5546f - wheelOffset, -0.9242f);
|
||||||
transform->Scale = glm::vec3(1.0f);
|
transform->Scale = glm::vec3(1.0f);
|
||||||
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
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");
|
||||||
model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj";
|
model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj";
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f - hardPointOffset, 0.f);
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
Wheel->AxleID = 0;
|
Wheel->AxleID = 0;
|
||||||
Wheel->Mass = 50;
|
Wheel->Mass = 50;
|
||||||
Wheel->Radius = 0.837f;
|
Wheel->Radius = 0.837f;
|
||||||
Wheel->Steering = true;
|
Wheel->Steering = true;
|
||||||
Wheel->SuspensionStrength = 50.f;
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
Wheel->Friction = 3.5f;
|
Wheel->Friction = 4.f;
|
||||||
Wheel->ConnectedToHandbrake = true;
|
Wheel->ConnectedToHandbrake = true;
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
}
|
}
|
||||||
@@ -131,17 +134,17 @@ void GameWorld::Initialize()
|
|||||||
{
|
{
|
||||||
auto wheel = CreateEntity(jeep);
|
auto wheel = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
transform->Position = glm::vec3(0.2726f, 0.2805f + wheelOffset, 1.9307f);
|
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");
|
||||||
model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj";
|
model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj";
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f - hardPointOffset, 0.f);
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
Wheel->AxleID = 1;
|
Wheel->AxleID = 1;
|
||||||
Wheel->Mass = 50;
|
Wheel->Mass = 50;
|
||||||
Wheel->Radius = 0.737f;
|
Wheel->Radius = 0.737f;
|
||||||
Wheel->Steering = false;
|
Wheel->Steering = false;
|
||||||
Wheel->SuspensionStrength = 40.f;
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
Wheel->Friction = 3.5f;
|
Wheel->Friction = 4.f;
|
||||||
Wheel->ConnectedToHandbrake = true;
|
Wheel->ConnectedToHandbrake = true;
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
}
|
}
|
||||||
@@ -149,18 +152,18 @@ void GameWorld::Initialize()
|
|||||||
{
|
{
|
||||||
auto wheel = CreateEntity(jeep);
|
auto wheel = CreateEntity(jeep);
|
||||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||||
transform->Position = glm::vec3(-0.2726f, 0.2805f + wheelOffset, 1.9307f);
|
transform->Position = glm::vec3(-0.2726f, 0.2805f - wheelOffset, 1.9307f);
|
||||||
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
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");
|
||||||
model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj";
|
model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj";
|
||||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f - hardPointOffset, 0.f);
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
Wheel->AxleID = 1;
|
Wheel->AxleID = 1;
|
||||||
Wheel->Mass = 50;
|
Wheel->Mass = 50;
|
||||||
Wheel->Radius = 0.737f;
|
Wheel->Radius = 0.737f;
|
||||||
Wheel->Steering = false;
|
Wheel->Steering = false;
|
||||||
Wheel->SuspensionStrength = 40.f;
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
Wheel->Friction = 3.5f;
|
Wheel->Friction = 4.f;
|
||||||
Wheel->ConnectedToHandbrake = true;
|
Wheel->ConnectedToHandbrake = true;
|
||||||
CommitEntity(wheel);
|
CommitEntity(wheel);
|
||||||
}
|
}
|
||||||
@@ -191,27 +194,28 @@ void GameWorld::Initialize()
|
|||||||
CommitEntity(entity);
|
CommitEntity(entity);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
for(int i = 0; i < 0; i++)
|
||||||
{
|
{
|
||||||
auto wall = CreateEntity();
|
auto wall = CreateEntity();
|
||||||
auto transform = AddComponent<Components::Transform>(wall, "Transform");
|
auto transform = AddComponent<Components::Transform>(wall, "Transform");
|
||||||
transform->Position = glm::vec3(10, 0, -20);
|
transform->Position = glm::vec3(10, 0, -20 + (-10 * i));
|
||||||
transform->Orientation = glm::angleAxis(glm::pi<float>()/2.f, glm::vec3(0, 1, 0));
|
//transform->Orientation = glm::angleAxis(glm::pi<float>()/2.f, glm::vec3(0, 1, 0));
|
||||||
|
|
||||||
for (int y = 0; y < 10; y++)
|
for (int y = 0; y < 15; y++)
|
||||||
{
|
{
|
||||||
for (int x = -5; x < 5; x++)
|
for (int x = -5; x < 5; x++)
|
||||||
{
|
{
|
||||||
auto brick = CreateEntity(wall);
|
auto brick = CreateEntity(wall);
|
||||||
auto transform = AddComponent<Components::Transform>(brick, "Transform");
|
auto transform = AddComponent<Components::Transform>(brick, "Transform");
|
||||||
transform->Position = glm::vec3(x + 0.01f, y*0.3f + 0.01f, 0);
|
transform->Position = glm::vec3(x + 0.01f, y * 0.3f + 0.01f, 0);
|
||||||
transform->Position.x += (y % 2)*0.5f;
|
transform->Position.x += (y % 2)*0.5f;
|
||||||
transform->Scale = glm::vec3(1, 0.3f, 0.6f);
|
transform->Scale = glm::vec3(1, 0.3f, 0.4f);
|
||||||
transform->Orientation = glm::quat(glm::vec3(0.0f, 0.0f, 0.0f));
|
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");
|
||||||
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj";
|
model->ModelFile = "Models/Placeholders/PhysicsTest/Cube2.obj";
|
||||||
|
|
||||||
auto physics = AddComponent<Components::Physics>(brick, "Physics");
|
auto physics = AddComponent<Components::Physics>(brick, "Physics");
|
||||||
physics->Mass = 1;
|
physics->Mass = 3;
|
||||||
auto box = AddComponent<Components::BoxShape>(brick, "BoxShape");
|
auto box = AddComponent<Components::BoxShape>(brick, "BoxShape");
|
||||||
box->Width = 0.5f;
|
box->Width = 0.5f;
|
||||||
box->Height = 0.15f;
|
box->Height = 0.15f;
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ void VehicleSetup::setupComponent(const hkpVehicleData& data, hkpVehicleDefaultA
|
|||||||
aerodynamics.m_liftCoefficient = -0.3f;
|
aerodynamics.m_liftCoefficient = -0.3f;
|
||||||
|
|
||||||
// Extra gavity applies in world space (independent of m_chassisCoordinateSystem).
|
// Extra gavity applies in world space (independent of m_chassisCoordinateSystem).
|
||||||
aerodynamics.m_extraGravityws.set(0.0f, -0.982f, 0.0f); // fuck this shit
|
aerodynamics.m_extraGravityws.set(0.0f, -8.0f, 0.0f); // fuck this shit
|
||||||
}
|
}
|
||||||
|
|
||||||
void VehicleSetup::setupComponent(const hkpVehicleData& data, hkpVehicleDefaultVelocityDamper& velocityDamper, Components::Vehicle vehicleComponent)
|
void VehicleSetup::setupComponent(const hkpVehicleData& data, hkpVehicleDefaultVelocityDamper& velocityDamper, Components::Vehicle vehicleComponent)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Systems::PhysicsSystem::PhysicsSystem(World* world) : System(world)
|
|||||||
{
|
{
|
||||||
m_Accumulator = 0;
|
m_Accumulator = 0;
|
||||||
|
|
||||||
hkMemorySystem::FrameInfo finfo(500 * 1024); // Allocate 500KB of Physics solver buffer
|
hkMemorySystem::FrameInfo finfo(6000 * 1024); // Allocate 6MB of Physics solver buffer
|
||||||
hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault(hkMallocAllocator::m_defaultMallocAllocator, finfo);
|
hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault(hkMallocAllocator::m_defaultMallocAllocator, finfo);
|
||||||
hkBaseSystem::init(memoryRouter, HavokErrorReport);
|
hkBaseSystem::init(memoryRouter, HavokErrorReport);
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ void Systems::PhysicsSystem::Update(double dt)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const double timestep = 1 / 60.0;
|
static const double timestep = 1 / 30.0;
|
||||||
m_Accumulator += dt;
|
m_Accumulator += dt;
|
||||||
while (m_Accumulator >= timestep)
|
while (m_Accumulator >= timestep)
|
||||||
{
|
{
|
||||||
@@ -153,12 +153,14 @@ void Systems::PhysicsSystem::Update(double dt)
|
|||||||
m_Context->syncTimers(m_ThreadPool);
|
m_Context->syncTimers(m_ThreadPool);
|
||||||
// Step the visual debugger
|
// Step the visual debugger
|
||||||
StepVisualDebugger();
|
StepVisualDebugger();
|
||||||
|
|
||||||
|
// Clear accumulated timer data in this thread and all slave threads
|
||||||
|
hkMonitorStream::getInstance().reset();
|
||||||
|
m_ThreadPool->clearTimerData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Clear accumulated timer data in this thread and all slave threads
|
|
||||||
hkMonitorStream::getInstance().reset();
|
|
||||||
m_ThreadPool->clearTimerData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
@@ -218,10 +220,9 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[entity]->m_deviceStatus;
|
hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[entity]->m_deviceStatus;
|
||||||
|
|
||||||
|
|
||||||
if(inputComponent->KeyState[GLFW_KEY_UP] != 0 || inputComponent->KeyState[GLFW_KEY_DOWN] != 0)
|
if(inputComponent->KeyState[GLFW_KEY_UP] != 0 || inputComponent->KeyState[GLFW_KEY_DOWN] != 0)
|
||||||
{
|
{
|
||||||
deviceStatus->m_positionY += inputComponent->KeyState[GLFW_KEY_UP] * -1 * 0.05f + inputComponent->KeyState[GLFW_KEY_DOWN] * 1 * 0.05f;
|
deviceStatus->m_positionY += inputComponent->KeyState[GLFW_KEY_UP] * -1 * 0.1f + inputComponent->KeyState[GLFW_KEY_DOWN] * 1 * 0.1f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -233,21 +234,26 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
else if(deviceStatus->m_positionY < -1)
|
else if(deviceStatus->m_positionY < -1)
|
||||||
deviceStatus->m_positionY = -1;
|
deviceStatus->m_positionY = -1;
|
||||||
|
|
||||||
|
float turningSpeed = 0.02f;
|
||||||
|
|
||||||
if(inputComponent->KeyState[GLFW_KEY_LEFT] != 0 || inputComponent->KeyState[GLFW_KEY_RIGHT] != 0)
|
if(inputComponent->KeyState[GLFW_KEY_LEFT] != 0 || inputComponent->KeyState[GLFW_KEY_RIGHT] != 0)
|
||||||
{
|
{
|
||||||
deviceStatus->m_positionX += inputComponent->KeyState[GLFW_KEY_LEFT] * -1 * 0.01f + inputComponent->KeyState[GLFW_KEY_RIGHT] * 1 * 0.01f;
|
deviceStatus->m_positionX += inputComponent->KeyState[GLFW_KEY_LEFT] * -1 * turningSpeed + inputComponent->KeyState[GLFW_KEY_RIGHT] * 1 * turningSpeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(deviceStatus->m_positionX > 0)
|
if(deviceStatus->m_positionX > 0)
|
||||||
{
|
{
|
||||||
deviceStatus->m_positionX += -1 * 0.01f;
|
deviceStatus->m_positionX += -1 * turningSpeed;
|
||||||
}
|
}
|
||||||
else if(deviceStatus->m_positionX < 0)
|
else if(deviceStatus->m_positionX < 0)
|
||||||
{
|
{
|
||||||
deviceStatus->m_positionX += 1 * 0.01f;
|
deviceStatus->m_positionX += 1 * turningSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceStatus->m_positionX > -turningSpeed && deviceStatus->m_positionX < turningSpeed)
|
||||||
|
{
|
||||||
|
deviceStatus->m_positionX = 0.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 2012
|
# Visual Studio 2013
|
||||||
|
VisualStudioVersion = 12.0.30110.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Returngeance", "Returngeance\Returngeance.vcxproj", "{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Returngeance", "Returngeance\Returngeance.vcxproj", "{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{F088123C-0E9E-452A-89E6-6BA2F21D5CAC}") = "ModelingProject1", "ModelingProject1\ModelingProject1.modelproj", "{B35F204C-3377-457E-AC9E-D9606F421191}"
|
Project("{F088123C-0E9E-452A-89E6-6BA2F21D5CAC}") = "ModelingProject1", "ModelingProject1\ModelingProject1.modelproj", "{B35F204C-3377-457E-AC9E-D9606F421191}"
|
||||||
|
|||||||
Reference in New Issue
Block a user