Fly Tool with Collision Detection

Created:01/10/2003
Description:

This tool mimics the Fly tool available in ArcScene. In order to make it more interactive some features such as flying at constant height, flying within a restricted area and collision detection options have been provided.



How to use:

    Steps for adding a command/tool from a DLL:

  1. Register the DLL: FlyTool.dll.
  2. In the Customize dialog, click on 'Add from file' and select this sample's dll.
  3. Select the command 'Fly with Restrictions' from the Restricted Fly Tool Category on the Commands tab. Drag and drop it to the desired location on ArcScene's user interface. Dismiss the Customize dialog.

    Using the Tool:

  1. Load all the data in the scene you intend to use, and set up any base heights and extrusion options for the data on the layer's property pages.
  2. To use the Fly tool, click on the tool you just added.
  3. Click on the left mouse button to start navigating in the scene.
  4. The left and right mouse buttons control the speed of flying. A single click of the left mouse button or right mouse button increases or decreases the speed by one unit, respectively.
  5. For providing restrictions to the fly tool, reduce the speed to zero and make sure that the scene is still.
  6. Select the layer in the TOC to be considered as the base surface. You can change this later on.
  7. Press the key 'k' on the keyboard. A dialog box pops having three mutually exclusive options for controlling the navigation in the scene.
  8. For flying at a constant height above the selected layer in TOC, enter a value of the height in the textbox provided in 'Constant Height Flight' frame.
  9. Select Zmin, Zmean, or Zmax to specify the base height for the flight. For example, if you choose Zmin and enter a value of 100 as the height, the flight height = Zmin (of the layer) + 100.
  10. After you specify the desired flying options, start navigating in the scene and you will notice that the flight height is fixed and you cannot move up/down in the Z direction.
  11. The second restricted flying option 'Fly Within Specified Extent' is essentially like flying within a bounding box. The user can choose the X, Y, and Z bounds from the selected layer in the scene by clicking on the 'Choose from Layer' checkbox. If desired, the user can enter also the values in the textboxes provided to create his/her own X, Y, Z bounds for navigation.
    NOTE: In case of a layer without Z's, enter values for the Zmin and Zmax keeping in mind that Z for a 2D layer is zero.
  12. The user also has the option to navigate in the scene without any Z bounds. This can be done by clicking on the 'Exclude Z Constraints' checkbox.
  13. In order to specify the behavior after the collision with any of the bounding box walls, an option from the 'Options after Collision' frame need to be checked.

    If the first option i.e., 'Bounce Back' is chosen, the observer will bounce back as soon a hit with the X, Y, or Z wall is detected.
    NOTE: that the speed becomes negative when using the 'Bounce Back' option. So, in order to move further, the speed needs to be adjusted accordingly.

    If the second option i.e., 'Stand Still' is chosen, after a collision is detected, the observer comes to a halt (speed = 0).Now, in order to navigate further, the speed needs to be increased by clicking the left mouse button and choosing a desired direction for flying.
    NOTE: You may have to click the left mouse a number of times to increase the speed for navigating again.

  14. For using the third option i.e., 'Collision Detection', there are two options to choose from.

    If a collision with the surface of a layer needs to be detected, the first option 'With Surface' in the 'Collision Detection' frame needs to be checked. A certain tolerance needs to be provided in order to detect the collision with the surface. The tolerance essentially acts as a buffer zone around the surface layer. As a general rule for smooth working of the tool, the higher the speed, the higher should be the tolerance specified. Internally, this option makes use of the ISurface:GetElevation property to detect the collision. This option does not work for layers without any Z values attached.

    If a collision with anything present in the scene needs to be detected, the second option 'With Anything' in the 'Collision Detection' frame needs to be checked. Internally, this option makes use of the IScenegraph:Loacte method to detect the collision. This option works fine for both 2D or 3D layers. This method is slower than the ISurface:GetElevation method.

    NOTE: For the after collision behaviour, both the 'Bounce Back' and 'Stand Still' options are available for the 'With Surface'collison detection. But, for the 'With Anything' collision detection, only the 'Bounce Back' option is made available.

Application:
ArcScene

Requires: An ArcScene session with a surface layer to fly over.

Difficulty: Intermediate


Visual Basic
File Description
clsFlyTool.cls Implementation of ICommand and ITool for FlyTool class.
FlyByfrm.frm Form which presents the user interface for restricted flying options.
GeneralFunctions.bas Module containing some general functions used in the project.
PublicVariables.bas Module containing public variables declarations.
FlyFunctions.bas Module containing functions necessary for navigation and collision detection in the scene.
FlyTool.vbp Visual Basic Project file for the tool.
FlyTool.dll The compiled DLL containing the implementation of the Fly Tool.


Key CoClasses: Vector3D
Key Interfaces: ICamera, IEnvelope, IMessageDispatcher, ISceneViewer, ISceneGraph, IStatusbar, ISurface
Key Members: ICamera::Observer, ICamera::Target, ICamera::RollAngle, IMessageDispatcher::Dispatch, ISceneViewer::Camera, ISceneGraph::Locate, ISceneGraph::RefreshViewers, IStatusBar::Message, ISurface::GetElevation