An helper class to draw stuffs in the world. More...

Inheritance diagram for GraphicalWObject:

List of all members.

Public Member Functions

 GraphicalWObject (World *world, QString name="unamed", const wMatrix &tm=wMatrix::identity())
 Constructor.
virtual ~GraphicalWObject ()
 Destructor.
WObjectattachedObject () const
 The object to which we are attached.
void attachToObject (WObject *object, bool makeOwner=false)
 Attaches this object to another WObject.
void updateAndCalculateAABB (wVector &minPoint, wVector &maxPoint, const wMatrix tm)
 Returns the min and max points of the Axis-Aligned Bounding Box (AABB)
void updateAndCalculateOBB (wVector &dimension, wVector &minPoint, wVector &maxPoint)
 Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame.
void updateAndRender (RenderWObject *renderer, QGLContext *gw)
 Performs the actual drawing.
void updateAndRenderAABB (RenderWObject *renderer, RenderWorld *gw)
 The function rendering the Axis-Aligned Bounding Box (AABB)

Protected Member Functions

virtual void calculateAABB (wVector &minPoint, wVector &maxPoint, const wMatrix tm)
 Returns the min and max points of the Axis-Aligned Bounding Box (AABB)
virtual void calculateOBB (wVector &dimension, wVector &minPoint, wVector &maxPoint)
 Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame If there is no meaningful OBB, set dimension, minPoint and maxPoint to (0, 0, 0), as the default implementation does.
virtual void render (RenderWObject *renderer, QGLContext *gw)=0
 Performs the actual drawing.
virtual void renderAABB (RenderWObject *renderer, RenderWorld *gw)
 The function rendering the Axis-Aligned Bounding Box (AABB)
void updateMatrixFromAttachedObject ()
 Updates the transformation matrix from the object to which we are attached (if there is one)

Protected Attributes

WObjectm_attachedObject
 The WObject to which we are attached.

Detailed Description

An helper class to draw stuffs in the world.

This class is useful to add to the world purely graphical objects. All the drawing can be done directly inside child of this classes (without the need for a separate RenderWObject class). Moreover it is possible to attach object of this type to another WObject: the transformation matrix of this object will be set to be the same as the one of the WObject to which this one is attached when drawing is required

Definition at line 47 of file graphicalwobject.h.


Constructor & Destructor Documentation

GraphicalWObject ( World world,
QString  name = "unamed",
const wMatrix tm = wMatrix::identity() 
)

Constructor.

Parameters:
worldthe world the object lives in
namethe name of this object
tmthe transformation matrix for this object

Definition at line 28 of file graphicalwobject.cpp.

~GraphicalWObject ( ) [virtual]

Destructor.

Definition at line 37 of file graphicalwobject.cpp.


Member Function Documentation

WObject* attachedObject ( ) const [inline]

The object to which we are attached.

Returns:
the object to which we are attached

Definition at line 84 of file graphicalwobject.h.

void attachToObject ( WObject object,
bool  makeOwner = false 
)

Attaches this object to another WObject.

When we are attached to an object, our transformation matrix is set to the one of the object to which we are attached before drawing is performed

Parameters:
objectthe WObject to which we are attached. If NULL we are not attached to any object
makeOwnerif true object is made the owner of this so that when object is destroyed this one is destroyed too

Definition at line 42 of file graphicalwobject.cpp.

References GraphicalWObject::m_attachedObject, and Ownable::setOwner().

Referenced by SingleIRGraphic::SingleIRGraphic().

void calculateAABB ( wVector minPoint,
wVector maxPoint,
const wMatrix  tm 
) [protected, virtual]

Returns the min and max points of the Axis-Aligned Bounding Box (AABB)

If there is no meaningful AABB, set both minPoint and maxPoint to (0, 0, 0), as the default implementation does

Parameters:
minPointthe minimum point of the AABB
maxPointthe maximum point of the AABB
tmthe transformation matrix with respect to which the minPoint and maxPoint of AABB have to be calculated

Definition at line 86 of file graphicalwobject.cpp.

Referenced by GraphicalWObject::updateAndCalculateAABB().

void calculateOBB ( wVector dimension,
wVector minPoint,
wVector maxPoint 
) [protected, virtual]

Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame If there is no meaningful OBB, set dimension, minPoint and maxPoint to (0, 0, 0), as the default implementation does.

Parameters:
dimensionthe dimension of the OBB
minPointthe minimum point of the OBB
maxPointthe maximum point of the OBB

Definition at line 93 of file graphicalwobject.cpp.

Referenced by GraphicalWObject::updateAndCalculateOBB().

virtual void render ( RenderWObject renderer,
QGLContext *  gw 
) [protected, pure virtual]

Performs the actual drawing.

Reimplement to draw what you need

Parameters:
rendererthe RenderWObject object associated with this one. Use it e.g. to access the container
gwthe OpenGL context

Implemented in SingleIRGraphic.

Referenced by GraphicalWObject::updateAndRender().

void renderAABB ( RenderWObject renderer,
RenderWorld gw 
) [protected, virtual]

The function rendering the Axis-Aligned Bounding Box (AABB)

The default implementation does nothing

Parameters:
rendererthe RenderWObject object associated with this one. Use it e.g. to access the container
gwthe object rendering the world

Definition at line 81 of file graphicalwobject.cpp.

Referenced by GraphicalWObject::updateAndRenderAABB().

void updateAndCalculateAABB ( wVector minPoint,
wVector maxPoint,
const wMatrix  tm 
)

Returns the min and max points of the Axis-Aligned Bounding Box (AABB)

This calls the calculateAABB() function after updating the transformation matrix. See the description of that function for more details

Parameters:
minPointthe minimum point of the AABB
maxPointthe maximum point of the AABB
tmthe transformation matrix with respect to which the minPoint and maxPoint of AABB have to be calculated

Definition at line 67 of file graphicalwobject.cpp.

References GraphicalWObject::calculateAABB(), and GraphicalWObject::updateMatrixFromAttachedObject().

Referenced by GraphicalWObjectRenderer::calculateAABB().

void updateAndCalculateOBB ( wVector dimension,
wVector minPoint,
wVector maxPoint 
)

Returns the dimension of the Oriented Bounding Box (OBB) in the object local frame.

This calls the calculateOBB() function after updating the transformation matrix. See the description of that function for more details

Parameters:
dimensionthe dimension of the OBB
minPointthe minimum point of the OBB
maxPointthe maximum point of the OBB

Definition at line 74 of file graphicalwobject.cpp.

References GraphicalWObject::calculateOBB(), and GraphicalWObject::updateMatrixFromAttachedObject().

Referenced by GraphicalWObjectRenderer::calculateOBB().

void updateAndRender ( RenderWObject renderer,
QGLContext *  gw 
)

Performs the actual drawing.

This calls the render() function after updating the transformation matrix. See the description of that function for more details

Parameters:
rendererthe RenderWObject object associated with this one. Use it e.g. to access the container
gwthe OpenGL context

Definition at line 53 of file graphicalwobject.cpp.

References GraphicalWObject::render(), and GraphicalWObject::updateMatrixFromAttachedObject().

void updateAndRenderAABB ( RenderWObject renderer,
RenderWorld gw 
)

The function rendering the Axis-Aligned Bounding Box (AABB)

This calls the renderAABB() function after updating the transformation matrix. See the description of that function for more details

Parameters:
rendererthe RenderWObject object associated with this one. Use it e.g. to access the container
gwthe object rendering the world

Definition at line 60 of file graphicalwobject.cpp.

References GraphicalWObject::renderAABB(), and GraphicalWObject::updateMatrixFromAttachedObject().

Referenced by GraphicalWObjectRenderer::renderAABB().

void updateMatrixFromAttachedObject ( ) [protected]

Updates the transformation matrix from the object to which we are attached (if there is one)

Definition at line 101 of file graphicalwobject.cpp.

References GraphicalWObject::m_attachedObject, WObject::matrix(), and WObject::setMatrix().

Referenced by GraphicalWObject::updateAndCalculateAABB(), GraphicalWObject::updateAndCalculateOBB(), GraphicalWObject::updateAndRender(), and GraphicalWObject::updateAndRenderAABB().


Member Data Documentation

WObject* m_attachedObject [protected]

The WObject to which we are attached.

If NULL we are not attached to any object

Definition at line 195 of file graphicalwobject.h.

Referenced by GraphicalWObject::attachToObject(), and GraphicalWObject::updateMatrixFromAttachedObject().


The documentation for this class was generated from the following files: