NewtonUpdate

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: NewtonUpdate

Postby Stucuk » Tue Feb 03, 2009 12:32 pm

@Julio: Im confused as to what your saying. Currently im sending NewtonUpdate() 1/60 as the time, nomatter how meny times NewtonUpdate() is called in a second. If i pass the actual time that has passed between frames then each world will go slow. (With the more updated worlds going slightly slower).

Id modify the newton demo which comes with the SDK if it would compile on VS2003 without errors(Some because of the missing raycastcar joint files).

The actual code im using is the following, where FTimeSlice is either 1/60, 1/120 or 1/240 depending on which world it is.
Code: Select all
procedure TNewtonWorld.Update(FrameTime : Float);
begin
  if not FEnabled then Exit;

  FLastFrameTime := FLastFrameTime + FrameTime;
  If FLastFrameTime > 1 then
  FLastFrameTime := 1;
  If FLastFrameTime >= FTimeSlice then
  Repeat
    NewtonUpdate(FWorld, 1/60);
    FLastFrameTime := FLastFrameTime - FTimeSlice;
    Timer.Refresh;
  Until (FLastFrameTime < FTimeSlice);
end;


@Dave Gravel: I don't see the relevents. The NewtonUpdate() is being called independantly from what FPS the app is getting. If the app is getting 60 FPS, the world thats updated 240 times per second is still being updated at 240 times per second.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: NewtonUpdate

Postby Julio Jerez » Tue Feb 03, 2009 1:14 pm

in thsi code you are calling upfate with a tiem step of 1/60
so when you update at 1/120 teh sice will move for 2 time faster sicne it si advancing by bu tow teh ampung opt time of the tiem slice

Code: Select all
procedure TNewtonWorld.Update(FrameTime : Float);
begin
  if not FEnabled then Exit;

  FLastFrameTime := FLastFrameTime + FrameTime;
  If FLastFrameTime > 1 then
  FLastFrameTime := 1;
  If FLastFrameTime >= FTimeSlice then
  Repeat
    NewtonUpdate(FWorld, 1/60);
    FLastFrameTime := FLastFrameTime - FTimeSlice;
    Timer.Refresh;
  Until (FLastFrameTime < FTimeSlice);
end;


you need to call with the same time slice each time
Code: Select all
begin
  if not FEnabled then Exit;

  FLastFrameTime := FLastFrameTime + FrameTime;
  If FLastFrameTime > 1 then
  FLastFrameTime := 1;
  If FLastFrameTime >= FTimeSlice then
  Repeat
    // look here
    NewtonUpdate(FWorld, FTimeSlice);
    FLastFrameTime := FLastFrameTime - FTimeSlice;
    Timer.Refresh;
  Until (FLastFrameTime < FTimeSlice);
end;



now when time slice is 1/120, the simulation will take twice as many steps than it takes when FTimeSlice is 1/60
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonUpdate

Postby Stucuk » Tue Feb 03, 2009 2:54 pm

The point of not doing that was to make the physics react more naturaly. At 60 updates per second the physics is slow, each object falls as if it was a feather. Only when the simulation is faster does objects fall at a more realistic rate. The point of the different worlds at different speeds was to see what looked more like how real life objects fall and to see if my app was the only one experiencing slow physics at 60 updates per second.

EDIT: to keep things simple iv modifyed the TestApp, it now only has objects in the 60 updates per second world. They fall unrealisticly slow.

- TestApp
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: NewtonUpdate

Postby Julio Jerez » Tue Feb 03, 2009 3:08 pm

like I said you can determine if the physics is correct by comparing a body in free fall to the equation of a free falling body.
they should be very close.
I do not underntand what is the problem.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonUpdate

Postby Stucuk » Tue Feb 03, 2009 3:23 pm

Julio Jerez wrote:like I said you can determine if the physics is correct by comparing a body in free fall to the equation of a free falling body.
they should be very close.

Stucuk wrote:What does y0 mean? I assume v0 is velocity, t for time, g for gravity?


I would if you would tell me what the varibles in the equation were.
Last edited by Stucuk on Tue Feb 03, 2009 3:29 pm, edited 1 time in total.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: NewtonUpdate

Postby Julio Jerez » Tue Feb 03, 2009 3:28 pm

With a gravity of 9.8 starting with velocity zero a body should fall
Y = 0.5 * 9.8 * 1.0 * 1.0 = 4.9 meters
Run the animation for 1 secund and compare the value the body fall from its initial postion to the final position
The value should be very close at .1/60, 1.20 or 1/180
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonUpdate

Postby Stucuk » Tue Feb 03, 2009 3:39 pm

Using a bad resolution timer im getting 4.6, guess its just the size of the objects then(As its just a test app to test my wrapper as its being built, iv just been using "Any old value" for things like size of objects). Thanks Julio.

EDIT: To anyone who sais size doesn't matter, there wrong!

- Size Matters
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: NewtonUpdate

Postby Dave Gravel » Wed Feb 04, 2009 12:23 am

Yes the size and the time is two very important thing.
From my experience normal little size object and normal big size object can work pretty good with the same behaving but need totally different setting.
when it is very very little or very very big the problem can begin, and the setup is more hard or complex.
Anyway you can reproduce any reality from normal sizing and timing, after it coming more experimental or totally out of physics reality.
You search a nice physics solution, if you can read this message you're at the good place :wink:
OrionX3D Projects & Demos:
https://orionx3d.sytes.net
https://www.facebook.com/dave.gravel1
https://www.youtube.com/user/EvadLevarg/videos
User avatar
Dave Gravel
 
Posts: 800
Joined: Sat Apr 01, 2006 9:31 pm
Location: Quebec in Canada.

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 20 guests

cron