Custom joints vehicle and weak joints

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Wed Dec 30, 2009 1:51 pm

what time slicing world update means?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby PJani » Wed Dec 30, 2009 2:37 pm

Hmm i mean this...
this is time slicing...i think...
Code: Select all
    m_elapsed += evt.timeSinceLastFrame;

    int count = 0;

    // loop through and update as many times as necessary (up to 10 times maximum).
    if ((m_elapsed > m_update) && (m_elapsed < (m_update * 10)) )
    {
        while (m_elapsed > m_update)
        {
            m_World->update( m_update );
            m_elapsed -= m_update;
            count++;
        }
    }
    else
    {
        if (m_elapsed < (m_update))
        {
            // not enough time has passed this loop, so ignore for now.
        }
        else
        {
            // too much time has passed (would require more than 10 updates!), so just update once and reset.
            // this often happens on the first frame of a game, where assets and other things were loading, then
            // the elapsed time since the last drawn frame is very long.
            m_World->update( m_elapsed );
            count++;
            m_elapsed = 0.0f; // reset the elapsed time so we don't become "eternally behind".
        }
    }


and this is new code in frame listener
Code: Select all
m_World->update(  evt.timeSinceLastFrame ); :roll:
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Custom joints vehicle and weak joints

Postby kallaspriit » Wed Dec 30, 2009 2:52 pm

I see that you have replaced the time slicing method (that previously kept physics updated at a specific framerate) with interpolation variant of it but should it not work in a way that even if you are updating the physics at a very low rate, the visual should still look smooth?

When I removed the limititation in World.cpp:
Code: Select all
if (m_timestep > 1.0f / 60.0f) {
   //m_timestep = 1.0 / 60.0f;
}


And made the physics update at 10FPS, the visual still looks choppy. Is this correct or am I missing something?

And one more thing, please keep OgreNewt convention of starting method names with lowercase character. For example World::setUpdateFPS() not World::SetUpdateFPS().
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Wed Dec 30, 2009 3:03 pm

the time slicing is part of the OgreNewt::World

Code: Select all
void World::update( Ogre::Real t_step )
{
   // clean up all pending bodies for update
   for( BodyVectorVector::iterator it = m_bodyUpdateNodeRequests.begin(); it != m_bodyUpdateNodeRequests.end(); it++ )
   {
      for( BodyVector::iterator body = it->begin(); body != it->end(); body++ )
      {

         (*body)->SetNodeUpdateState (false);
      }
      it->clear();
   }


#ifdef _DEBUG
//   Ogre::LogManager::getSingleton().logMessage("   Newton Frame Listener... m_elapsed: "+Ogre::StringConverter::toString( t_step)+
//      "  m_update:"+Ogre::StringConverter::toString(m_update));
#endif

   // clamp thE step if necessary
   if (t_step > (m_timestep * m_maxTicksPerFrames)) {
      t_step = m_timestep * m_maxTicksPerFrames;
   }

   // advance the accumulator;
   m_timeAcumulator += t_step;
   while (m_timeAcumulator >= m_timestep) {
      NewtonUpdate (m_world, m_timestep);
      m_timeAcumulator -= m_timestep;
   }

#ifdef _DEBUG
//   Ogre::LogManager::getSingleton().logMessage("   Newton updates this loop: "+Ogre::StringConverter::toString(count));
#endif


   Ogre::Real param = m_timeAcumulator * m_invTimestep;
//if (param < 0.999)
//param = 1.0f;

   for( BodyVectorVector::iterator it = m_bodyUpdateNodeRequests.begin(); it != m_bodyUpdateNodeRequests.end(); it++ )
   {
      for( BodyVector::iterator body = it->begin(); body != it->end(); body++ )
      {
         (*body)->updateNode(param);
      }
   }
}


it should work smooth at all time and all timestep.
The problesm is teh Ogre does no mangle teh oder of the listeners.
in you systenes you probably get teh Netwon Listener line up at teh end of teh Listener set
until that stuff is fixed it will always behave as if it is random, when it is correct.

the only way to fix that it is by one of these tree things.
1- fixing Ogre
2- Implemnet teh upfate in teh Ogre Event
3- only use ine listenr for teh entore game.

for teh record I do no thonk tshi si a unique bug to OgerNewt, all Ogre application susing mor ethan one lister will have teh hurrent Flaw.
in all the year woraking fo eth Game industry, I's never saw a blonder of that caliber and teh archietect refusing to fix it knowing what the problems is.
and I have maded completed full Game Engines for very Big Companies.

abuot the convection, yes you are right I forget that one, It will be change.
I am trying to keep it the way you guy like, it but I forget that one.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby kallaspriit » Wed Dec 30, 2009 3:23 pm

Smoothness does not seem to have anything to do with framelisteners, I tried modifying Demo01 and also MinimalOgreNewt, the result is the same.

Comment out line 94 of World.cpp:
Code: Select all
if (m_timestep > 1.0f / 60.0f) {
   //m_timestep = 1.0 / 60.0f; //< Comment this out
}


Now it is possible to set timestep that is less than 60FPS. Now set desired FPS to 10 instead of 100 in OgreNewtonApplication::createFrameListener() of Demo01 and run the demo.
Code: Select all
mNewtonListener = new OgreNewt::BasicFrameListener( mWindow, m_World, 10 );


You will see that the graphics are choppy, but I guess it should be smooth with the interpolation?
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Wed Dec 30, 2009 3:41 pm

I just set did this in demo_02
Code: Select all
void OgreNewtonApplication::createFrameListener()
{
   mNewtonListener = new OgreNewt::BasicFrameListener( mWindow, m_World, 10 );
   mRoot->addFrameListener(mNewtonListener);

   mFrameListener = new OgreNewtonFrameListener( mWindow, mCamera, mSceneMgr, m_World);
   mRoot->addFrameListener(mFrameListener);
}

and the FPS is smooth as silk

The function SetUpdateFPS clamp the fps between 60 an 1000
it do not make any diffrnet if you mak eteh low limit leass ths 60 becau se teh Newtpon DLL will cample it

Code: Select all
void World::SetUpdateFPS(Ogre::Real desiredFps, int maxUpdatesPerFrames)
{
   if (maxUpdatesPerFrames < 2) {
      maxUpdatesPerFrames = 2;
   }

   if (maxUpdatesPerFrames > 5) {
      maxUpdatesPerFrames = 5;
   }
   m_maxTicksPerFrames = maxUpdatesPerFrames;

   m_timestep = 1.0f / desiredFps;
   if (m_timestep > 1.0f / 60.0f) {
      m_timestep = 1.0 / 60.0f;
   }

   if (m_timestep < 1.0f / 1000.0f) {
      m_timestep = 1.0 / 1000.0f;
   }

   m_invTimestep = 1.0f / m_timestep;
   m_timeAcumulator = m_timestep;
}

what we can do is that if the FPS is set to less tha 60, the function SetUpdateFPS can re-scale the values so that in meet the desired FPS in multiple of a the Minimun 60 fps the Netwon DLL accept as minimun.
if the required fps is highet than 60 fps then is leaves it like it is now. what do you think about tah ottion.
that way any application can do say ligitimate 10 fps update bu but by making multiple calls.
for example if a game is desgined to run a 30 fps because is heavy on graphics or game logic, then the phisics will do 2 physics update per call.

if you agree I can make that change and submit another update.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Wed Dec 30, 2009 3:55 pm

basically all we nee to do is to modify line 94 of World.cpp to this

Code: Select all
   m_timestep = 1.0f / desiredFps;
   if (m_timestep > 1.0f / 60.0f) {
      // recalculate the iteration count to met the desire fps
      m_maxTicksPerFrames += ceilf (m_timestep / (1.0f / 60.0f));

      m_timestep = 1.0 / 60.0f;
   }


try and see if the physic si ssmooth ate even 10 ffps update, in look fine in my system.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Wed Dec 30, 2009 7:49 pm

Ok I added the changes you mention, plus I added teh start of the Car (just setting up the scene)
I also fix some assets that have wrong UV.
Now the FPS should be smooth at any speed.

The is one more fix to teh Player controller make sure you get 2.16 again for these download
(it will work with the one you have, but there is another fix to the player controller that prevent jitter when the player get into accute angle corners)
you may wna to chet thes in SVN because of the (time slicing fix)

I will continue tomorrow, I am hoppen to get teh Ray cast car going before the week end is out.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby kallaspriit » Thu Dec 31, 2009 4:51 am

Good, I dont have time to update SVN right now, perhaps later today. Keep it up :P
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Fri Jan 01, 2010 12:35 pm

This is where I am so far
http://www.newtondynamics.com/downloads/OgreNewt.rar

I adde dteh beginning of teh Ray cast car plsu few minor thongs,
It is still a work in progress, the car does no drive but I adde dteh framework to complete the system.

I added two car models plus a simple track geomtry, teh same use in the Netwon SDK.

after you check it out if it ok you can mopmmit do SVN so tah it doe no fall too far behind

I also have the fix to smoth SPF even a low sampling (time slicing plus smooth frame intepolation)
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby kallaspriit » Fri Jan 01, 2010 1:46 pm

Sorry I did not respond earlier but I have not had much time behind the computer with all the new-year activities. I made minor changes and updated SVN, please do a new checkout and in the future, try to place the resources in the correct folders - demos\media\primitives should only contain the collision primitives, not models like the car, place those in demos\media\models. Also place .material files in media\materials\scripts and textures in demos\media\materials\textures :wink:

Good work, hope to see the raycast car driving soon :P
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Fri Jan 01, 2010 3:16 pm

Did you check it in?

kallaspriit wrote:try to place the resources in the correct folders - demos\media\primitives should only contain the collision primitives, not models like the car, place those in demos\media\models. Also place .material files in media\materials\scripts and textures in demos\media\materials\textures :wink:


that will be a problem because when I converter file from my format to the ogre format the converter serach for directories relative to a root path whe teh assey is.
in Ogre ther meadia forlder is all wacked because it can read for Promitive or from otherh forder and that makes any exported/importer very hard specially if it deal with sevral docent assets.

so there is not way to export a complex contraction like a vehicle in Ogre?
a vehicle have body, tires, and many other part. you woudl thonk teher tehr woudl be a way to save a Scene Node with it children, enetites an dlink to teh meshes it uses.
plus the should be a way to save animation for nodes. As it stand now the only way to do this is by making the model a skin mesh, but that changes the mesh topology,
as a matter for fact the skeleton format is all wacked because it should be a hierchy of base scene node, instead of the stuff that it is now.
The bod are node but there is no a posibility of a skeleton to be coneted to a SneceNode, is either bone node node deal with skin mesh or a discrete mesh must be and entity controlled by a scene node.
There should no be any different bewten a scen node and a bone node.

plus making every thing skin not only is the most expensive way to have simple meshes it is also limited on the number of nodes you can have.
Ogre could use some serius design re-factoring, as it is now is not unified and it is too fragmented design.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Fri Jan 01, 2010 3:44 pm

awesome, very cool you moved the assets already,
I guess you also need to move the new textures from folder \demos\media\primitives\textures to \demos\media\materials\textures just to be consistent.
I also moved playground.mesh and castle.mes to the media/model subfolder

I'l see how I change my file converter to search script material and texture to the correct folder under media
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby Julio Jerez » Sat Jan 02, 2010 10:13 pm

Ok I have enough changes to add to SVN I think.
http://www.newtondynamics.com/downloads/OgreNewt.rar

-fixed the AABB interface of the Body and Collision to use the same low level function CollisionCalculateFittingAABB I thonk you wrote your self
-added debug display for Joints, now the joing have a method the the end application can define to display any debug info it want, I added default info fo rteh Player controller and for the RayCast car.
-added more funtionality to the Raycast car but it is not functional yet, it can have tire and it rool free ove the terrain.
I want to move on fhe Ray cast car but withpout those basic feature it si too diffcult. It is no wonder I see people having so much difficulty getting anying done.
-I also move the rest of the Texture assets from the promitive forderl to the media/texture folder.

In this demo to get the ball ralling I put 25 cars in the scene (jeep and formula 1)
It may be slow I some low end system but this is just to test how stable it is at low FPS.
I still have to add a lots of funtionality like the Camera, steerring, tire troque, and so on, but I am tire now I will continue tomorrow.

You need to get Netwon 2.16 again because I had to add two methods to the Player joint
CustomPlayerController::GetPlayerStairHeight(void)const
CustomPlayerController::GetStairStepShape(void)const

Thse are nessesary for the debug display.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Custom joints vehicle and weak joints

Postby PJani » Sun Jan 03, 2010 12:16 am

If you are building stuff in debug mode on VC++ then OGRE is very slow.

Anyway will be there any multibody car joint in newton 2?
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron