QtLargeModelViewer - demonstrates adaptive viewing and simplification
QtLargeModelViewer
The QtLargeModelViewer program is a demonstration of the adaptive viewing, simplification, and ordering traversal techniques in Open Inventor.
File Menu
The File menu items allow you to load scene files in the Qt Large Model Viewer.
- Open - Clear the current scene and load a new scene.
- Reload - Clear the current scene and reload the last file previously loaded with the Open command.
- MRU list - List of the files most recently loaded with the Open command.
View Menu
The View menu allows you to change the viewer type, activate collision detection and gravity when in a Walk viewer, set stereo and stereo parameters, adjust adaptive viewing parameters, select the transparency type, and turn on and off various display options.
- Stereo - Turn stereo on and off.
- Stereo Settings - Set the type of stereo (Red/Cyan, raw, etc.), the zero parallax balance, and the camera offset.
- Adaptive Viewing - This item will display a dialog box to control the scene complexity through the new decimation elements. There are four radio buttons for choosing the strategy the viewer should use:
- Normal - Do not control the decimation element; works the same as previous versions of Open Inventor.
- Fixed Number of Triangles - The viewer will use a GetPrimitiveCountAction to find how many triangles are in the scene, and then adjust the decimation element so that the number of triangles rendered remains constant.
- Frames Per Second - The viewer will time each render traversal and then adjust the decimation element to keep the render time close to the desired frame rate.
- Fixed Percentage - The same decimation percentage will always be used. In addition, the DecimationType element will be set to PERCENTAGE, so that SoLOD and SoLevelOfSimplification nodes will choose a child based on the DecimationPercentage element alone, without looking at the camera position. Because the LOD node is no longer dependent on the camera position, its GL calls can be cached and may result in quicker rendering.
- Do Full Rendering When Still - This check box tells the viewer to render at 1.0 decimation (full detail) when the scene is still. This allows you to interact with the scene at a lower decimation, and then see all of the details when done.
- Disable GL Normalize - This item, if turned on, disables the OpenGL GL_NORMALIZE flag. This can be used to increase the rendering speed for scenes that do not contain modeling scale factors (e.g., SoTransform scaleFactor field). If the model contains scale factors, then these parts may be too bright or too dark. Often, using the ReorganizeAction (under the Processing menu) will remove the scale factors, allowing you to disable GL_NORMALIZE for increased performance. (Try, for example, the data/models/vehicles/kittyHawk.iv file; the engine will be too bright if GL_NORMALIZE is disabled).
- Transparency - Choose the type of transparency to use if any object has a transparency greater than 0.
- Alpha Test - Enable or disable the OpenGL alpha test for rendering.
Traversal Menu
The Traversal menu allows you to experiment with the new ordering nodes derived from SoRenderList. This menu alters the type of grouping node kept above the loaded scene. This node is kept below the lights and camera, but above the actual geometry. The default option is SoSeparator, which will result in the usual traversal behavior. The other options use an SoValueOrdering node, an SoOctreeOrdering node, or an SoOcclusionCulling node.
- Value Ordering - This item will insert an SoValueOrdering node at the top of the scene graph. It works well with assemblies where there are many parts of various sizes. This node also allows you to use the Adaptive Viewing techniques on scenes that normally would not respond to the Decimation element, if, for instance, there are no LODs in the scene.
- Octree Ordering - This item will insert an SoOctreeOrdering node at the top of the scene graph. In contrast, this node provides better results in spatially large scenes, where the viewer moves through the scene instead of around it. The SoOctreeOrdering node organizes the shapes spatially into an octree, which allows it to quickly cull large regions of space that will not be within the view frustum.
- Octree + Occlusion - This item will insert an SoOctreeOrdering node followed by an SoOcclusionCulling node, combining the effects of these two nodes.
- Occlusion Culling - This item will insert an SoOcclusionCulling node at the top of the scene graph. SoOcclusionCulling uses the functionality from SoRenderList to create a list of paths to the shapes beneath it. It then reorganizes the list of shapes from front to back to perform an OpenGL-based occlusion culling test. The result is that render objects completely hidden by another visible object are not rendered. For instance, if the camera is inside an object, only the object containing the camera will be drawn (because that's the only object that the camera can see). The SoOcclusionCulling node depends on the graphics board having support for the OpenGL GL_OCCLUSION_TEST_HP extension. If this OpenGL extension is not supported, the SoOcclusionCulling node will have no effect on the display of the scene graph. Notice that after reorganization, some small shapes that are far away from each other will be grouped into one large shape. This will prevent the Ordering nodes from drop culling effectively. If you are curious how the shapes are grouped, try changing the draw style to Bounding Box with the right mouse button menu. The same is true for GlobalSimplify because it groups together all of the shapes. However, the ordering nodes should work well with the ShapeSimplifyAction.
- Edit Traversal Parameters - This menu item brings up the Traversal Tuning dialog box. The parameters associated with each of the traversal types can be edited.
Processing
The Processing menu allows you to apply actions to the loaded scene. This menu is only available if a scene is loaded. Note that you can only simplify the scene once. If you want to try a different simplify technique on the same scene, you will have to reload the original file again.
- Load Inlines Immediately - If checked, Inline nodes (SoWWWInline and SoVRMLInline) will be read in immediately instead of having loading delayed for processing during idle time.
- Find VRML 2.0 Animations - If checked, the scene graph is searched for SoVRMLTimeSensor nodes. The nodes affected by the VRMLTimeSensors are named so that the Ordering nodes can treat the moving parts as special sub-graphs in order to improve performance.
- Reorganize (triangle strips) - This item applies an SoReorganizeAction with the generateNormals and generateTriangleStrips flags set to TRUE. The result is similar to the ivfix utility program result. In files with no Inlines or LOD nodes, this will group shapes by material and texture, and then convert the shapes into SoIndexedTriangleStripSet nodes. The reorganized scene graph should render more quickly, although the effects will be more noticeable on hardware-accelerated graphics boards. Notice that the Triangle-Stripping algorithm has been improved in version 2.5 (and higher), so if you have used ivfix before and were unsatisfied, be sure to try it again now.
- Shape Simplify - This item applies an SoShapeSimplifyAction with an SoDecimator as simplifier, three levels of simplifications (1, 0.3, and 0.1), and the minimum number of triangles set to 20.
- Global Simplify - This item applies an SoGlobalSimplifyAction with an SoDecimator as simplifier, three levels of simplifications (1, 0.3, and 0.1), a size factor of 4, and the minimum number of triangles set to 20.
- Shape Simplify (triangle strips) - This item does the same as the Shape simplify, and then each of the simplified shapes are organized into triangle strips.
- Global Simplify (triangle strips) - This item does the same as the Global simplify, and then each of the simplified shapes are organized into triangle strips.
- Split Shapes - This item displays a dialog box allowing you to set the parameters of an SoSplitAction to be applied on the scene graph.
Viewpoints
The ViewPoints menu allows you to change the camera position to one of the viewpoints contained in the scene graph. This menu is only available if VRML viewpoints are present in the loaded scene.
Animations
The Animations menu allows you to animate the camera in the scene, if the scene has an LMV_ANIM sub scene graph. An LMV_ANIM sub scene graph consists of a separator node called "LMV_ANIM" which contains an SoTransform node (whose name is the name of the animation) and a sub scene graph for the moving object.
The menu allows you to select an LMV_ANIM to follow, i.e., the SoTransform node translation and rotation fields are used as a reference for the camera, even if they are changing due to an engine connection. The Animations menu also has items to select various viewing options:
- Free View - This item allows you to turn around the moving object using the left mouse button and to go closer to or farther from the object using the middle mouse button. Note: You must be using selection mode (i.e., using the arrow cursor).
- Point At Object - This item orients the camera to point to the center of the SoTransform node. If it is not checked, then the camera points in the same direction as obtained from the orientation field of the SoTransform node.
- Roll With Object - If this item is not checked, the up vector of the camera doesn't change with the SoTransform node orientation field.
- Show Object - If this item is not checked, the nodes following the SoTransforms under the LMV_ANIM separator are removed from the scene graph.
SpaceMouse / SpaceBall
The QtLargeModelViewer supports SpaceMouse/SpaceBall devices. Support and drivers for the SpaceMouse/SpaceBall are available at: www.3dconnexion.com.
By default, you are in rotation-only mode. You can use the mouse buttons to change the mode or perform other actions, as shown:
- 1 - Rotation-only mode
- 2 - Translation-only mode
- 3 - Translation and rotation mode
- 4 - Reset to home: because of the way the SpaceMouse is handled by Open Inventor, the viewer's reset to home button will not work. You must use this button instead.
- 5 - Increase rotation scale factor
- 6 - Decrease rotation scale factor
- 7 - Increase translation scale factor
- 8 - Decrease translation scale factor
Source code to QtLargeModelViewer is in $OIVHOME/src/Inventor/examples/Qt/QtLargeModelViewer.
QtLargeModelViewer [-Pfilename] [infile]
filename is the name of an Open Inventor configuration file. infile is the scene file to open.
The configuration file can contain any of the standard Open Inventor configuration parameters, plus any of the following additional configuration parameters, which are specific to the QtLargeModelViewer:
- LMV_VIEWER_TYPE - Specifies the initial viewer type. Valid values are EXAMINER, WALK, FLY, and PLANE.
- LMV_TRAVERSAL_TYPE - Specifies the initial traversal type. Valid values are SEPARATOR, VALUE_ORDER, OCTREE, OCCLUSION, and OCTREE_OCCLUSION.
- LMV_GRAVITY_OFFSET - Specifies the altitude at which the camera will be considered to be on the ground.
- LMV_TRACK_TO_FOLLOW - Index of the track to follow once the file is opened (starting at 0).
- LMV_TRACK_VIEW - Specifies the initial track viewing type. Valid values are INSIDE, FROM_BEHIND, TOP, and FREE.
$OIVHOME/data/LargeModel/*
The "formula1" example contains many SoLOD nodes, so the best method would be to use the DecimationStrategy dialog to set the desired level of detail, and leave the Traversal as "Separator". This would also be the case for files output from the Simplification demo programs.
The Harley.iv file contains many parts, but does not contain LOD nodes, so the ValueOrdering node can be used to allow the scene to be decimated through bounding boxes and drop culling of individual shapes, or a simplify action can be applied.
The directory "allModels" under "data/models", uses WWWInlines to link the other example files into one scene. Each file represents a directory under data/models. The file "allModels.iv" joins these files into one large scene. This can be used as an example for the OctreeOrdering node.
$OIVHOME/data/models/toys/TrackSample/*
These files contains LMV_ANIM sub scene graphs. Load animation.iv to exercise features of the Animations menu. The actions (View from Top, etc.) apply to the selected item, not to the entire scene.
ivfix, Large Model Viewing Overview, SceneViewer, SoGetPrimitiveCountAction, SoGlobalSimplifyAction, SoLevelOfSimplification, SoLOD, SoOctreeOrdering, SoRenderList, SoReorganizeAction, SoShapeHints, SoShapeSimplifyAction, SoSimplifyAction, SoValueOrdering, SoWinViewer