Inertia problems

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Inertia problems

Postby Aldeminor » Wed Jun 30, 2010 2:18 pm

Hi there and first need to warn - i'm not a programmer, but only member of our small team who speaks english well enough (but may be not wery well time to time :P ). Because of this I'll just translate here questions of our main programmer as exactly as possible.

So, we are developing a space simulator based on TV3D engine and NGD physics and has encountered following situation. We need to simulate real zero-gravity and vacuum movement, which implies a "impulse-thrust" movement model. But when we stop the moment transfer, the object starts to slow down and stops, like it is placed in atmosphere. What we are doing wrong?
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby Julio Jerez » Wed Jun 30, 2010 2:31 pm

It needs to set the Linear Drag when creating the body.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Inertia problems

Postby Aldeminor » Mon Jul 05, 2010 1:54 pm

Can you describe more detail, please? Programmer says the "Linear Drag" don't give him any idea about what is it. May be he is not skilled enough, but there are real problem for our small project and we are stuck here for long :(
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby kallaspriit » Mon Jul 05, 2010 2:59 pm

Set linear and angular damping to (near) zero using NewtonBodySetLinearDamping and NewtonBodySetAngularDamping :wink:
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Inertia problems

Postby Aldeminor » Mon Jul 05, 2010 3:47 pm

Thanks very much, will try :D
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby Aldeminor » Wed Jul 07, 2010 12:30 pm

Another question, not about inertia :). We have an idea to simply simulate orbital movement of spaceships. The point is the ship must move on surface of the logical sphere with ceter in the center of planet and with radius a little bit more than a planetary one. By the idea, player will able to change speed and height of the orbit, all other movements must be like in shooter games, where you just walking on the flat floor, but there are "floor" is spherical and non-physical object.

Is it possible, should it works and any ideas to realize that? It is not critical question, but if we can do it, it will be a good and intersting feature.
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby Julio Jerez » Wed Jul 07, 2010 1:26 pm

I am confused, are you making a planetary size simulation?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Inertia problems

Postby Aldeminor » Wed Jul 07, 2010 3:41 pm

Yes, something like this. Not in real sizes, of course, but in scales wich gives to player impression of a real space.
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby Aldeminor » Sat Jul 10, 2010 2:09 pm

And inertia again... :(
Why the bodies with different mass equally reacts on the same impulses?
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby Julio Jerez » Sat Jul 10, 2010 4:42 pm

void NewtonBodyAddImpulse (const NewtonBody* body, const dFloat* pointDeltaVeloc, const dFloat* pointPosit);

The impulse funtion is designed to force a point on a body to achive and instantanue veleocity.
pointDeltaVeloc is the desired increase in velocity at point pointPosit.

I never added that a funtion to apply impulse as a mass time a delta velocity to a body in Newton.
with Newton I am trying to get away from the way the the experts have re-invented a brand new laws of Physics where impulses replace forces.

The correct way to add teh impuslse to a body in newton is

Code: Select all
F = bodyMass * desiredVelocity / tiemstep
T = cross ((pointOfOnBody - CenterMass), F)
NewtonAddForce (F);
NewtonAddTorque (T);
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Inertia problems

Postby JernejL » Sat Jul 10, 2010 6:50 pm

Aldeminor - if you are trying to add force to a point on the body? you can use this - code is in delphi but it can be translated easily:

Code: Select all
// retrieves body's velocity at specific point in global space
function GetPointGlobalVelocity(const body: PNewtonBody; Point: Vector): Vector;
var
  velocity, omega: Vector;
begin
  NewtonBodyGetVelocity(body, @velocity);
  NewtonBodyGetOmega(body, @omega);

  Result := AddVectors(velocity, crossProduct(omega, point));
end;

// retrieves body's velocity at specific point in local space
function GetPointLocalVelocity(const body: PNewtonBody; Point: Vector): Vector;
var
  bodymatrix: Tmatrix4F;
begin
  NewtonBodyGetMatrix(body, @bodymatrix);
  Result := GetPointGlobalVelocity(body, MatrixRotateVector(Point, bodymatrix));
  Result := MatrixUNRotateVector(Result, bodymatrix);
end;

// adds force to body at a specified point in global space
procedure AddPointGlobalForce(const body: PNewtonBody; PrevBodyMatrix: pointer; Force, Point: Vector);
var
  GlobalForce: vector;
  bodymatrix:  Tmatrix4F;
  Torque:      vector;
begin

  if PrevBodyMatrix = nil then
    NewtonBodyGetMatrix(body, @bodymatrix)
  else
    move(PrevBodyMatrix^, bodymatrix, sizeof(Tmatrix4F));

  GlobalForce.x := Point.x - bodymatrix[3][0];
  GlobalForce.y := Point.y - bodymatrix[3][1];
  GlobalForce.z := Point.z - bodymatrix[3][2];

  Torque := CrossProduct(GlobalForce, Force);

  NewtonBodyAddForce(body, @Force.x);
  NewtonBodyAddTorque(body, @Torque.x);
end;


// adds force to body at a specified point in local space
procedure AddPointLocalForce(const body: PNewtonBody; Force, Point: Vector);
var
  GlobalForce, GlobalPoint: Vector;
  bodymatrix: Tmatrix4F;
begin
  NewtonBodyGetMatrix(body, @bodymatrix);

  GlobalForce := MatrixRotateVector(Force, bodymatrix);
  GlobalPoint := MatrixTransformVector(Point, bodymatrix);

  AddPointGlobalForce(body, @bodymatrix, GlobalForce, GlobalPoint);
end;
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Inertia problems

Postby Aldeminor » Sun Jul 11, 2010 12:51 pm

Julio, Delfi, thanks! Seems like it works :roll:
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby Aldeminor » Tue Jul 13, 2010 6:23 am

I'm assured, there are exist answear somewhere in the forum, but I'm not found it - how to switch off collisions between certain obects?

And is it possible to use custom physical meshes for newton bodies, or there are only generated by engine?
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby JernejL » Tue Jul 13, 2010 6:45 am

Aldeminor wrote:I'm assured, there are exist answear somewhere in the forum, but I'm not found it - how to switch off collisions between certain obects?

And is it possible to use custom physical meshes for newton bodies, or there are only generated by engine?


You can set a material pair to non-collideable, or discard the AABB check inside the collision aabb match callback.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Inertia problems

Postby kallaspriit » Wed Jul 14, 2010 5:53 am

Or discard-delete the contacts in contact-callback :)
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 42 guests