It appears that by changing the nr. of iterations each loop from 8 (default) down to 2, I am able to get a solid "60fps" feel to the physics. Undependent on Screen FPS.
` DarkPhysics timer based movement tests.
` Test 2.
` Manual timing
SyncRate = 60
Sync On
Sync Rate SyncRate
AutoCam Off
Color Backdrop RGB( 0, 128, 255 )
Ink RGB( 0, 64, 0 ), 0
Set Point Light 0, 0, 0, 0
Phy Start
Phy Set Continuous CD 1
` floor
For x = 1 To 10 : For y = 1 To 10
Inc o
Make Object Box o, 10, 10, 10
Position Object o, ((x*10)-50), -5+(rnd(5.0)), ((y*10)-50)
Rotate Object o, rnd(90), rnd(90), rnd(90)
Color Object o, RGB( 128, 255, 128 )
Phy Make Rigid Body Static Box o
Next : Next
` Walls
For x = 101 To 105
Make Object Box x, 100, 100, 5
yRotate Object x, angle
Phy Make Rigid Body Static Box x
Hide Object x
Inc angle, 90
Next x
Phy Set Rigid Body Position 101, 0, 50, 50
Phy Set Rigid Body Position 102, 50, 50, 0
Phy Set Rigid Body Position 103, 0, 50, -50
Phy Set Rigid Body Position 104, -50, 50, 0
Phy Set Rigid Body Position 105, 0, 100, 0 : Phy Set Rigid Body Rotation 105, 90, 0, 0
` falling object
Make Object Sphere 110, 10, 8, 8
Position Object 110, 0, 50, 0
Phy Make Rigid Body Dynamic Sphere 110
` camera
Position Camera -50, 50, -50
Point Camera 0, 0, 0
` Timer Based Physics Variables
startTime# = Timer() ` variable to determine how long the application has ran (in MS)
timerA# = Timer() ` variable to help calculate time step
Do
` info 1
Set Cursor 0, 0
Print "FPS: ", Screen FPS()
` light position
Inc LightCount
x# = (x# + Sin(LightCount)) : y# = 50 : z# = (z# + Cos(LightCount))
Position Light 0, x#, y#, z#
` sphere add force on spacekey
If SpaceKey() And SpakeCey=0
SpakeCey =1
Phy Add Rigid Body Force 110, 0, 100, 0, 2
EndIf
If Not SpaceKey() Then SpakeCey =0
` syncrate change between 60 and 0
If MouseClick() =1 And MouseClikc =0
MouseClikc =1
Inc SyncRate, 60
If SyncRate > 60 Then SyncRate = 0
Sync Rate SyncRate
EndIf
If MouseClick() <> 1 Then MouseClikc =0
` camera rotate
oldx# = Camera Angle X() : oldy# = Camera Angle Y() : oldz# = Camera Angle Z()
Point Camera Object Position X(110), Object Position Y(110), Object Position Z(110)
newx# = Camera Angle X() : newy# = Camera Angle Y() : newz# = Camera Angle Z()
Rotate Camera oldx#, oldy#, oldz#
Rotate Camera CurveAngle( newx#, oldx#, 80.0 ), CurveAngle( newy#, oldy#, 80.0 ), 0.0
` info 2
Set Cursor 0, 500
Print "Sync Rate: ", SyncRate
Print "Time Step ", timerC#/1000
` Timer Based Physics
TimerB# = Timer() - TimerA#
If TimerB# <> TimerC#
TimerC# = TimerB#
TimerA# = Timer()
EndIf
elapsedTime# = Timer() - startTime#
PHY SET FIXED TIMING elapsedTime#
PHY SET TIMING timerC#/1000, 2, 0
` Refresh
Phy Update
Sync
Loop
Can anyone confirm it works for you too?
Edit,
Works well with update method 2 as well
` DarkPhysics timer based movement tests.
` Test 2.
` Manual timing
SyncRate = 60
Sync On
Sync Rate SyncRate
AutoCam Off
Color Backdrop RGB( 0, 128, 255 )
Ink RGB( 0, 64, 0 ), 0
Set Point Light 0, 0, 0, 0
If PhysX()=1 Then Phy Start 1,0,1 Else Phy Start
Phy Update 0
Phy Set Continuous CD 1
Phy Set Gravity 0, -20.0, 0
Phy Set Bounce Threshold -2.0
` floor
For x = 1 To 10 : For y = 1 To 10
Inc o
Make Object Box o, 10, 10, 10
Position Object o, ((x*10)-50), -5+(rnd(5.0)), ((y*10)-50)
Rotate Object o, rnd(90), rnd(90), rnd(90)
Color Object o, RGB( 128, 255, 128 )
Phy Make Rigid Body Static Box o
Next : Next
` Walls
For x = 101 To 105
Make Object Box x, 100, 100, 5
yRotate Object x, angle
Phy Make Rigid Body Static Box x
Hide Object x
Inc angle, 90
Next x
Phy Set Rigid Body Position 101, 0, 50, 50
Phy Set Rigid Body Position 102, 50, 50, 0
Phy Set Rigid Body Position 103, 0, 50, -50
Phy Set Rigid Body Position 104, -50, 50, 0
Phy Set Rigid Body Position 105, 0, 100, 0 : Phy Set Rigid Body Rotation 105, 90, 0, 0
` falling object
Make Object Sphere 110, 10, 8, 8
Position Object 110, 0, 50, 0
Phy Make Rigid Body Dynamic Sphere 110
` camera
Position Camera -50, 50, -50
Point Camera 0, 0, 0
` Timer Based Physics Variables
startTime# = Timer() ` variable to determine how long the application has ran (in MS)
timerA# = Timer() ` variable to help calculate time step
Do
` info 1
Set Cursor 0, 0
Print "FPS: ", Screen FPS()
` light position
Inc LightCount
x# = (x# + Sin(LightCount)) : y# = 50 : z# = (z# + Cos(LightCount))
Position Light 0, x#, y#, z#
` sphere add force on spacekey
If SpaceKey() And SpakeCey=0
SpakeCey =1
Phy Add Rigid Body Force 110, 0, 100, 0, 2
EndIf
If Not SpaceKey() Then SpakeCey =0
` syncrate change between 60 and 0
If MouseClick() =1 And MouseClikc =0
MouseClikc =1
Inc SyncRate, 60
If SyncRate > 60 Then SyncRate = 0
Sync Rate SyncRate
EndIf
If MouseClick() <> 1 Then MouseClikc =0
` camera rotate
oldx# = Camera Angle X() : oldy# = Camera Angle Y() : oldz# = Camera Angle Z()
Point Camera Object Position X(110), Object Position Y(110), Object Position Z(110)
newx# = Camera Angle X() : newy# = Camera Angle Y() : newz# = Camera Angle Z()
Rotate Camera oldx#, oldy#, oldz#
Rotate Camera CurveAngle( newx#, oldx#, 80.0 ), CurveAngle( newy#, oldy#, 80.0 ), 0.0
` info 2
Set Cursor 0, 500
Print "Sync Rate: ", SyncRate
Print "Time Step ", timerC#/1000
` Timer Based Physics
TimerB# = Timer() - TimerA#
If TimerB# <> TimerC#
TimerC# = TimerB#
TimerA# = Timer()
EndIf
elapsedTime# = Timer() - startTime#
PHY SET FIXED TIMING elapsedTime#
PHY SET TIMING timerC#/1000, 2, 0
` Refresh
Phy Update 1
Phy Update 0
Sync
Phy Update 1
Loop
I allways afraided from a clowns. aww..