Newton car dynamics demo

Share with us how are you using the powerrrr of the force

Moderator: Alain

Newton car dynamics demo

Postby kallaspriit » Tue Aug 08, 2006 5:08 am

During my testing with newton and the vehicle component, I made a small application simulating a vehicle. Basicly you can just drive around a small city . It features a well-tuned car with simulated manual gearbox including torque curve, automatic clutch, optional traction control and so on. It's just 5,52 MB so give it a try and tell me what do you think :P

The controls are:

ESC - exit

C - toggle follow camera
R - reset car position
P - place car at the start pos
T - toggle traction control
N - make a new vehicle

F1 - toggle show collisions
F2 - toggle show contacts
F3 - toggle show data
F4 - make a pile of boxes
F5 - throw a box
F6 - create a big terrain under the city (take a while)

wheel mouse - change car power (press F3 to see the percent)
arrows - steer and accelerate/brake the car
A - shift up
Z - shift down
ENTER - change drive type (4WD/FWD/RWD) (press F3 to see current)
SPACE - handbrake


The city model I kind of stole from someones app, but I cant really remember where so credits for the city don't go to me :)

Download | 5,52MB

ImageImage

Enjoy
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Postby Dave Gravel » Tue Aug 08, 2006 10:20 am

> The city model I kind of stole from someone but I cant really remember > where
> so credits for the city dont go to me :)

You have forget the vehicle modeler too ?
http://pgrafica.webideas4all.com/descargas.html

Looking good.
Good continuation.
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Postby walaber » Tue Aug 08, 2006 1:34 pm

very fast car!! are you updating the physics "faaster" than realtime? everything feels slightly faster than real life (gravity, etc).

overall, the car tuning is working great! nice work.
Independent game developer of (mostly) physics-based games. Creator of "JellyCar" and lead designer of "Where's My Water?"
User avatar
walaber
Moderator
Moderator
 
Posts: 393
Joined: Wed Mar 17, 2004 3:40 am
Location: California, USA

Postby Julio Jerez » Tue Aug 08, 2006 11:35 pm

Hey this is very cool, It reminds me of a remote control car, and it even sound and behave like one. :o
What technique are you using maybe giving some pointer to the less fortunate apprentices front time to time. 8)
I only am making a physics engine here. :D
very nice.


One recommendation. If you add a delay between the camera matrix and the vehicle matrix, it will be possible to see all the movement of the vehicle frame. Now it is too rigid and it is like a FPS camera but in third person.
It is very easy to make a camera like that.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby kallaspriit » Wed Aug 09, 2006 5:48 am

You have forget the vehicle modeler too ?

I indeed found the nice impreza googling the open space of internet and have not done it myself :P

very fast car!! are you updating the physics "faaster" than realtime? everything feels slightly faster than real life (gravity, etc).


What I'm always missing in racing games is the actual feeling of speed so that is what I wanted to achive. The best way I could do it was by updating Newton twice every render which is ofcourse not a good idea for performance. For some reason two updates with timestep of 0.03 does not give even close the same results as one update with timestep of 0.06 - am I missing something? FPS is simply limited to 60 and Newton updated twice with a constant timestep. I'm sure this is not the best way so I'm open for suggestions:
Code: Select all
    int fpslimiter = 0;
   
    while(game->isRunning())
    {   
        if(game->isWindowActive())
        {
            if(game->getTickCount() - fpslimiter >= 16)
            {
                fpslimiter = game->getTickCount();

                game->updatePhysics(0.03);
                game->updatePhysics(0.03);
            
                game->updateSound();
                game->startScene();
                game->renderGraphics();
                game->render2D();
                game->endScene();
                game->parseInput();
            }
        }
    }


Car gravity constant is not 9.8 either, I came up with 15 by testing - jumping with the car and changing the value until the jump looked real for the eye. Additionally a bit of downforce is added to the gravity based on another fictional constant and car speed:
Code: Select all
force[1] = -mass * 15.0f + avg_speed * 5.0f;


The driveshaft has automated clutch, engine drag, wheel drag and speed drag (missing time delay between gear shifts.

The coeficents are calculated as follows and probably doesn't have too much to do with real physics either, just seemed to work ok. Any ideas for them are welcome:
Code: Select all
float use_load = fabs(load) <= 10000 ? fabs(load) : 10000;
float use_speed = fabs(speed) <= 100 ? fabs(speed) : 100;

float slc = use_speed*0.1/(((9999-use_load)/10000));

NewtonVehicleSetTireSideSleepCoeficient(vehicle, id, slc);
NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle, id, load * grip * fabs(speed));
// (where 1 < grip < 3)


One recommendation. If you add a delay between the camera matrix and the vehicle matrix, it will be possible to see all the movement of the vehicle frame. Now it is too rigid and it is like a FPS camera but in third person.
It is very easy to make a camera like that.


I have tried to do it and searched for it but with little success. I'm new with matrixes and 3d algebra so it would be great if someone could help me with the camera - it would indeed be nice to see the side of the car while powersliding and such. My current (messy) camera code:
Code: Select all
f32 camZoom = 5;
core::vector3df camDist = core::vector3df(0,0.35f,1.0f) * camZoom;
core::vector3df camRot(0,90,0);

core::matrix4 rotation;
rotation.setRotationDegrees(camRot);
rotation.rotateVect(camDist);
       
core::matrix4 transformation = truck->node->getAbsoluteTransformation();

transformation.transformVect(camDist);
               
camNode->setTarget(transformation.getTranslation());
camNode->setPosition(camDist);


Thanks for the support and great physics engine! I remember Julio mentioning axes in the future, looking forward to new features :D
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Postby Lyrical » Thu Aug 02, 2007 4:50 am

This is a really good demo,

I am creating something simlar
I have the car model working i just having lots of problems with
gears. is there a small cutdown version of your demo to look at the gear
setup and how to apply the wheel torque.

This subject of gears is somewhat of a mystery.

Any help you can give would be apprieciated.

BTW: is the Impreza car model yours or do you know who it belongs to?
I am using it for my demo and would like to acknowledge them appropriatly.

Chears
Lyrical
 
Posts: 1
Joined: Sat Nov 26, 2005 5:08 pm


Return to User Gallery

Who is online

Users browsing this forum: No registered users and 22 guests

cron