Help with adapting car physics sample to 3D

Blitz3D Forums/Blitz3D Programming/Help with adapting car physics sample to 3D

GR(Posted 2003) [#1]
Hello,

I found a car physics example in the code archives
(Code archives/Algorithms/Car Physics) and was wondering if somebody could show me how to adapt it to work with a 3D Object.

Thanks.
Steve


Insane Games(Posted 2003) [#2]
I've tried sometimes but with no success...
If someone can help i really wan't those code too!

Thanks!
MB


EviLToYLeT(Posted 2003) [#3]
if you look at the code, you'll notice that the y components and x components are quite similar. Since forces that act on each axis are independent of each other, you can simply add in the z component.

actually just took a look at the code, there's a lot of limiting to 800 x 600 it seems....

n/m.


GR(Posted 2003) [#4]
I was really looking for a bit of code that updates a 3D model's position as opposed to drawing the square as the example does...

If you can help with that, I'd appreciate it.


EviLToYLeT(Posted 2003) [#5]
I'd be happy to help with it -- when do you need it by? I'm only free on weekends it seems.


GR(Posted 2003) [#6]
Your help would be much appreciated! No hurry at all, I am working on a couple of different projects to help me learn B3D and am also struggling with learning more about physics so your help on this would be a great help in both those areas.

Thank you.


Tom(Posted 2003) [#7]
Don't want to put a damper (<< bad pun sorry!) on things, but the code in the archives is really suited to 2D and not 3D. I quickly learned that what I was after was a full, 6 degrees of freedom, physics engine.

Vorderman (who also converted the monster car code over to blitz code) created a DLL based on a physics engine called ODE, it worked good but I'm unsure if it still works with burrent B3D updates, it's something I want to get back to eventualy though.

Having said that, if you don't plan on your vehicles pitching & rolling too much, the car example in the code archives can produce some 'fun' driving :)

Cya!
Tom


Vorderman(Posted 2003) [#8]
It certainly can produce a fun drive - I've adapted it many times since I put that code in the archives, tweaking bits here and there, and it produces a pretty good rally car.

It does just work in 2D, but to use in 3D just position your entity at the coords set into the variables CAR1_POSITION_X and Y (they may be called something slightly different, I can't remember, but they're set at the end of the physics routine). Remember you'll need to scale them up or down to match your world. Then orient your entity along it's Y (vertical) axis to match the ANGLE variable (again - check the code for the exact variable name, but once again look near the bottom of the physics routine).

Call the control routine and then the physics routine and you should have the car up and driving quite easily. You'll need to tweak the SCALE parameters to match the physics 'speeds' to your world and model sizes to get it to look right.

Bear in mind you'll get no vertical freedom within the model, so no hills or jumps, but you can bodge this on if you want to using a modified spring system for the suspension. It's not perfect or realistic, but then it is only a couple of pages of code, and for its' size it produces a fun drive.

The ODE DLL I believe doesn't work with the current versions of Blitz. You'll need to use I think v1.77 to get it to work correctly. To be honest it's not that good for simulating a car - I've tried lots of times and it just doesn't work. You'll need to go a bit more in-depth to simulate the rubber to road contacts and friction, and also probably build a better suspension model to get a 'real' car sim.


Tom(Posted 2003) [#9]
Hi James,

I malied you a few days ago, in case your email is down, could you drop me an email, thanks :)

Tom


Vorderman(Posted 2003) [#10]
Hi Tom,

I got your mail last night - you wanted the ODE DLL source code? I'll email it to you at the start of next week - I won't have net access this weekend I'm afraid.


Tom(Posted 2003) [#11]
Cheers!