Navigation Utilities ImplementationThe navigation utilities code come from a wide range of capabilities. The main area of interest from an implementation perspective is how we move the viewpoint in response to commands from the mouse and keyboard.
Navigation provides a number of different modes. Within each mode you can have the ability to do terrain following and/or collision avoidance. For collision avoidance and terrain following, we will refer you to the tutorial on the main site as the process is described there. The one footnote to add is that we use the geometry intersection tools from this library.
The terrain following is based on a generalised collision detection system. As we have to build a completely generalised system we cannot use more specialised code. In fact, we recommend that if you can build a specialised scenegraph for your application that it will be more efficient than this code.
Determining Frame Delay AmountsThis section is provided by Lazlo about how he came up with the numbers in the code for calculating the frame delays for movement.
The goal is to increase frame-rate as much as possible on a Canvas3D. The main question is when should I ask a Canvas3D to render a new frame?
First guess would be:
long approximateTimeForNextFrameDuration= view.getLastFrameDuration();I wrote a small test program to find the maximum possible frame-rate for a scene with a few iterations. It measured the elapsed time in the rendering loop, then set a timer which triggered the Canvas3D rendering. When it found the optimal value it printed it. After examining the resulting values compared with the
My first navigation module worked with this iterating algorithm. Then I got tired of it and decided to find the function that is the most closest to the iterating algorithm's result, so I might even gain more performance with not doing the iteration, but loose some timing accuracy.
Just think of it! If you turn around in a scene and in a corner of the room there is a messy heavy object, but the other end is empty (You should see my flat!), then the iterating algorithm really has a job to do and some frames will not be shot with the best possible timing until the algorithm settles.
The function that fitted the best was this:
timerDelay = 10 + (int)view.getLastFrameDuration() / 2;
WHY /2.0 ???
I do not understand this function, but it gave me the best results ever.
Then I tested it with different video cards and platforms and operating systems. They all gave the same results. Actually the value 10 could be smaller for faster PCs, but 10 worked for all and 10ms is not much.
[ Home ]
[ License ]
[ javadoc ]
[ Online Examples ]
[ Download ]
[ j3d.org ] [ Aviatrix3D ] [ Code Repository ] [ Java3D ] [ OpenGL ] [ Books ] [ Contact Us ]
Last Updated: $Date: 2010-01-27 21:36:00 -0800 (Wed, 27 Jan 2010) $