Kind of retarded tank
This commit is contained in:
@@ -10,9 +10,10 @@ namespace Components
|
|||||||
struct Vehicle : Component
|
struct Vehicle : Component
|
||||||
{
|
{
|
||||||
Vehicle()
|
Vehicle()
|
||||||
: MaxTorque(1000.0f), MinRPM(1000.0f), OptimalRPM(3000.0f), MaxRPM(4000.0f), MaxSteeringAngle(35), TopSpeed(130.0f),
|
: MaxTorque(1000.0f), MinRPM(0.0f), OptimalRPM(2000.0f), MaxRPM(3000.0f), MaxSteeringAngle(35), TopSpeed(70.0f),
|
||||||
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f){ }
|
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(2500.0f), DownshiftRPM(500.0f),
|
||||||
|
gearsRatio0(4.5f), gearsRatio1(2.5f), gearsRatio2(1.0f), gearsRatio3(0.5f){ }
|
||||||
|
//gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f)
|
||||||
float MaxTorque;
|
float MaxTorque;
|
||||||
float MinRPM;
|
float MinRPM;
|
||||||
float OptimalRPM;
|
float OptimalRPM;
|
||||||
@@ -23,7 +24,13 @@ struct Vehicle : Component
|
|||||||
float TopSpeed;
|
float TopSpeed;
|
||||||
float MaxSpeedFullSteeringAngle;
|
float MaxSpeedFullSteeringAngle;
|
||||||
float SpringDamping;
|
float SpringDamping;
|
||||||
|
float DownshiftRPM;
|
||||||
|
float UpshiftRPM;
|
||||||
|
float gearsRatio0;
|
||||||
|
float gearsRatio1;
|
||||||
|
float gearsRatio2;
|
||||||
|
float gearsRatio3;
|
||||||
|
|
||||||
Vehicle* Clone() const override { return new Vehicle(*this); }
|
Vehicle* Clone() const override { return new Vehicle(*this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+10
-47
@@ -71,33 +71,6 @@ void GameWorld::Initialize()
|
|||||||
e.ViewportFrame = "ViewportFreeCam";
|
e.ViewportFrame = "ViewportFreeCam";
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//{
|
|
||||||
// auto ground = CreateEntity();
|
|
||||||
// auto transform = AddComponent<Components::Transform>(ground);
|
|
||||||
// transform->Position = glm::vec3(0, -50, 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->ModelFile = "Models/TestScene3/testScene.obj";
|
|
||||||
// //model->ModelFile = "Models/Placeholders/Terrain/Terrain2.obj";
|
|
||||||
//
|
|
||||||
// auto physics = AddComponent<Components::Physics>(ground);
|
|
||||||
// physics->Mass = 10;
|
|
||||||
// physics->Static = true;
|
|
||||||
|
|
||||||
|
|
||||||
// auto groundshape = CreateEntity(ground);
|
|
||||||
// auto transformshape = AddComponent<Components::Transform>(groundshape);
|
|
||||||
// auto meshShape = AddComponent<Components::MeshShape>(groundshape);
|
|
||||||
// //meshShape->ResourceName = "Models/Placeholders/Terrain/Terrain2.obj";
|
|
||||||
// meshShape->ResourceName = "Models/TestScene3/testScene.obj";
|
|
||||||
|
|
||||||
//
|
|
||||||
// CommitEntity(groundshape);
|
|
||||||
// CommitEntity(ground);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto ground = CreateEntity();
|
auto ground = CreateEntity();
|
||||||
@@ -575,7 +548,6 @@ void GameWorld::CreateGate(glm::vec3 Position)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EntityID GameWorld::CreateTank(int playerID)
|
EntityID GameWorld::CreateTank(int playerID)
|
||||||
{
|
{
|
||||||
auto tank = CreateEntity();
|
auto tank = CreateEntity();
|
||||||
@@ -586,7 +558,7 @@ EntityID GameWorld::CreateTank(int playerID)
|
|||||||
physics->Mass = 63000 - 16000;
|
physics->Mass = 63000 - 16000;
|
||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
auto vehicle = AddComponent<Components::Vehicle>(tank);
|
auto vehicle = AddComponent<Components::Vehicle>(tank);
|
||||||
vehicle->MaxTorque = 36000.f;
|
vehicle->MaxTorque = 8000.f;
|
||||||
vehicle->MaxSteeringAngle = 90.f;
|
vehicle->MaxSteeringAngle = 90.f;
|
||||||
vehicle->MaxSpeedFullSteeringAngle = 4.f;
|
vehicle->MaxSpeedFullSteeringAngle = 4.f;
|
||||||
auto player = AddComponent<Components::Player>(tank);
|
auto player = AddComponent<Components::Player>(tank);
|
||||||
@@ -784,7 +756,7 @@ void GameWorld::AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int ax
|
|||||||
Wheel->Radius = 0.6f;
|
Wheel->Radius = 0.6f;
|
||||||
Wheel->Steering = steering;
|
Wheel->Steering = steering;
|
||||||
Wheel->SuspensionStrength = suspensionStrength;
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
Wheel->Friction = 3.f;
|
Wheel->Friction = 4.f;
|
||||||
Wheel->ConnectedToHandbrake = true;
|
Wheel->ConnectedToHandbrake = true;
|
||||||
Wheel->TorqueRatio = 0.125f;
|
Wheel->TorqueRatio = 0.125f;
|
||||||
Wheel->Width = 0.6f;
|
Wheel->Width = 0.6f;
|
||||||
@@ -807,7 +779,7 @@ void GameWorld::AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int ax
|
|||||||
Wheel->Radius = 0.6f;
|
Wheel->Radius = 0.6f;
|
||||||
Wheel->Steering = steering;
|
Wheel->Steering = steering;
|
||||||
Wheel->SuspensionStrength = suspensionStrength;
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
Wheel->Friction = 3.f;
|
Wheel->Friction = 4.f;
|
||||||
Wheel->ConnectedToHandbrake = true;
|
Wheel->ConnectedToHandbrake = true;
|
||||||
Wheel->TorqueRatio = 0.125f;
|
Wheel->TorqueRatio = 0.125f;
|
||||||
Wheel->Width = 0.6f;
|
Wheel->Width = 0.6f;
|
||||||
@@ -859,7 +831,14 @@ EntityID GameWorld::CreateJeep(int playerID)
|
|||||||
physics->Mass = 1800;
|
physics->Mass = 1800;
|
||||||
physics->Static = false;
|
physics->Static = false;
|
||||||
auto vehicle = AddComponent<Components::Vehicle>(jeep);
|
auto vehicle = AddComponent<Components::Vehicle>(jeep);
|
||||||
|
vehicle->DownshiftRPM = 3500.f;
|
||||||
|
vehicle->UpshiftRPM = 6000.f;
|
||||||
|
|
||||||
AddComponent<Components::Input>(jeep);
|
AddComponent<Components::Input>(jeep);
|
||||||
|
auto player = AddComponent<Components::Player>(jeep);
|
||||||
|
player->ID = playerID;
|
||||||
|
auto health = AddComponent<Components::Health>(jeep);
|
||||||
|
health->Amount = 100.f;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = CreateEntity(jeep);
|
auto shape = CreateEntity(jeep);
|
||||||
@@ -867,12 +846,6 @@ EntityID GameWorld::CreateJeep(int playerID)
|
|||||||
auto meshShape = AddComponent<Components::MeshShape>(shape);
|
auto meshShape = AddComponent<Components::MeshShape>(shape);
|
||||||
meshShape->ResourceName = "Models/Jeep/Chassi/ChassiCollision.obj";
|
meshShape->ResourceName = "Models/Jeep/Chassi/ChassiCollision.obj";
|
||||||
CommitEntity(shape);
|
CommitEntity(shape);
|
||||||
|
|
||||||
// auto box = AddComponent<Components::Box>(jeep);
|
|
||||||
// box->Width = 1.487f;
|
|
||||||
// box->Height = 0.727f;
|
|
||||||
// box->Depth = 2.594f;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -883,16 +856,6 @@ EntityID GameWorld::CreateJeep(int playerID)
|
|||||||
model->ModelFile = "Models/Jeep/Chassi/chassi.obj";
|
model->ModelFile = "Models/Jeep/Chassi/chassi.obj";
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
|
||||||
auto lightentity = CreateEntity(jeep);
|
|
||||||
auto transform = AddComponent<Components::Transform>(lightentity);
|
|
||||||
transform->Position = glm::vec3(0, 15, 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Create wheels
|
//Create wheels
|
||||||
float wheelOffset = 0.4f;
|
float wheelOffset = 0.4f;
|
||||||
float springLength = 0.3f;
|
float springLength = 0.3f;
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
void VehicleSetup::buildVehicle(World *world, const hkpWorld* physicsWorld, hkpVehicleInstance& vehicle, EntityID vehicleEntity, std::vector<EntityID> wheelEntities)
|
void VehicleSetup::buildVehicle(World *world, const hkpWorld* physicsWorld, hkpVehicleInstance& vehicle, EntityID vehicleEntity, std::vector<EntityID> wheelEntities)
|
||||||
{
|
{
|
||||||
auto vehicleComponent = world->GetComponent<Components::Vehicle>(vehicleEntity);
|
auto vehicleComponent = world->GetComponent<Components::Vehicle>(vehicleEntity);
|
||||||
|
auto tankSteeringComponent = world->GetComponent<Components::TankSteering>(vehicleEntity);
|
||||||
|
|
||||||
WheelData wheelData;
|
WheelData wheelData;
|
||||||
for (int i = 0; i < wheelEntities.size(); i++)
|
for (int i = 0; i < wheelEntities.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -22,7 +23,14 @@ void VehicleSetup::buildVehicle(World *world, const hkpWorld* physicsWorld, hkpV
|
|||||||
//
|
//
|
||||||
vehicle.m_data = new hkpVehicleData;
|
vehicle.m_data = new hkpVehicleData;
|
||||||
vehicle.m_driverInput = new hkpVehicleDefaultAnalogDriverInput;
|
vehicle.m_driverInput = new hkpVehicleDefaultAnalogDriverInput;
|
||||||
vehicle.m_steering = new TankSteering;
|
if(tankSteeringComponent)
|
||||||
|
{
|
||||||
|
vehicle.m_steering = new TankSteering;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vehicle.m_steering = new hkpVehicleDefaultSteering;
|
||||||
|
}
|
||||||
vehicle.m_engine = new hkpVehicleDefaultEngine;
|
vehicle.m_engine = new hkpVehicleDefaultEngine;
|
||||||
vehicle.m_transmission = new hkpVehicleDefaultTransmission;
|
vehicle.m_transmission = new hkpVehicleDefaultTransmission;
|
||||||
vehicle.m_brake = new hkpVehicleDefaultBrake;
|
vehicle.m_brake = new hkpVehicleDefaultBrake;
|
||||||
@@ -196,15 +204,15 @@ void VehicleSetup::setupComponent(const hkpVehicleData& data, hkpVehicleDefaultT
|
|||||||
transmission.m_gearsRatio.setSize(numberOfGears);
|
transmission.m_gearsRatio.setSize(numberOfGears);
|
||||||
transmission.m_wheelsTorqueRatio.setSize(data.m_numWheels);
|
transmission.m_wheelsTorqueRatio.setSize(data.m_numWheels);
|
||||||
|
|
||||||
transmission.m_downshiftRPM = 3500.0f; //HACK: Should be in VehicleComponent
|
transmission.m_downshiftRPM = vehicleComponent.DownshiftRPM; //HACK: Should be in VehicleComponent
|
||||||
transmission.m_upshiftRPM = 7000.0f;
|
transmission.m_upshiftRPM = vehicleComponent.UpshiftRPM;
|
||||||
|
|
||||||
transmission.m_clutchDelayTime = 1.5f;
|
transmission.m_clutchDelayTime = 0.0f;
|
||||||
transmission.m_reverseGearRatio = 1.0f;
|
transmission.m_reverseGearRatio = 1.0f;
|
||||||
transmission.m_gearsRatio[0] = 3.0f;
|
transmission.m_gearsRatio[0] = vehicleComponent.gearsRatio0;
|
||||||
transmission.m_gearsRatio[1] = 2.25f;
|
transmission.m_gearsRatio[1] = vehicleComponent.gearsRatio1;
|
||||||
transmission.m_gearsRatio[2] = 1.5f;
|
transmission.m_gearsRatio[2] = vehicleComponent.gearsRatio2;
|
||||||
transmission.m_gearsRatio[3] = 1.0f;
|
transmission.m_gearsRatio[3] = vehicleComponent.gearsRatio3;
|
||||||
|
|
||||||
for(int i = 0; i < m_Wheels.size(); i++)
|
for(int i = 0; i < m_Wheels.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -212,7 +220,7 @@ void VehicleSetup::setupComponent(const hkpVehicleData& data, hkpVehicleDefaultT
|
|||||||
transmission.m_wheelsTorqueRatio[i] = m_Wheels[i].WheelComponent->TorqueRatio;
|
transmission.m_wheelsTorqueRatio[i] = m_Wheels[i].WheelComponent->TorqueRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
transmission.m_primaryTransmissionRatio = hkpVehicleDefaultTransmission::calculatePrimaryTransmissionRatio(
|
transmission.m_primaryTransmissionRatio = hkpVehicleDefaultTransmission::calculatePrimaryTransmissionRatioKPH(
|
||||||
vehicleComponent.TopSpeed,
|
vehicleComponent.TopSpeed,
|
||||||
m_Wheels[0].WheelComponent->Radius, // HACK: All wheels are the same size right?
|
m_Wheels[0].WheelComponent->Radius, // HACK: All wheels are the same size right?
|
||||||
vehicleComponent.MaxRPM,
|
vehicleComponent.MaxRPM,
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "Components/Vehicle.h"
|
#include "Components/Vehicle.h"
|
||||||
#include "Components/Wheel.h"
|
#include "Components/Wheel.h"
|
||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
|
#include "Components/TankSteering.h"
|
||||||
|
|
||||||
|
|
||||||
/// Tank specific steering implementation. Rear wheels steer in opposite direction
|
/// Tank specific steering implementation. Rear wheels steer in opposite direction
|
||||||
|
|||||||
Reference in New Issue
Block a user