The Nebula Device 3: Graphics::Stage Class Reference

The Nebula Device 3

Graphics::Stage Class Reference

#include <stage.h>

Inheritance diagram for Graphics::Stage:

Core::RefCounted


Detailed Description

A graphics stage groups graphics entities (models, cameras and lights) together for rendering. The main job of a Stage is to speed up visibility queries between the attached graphics entities. Different visibility query strategies are implemented by Stage subclasses. Nebula3 comes with a set of generic Stage subclasses for different purposes, but applications are free to derive their own subclasses which implement visibility query mechanisms tailored to the application.

Visibility queries exist in the following variations:

  • Camera->Light: this finds all light entities visible from a given camera
  • Camera->Model: this finds all model entities visible from a given camera
  • Light->Model: this finds all model entities which are lit by a given light source

Those visibility queries establish so-called visibility links between graphics entities which are then used by the lower level rendering subsystems to speed up rendering.

To render the content of a stage, at least one View object is needed. A View object binds renders a stage through a camera entity into a render target. Any number of View objects can exist in parallel, and may be bound to any Stage. Furthermore, dependencies between View objects may be defined (so that a View object will first ask the View objects it depends on to render themselves).

(C) 2007 Radon Labs GmbH

Public Member Functions

 Stage ()
 constructor
virtual ~Stage ()
 destructor
bool IsAttachedToServer () const
 return true if currently attached to graphics server
const Util::StringAtomGetName () const
 get human readable name of the stage
const Ptr
< StageBuilder > & 
GetStageBuilder () const
 get stage builder object
void SetRootCell (const Ptr< Cell > &rootCell)
 set the root cell of the stage
const Ptr< Cell > & GetRootCell () const
 get the root cell of the stage
virtual void AttachEntity (const Ptr< GraphicsEntity > &graphicsEntity)
 attach an entity to the stage
virtual void RemoveEntity (const Ptr< GraphicsEntity > &entity)
 remove an entity from the stage
const Util::Array
< Ptr
< GraphicsEntity > > & 
GetEntities () const
 get an array of all entities attached to the stage
const Util::Array
< Ptr
< GraphicsEntity > > & 
GetEntitiesByType (GraphicsEntity::Type type) const
 get entities by type
virtual void UpdateEntities (Timing::Time curTime, IndexT frameCount)
 update (animate) entities in the cell
virtual void UpdateCameraLinks (const Ptr< CameraEntity > &cameraEntity)
 update camera links for a given camera
virtual void UpdateLightLinks ()
 update light links for all visible lights (after updating camera links!)
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Static Public Member Functions

static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

Protected Member Functions

void SetName (const Util::StringAtom &name)
 set a human readable name on the stage
void SetStageBuilder (const Ptr< StageBuilder > &stageBuilder)
 set stage builder object
virtual void OnAttachToServer ()
 called when the stage is attached to graphics server
virtual void OnRemoveFromServer ()
 called when the stage is detached from graphics server

Member Function Documentation

void Graphics::Stage::SetRootCell ( const Ptr< Cell > &  cell  ) 

set the root cell of the stage

Setting a root cell will also initialize it.

void Graphics::Stage::AttachEntity ( const Ptr< GraphicsEntity > &  entity  )  [virtual]

attach an entity to the stage

Add an entity to the stage. The method OnAttachToStage() will be invoked on the entity, and the entity will be inserted into the cell hierarchy of the stage (which in turn call OnAttachToCell() on the entity).

void Graphics::Stage::RemoveEntity ( const Ptr< GraphicsEntity > &  entity  )  [virtual]

remove an entity from the stage

Remove an entity from the stage. This will remove the entity from the cell hierarchy of the stage (which invoked OnRemoveFromCell() on the entity), and then the method OnRemoveFromStage() will be called on the entity.

void Graphics::Stage::UpdateEntities ( Timing::Time  curTime,
IndexT  curFrameCount 
) [virtual]

update (animate) entities in the cell

Update the entities in the stage. This usually implements graphics animations, etc... This method must be called first after BeginUpdate() and before any of the visibility link update methods to make sure entity transforms and bounding boxes are uptodate before resolving visibility.

FIXME: this is no good for worlds with many static entities, entities should know whether they need to have their Update method called, and register themselves somewhere!

void Graphics::Stage::UpdateCameraLinks ( const Ptr< CameraEntity > &  cameraEntity  )  [virtual]

update camera links for a given camera

Update visibility links for a given camera. This will create bidirectional visibility links between the camera and all other entities (most importantly light and model entities) which are visible through this camera. This method must be called once for each active camera after UpdateEntities() and before UpdateVisibleLightLinks().

void Graphics::Stage::UpdateLightLinks (  )  [virtual]

update light links for all visible lights (after updating camera links!)

For each visible light entity, this method will create light links between the light entities, and model entities influenced by this light. This method must be called after UpdateCameraLinks() (this makes sure that no invisible lights and models will be checked).

int Core::RefCounted::GetRefCount (  )  const [inline, inherited]

get the current refcount

Return the current refcount of the object.

void Core::RefCounted::AddRef (  )  [inline, inherited]

increment refcount by one

Increment the refcount of the object.

void Core::RefCounted::Release (  )  [inline, inherited]

decrement refcount and destroy object if refcount is zero

Decrement the refcount and destroy object if refcount is zero.

const Util::String & Core::RefCounted::GetClassName (  )  const [inline, inherited]

get the class name

Get the class name of the object.

Util::FourCC Core::RefCounted::GetClassFourCC (  )  const [inline, inherited]

get the class FourCC code

Get the class FourCC of the object.

void Core::RefCounted::DumpRefCountingLeaks (  )  [static, inherited]

dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

This method should be called as the very last before an application exits.