GL Studio SCECpp Runtime Library
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GlsDisplayObject Class Referenceabstract

#include <gls_display_object.h>

Inheritance diagram for GlsDisplayObject:
GlsCompositeObject GlsRenderObject GlsComponentBase GlsGroup GlsPolygon GlsText GlsTriangleMesh GlsOdometer GlsTextBox GlsTextGrid

Classes

struct  InitParameters
 
struct  PickRegion
 

Public Types

enum  ObjectType { OBJECT_TYPE_COMPOSITE, OBJECT_TYPE_RENDERABLE }
 
enum  PickMode { PICK_MODE_NEVER, PICK_MODE_FIRST, PICK_MODE_ALWAYS }
 

Public Member Functions

virtual void Draw (GlsStateManager &gl, const GlsFloat64 time)=0
 
virtual void Calculate (const GlsFloat64 time)
 
virtual GlsDisplayObjectPickTest (const GlsVector2D &windowCoord, GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
GlsDisplayObjectHandleEvent (GlsEvent &event)
 
ObjectType GetObjectType (void) const
 
void SetBlinking (const GlsBool blinking)
 
void SetBlinkRate (const GlsFloat32 blinkRate)
 
void SetDynamicRotation (const GlsVector3D &dynamicRotation)
 
void SetDynamicScale (const GlsVector3D &dynamicScale)
 
void SetDynamicTranslation (const GlsVector3D &dynamicTranslation)
 
void SetVisibility (const GlsBool visible)
 
void SetParent (GlsDisplayObject *const parent)
 
void SetPickMode (const PickMode pickMode)
 
GlsBool NeedCalculate (void) const
 
void InvalidatePickCache (void)
 

Protected Member Functions

 GlsDisplayObject (const InitParameters &initParameters, const ObjectType objectType, GlsEventDispatcher *const eventDispatcher)
 
virtual ~GlsDisplayObject ()
 
GlsBool CalcDrawMatrix (const GlsMatrixAffineD *const additionalTransform, const GlsBool includeLocation)
 
virtual void CalcWindowPickRegion (GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
GlsBool IsBlinkedOff (const GlsFloat64 time) const
 

Protected Attributes

const GlsMatrixAffineD _dcsMatrix
 
const GlsMatrixAffineD _dcsMatrixInverse
 
const GlsBool _dcsMatrixIsIdentity
 
const GlsVector3D _location
 
const GlsBool _needCalculate
 
const ObjectType _objectType
 
const PickRegion _pickRegion
 
GlsEventDispatcher *const _eventDispatcher
 
const GlsVector3D _rotationPoint
 
GlsBool _blinking
 
GlsFloat32 _blinkRate
 
GlsMatrixAffineD::GLMatrixAffineF _drawMatrix
 
GlsVector3D _dynamicRotation
 
GlsVector3D _dynamicScale
 
GlsBool _dynamicScaleIsUnity
 
GlsVector3D _dynamicTranslation
 
GlsBool _needCalcDrawMatrix
 
GlsBool _visible
 
PickMode _pickMode
 
GlsBool _windowPickRegionValid
 
GlsVector2D _windowPickLowerLeft
 
GlsVector2D _windowPickUpperRight
 
GlsVector2D _windowPickUpperLeft
 
GlsVector2D _windowPickLowerRight
 
GlsMatrixAffineD::GLMatrixAffineF _pickMatrix
 
GlsDisplayObject_parent
 

Detailed Description

Base Class for all graphical objects. It is an abstract class. All drawn objects are derived from this class.

Invariant
_dcsMatrix.Invariant(), _location.IsValid(), GlsDisplayObjectTypeIsValid( _objectType ), GlsDisplayObjectPickModeIsValid( _pickMode ), _pickRegion.IsValid(), _rotationPoint.IsValid(), _blinkRate > 0.0f, _drawMatrix.Invariant(), _dynamicRotation.IsValid(), _dynamicScale.IsValid(), ( _dynamicScale.x >= 0.0f ) && ( _dynamicScale.y >= 0.0f ) && ( _dynamicScale.z >= 0.0f ), _dynamicTranslation.IsValid()

Member Enumeration Documentation

Enumeration for possible base object types

Enumerator
OBJECT_TYPE_COMPOSITE 

Object is derived from GlsCompositeObject

OBJECT_TYPE_RENDERABLE 

Object is dervied from GlsRenderObject

Enumeration for possible pick modes

Enumerator
PICK_MODE_NEVER 

Picking will be disabled for this object

PICK_MODE_FIRST 

Picking is based on draw order only. The first geometry hit wins.

PICK_MODE_ALWAYS 

Picking will ignore geometry of this object, and always return a pick as if hit. This is still only found through normal draw order traversal.

Constructor & Destructor Documentation

GlsDisplayObject::GlsDisplayObject ( const InitParameters initParameters,
const ObjectType  objectType,
GlsEventDispatcher *const  eventDispatcher 
)
protected

Constructor for display objects. Invoked by constructors of derived classes.

Parameters
initParametersinitialization parameters
objectTypeobject type for this object
eventDispatcherevent dispatcher for this object else GLS_NULL
Precondition
initParameters.IsValid(), GlsDisplayObjectTypeIsValid( objectType )
Postcondition
object is constructed and initialized
virtual GlsDisplayObject::~GlsDisplayObject ( )
protectedvirtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

GlsBool GlsDisplayObject::CalcDrawMatrix ( const GlsMatrixAffineD *const  additionalTransform,
const GlsBool  includeLocation 
)
protected

Recalculates the _drawMatrix if needed If _dynamicRotation, _dynamicScale, or _dynamicTranslate change you must call CalcDrawMatrix()

Parameters
additionalTransformadditional transform to apply to calculated draw matrix else GLS_NULL for no addition transform
includeLocationGLS_TRUE to include contribution from _location else GLS_FALSE
Returns
GLS_TRUE if draw matrix was recalculated else GLS_FALSE
Precondition
none
Postcondition
_drawMatrix is recalculated if needed
virtual void GlsDisplayObject::Calculate ( const GlsFloat64  time)
virtual

Provides a mechanism for performing regular calculations, separate from drawing. In a standalone applicaton Calculate is recursively called by the main loop before the objects are drawn.

Parameters
timeThe elaspsed time in seconds since program start
Precondition
time >= 0.0
Postcondition
calculations (if any) completed

Reimplemented in GlsComponentBase, and GlsGroup.

virtual void GlsDisplayObject::CalcWindowPickRegion ( GlsInputManager inputManager,
const GlsMatrixAffineD::GLMatrixAffineF parentDrawMatrix 
)
protectedvirtual

Recalculates the window picking region if needed

Parameters
inputManagerinput manager managing input for this object
parentDrawMatrixdraw matrix used when rendering parent object
Precondition
_needCalcDrawMatrix == GLS_FALSE (_drawMatrix is up to date)
Postcondition
_windowPickLowerLeft, _windowPickUpperRight, _windowPickUpperLeft, _windowPickLowerRight and _pickMatrix are recalculated if _windowPickRegionValid == GLS_FALSE,
virtual void GlsDisplayObject::Draw ( GlsStateManager gl,
const GlsFloat64  time 
)
pure virtual

Draws this object. Pure virtual method

Parameters
glGL State manager for OpenGL into which object is drawn
timethe elaspsed time in seconds since program start
Precondition
time >= 0.0
Postcondition
object is drawn to OpenGL if visible and not blinked off

Implemented in GlsText, GlsTriangleMesh, GlsComponentBase, GlsGroup, and GlsPolygon.

ObjectType GlsDisplayObject::GetObjectType ( void  ) const

Get the type of this object

Returns
type of this object
Precondition
none
Postcondition
none
GlsDisplayObject* GlsDisplayObject::HandleEvent ( GlsEvent event)

Handle an event

Parameters
eventevent in question
Returns
object that handled event else GLS_NULL
Precondition
event.IsValid()
Postcondition
event is handled if return value is not GLS_NULL
void GlsDisplayObject::InvalidatePickCache ( void  )

Invalidate cached picking screen coordinates

Precondition
none
Postcondition
cached screen picking coordinates are marked invalid
GlsBool GlsDisplayObject::IsBlinkedOff ( const GlsFloat64  time) const
protected

Determine if the object is in an "off" blink cycle (invisible)

Parameters
timeelapsed time in seconds since program start
Returns
GLS_TRUE if blinked off else GLS_FALSE
Precondition
_blinking == TRUE, _blinkRate > 0.0f, time >= 0.0, _blinkRate > 0.0
Postcondition
none
GlsBool GlsDisplayObject::NeedCalculate ( void  ) const

Determine if Calculate() needs to be called on this object

Returns
GLS_TRUE if Calculate() needs to be called else GLS_FALSE
Precondition
none
Postcondition
none
virtual GlsDisplayObject* GlsDisplayObject::PickTest ( const GlsVector2D windowCoord,
GlsInputManager inputManager,
const GlsMatrixAffineD::GLMatrixAffineF parentDrawMatrix 
)
virtual

Perform a pick test of the given point in window coordinates against this object

Parameters
windowCoordpoint in question
inputManagerinput manager managing input for this object
parentDrawMatrixdraw matrix used when rendering parent object
Returns
object that is picked by given window coordinate else GLS_NULL
Precondition
windowCoord.IsValid(), GLMatrixAffineFIsValid( parentDrawMatrix )
Postcondition
none

Reimplemented in GlsComponentBase, and GlsGroup.

void GlsDisplayObject::SetBlinking ( const GlsBool  blinking)

Set the blinking state for this object

Parameters
blinkingWhether or not to blink this object ( GLS_TRUE, GLS_FALSE )
Precondition
none
Postcondition
object has new blinking state
void GlsDisplayObject::SetBlinkRate ( const GlsFloat32  blinkRate)

Set the blinking rate for this object

Parameters
blinkRateNumber of times per second to blink this object
Precondition
blinkRate > 0.0, GlsFloatIsValid( blinkRate )
Postcondition
object has new blink rate
void GlsDisplayObject::SetDynamicRotation ( const GlsVector3D dynamicRotation)

Sets the dynamic rotations to the specified value for all axes (in degrees)

Parameters
dynamicRotationVector containing the new dynamic rotation angles for each axis
Precondition
dynamicRotation.IsValid()
Postcondition
object has new dynamic rotation
void GlsDisplayObject::SetDynamicScale ( const GlsVector3D dynamicScale)

Sets the dynamic scale values for each axis

Parameters
dynamicScaleThe new dynamic scale for the object
Precondition
dynamicScale.IsValid(), dynamicScale.x >= 0.0, dynamicScale.y >= 0.0, dynamicScale.z >= 0.0
Postcondition
object has new dynamic scale
void GlsDisplayObject::SetDynamicTranslation ( const GlsVector3D dynamicTranslation)

Sets the dynamic translation to the specified value for all axes (in logical units)

Parameters
dynamicTranslationThe new dynamic translation for the X, Y, and Z axes
Precondition
dynamicTranslation.IsValid()
Postcondition
object has new dynamic translation
void GlsDisplayObject::SetParent ( GlsDisplayObject *const  parent)

Set the parent object for this object

Parameters
parentparent object for this object
Precondition
parent != GLS_NULL
Postcondition
object has new parent
void GlsDisplayObject::SetPickMode ( const PickMode  pickMode)

Set the pick mode for this object

Parameters
pickModenew pick mode
Precondition
GlsDisplayObjectPickModeIsValid( pickMode )
Postcondition
object has new pick mode
void GlsDisplayObject::SetVisibility ( const GlsBool  visible)

Set the visiblity state for this object

Parameters
visibleGLS_TRUE to enable this object for drawing else GLS_FALSE
Precondition
none
Postcondition
object has new visibility state

Member Data Documentation

GlsBool GlsDisplayObject::_blinking
protected

GLS_TRUE if blinking is turned on else GLS_FALSE )

GlsFloat32 GlsDisplayObject::_blinkRate
protected

Number of times per second the object will blink (>0.0)

const GlsMatrixAffineD GlsDisplayObject::_dcsMatrix
protected

The dynamic coordinate system. The Dynamic changes to rotation, scale, and translate will be modified by this and applied to the _drawMatrix.

const GlsMatrixAffineD GlsDisplayObject::_dcsMatrixInverse
protected

inverse of _dcsMatrix

const GlsBool GlsDisplayObject::_dcsMatrixIsIdentity
protected

GLS_TRUE if _dscMatrix is identity else GLS_FALSE

GlsMatrixAffineD::GLMatrixAffineF GlsDisplayObject::_drawMatrix
protected

The objects contribution to the OpenGL draw matrix. This will be multiplied by the current matrix at draw time. If identity, this object has no contribution (it is not dynamic)

GlsVector3D GlsDisplayObject::_dynamicRotation
protected

The current (dynamic) rotation of the object, in degrees and relative to the object's rotation point. Order of rotation is x, then y, then z

GlsVector3D GlsDisplayObject::_dynamicScale
protected

The current (dynamic) scale of the object

GlsBool GlsDisplayObject::_dynamicScaleIsUnity
protected

GLS_TRUE if _dynamic scale is unity on all three axes

GlsVector3D GlsDisplayObject::_dynamicTranslation
protected

The current (dynamic) translation of the object, in logical units and relative to the object's DCS.

GlsEventDispatcher* const GlsDisplayObject::_eventDispatcher
protected

dispatcher for received events else GLS_NULL

const GlsVector3D GlsDisplayObject::_location
protected

The location of the origin point for this object, in the world coordinate system.

GlsBool GlsDisplayObject::_needCalcDrawMatrix
protected

GLS_TRUE if CalcDrawMatrix() needs to be called on this object else GLS_FALSE.

const GlsBool GlsDisplayObject::_needCalculate
protected

GLS_TRUE if Calculate() needs be called on this object else GLS_FALSE.

const ObjectType GlsDisplayObject::_objectType
protected

OBJECT_TYPE_RENDERABLE or OBJECT_TYPE_COMPOSITE

GlsDisplayObject* GlsDisplayObject::_parent
protected

parent of this object else GLS_NULL

GlsMatrixAffineD::GLMatrixAffineF GlsDisplayObject::_pickMatrix
protected

matrix used to transform window pick region if _windowPickRegionValid == GLS_TRUE

PickMode GlsDisplayObject::_pickMode
protected

pick mode for object

const PickRegion GlsDisplayObject::_pickRegion
protected

pick region for object

const GlsVector3D GlsDisplayObject::_rotationPoint
protected

The location, in the object coordinate system, of the point to rotate this object around when the object is dynamically rotated. So when we want to rotate this object (not just rotate the view), this is the point to rotate about. This point is relative to the _location, which makes in in the objects coordinate system.

GlsBool GlsDisplayObject::_visible
protected

GLS_TRUE if object drawing is enabled else GLS_FALSE

GlsVector2D GlsDisplayObject::_windowPickLowerLeft
protected

lower left coord of pick region in window coords if _windowPickRegionValid == GLS_TRUE

GlsVector2D GlsDisplayObject::_windowPickLowerRight
protected

lower right coord of pick region in window coords if _windowPickRegionValid == GLS_TRUE

GlsBool GlsDisplayObject::_windowPickRegionValid
protected

GLS_TRUE if cached window pick region values are valid

GlsVector2D GlsDisplayObject::_windowPickUpperLeft
protected

upper left coord of pick region in window coords if _windowPickRegionValid == GLS_TRUE

GlsVector2D GlsDisplayObject::_windowPickUpperRight
protected

upper right coord of pick region in window coords if _windowPickRegionValid == GLS_TRUE