VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
8. 1 - 2D Window Object API

Table of Contents

The window object API supports the drawing of multiple 2D graphical objects and text on screen.

The API implements a parenting system similar to a scene graph, and is maintained outside of OSG in vrvCore.

All of the window objects described have agent implementations. exampleWindowObjects and exampleWindowObjectHud show how to use them.

8.1.1 Objects

DtWindowObject - is the base class for all of the following window objects. It has no OSG implementation.

8.1.2 Parenting

A DtWindowObject holds a child list of DtUniqueIDs, all of the above window objects can be attached to each other using addChild. Although DtWindowObject has no OSG implementation, one can be created to hold a number of objects for control through a single object; this is also the concept behind surfaces.

DtWindowObject::needsUpdate processes its own child list, and calls needsUpdate on them. It also gets information from its own parent that it needs to update specific member variables, more on this below.

8.1.3 Surfaces

The concept of surfaces is that 2D objects can be drawn "on" them, when really they inherit from DtWindowObject and behave like any other window object with a few exceptions.

DtWindowSurface defines a section of the screen that window objects can render within. This is done by setting a clipBox that will clip window object vertices that extend past the edges of the box. Clip boxes are defined in normalised screen coordinates on a per channel basis using two coordinates, a bottom left 2D Vector and top right 2D vector (setClipBox method).

Surfaces should be top level objects. In DtWindowObject::needsUpdate an object will get the clipBox information from its parent and set it to its own myClipBox member variable; this way the information is passed down through the hierarchy.

virtual void setSurfaceCoordinateExtents( float minU, float minV, float maxU, float maxV );

The UV coordinates passed into setSurfaceCoordinateExtents allow for a sub coordinate system "on" the surface. For example: the screen is 0.0->1.0, the surface clipbox can be from 0.25->0.75 but you may wish to represent the 0.25->0.75 as 0.0->1.0. The scale and origin or position of the surface uses these values (from the setClipBox method):

scaleX = ( TopRight.x - BottomLeft.x ) / ( MaxU - MinU )
scaleY = ( TopRight.y - BottomLeft.y ) / ( MaxV - MinV )
originX = BottomLeft.x - ( MinU * scaleX)
originY = BottomLeft.x - ( MinV * scaleY)

A DtWindowEntityAttachedSurface allows for surfaces to move around the screen and track an entity's position. A user can set the entity ID on the surface, and the surface will update its own clipBox information in needsUpdate(). As the clip box is constantly updating, the clipbox is specified as a width and height in normalised screen coordinates (setSurfaceWidthHeight). A user can also set offsets from the entity position that are added to the entity position before the position is projected to the screen (setOffsets).

Note that for a DtWindowEntityAttachedSurface a user must set the channel that the surface is to be located by either using - setChannel( DtChannel* channel ) or setChannelOverlay( std::string displayName, std::string windowName, std::string channelName )

8.1.4 Channels

By default all channels are ceated with the "showRemoteGraphics" keyword, any window objects created will be shown on all channels with this keyword. When removing the keyword from channels, is it recommended to save the display settings as a .dcx file, and restart vrVantage.

In order to render specific objects on specific channels, a user must remove this keyword from the channel, and call setChannelOverlay. Note that this does not work for remote displays.

setChannelOverlay only needs to be called on the top level parent object, it will traverse the child list and update their channels too.

8.1.5 Transforms

Each window object has a position, rotation and scale, these are combined into a transform matrix (relative transform) in needsUpdate. If the object has no parent, this transform is set as myWindowTransform, the final transform for the object. If the object has a parent the relative transform matrix is multiplied by the parent objects myWindowTransform, to give its own final window transform.

Non-uniform scales are supported. However, if a user sets a surface as a base level window object, with non-uniform scales, then proceeds to attach children and rotate the child, they will get shear/skewing of the child object. This is a product of parent / child matrice hierarchies. This limitation is expected.

8.1.6 Objects

[<< Attributes] [Home] [Top of Page]


Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)