## CarLab

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

Moderator: Alain

*lol* vbo. yeah.
I have created the world in giles, something about the vertex part that may have its oirigin there ?

kjelle69

Posts: 60
Joined: Fri Aug 27, 2004 9:08 am
Location: Koskullskulle, Sweden

something vierd happens for me, the car wheels wobble a lot unless i put minimum frame-rate above the current one :/
Help improving the Newton Game Dynamics WIKI

JernejL

Posts: 1500
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

I also had to up the minimum fps to get it to be more stable... you might want to try a proper time-slicer system, as discussed in other parts of this forum.
Independent game developer of (mostly) physics-based games. Creator of "JellyCar" and lead designer of "Where's My Water?"

walaber
Moderator

Posts: 393
Joined: Wed Mar 17, 2004 3:40 am
Location: California, USA

I have read the threads, and trying to get a grip. The deeper you sink into the physic engine thoughts, the more complex thing become, like real life.

Is this right? :
If I call newtonupdate with the elapsed time since the last call, it will perform right as long as the framrate does not drop below 60 fps, because the lowest value is clamped to 1/60. (Not performing right if the framerate is above 1/1000 either, but that will never happen at least not with DBPRo)

Simplified thesis:
So what happens, if the framerate is 30, Newton will still update the physics to 1/60 resulting in slow motion like effects. We think that e.g. the car should move as far as it does in 1/30 of a sec, but newton only moves it as far as 1/60'th second takes it.

Solution in the 30 fps case:
Call newtonupdate twice every frame with the updatetime set to 1/60. ?

-------

In the Carlab I have clamped the FPS rate to 60 in DBPRo, that means that Newton is performing updates with the timestep 1/60 as long as the computer have enough performance to do 60 loops / sec. IF the fps sinks below 60 the application should perform in a slowmotion like behaviour regarding to physics.

The car feels jumpy at newton update times at 60 , this must be because of the newton system really needs to make calculations above (ca)80 times / sec to make any vehiclejoint perform well. The movement of the system gets a bit too long when making updates below 80 updates/sec.

But if the system goes FASTER than 80 fps, then the newton update would perform right as it only gets smaller updatetimes as long as it is inside the scope of 60-1000 fps. BUT what happens if the application adds a force at higher rate/sec on a faster computer than on a slower, then each update will get a higher frequency of force adding to the system. The total sum of force added to the system Integral gets higher then !

I guess that the best approach would be to LOCK the application looptime to a specific maximum value and perform multiple calls to newtonupdate each with the same fraction of the correct TOTAL time each program loop. If all fractions each loop are added the result should be the same as the actual time of the last loop.

The complexity of the system decides how much the maximum update time Newton needs each Callback. (Minimum framerate , minimum fraction of a second) A very complex system such as a vehicle needs some more precision each call to perform realistic ! So it needs more calculations/ second to make it stable. And this is good as long as the mother application does not perform slower each loop that the actual time needed for each system.

Oh and if the Vsync option is used, we have another Clamped framerate which is hard to predict in an application to deal with right.

(Am I completely out riding the bike, or it is somewhat like this it really works) ?

Paouuh, now I need to think a bit about how to solve this in the code.

kjelle69

Posts: 60
Joined: Fri Aug 27, 2004 9:08 am
Location: Koskullskulle, Sweden

google for "Canonical Game Loop", "Fixed timestep" etc

EDIT: I'm using fixed timestep - 24fps, Newton works at 120FPS, so one Game::update involves 5 NewtonUpdate. Rendering is interpolated between frames. Update is called only if time from last update exceeds 1/24s, otherwise rendering with appropriate interpolator is called
tomek

Posts: 102
Joined: Wed Jun 23, 2004 12:34 pm

Ok, Now IF your game's framrate would sink temporarily to 15 fps due to disk access or whatever, your models would behave unpredictably.

If thats the case and newton framerate is set to 125, you've had to:

Call newtonupdate 8.33 times instead of 5.

Or decrease theminimum fps to 75.

Or increase the newton update time to 0.06 sec instead of 0.04.

Am I thinking right here ?

kjelle69

Posts: 60
Joined: Fri Aug 27, 2004 9:08 am
Location: Koskullskulle, Sweden

No If framertate drops below 24fps then simulation becomes slow-motion, but if it's faster than 24 then it's deterministic and as smooth as can be because of interpolation.
tomek

Posts: 102
Joined: Wed Jun 23, 2004 12:34 pm

I tried to do the very simple yet efficient method suggested by Julio:

Sec#=NDB_GetElapsedTimeInSec()

if Sec#>0.017
for t = 1 to 2
NDB_NewtonUpdate Sec#/2
Next t
else
NDB_NewtonUpdate Sec#
endif

I think it works !

kjelle69

Posts: 60
Joined: Fri Aug 27, 2004 9:08 am
Location: Koskullskulle, Sweden

Try getting 1.32, I think there was a bug on 1.31 the might explain the jiter
Julio Jerez
Moderator

Posts: 11048
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Done !

CarLab v1.0c updated with some new functionality and also using Newton SDK v1.32

http://web.telia.com/~u97007521/CarLab.zip

kjelle69

Posts: 60
Joined: Fri Aug 27, 2004 9:08 am
Location: Koskullskulle, Sweden

First of all - great example, thanks

I noticed one problem. On my machine it seems that car turns "harder" on left turn than on right? (it makes complete 180 turn in some cases, and with same speed but steering right it doesn't)

I donâ€™t know why... is it bug or it's intentionally like that (or is it just me )
A1200

Posts: 2
Joined: Fri Mar 11, 2005 7:41 pm

Groovy !!!

This is the steeringcode, nothing should differ between left and right:
MaxSteeringAngle is set to 45 Degrees.

STEERING = 1
inc steerangle#, 0.7
if steerangle# > MaxSteeringAngle# then steerangle# = MaxSteeringAngle#
endif

if keystate(30)
STEERING = 1
dec steerangle#, 0.7
if steerangle# < -MaxSteeringAngle# then steerangle# = -MaxSteeringAngle#
endif

Could it be the Corioliseffect and the rotation of the earth ?

kjelle69

Posts: 60
Joined: Fri Aug 27, 2004 9:08 am
Location: Koskullskulle, Sweden

how are you updating the newton world?

ive noticed that sometimes it feels like the physics simulation is in fast forward
_Tux_

Posts: 81
Joined: Wed Sep 08, 2004 10:38 am
Location: UK

This is the loop that updates the Newton World:
Like Julio suggested, if going below 1/60 then split the Sec# into two shorter intervals that lies within the newton specs of 1/60 to 1/1000, well I dont really check for the 1/1000 situation, but that will most likely not occur with DBPro code within the next 10 years of processing power.

Sec#=NDB_GetElapsedTimeInSec()

if Sec#>0.017
for t = 1 to 2
NDB_NewtonUpdate Sec#/2
Next t
text 90,70,"XXX"
else
NDB_NewtonUpdate Sec#
endif

kjelle69

Posts: 60
Joined: Fri Aug 27, 2004 9:08 am
Location: Koskullskulle, Sweden

Its imposible to test a car thats 5 times the size of the default. Since the spawn point is too low for it. You should increase the spawn points Y axis by 1*Maxsize , MaxSize would be the maximum of the radius's and the car's size.

Stucuk

Posts: 800
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

PreviousNext