Im pleased to see some folks getting interested in this, and possibly spend some time to improve it???
If thats the case then I think i should spend some time explaining a few things.
First the code is a mess still. There are alot of half finished ideas all thru it. The one area that is
especially messed up is the friction code. Now lets start by reaching an agreement what types of friction
we need and why.
lets start with a contact friction type that is a variable assigned to each verlet. Each verlet
represents a "part" of the car. So contact friction on chassis or "body" parts need to be very high.
So When the car rolls over or land on the roof it will decelerate rapidly. Body verlet friction will
not change so its rather simple to implement. Now the verlet contact friction for the wheels is much more
complex. It needs to have at least two values. The first is rolling friction. This value is used whenever
the direction of travel matches the rolling direction of the wheel. when in this state the friction will
be very very low. But each time the car turns forces are applied away from the rolling direction. In this
case a static friction model needs to be used. The tire needs to stick to the road until a critical point
is reached where the forces away from the direction of roll exceed the ability of the tire to stick to the
road. Then once the forces have exceeded that critical point they need to let loose with a much lower level
of friction. As the car slows and the forces diminish then the tire will need to "re-stick" to the road.
the second major friction type is world friction. Think of this as air resistance. Now there is a peculiar
effect with air resistance where its resitance is a product of the vehicles speed. At zero velocity air
resistance is zero. but at much higher velocities it reaches such a high value that the vehicle will reach
a state known as terminal velocity. Terminal velocity simply means that the vehicle has reached its maximum
velocity.
So as a first step here is a very simple change that will change the simulation from "a train on tracks" to a
linear slip allowed for the tires. remember this is not accurate because we need two states for the wheels
and since this is simply linear it means the wheels are allowed to slip all the time.
In the DoVerlet function change this line;
;tempvmx is purposefully not computed so the wheels only travel up and down, and forward/back
TO;
tempvmx = tempvmx - ((tempvoldx*.5) + (tempvax * (DeltaTime * DeltaTime))) + (temptempx * .5)
you will need to reduce the turn_rate variable, also located in DoVerlet, because now that the wheels
are allowed to slip the force applied to turn the vehicle is applied with much less resistance. I suggest
changing it from;
turn_rate = turn_rate + .7
To
turn_rate = turn_rate + .5
Now this change allows 50 percent of the forces that previously we entirely excluded to now be computed.
Note the car will still roll over if you push it hard.
Remember how we needed two states for the tire? Well this is a simple hack to illustrate how we can achieve
the those states.
In the DoVerlet function change this line;
;tempvmx is purposefully not computed so the wheels only travel up and down, and forward/back
To this;
If Abs(tempvmx - tempvoldx) > 3 Then
tempvmx = tempvmx - ((tempvoldx*1) + (tempvax * (DeltaTime * DeltaTime))) + (temptempx * 1)
Else tempvmx = tempvmx - ((tempvoldx*.1) + (tempvax * (DeltaTime * DeltaTime))) + (temptempx * .1)
End If
And reduce the turn_rate, also located in DoVerlet, from;
turn_rate = turn_rate + .7
TO
turn_rate = turn_rate + .6 or even lower.
How this works is, it computes the difference from the old position to the new position. The difference is
effectively the force, or more accuratly the velocity change, exerted on the tire. when the difference is greater
than 3 the verlet is allowed to fully travel in all 3 axis with no friction. it wont look realistic but it will
prove that we can achieve two states.
Ok thats enough for now. Have fun.
If thats the case then I think i should spend some time explaining a few things.
First the code is a mess still. There are alot of half finished ideas all thru it. The one area that is
especially messed up is the friction code. Now lets start by reaching an agreement what types of friction
we need and why.
lets start with a contact friction type that is a variable assigned to each verlet. Each verlet
represents a "part" of the car. So contact friction on chassis or "body" parts need to be very high.
So When the car rolls over or land on the roof it will decelerate rapidly. Body verlet friction will
not change so its rather simple to implement. Now the verlet contact friction for the wheels is much more
complex. It needs to have at least two values. The first is rolling friction. This value is used whenever
the direction of travel matches the rolling direction of the wheel. when in this state the friction will
be very very low. But each time the car turns forces are applied away from the rolling direction. In this
case a static friction model needs to be used. The tire needs to stick to the road until a critical point
is reached where the forces away from the direction of roll exceed the ability of the tire to stick to the
road. Then once the forces have exceeded that critical point they need to let loose with a much lower level
of friction. As the car slows and the forces diminish then the tire will need to "re-stick" to the road.
the second major friction type is world friction. Think of this as air resistance. Now there is a peculiar
effect with air resistance where its resitance is a product of the vehicles speed. At zero velocity air
resistance is zero. but at much higher velocities it reaches such a high value that the vehicle will reach
a state known as terminal velocity. Terminal velocity simply means that the vehicle has reached its maximum
velocity.
So as a first step here is a very simple change that will change the simulation from "a train on tracks" to a
linear slip allowed for the tires. remember this is not accurate because we need two states for the wheels
and since this is simply linear it means the wheels are allowed to slip all the time.
In the DoVerlet function change this line;
;tempvmx is purposefully not computed so the wheels only travel up and down, and forward/back
TO;
tempvmx = tempvmx - ((tempvoldx*.5) + (tempvax * (DeltaTime * DeltaTime))) + (temptempx * .5)
you will need to reduce the turn_rate variable, also located in DoVerlet, because now that the wheels
are allowed to slip the force applied to turn the vehicle is applied with much less resistance. I suggest
changing it from;
turn_rate = turn_rate + .7
To
turn_rate = turn_rate + .5
Now this change allows 50 percent of the forces that previously we entirely excluded to now be computed.
Note the car will still roll over if you push it hard.
Remember how we needed two states for the tire? Well this is a simple hack to illustrate how we can achieve
the those states.
In the DoVerlet function change this line;
;tempvmx is purposefully not computed so the wheels only travel up and down, and forward/back
To this;
If Abs(tempvmx - tempvoldx) > 3 Then
tempvmx = tempvmx - ((tempvoldx*1) + (tempvax * (DeltaTime * DeltaTime))) + (temptempx * 1)
Else tempvmx = tempvmx - ((tempvoldx*.1) + (tempvax * (DeltaTime * DeltaTime))) + (temptempx * .1)
End If
And reduce the turn_rate, also located in DoVerlet, from;
turn_rate = turn_rate + .7
TO
turn_rate = turn_rate + .6 or even lower.
How this works is, it computes the difference from the old position to the new position. The difference is
effectively the force, or more accuratly the velocity change, exerted on the tire. when the difference is greater
than 3 the verlet is allowed to fully travel in all 3 axis with no friction. it wont look realistic but it will
prove that we can achieve two states.
Ok thats enough for now. Have fun.