SOLVED: Forces on a body enigma

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Forces on a body enigma

Postby Julio Jerez » Wed Apr 04, 2018 10:58 am

when I run it in single perdition I see a lot of camera flicker, the pilar does no stay put, if fall over teh size.
Is that the problem?
I am late for work now, I will check later, but please tell of this what teh problem is supposed to show?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Forces on a body enigma

Postby misho » Wed Apr 04, 2018 11:06 am

Sorry, don't understand... I put up PhysicsUtils.cpp file, and the only change there is in PhysicsApplyGravityForce(), where I put a spacebar-triggered thrust force that adds to gravity force: (the original code is under "#if 0")

Code: Select all
// add force and torque to rigid body
void  PhysicsApplyGravityForce (const NewtonBody* body, dFloat timestep, int threadIndex)
{
   dFloat Ixx;
   dFloat Iyy;
   dFloat Izz;
   dFloat mass;

#if 0
   NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz);
   dVector dir(0.0f, 1.0f, 0.0f);
   dVector force(dir.Scale(mass * DEMO_GRAVITY));
   NewtonBodySetForce(body, &force.m_x);
#else

   NewtonWorld* const world = NewtonBodyGetWorld(body);
   DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(world);

   bool bThrust = false;

   if (scene->GetKeyState(' ')) {
      bThrust = true;
   }
   NewtonBodyGetMass(body, &mass, &Ixx, &Iyy, &Izz);

   // mass in "MishosRocketTest" is set to one million kg
   dVector force(dVector(0.0f, 1.0f, 0.0f).Scale(mass * DEMO_GRAVITY)); // Force calculated here is 9.8 million N

   // Misho added
   dVector thrust(dVector(0.0f, 1.0f, 0.0f).Scale(0.0));
   if (bThrust)
      thrust = dVector(0.0f, 1.0f, 0.0f).Scale(10000000.0); // ten million newtons, so the bodies will "rise" slowly...
   else
      thrust = dVector(0.0f, 1.0f, 0.0f).Scale(0.0); // ten million newtons, so the bodies will "rise" slowly...

   dVector resultant = thrust + force;
   NewtonBodySetForce(body, &resultant.m_x);

#endif
}
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Forces on a body enigma

Postby misho » Wed Apr 04, 2018 11:09 am

Julio Jerez wrote:when I run it in single perdition I see a lot of camera flicker, the pilar does no stay put, if fall over teh size.
Is that the problem?
I am late for work now, I will check later, but please tell of this what teh problem is supposed to show?


Yes, precisely, that is the problem. The pillar (rocket body) just starts to tumble on its own. The thrust has no effect. In double precision, it works, but the movement is "choppy".
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Forces on a body enigma

Postby Julio Jerez » Wed Apr 04, 2018 11:28 am

Ok, in single presicion will not work, we do not need to worry about that, let us focus in the double presicion case.

In double I did not see the pillar tumbling, although it seems tilted, that could be contact tolerance. So that's one thing to check.

Then when I navigate, the navigation is choopy, but I believe this is because open gl is not set to deal with double matrices, instead I have a macro that cast the values to glfloat.
I have not veryfied this yet, I will check later.

Also do not forget to tell me if the change to the it ill is necessary, you did not put that file in the link
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Forces on a body enigma

Postby misho » Wed Apr 04, 2018 2:50 pm

Sounds good. If only the visuals are "jerky", I will move my project to latest code and test - it may be that everything is working properly, since I am on a year-old build.

Julio Jerez wrote:Also do not forget to tell me if the change to the it ill is necessary, you did not put that file in the link


Sorry - don't understand - change to "it ill"? All the files I changed (3) I put onto the link.
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Forces on a body enigma

Postby Julio Jerez » Wed Apr 04, 2018 4:33 pm

I mean that I do not know if the change to the utility is needed, because the code compile and runs.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Forces on a body enigma

Postby Julio Jerez » Thu Apr 05, 2018 10:48 am

Are you getting better results?
I did not have much time to look at it,
But for what I can see, in the sandbox demos, the problem is that I am not using gldouble, instead I am casting to to float.
This should not be a problem, for any rendering engine with proper viewing calling.
But the demos do not have that.

In general what it need is to add two matrix to the view pile line.

This tow matrices are the inverse of the origin of the view area.
The every matrix coming form rigid body is mutiplyer by the offset which in double remove the high bit, the the matrix fix nice in double.

I hope you have something like that, if not I will ad a basic implementation in the sand box this weekend.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Forces on a body enigma

Postby misho » Sun Apr 08, 2018 10:14 pm

Julio Jerez wrote:Are you getting better results?


Hi! Yes, I had a chance just now to do some work. I still see a jerky, step motion of a rocket rising upwards.

So, I inserted the debug readout into DemoEntityManager::RenderStats() that shows the y-position of the rocket body object, and sure enough, as I add thrust force, a precise movement readout is shown, down to the tenths of a millimeter... So I'd say that the physics is good, and the "step" problem is in the visual renderer, which I am not using (although it would be nice if you could have that addressed/fixed as well).

A few days ago I wanted to re-integrate the latest Newton into my project, and although everything went fine (except the Euler order thing, which I posted about in another thread), I am now thinking I want to re-organize a lot of my code to more closely follow the demoSandBox structure and to subclass my rocket class to DemoEntity, much like the SuperCarEntity in the demos.

From the looks of it, I seem to be able to use DemoEntity as a generic object in almost any application, as in, I don't have to remove all of the openGL or Mesh functionality, since my display system doesn't use those, correct?
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Forces on a body enigma

Postby misho » Tue Apr 17, 2018 6:27 pm

Hi - I was just wondering if you had any suggestions on the following:

misho wrote:From the looks of it, I seem to be able to use DemoEntity as a generic object in almost any application, as in, I don't have to remove all of the openGL or Mesh functionality, since my display system doesn't use those, correct?


I want to go this way because, even though I have now upgraded to the latest code, I am STILL having the same problem, namely, my thrust force has to be 9x larger than the weight of the rocket body to lift it... :? :roll:

The demoSandBox case I built works fine, so I am guessing there is something in my physics setup that is giving me this problem. Therefore, I'd like to set it up exactly as in the demoSandBox (namely, DemoEntityManager class that runs everything)
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Re: Forces on a body enigma

Postby misho » Mon May 07, 2018 6:27 pm

SOLVED!

I have migrated to the latest code, and I am now getting the results I expect. The problem was in the way the timing was calculated in the old demo sandbox vs. the latest version, namely somewhere within the UpdatePhysics() code - once I re-worked my code to conform to it, the problem was gone :roll:
Misho Katulic
CTO, FSX SpacePort
TerraBuilder
www.terrabuilder.com
misho
 
Posts: 673
Joined: Tue May 04, 2010 10:13 am

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 14 guests

cron