Scaling the world.

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Scaling the world.

Postby DarthGak » Wed Sep 03, 2008 1:11 am

Newton uses units of 1.0=1 meter. But the app I am interfacing with (Sketchup) uses 1.0=1 Inch. As far as I know you cant change the unit size in either. Without any scale conversion a 1 inch cube behaves like a 1 meter cube and everything seems to move in slow motion. So I am having to convert scale all over the place in my app and it is driving me nuts and making a mess out of my nice clean code. :)

The question is: can I get rid of the scaling if I instead scale the forces. Instead of gravity of 9.8 use 9.8*39.3 (meters to inches). Also scale the default material properties the same way. Would that work? Would it behave the same as if the scale was correct?
DarthGak
 
Posts: 25
Joined: Sat Nov 25, 2006 4:55 pm

Re: Scaling the world.

Postby JernejL » Wed Sep 03, 2008 4:01 am

DarthGak wrote:Newton uses units of 1.0=1 meter.


No, it doesn't. Newton uses simply.. units, and they can be whatever you like, however in most games you will find 1.0 unit = 1.0 meter ratio is used, this is not just due to convinience for 3d modellers and when using various mathematical formula constants, which are in most cases in meters (which is this world's standard) but also to use the 32 bit floating point range better (meter is longer than inch, so you get a better floating point precision range usage and you get a "larger" stable simulation area).

I would suggest you to scale the models to meters when loading them, you will get less problems with unit conversions that way.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1531
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Scaling the world.

Postby DarthGak » Wed Sep 03, 2008 1:48 pm

So you are saying I CAN scale the simulation forces so that 1.0 appears to be an Inch? I understand I would loose some precision but I can live with that.

I dont really have a "load time". Sketchup is acting like a frontend to Newton and constantly interacting with it. Thats why I have to scale all over the place. So for example when a user clicks on something I have to scale it.
DarthGak
 
Posts: 25
Joined: Sat Nov 25, 2006 4:55 pm

Re: Scaling the world.

Postby Julio Jerez » Wed Sep 03, 2008 3:24 pm

Dark IU would no use any scale,
can you try thsi set you scale to 1.0, that will leave make 1 to 1 ratio.
then try to apply a scale force by use a gravity in inch/se2, I beleive it is about 380
if that do not work then In newton the is a global scal featiore that I have negleet to finish, but maybe thsi is teh rwight time fo do it, sisnce you have such powerful app.

The reason I have neglet the scale is because of the call back.
I agree with you im[posing teh scale on teh clint size in very tidius to maintain, and soem application they is no choice
so maybe this is the right time to do that.

where you using scaling thing in schetchy phyiocsl 1.0?
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling the world.

Postby DarthGak » Wed Sep 03, 2008 10:20 pm

In SketchyPhysics 1 & 2 I did the scaling. But it was a lot less complex that the version I am working on now. I rewrote SP3 to allow it to interface with Newton much more directly so I can expose features like user defined forces, vehicles and breakable joints.

I tried setting the gravity to be in the right scale and it did work somewhat better. But the objects acted like they were very heavy. The would interpenetrate and snap around. My guess is that the default materials values like elasticity would also have to be scaled. But is that it? Or is there always going to be one more thing that doesn't work right?

Julio, if you could add a world scale to Newton that would be beyond awesome! I don't know the design of the underlying code but I suspect it might be a lot less code to handle it down in the physics engine. How hard would it be? I wouldn't want to delay 2.0 for it. :)

Thanks!
Chris
DarthGak
 
Posts: 25
Joined: Sat Nov 25, 2006 4:55 pm

Re: Scaling the world.

Postby Julio Jerez » Thu Sep 04, 2008 1:31 am

DarthGak wrote:I tried setting the gravity to be in the right scale and it did work somewhat better. But the objects acted like they were very heavy. The would interpenetrate and snap around. My guess is that the default materials values like elasticity would also have to be scaled. But is that it? Or is there always going to be one more thing that doesn't work right?

You got that right, there are many torlerance that wodl he to be rescale as well, ther fore jut scali teh force will no do it. But it can be a temprary solution until teh scaleing is in.

DarthGak wrote:Julio, if you could add a world scale to Newton that would be beyond awesome! I don't know the design of the underlying code but I suspect it might be a lot less code to handle it down in the physics engine. How hard would it be? I wouldn't want to delay 2.0 for it.

Oh do not worrie about, teh beta is presissly for peopel to sugget feaures. I will add the scaling.
you have to give me some time, as I am working at teh momenet is a really cool feature that I thing will make user very happy.
so the next Beta will no have teh scaleiing but I promise it will be on the next next.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling the world.

Postby DarthGak » Thu Sep 04, 2008 2:14 am

Thanks Julio! I'll spend the time working on other features.
DarthGak
 
Posts: 25
Joined: Sat Nov 25, 2006 4:55 pm

Re: Scaling the world.

Postby DarthGak » Fri Sep 05, 2008 12:26 am

I have a version now that has most of the scaling in. I set it up so I can rip it out when scaling is in Newton.

But now I am having a problem where objects below a certain mass act like they are static.

I use mass=volume*density. Volume I use newton to calculate. Density is 1.0. If the object is less than a few inches it will not move. If I increase the density it will start working. But a density of 30 or more is needed for millimeter objects.

Any ideas what I am doing wrong? Or is there a minimum in Newton?
DarthGak
 
Posts: 25
Joined: Sat Nov 25, 2006 4:55 pm

Re: Scaling the world.

Postby Julio Jerez » Fri Sep 05, 2008 9:14 am

Code: Select all
void NewtonBodySetMassMatrix(const NewtonBody* bodyPtr, dFloat mass, dFloat Ixx, dFloat Iyy, dFloat Izz)
{
   dgBody *body;
   dFloat Ixx1;
   dFloat Iyy1;
   dFloat Izz1;
   body = (dgBody *)bodyPtr;

   TRACE_FUNTION(__FUNCTION__);
   mass = dgAbsf (mass);
   Ixx = dgAbsf (Ixx);
   Iyy = dgAbsf (Iyy);
   Izz = dgAbsf (Izz);

   if (mass < dgFloat32 (1.0e-3f)) {
             mass = DG_INFINITE_MASS * dgFloat32 (1.5f);
   }

   body->SetMassMatrix (mass, Ixx1, Iyy1, Izz1);
}



this is the function that set the mass of a body
as you can see if teh mass el lower than 0.001 I assuem it si zero and I set ot to infinity.
as body with 0.001 is a very ligh body, in kilogram tehis is aboput one grame of mass.
can you take that into account?
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling the world.

Postby DarthGak » Fri Sep 05, 2008 9:48 pm

Yes. Now that I know the limit I can say If(mass<0.001)mass=0.001; or whatever. Thanks Julio.
DarthGak
 
Posts: 25
Joined: Sat Nov 25, 2006 4:55 pm

Re: Scaling the world.

Postby DarthGak » Fri Sep 05, 2008 10:51 pm

Ok. I am pretty close. I have an cube that I drop from a height of 20.0m (measured from bottom of cube) using a gravity of 9.800722m/s. By my calculator (http://www.softpedia.com/get/Science-CA ... ator.shtml) it should hit the floor in 2.02 seconds or frame 121.2 @ 60fps. In fact it hits at 126. Now that is more than close enough for me. :) But is that amount of error normal? Or do I have something still out of scale?
DarthGak
 
Posts: 25
Joined: Sat Nov 25, 2006 4:55 pm

Re: Scaling the world.

Postby Julio Jerez » Fri Sep 05, 2008 10:56 pm

That's very good for physics sismulation and low fps,
has you set teh drag coeficent to zero, Maybe you can do even better :idea:
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron