IDrawObject

The interface for objects that are drawn on screen.  The IDrawObject class is an implementation of the Prototype design pattern.  When a RuleSet is loaded, all of its associated IDrawObjects are stored in the IDrawObjectEngine.  When a new IGameObject is added to the game, the IDrawObjectEngine is queried for any IDrawObject capable of drawing it.  If one is found, that IDrawObject is cloned and given the IGameObject to draw.

Project

RulesCore

Include

IDrawObject.h

Summary
The interface for objects that are drawn on screen.
The DrawObject destructor.
Queries the IDrawObject to see if they can draw a certain IGameObject.
Returns whether this IDrawObject can be deleted.
Returns whether this IDrawObject can be selected.
Creates a clone of the IDrawObject.
Returns the draw priority of this object.
Draws the object on the screen.
Allows derived classes to do their own resource management.
Allows derived classes to do clean up after themselves.

Public

Summary
The DrawObject destructor.
Queries the IDrawObject to see if they can draw a certain IGameObject.
Returns whether this IDrawObject can be deleted.
Returns whether this IDrawObject can be selected.
Creates a clone of the IDrawObject.
Returns the draw priority of this object.
Draws the object on the screen.
Allows derived classes to do their own resource management.
Allows derived classes to do clean up after themselves.

Destructor

~IDrawObject

virtual ~IDrawObject()=0

The DrawObject destructor.  It is pure virtual because this class must be derived from in order to be used.

Pure Virtual Functions

CanBuild

virtual bool CanBuild(const GameObjectPtr &object) const=0

Queries the IDrawObject to see if they can draw a certain IGameObject.

Parameters

objectThe GameObject this IDrawObject is being asked if it can build.

Returns

A bool indicating whether the IDrawObject can build the given IGameObject.  The value is true if it can, false if not.

CanDelete

virtual bool CanDelete() const=0

Returns whether this IDrawObject can be deleted.

Returns

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

CanSelect

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

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.

Clone

virtual IDrawObject *Clone(const GameObjectPtr &pObject) const=0

Creates a clone of the IDrawObject.  IDrawObjects are an implementation of the Prototype pattern and must provide a way to clone themselves from a stored prototype.

Parameters

pObjectThe GameObject the cloned DrawObject will reference.

GetPriority

virtual wxInt32 GetPriority() const=0

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.

Render

virtual void Render(const wxInt32 selection) const=0

Draws the object on the screen.

Parameters

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

Obtain

virtual void Obtain()=0

Allows derived classes to do their own resource management.  They must override this function to do any special OpenGL texture or display list initialization.  It is called once per Cities3D game.

Release

virtual void Release()=0

Allows derived classes to do clean up after themselves.  It is called once per Cities3D game.

virtual ~IDrawObject()=0
The DrawObject destructor.
virtual bool CanBuild(const GameObjectPtr &object) const=0
Queries the IDrawObject to see if they can draw a certain IGameObject.
An interface for all game objects.
virtual bool CanDelete() const=0
Returns whether this IDrawObject can be deleted.
virtual bool CanSelect(const Vector &origin,
const Vector &ray,
float &distance,
wxInt32 &id)=0
Returns whether this IDrawObject can be selected.
virtual IDrawObject *Clone(const GameObjectPtr &pObject) const=0
Creates a clone of the IDrawObject.
virtual wxInt32 GetPriority() const=0
Returns the draw priority of this object.
virtual void Render(const wxInt32 selection) const=0
Draws the object on the screen.
virtual void Obtain()=0
Allows derived classes to do their own resource management.
virtual void Release()=0
Allows derived classes to do clean up after themselves.
A repository of all things rules-related.
The interface of the IDrawObject engine.
The interface for objects that are drawn on screen.
RulesCore is the HOSS of Cities3D.