Modifying the behavior of osgART::ARTTransform

From ARToolworks support library

Jump to: navigation, search

Main Page > osgART > Modifying the behavior of osgART::ARTTransform

One frequently asked question when using osgART is how to change the default behavior (as seen in the osgART examples) when a marker first comes into camera view or when a marker disappears from camera view. In the examples, any models associated with the marker will appear and disappear on these events. How do you change this? Read on....

First, it is helpful to understand how this default behavior actually occurs; The example codes creates a scene graph where underneath the root of the graph sit nodes of type osgART::ARTTransform. These nodes are subclassed from osg::MatrixTransform. Underneath each of these nodes is attached the actual model. The ARTTransform implements an OSG Node Callback which gets called as the scene graph is traversed. The behavior of this callback is what updates the model's pose with the pose of the actual marker, and it also activates/deactivates all its child nodes if the marker is visible/not visible. As you can see in the example code, the constructor for ARTTransform takes a parameter which is the Marker which the transform node should watch for updates.

So, modifying this behavior is simply a matter of doing things a little differently from the example programs. You have a few options:

  • Don't use an osgART::ARTTransform node in your scene graph at all. Use a regular osg::MatrixTransform, and in your runloop, update the MatrixTransform manually (by inspecting whatever markers you wish to, or even none at all.)
  • Use an osgART::ARTTransform node in your scene graph, but create your own callback to do the updating. You can base your callback on the implementation of class ARTTransformCallback in file src/osgART/ARTTransform.cpp. (Isn't it nice that you've got the sourcecode?). You can then change the behaviour to do something like wait a while after the marker becomes invalid before deactivating child nodes, or even examine other markers altogether.
  • Create your own subclass of osg::MatrixTransform and use that in place of osgART::ARTTransform.

The exact method you choose will depend on what you are doing with markers in your AR application, and how you want the behaviour of markers to affect the position and appearance of models in your application. If you have more questions, ask on the forum. http://www.artoolworks.com/community/forum/.

Views
Personal tools