wiki:visual_object

visual_object

Introduction

All objects in the 3D scene are nodes of the scenegraph. Besides the object management via controlling all object nodes manually, osgVisual provides a module for objects with convenience function for common tasks.

The module "visual_object" allows to manage objects in the scene, with fixed or dynamic position. An visual_object can be positioned in latitude, longitude and altitude, as well in rotations along all three axis. The object itself is not visible, it only provides the functions for managing the object. By adding text labels or geometries, it is visible in the scene.

If you want to specialize visual_object for more specifiy usage, subclass visual_object and add your new convenient values and calculations, e.g.:

  • visual_aircraft
    • Add gear : extraction_value
    • Add light : navigationlight_value
    • Add propeller rpm : prop_rpm_value

Overview Convenience Functions

visual_object provides the following convenience variables / functions for simple usage of objects in osgVisual:

  • positioning in lat, lon, alt (position)
  • rotating along all 3 object axis (attitude)
  • scaling along all 3 axis
  • loading/unloading 3D geometry
  • setting geometry rotation offset, if 3D model has wrong axis orientation
  • setting geometry translation offset, if 3D model has wrong coordinate frame origin
  • setting camera translation offset (used by node attached camera manipulator)
  • setting camera rotation offset (used by node attached camera manipulator)
  • adding/removing object_updater (see object updater for further information)
  • adding/removing label (see object labels for further information)

Units

The units used to configure visual_objects are meters and degree.

Technical Implementation

This description does not replace the dive into the source code, it should give you only a short overview how it works.
Please read the doxygen documentation of all function calls: http://www.osgvisual.org/documentation/trunk/

Basically, a visual_object is a subclass of a simple osg::MatrixTransform node which has the geometry as child node.
Additionally it contains variables and their setters/getter for all specified convenient functions.

The Matrixtransform has several children which are matrixes or drawables to provide the functionality:
visual_object_architecture.png

The core functionality is an update callback (installed on the visual_object class by its initializer), which transforms the specified object properties to the corresponding matrices:

  • lat/lon/alt via OSG'S ellipsoid model and its computeLocalToWorld() to the objects transform matrix.
  • scale values to the scaling matrix.
  • camera values to the camera matrix.
  • geometry offset values to the object matrix.

The object updater and label functions are not updated every frame by a seperate callback, they are just invokes from update functions of the visual_object, which are initiated the visual_objects update callback.

Object labels

It is possible to attach text labels to objects, e.g. for descriptions. osgVisual provides convenience functions for label management:

  • Adding label (id, message, color and offset to object).
  • Removing labels.
  • Remove all labels.
  • Updating label text.
  • Configure label as overlay/no overlay (draw it without/with depth test).
  • Get pointer to label.

Labels are osgText::Text labels. For further configuration besides the convenience functions retrieve the pointer of the label and configure it like osgText::Text.

Object updater

tbd

To allow flexible updates of visual_object or derived classes (short: object), an object_updater can be attached to a object. Update are also attachable to other updaters, so updater chains are possible to create.

Last modified 14 years ago Last modified on Jan 24, 2011, 8:33:46 PM