Verlet car help

Blitz3D Forums/Blitz3D Beginners Area/Verlet car help

Weetbix(Posted 2006) [#1]
Hey guys. I'v been away for a while but now I'v started a new project.

Its a car game using one of the open source verlet car physics demos. Its not a usual car game though, instead it's car trials. The main aim being climbing over objects and completeing courses without rolling your car.

You can check out what I have so far:
http://rapidshare.de/files/35567267/005.zip.html

My question is, whats the best way to make the car body rigid?, because right now the verlets just make a cube shape. Should i just add more velets?

Any help and comments are much apreciated :P I'll make a working journal for it later which will describe the game in full.


mindstorms(Posted 2006) [#2]
There are a lot of things like this already out there, just look throught the forums...I like the one with the download called wxRacer, although I can't remember who wrote it...

edit: here is the forumn topic, it seems to be a good start.
http://www.blitzbasic.com/Community/posts.php?topic=24611#259058


Weetbix(Posted 2006) [#3]
Thanks :P, Like I said I am using a demo for the basis and that happens to be it.

My question was to make the "roof" of the car, or really just shape the car better would I add more verlets to create the rigid body? Is there any better faster way?


mindstorms(Posted 2006) [#4]
I'm not an expert, talk to others for better information, but I think that you would want to do something like the wheels on the roof, except positioned so that the radius of the verlets don't go outside the car body... make four verlets for each corner of the top would be what I would do.


Weetbix(Posted 2006) [#5]
Thanks, Ill wait for some more replys but if it comes down to that I suppose I will.


Stevie G(Posted 2006) [#6]
Weetbix,

No reason to add more pointmasses for a vehicle. With my engine every object is basically a cube consisting of 9pointmasses and 36 constraints. I only need 3 iterations for the constraint phase to get stability. I can't divulage me methods for creating unbreakable structures atm I'm afraid but I guess it's not rocket science. Basically you'll need to find a method of detecting the break and then correcting.

To get subtle tilting and rocking when accelerating breaking etc..., the trick is to set the roof pointmasses to be heavier than the wheelbase pointmasses, obviously the center pointmass should be lower than center and heaviest of all for stability. I found that it was not necessary to use an elastic factor for the constraints but instead used an vector mass factor so that xz axis can differ from the Y axis. This takes effect during the constraint phase if you use InvMass proportioning anyway and simulates elasticity and suspension quite well.

If you do not need this best to have the wheelbase heavier than the roof and the vehicle will keep it's shape in the air.

I haven't really looked at the old demo in the thread mindstorms posted. TBH, the code is a bit of a mess and not very well structured even after Sean cleaned it up. I assume it uses a similar approach though.

The biggest problem you'll have is finding that sweet spot for everything, dealing with friction and other external forces .... it took me many months of tweeking to get to the stage I am.

Happy to help with anything else if I can. Must keep my hard earned secrets though ;)

Stevie


Weetbix(Posted 2006) [#7]
Thanks alot stevie, although you lost me on most of the complicated points ;). I'm really quite new to this, Right now im just modding the demo and having a play with it. But the reason I want to add more points is so the collisions dont go straight through the car etc.

Thanks for pointing out the stability options that is very helpful because I wasn't even thinking like that before :P

By the way, I dont mind you keepin your secrets ;)


Stevie G(Posted 2006) [#8]
No worries, assume you're talking about vehicle -----> geometry rather than vehicle ---> vehicle?

If you increase the collision radius of the roof parts but move them more toward center by the same amount you increase their radius by this will give you a better collision model.

Stevie


Weetbix(Posted 2006) [#9]
I think i fixed my problem. But now I have a new one , how do i get the wheels to move slower? they rotate way to fast and it looks unrealistic.


Stevie G(Posted 2006) [#10]
The tires should rotate based on the speed of the wheel pointmass in it's forward direction so you should increment the rotation each frame by ...

PointMassSpeed# * 90.0 / ( Pi * TireRadius# )

Stevie


Weetbix(Posted 2006) [#11]
I...ummm...I....

What... I cant find any place in the code that rotates the tires anyway, i think they are parented to the pivot..

Never mind got it :D


Stevie G(Posted 2006) [#12]
Weetbix,

I had a quick look at the VXrace1 code - assume this is what your using? The code is messy and hard to follow so I don't envy you!!

Anywho, change the last 4 lines of the DoVerlet function seems to do what you're after ...

TurnEntity name\v[1]\entity, TFormedZ() * 90.0 / (Pi * name\v[1]\radius ) , 0, 0, False 
	TurnEntity name\v[2]\entity, TFormedZ() * 90.0 / (Pi * name\v[2]\radius ) , 0, 0, False
	TurnEntity name\v[5]\entity, TFormedZ() * 90.0 / (Pi * name\v[5]\radius ) , 0, 0, False
	TurnEntity name\v[6]\entity, TFormedZ() * 90.0 / (Pi * name\v[6]\radius ) , 0, 0, False


Hope this helps.
Stevie


Weetbix(Posted 2006) [#13]
Stevie i was one step ahead, thanks anyway :P By the way all you have to do (for some reason) is TFormedZ() * Pi And it works just fine.

Heres another problem to ponder. How do I make breaks for the car? I can set the acceleration to 0 but this just stops the wheels spinning, the car still slides off slopes etc?


Stevie G(Posted 2006) [#14]
By the way all you have to do (for some reason) is TFormedZ() * Pi And it works just fine.
I need the * 90.0 and tire radius in my version. I guess this one is just set up differently. Probably the tire is scaled using scaleentity so the tform commands will take this into consideration.

Logically, you would set the acceleration to be -ve to decelerate ;) I'll leave that one with you.

Stevie


Weetbix(Posted 2006) [#15]
But how do I get the velocity of the car?


Stevie G(Posted 2006) [#16]
The overall velocity would be implied by the difference between the current and old pointmass position of the central pointmass.

If you then use ... tformvector velocityx, velocityy, velocityz, 0 , centralpointmassmesh ..... the resulting tformedz() will give you the forward velocity in local space. If the tformedz() > 0 then the car is moving forward relative to it's chassis otherwise reversing.

I do not have the time to trawl through badly commented code so not much more I can help with I'm afraid.

Hope this helps.

Stevie


Weetbix(Posted 2006) [#17]
Iv just spent a while trying to piece code from the new demos into the old one (personally the old physics suits my needs) and trying to get a velocity value. None of that help at all -,-

But now, thanks to you stevie I can try that :p Ill get back to you soon thanks for the help.

edit:
stevie, So I had a fiddle around and this is what I came up with for working out the velocity, and Iv put this in the doverlet function.



The number it returns doesnt really give me much stopping power, and the car still rolls down slopes when the "breaks" are on.