Skip to content

Commit

Permalink
[Bullet] Splits some parameters into custom class, for later
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvux committed Mar 1, 2017
1 parent f28f3cf commit 10ac53e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VVVV.Bullet.DataTypes.Vehicle
{
public class WheelInfoSettings
{
public WheelInfoSettings()
{
this.SuspensionStiffness = 20.0f;
this.WheelsDampingRelaxation = 2.3f;
this.WheelsDampingCompression = 4.4f;
this.FrictionSlip = 1000;
this.RollInfluence = 0.1f;
}

public float SuspensionStiffness;
public float WheelsDampingRelaxation;
public float WheelsDampingCompression;
public float FrictionSlip;
public float RollInfluence;
}

public class WheelConstructionSettings
{
public float WheelRadius = 0.7f;
public float WheelWidth = 0.4f;
public float SuspensionRestLength = 0.6f;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,24 @@
using VVVV.Internals.Bullet;
using VVVV.Utils.VMath;
using VVVV.Bullet.Utils;
using VVVV.Bullet.DataTypes.Vehicle;

namespace VVVV.Bullet.Nodes.Bodies.Rigid
{
[PluginInfo(Name = "CreateVehicle", Category = "Bullet", Author = "vux",
Help = "Creates a vehicle", AutoEvaluate = true)]
public class BulletCreateVehicleNode : AbstractRigidBodyCreator
{
private WheelInfoSettings wheelInfoSettings = new WheelInfoSettings();
private WheelConstructionSettings constructionSettings = new WheelConstructionSettings();

int rightIndex = 0;
int upIndex = 1;
int forwardIndex = 2;
float CUBE_HALF_EXTENTS = 1;
Vector3 wheelDirectionCS0 = new Vector3(0, -1, 0);
Vector3 wheelAxleCS = new Vector3(-1, 0, 0);

//float gEngineForce = 2000.0f;
/*float gBreakingForce = 0.0f;
float maxEngineForce = 2000.0f;//this should be engine/velocity dependent
float maxBreakingForce = 100.0f;
float gVehicleSteering = 0.0f;
float steeringIncrement = 1.0f;
float steeringClamp = 0.3f;*/
public float wheelRadius = 0.7f;
public float wheelWidth = 0.4f;
float wheelFriction = 1000;//BT_LARGE_FLOAT;
float suspensionStiffness = 20.0f;
float suspensionDamping = 2.3f;
float suspensionCompression = 4.4f;
float rollInfluence = 0.1f;//1.0f;

float suspensionRestLength = 0.6f;


[Output("Vehicle")]
protected ISpread<RaycastVehicle> FOutVehicle;
Expand Down Expand Up @@ -116,28 +101,28 @@ public override void Evaluate(int SpreadMax)
// choose coordinate system
vehicle.SetCoordinateSystem(rightIndex, upIndex, forwardIndex);

Vector3 connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius);
WheelInfo a = vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
Vector3 connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * constructionSettings.WheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - constructionSettings.WheelRadius);
WheelInfo a = vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, constructionSettings.SuspensionRestLength, constructionSettings.WheelRadius, tuning, isFrontWheel);

connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - wheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * constructionSettings.WheelWidth), connectionHeight, 2 * CUBE_HALF_EXTENTS - constructionSettings.WheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, constructionSettings.SuspensionRestLength, constructionSettings.WheelRadius, tuning, isFrontWheel);

isFrontWheel = false;
connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
connectionPointCS0 = new Vector3(-CUBE_HALF_EXTENTS + (0.3f * constructionSettings.WheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + constructionSettings.WheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, constructionSettings.SuspensionRestLength, constructionSettings.WheelRadius, tuning, isFrontWheel);

connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * wheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + wheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, suspensionRestLength, wheelRadius, tuning, isFrontWheel);
connectionPointCS0 = new Vector3(CUBE_HALF_EXTENTS - (0.3f * constructionSettings.WheelWidth), connectionHeight, -2 * CUBE_HALF_EXTENTS + constructionSettings.WheelRadius);
vehicle.AddWheel(connectionPointCS0, wheelDirectionCS0, wheelAxleCS, constructionSettings.SuspensionRestLength, constructionSettings.WheelRadius, tuning, isFrontWheel);


for (i = 0; i < vehicle.NumWheels; i++)
{
WheelInfo wheel = vehicle.GetWheelInfo(i);
wheel.SuspensionStiffness = suspensionStiffness;
wheel.WheelsDampingRelaxation = suspensionDamping;
wheel.WheelsDampingCompression = suspensionCompression;
wheel.FrictionSlip = wheelFriction;
wheel.RollInfluence = rollInfluence;
wheel.SuspensionStiffness = wheelInfoSettings.SuspensionStiffness;
wheel.WheelsDampingRelaxation = wheelInfoSettings.WheelsDampingRelaxation;
wheel.WheelsDampingCompression = wheelInfoSettings.WheelsDampingCompression;
wheel.FrictionSlip = wheelInfoSettings.FrictionSlip;
wheel.RollInfluence = wheelInfoSettings.RollInfluence;
}

FOutVehicle.SliceCount = 1;
Expand Down
1 change: 1 addition & 0 deletions Nodes/VVVV.DX11.Nodes.Bullet/VVVV.Nodes.Bullet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<Compile Include="DataTypes\Shapes\Soft\ConvexHullSoftShapeDefinition.cs" />
<Compile Include="DataTypes\Shapes\Soft\TriMeshSoftShapeDefinition.cs" />
<Compile Include="DataTypes\Shapes\Vehicle\VehicleSettings.cs" />
<Compile Include="DataTypes\Shapes\Vehicle\WheelInfoSettings.cs" />
<Compile Include="DataTypes\World\ObjectLifetimeContainer.cs" />
<Compile Include="Internals\Bodies\BodyCustomData.cs">
<SubType>Code</SubType>
Expand Down

0 comments on commit 10ac53e

Please sign in to comment.