DrawObject

A class that provides a default implementation of IDrawObject.  It prepares the way for an object to be rendered using OpenGL, providing pure virtual private functions that must be overridden by derived classes when the actual model data needs to be rendered.

Derived From

IDrawObject

Project

GLCore

Include

DrawObject.h

Summary
A class that provides a default implementation of IDrawObject.
The DrawObject constructor.
Provides a standard list of colors that can be used by derived objects.
Returns a material that matches the passed in Material enumeration type.
Returns a material that matches the passed in ColorType definition.
Returns the GameObject this DrawObject references.
Returns whether this DrawObject can be deleted.
Returns the draw priority of this object.
Returns whether this IDrawObject can be selected.
Draws the object on the screen using OpenGL.
Allows derived classes to render their model in the OpenGL canvas.
Allows derived classes to draw their model with an outline around it.
Allows derived classes to draw their model with a selection outline around it.
Determines if this draw object be deleted.
A weak pointer to the GameObject this DrawObject draws.
The draw priority for this object.

Public

Summary
The DrawObject constructor.
Provides a standard list of colors that can be used by derived objects.
Returns a material that matches the passed in Material enumeration type.
Returns a material that matches the passed in ColorType definition.
Returns the GameObject this DrawObject references.
Returns whether this DrawObject can be deleted.
Returns the draw priority of this object.
Returns whether this IDrawObject can be selected.
Draws the object on the screen using OpenGL.
Allows derived classes to render their model in the OpenGL canvas.
Allows derived classes to draw their model with an outline around it.
Allows derived classes to draw their model with a selection outline around it.

Constructors

DrawObject

DrawObject(const GameObjectPtr &pObject, 
const wxInt32 priority = 99)

The DrawObject constructor.

Parameters

pObjectThe GameObject that this DrawObject is rendering.
priorityThe render priority for this DrawObject.  Lower means it draws earlier.

Enumerations

Material

Provides a standard list of colors that can be used by derived objects.  The standard colors are Gray, LtGray, White, Gold, Red, Edge (the tile edge color), Black, Lava.

There are also three colors that can be set by the user, enumerated as: Selection, WhiteOutline, and LongestOutline.

Static Functions

material

static const GLMaterial &material(Material type)

Returns a material that matches the passed in Material enumeration type.

Parameters

typeThe material type.

Returns

A const GLMaterial that can be used to set the material properties in OpenGL.

material

static const GLMaterial &material(ColorType color)

Returns a material that matches the passed in ColorType definition.

Parameters

colorThe color to create the material with.

Returns

A const GLMaterial that can be used to set the material properties in OpenGL.

Functions

GetObject

IGameObject *GetObject() const

Returns the GameObject this DrawObject references.

Returns

A pointer to the GameObject.  The pointer may be NULL.

Virtual Functions

CanDelete

virtual bool CanDelete() const

Returns whether this DrawObject can be deleted.

Returns

A bool that is true if the object can be deleted and false if not.  An object can be deleted when the GameObject it references has been destroyed.

GetPriority

virtual wxInt32 GetPriority() const

Returns the draw priority of this object.

Returns

The draw priority.  The lower the number, the earlier in the list this object will be drawn.

CanSelect

virtual bool CanSelect(const Vector &origin,
const Vector &ray,
float &distance,
wxInt32 &id)

Returns whether this IDrawObject can be selected.

Parameters

originThe origin point of the selection ray.
rayThe selection ray direction.
distanceFilled with the outgoing distance the object is from the ray origin, if the object is selectable.
idFilled with the ougoing id of the selectable IGameObject, if the object is selectable.

Returns

A bool that is true if the object can be selected and false if not.

Render

virtual void Render(const wxInt32 selection) const

Draws the object on the screen using OpenGL.

Parameters

selectionThe OpenGL id of the currently selected object.  If it matches the id of this object, it should be rendered with a selection outline.

Pure Virtual Functions

RenderModel

virtual void RenderModel(const wxInt32 selection) const=0

Allows derived classes to render their model in the OpenGL canvas.

Parameters

selectionThe OpenGL id of the currently selected object.

RenderOutline

virtual void RenderOutline() const=0

Allows derived classes to draw their model with an outline around it.

RenderSelection

virtual void RenderSelection() const=0

Allows derived classes to draw their model with a selection outline around it.

Private

Summary
Determines if this draw object be deleted.
A weak pointer to the GameObject this DrawObject draws.
The draw priority for this object.

Variables

mDelete

mutable bool mDelete

Determines if this draw object be deleted.  It is set to true when the GameObject this DrawObject is drawing is destroyed.

mpObject

const boost::weak_ptr<IGameObject> mpObject

A weak pointer to the GameObject this DrawObject draws.  It is a weak pointer because the DrawObject should have no ownership of the GameObject, but simply draw it on the screen, and disappear if the GameObject is destroyed.

mPriority

wxInt32 mPriority

The draw priority for this object.

DrawObject(const GameObjectPtr &pObject, 
const wxInt32 priority = 99)
The DrawObject constructor.
static const GLMaterial &material(Material type)
Returns a material that matches the passed in Material enumeration type.
IGameObject *GetObject() const
Returns the GameObject this DrawObject references.
virtual bool CanDelete() const
Returns whether this DrawObject can be deleted.
virtual wxInt32 GetPriority() const
Returns the draw priority of this object.
virtual bool CanSelect(const Vector &origin,
const Vector &ray,
float &distance,
wxInt32 &id)
Returns whether this IDrawObject can be selected.
virtual void Render(const wxInt32 selection) const
Draws the object on the screen using OpenGL.
virtual void RenderModel(const wxInt32 selection) const=0
Allows derived classes to render their model in the OpenGL canvas.
virtual void RenderOutline() const=0
Allows derived classes to draw their model with an outline around it.
virtual void RenderSelection() const=0
Allows derived classes to draw their model with a selection outline around it.
mutable bool mDelete
Determines if this draw object be deleted.
const boost::weak_ptr<IGameObject> mpObject
A weak pointer to the GameObject this DrawObject draws.
wxInt32 mPriority
The draw priority for this object.
The interface for objects that are drawn on screen.
GLCore provides the underlying window classes and tools needed to create and use an OpenGL window with a camera, lighting, selection, mouse/keyboard handling, and IDrawObject rendering.
An interface for all game objects.