|
Using the Navigation UtilitiesThe navigation utilities code come from a wide range of capabilities. You may just use simple mouse orientation capabilities to a full navigation system that includes user interface components, cursor changing and more.PhilosophyNot everyone wants to do their navigation the same way. However, for a lot of cases a set of simple capabilities that just works as expected is really useful. That's the aim of the navigation utilities - to provide a componentised navigation framework that allows you to decide how you are going to add and display navigation to the end user. You may have everything from simple processing of mouse events passed to you, to full cursor changing and Swing GUI toolbars.The original impetus for this code came from a donation from the Halden VR center, Institute for Energy Technology. This provided a very simple VRML based framework for loading and navigating VRML worlds. With this very basic capability, we have extended the code to work with many more navigation modes. All of the modes presented here follow the VRML standards - FLY, WALK, EXAMINE etc.
Setting upSetup for the navigation utilities depends on the capabilities that you require.Code and ClasspathFirstly, you need to import the right package. Everything is contained in the org.j3d.ui.navigation package.If you wish to use any of the other tools such as toolbars and cursors, then you will also need to make sure that the config/images directory is in your classpath. Currently the makefiles do not build a JAR file with the images in it, so you have to either build one by hand or make the classpath point in the right direction. Simple Navigation UtilitiesFor this level, we are assuming that you want to use the raw navigation tools with none of the user interface. This means you have the choice of creating your own input handler and passing the events directly to the NavigationHandler or using AWT based behaviors with MouseViewHandler or Java3D based Behaviors with MouseViewBehavior
To set up for using the raw handler, you create an instance of
To use AWT based information, create an instance of
To use Java 3D based behaviors, create an instance of
Navigation ModesNext we need to choose what modes we would like to navigate in. This list shows you all of the options available. You can set any mouse button to using these modes. It is quick fine to have button 1 set to walk, button 2 to fly and button 3 to examine for example.
Setting up view informationBefore we can navigate around the scene you must provide the system with something to actually manipulate. For maximum flexibility, the code requests aTransformGroup rather than a ViewPlatform . There
are two reasons for this - firstly to move the camera around the scene you
will need a transform group anyway and secondly, you may acutally want to
move something other than a view around (eg other objects or have the
view deeply embedded in a HUD structure).
The other item required for view information is an instance of a
To disable navigation handling all you have to do is remove the transform
and view by calling the Providing geometry for navigationIf you intend to use one of the states that uses collision detection or terrain following then you need to provide us with information about what we can collide with and what is terrain. For performance reasons, we allow you to provide two different scene graph structures for collisions and terrain following.
To set the structures for collisions and terrain, you use the
navHandler.setWorldInfo(terrain, walls);Any geometry that is not part of either of these groups will not be used in any calculations. That allows you to build parts of the scene that the user can walk through and parts that are solid with no additional effort. Using User InterfacesTBD
Moving AboutOnce you have set the system up, all of the navigation is self contained. Internally events are recieved and the code will update the view transforms to automatically move the view transform according to the selected navigation mode. There are also controls over how and what functionality is to be used.Mouse Actions to move aboutThe user interface to move about rely on click and drag actions. To initiate a move you press the mouse button down. To move in a given direction, drag the mouse in that direction. The amount that you drag the mouse relative to it's starting position determines the speed to move at. A small drag will cause slow movement, while a large drag will cause fast movement. Holding the mouse steady with the button pressed will have a constant speed. Once you release the mouse, the movement will stop.Selecting a navigation modeNavigation modes are selected with thesetButtonNavigation()
method. This method takes the button that we want to use and the
navigation state that you want to use.
The button to use is one of the values defined in
navHandler.setButtonNavigation(MouseEvent.BUTTON1_MASK, NavigationState.WALK_STATE);This means that whenever button 1 is pressed on the mouse we will move around according to the rules of the WALK state - ie terrain following and collision detection. Disabling FunctionalityIf you decide that you don't want to have one of collision detection or terrain following, then you can disable it fairly easily. As thesetWorldInfo() method does the setup of the scenegraph used
for these operations, it can also be used to disable it. If you provide
a null parameter value then that action will not be used. For
example, if there is no terrain branchgroup provided we will not perform
terrain following.
|
[ 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) $ |