FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
FIFE::InstanceRenderer Class Reference

#include <instancerenderer.h>

+ Inheritance diagram for FIFE::InstanceRenderer:
+ Collaboration diagram for FIFE::InstanceRenderer:

Classes

class  AreaInfo
 
class  ColoringInfo
 
class  OutlineInfo
 
struct  s_image_entry
 

Public Member Functions

 InstanceRenderer (RenderBackend *renderbackend, int32_t position)
 constructor. More...
 
 InstanceRenderer (const InstanceRenderer &old)
 
RendererBaseclone ()
 Makes copy of this renderer. More...
 
virtual ~InstanceRenderer ()
 Destructor. More...
 
void render (Camera *cam, Layer *layer, RenderList &instances)
 This method is called by the view to ask renderer to draw its rendering aspect based on given parameters. More...
 
std::string getName ()
 Name of the renderer. More...
 
void addOutlined (Instance *instance, int32_t r, int32_t g, int32_t b, int32_t width, int32_t threshold=1)
 Marks given instance to be outlined with given parameters. More...
 
void addColored (Instance *instance, int32_t r, int32_t g, int32_t b, int32_t a=128)
 Marks given instance to be colored with given parameters. More...
 
void addTransparentArea (Instance *instance, const std::list< std::string > &groups, uint32_t w, uint32_t h, uint8_t trans, bool front=true)
 Marks given instance to have a transparent area with given parameters. More...
 
void removeOutlined (Instance *instance)
 Removes instance from outlining list. More...
 
void removeColored (Instance *instance)
 Removes instance from coloring list. More...
 
void removeTransparentArea (Instance *instance)
 Removes instance form area list. More...
 
void removeAllOutlines ()
 Removes all outlines. More...
 
void removeAllColored ()
 Removes all coloring. More...
 
void removeAllTransparentAreas ()
 Removes all transparent areas. More...
 
void addIgnoreLight (const std::list< std::string > &groups)
 Add groups(Namespaces) into a list. More...
 
void removeIgnoreLight (const std::list< std::string > &groups)
 Removes groups(Namespaces) from the list. More...
 
void removeAllIgnoreLight ()
 Removes all groups(Namespaces) More...
 
RenderBackendgetRenderBackend () const
 Provides access point to the RenderBackend. More...
 
void reset ()
 Removes all stuff. More...
 
void setRemoveInterval (uint32_t interval)
 Sets the interval in seconds (default is 60). More...
 
uint32_t getRemoveInterval () const
 Gets the interval in seconds (default is 60). More...
 
void addToCheck (const ImagePtr &image)
 Add properly old ImagePtr into a check list. More...
 
void check ()
 Timer callback, tried to remove old effect images. More...
 
void removeInstance (Instance *instance)
 Removes instance from all effects. More...
 
bool needColorBinding ()
 Returns true if coloring need binding, otherwise false. More...
 
- Public Member Functions inherited from FIFE::RendererBase
 RendererBase (RenderBackend *renderbackend, int32_t position)
 Constructor. More...
 
 RendererBase (const RendererBase &old)
 Copy Constructor. More...
 
virtual ~RendererBase ()
 Destructor. More...
 
int32_t getPipelinePosition () const
 Gets renderer position in the rendering pipeline. More...
 
void setPipelinePosition (int32_t position)
 Sets renderer position in the rendering pipeline Pipeline position defines in which order view calls the renderers when update occurs Note that renderers are called once per rendered layer, thus to update the whole screen, renderer might receive multiple calls. More...
 
virtual void setEnabled (bool enabled)
 Enables renderer. More...
 
bool isEnabled () const
 Is renderer enabled. More...
 
void setRendererListener (IRendererListener *listener)
 Sets listener for renderer. More...
 
void addActiveLayer (Layer *layer)
 Adds active layer to renderer. More...
 
void removeActiveLayer (Layer *layer)
 Removes active layer from renderer. More...
 
void clearActiveLayers ()
 Clears all active layers from renderer. More...
 
void activateAllLayers (Map *elevation)
 Activates all layers from given elevation. More...
 
bool isActivedLayer (Layer *layer)
 Returns if given layer is currently activated. More...
 
std::list< Layer * > getActiveLayers () const
 Returns list of activated layer. More...
 

Static Public Member Functions

static InstanceRenderergetInstance (IRendererContainer *cnt)
 Gets instance for interface access. More...
 

Private Types

typedef uint8_t Effect
 
typedef std::map< Instance *, OutlineInfoInstanceToOutlines_t
 
typedef std::map< Instance *, ColoringInfoInstanceToColoring_t
 
typedef std::map< Instance *, AreaInfoInstanceToAreas_t
 
typedef std::list< s_image_entryImagesToCheck_t
 
typedef std::map< Instance *, EffectInstanceToEffects_t
 

Private Member Functions

void renderOverlay (RenderDataType type, RenderItem *item, uint8_t const *coloringColor, bool recoloring)
 
ImagebindOutline (OutlineInfo &info, RenderItem &vc, Camera *cam)
 Binds new outline (if needed) to the instance's OutlineInfo. More...
 
ImagebindMultiOutline (OutlineInfo &info, RenderItem &vc, Camera *cam)
 
ImagebindColoring (ColoringInfo &info, RenderItem &vc, Camera *cam)
 
ImagePtr getMultiColorOverlay (const RenderItem &vc, OverlayColors *colors=0)
 
void renderUnsorted (Camera *cam, Layer *layer, RenderList &instances)
 
void renderAlreadySorted (Camera *cam, Layer *layer, RenderList &instances)
 
void removeFromCheck (const ImagePtr &image)
 
bool isValidImage (const ImagePtr &image)
 

Private Attributes

bool m_area_layer
 
uint32_t m_interval
 
bool m_timer_enabled
 
std::list< std::string > m_unlit_groups
 
bool m_need_sorting
 
bool m_need_bind_coloring
 
InstanceToOutlines_t m_instance_outlines
 
InstanceToColoring_t m_instance_colorings
 
InstanceToAreas_t m_instance_areas
 
ImagesToCheck_t m_check_images
 
Timer m_timer
 
InstanceDeleteListenerm_delete_listener
 
InstanceToEffects_t m_assigned_instances
 

Additional Inherited Members

- Protected Member Functions inherited from FIFE::RendererBase
 RendererBase ()
 
- Protected Attributes inherited from FIFE::RendererBase
std::list< Layer * > m_active_layers
 
RenderBackendm_renderbackend
 

Detailed Description

Definition at line 43 of file instancerenderer.h.

Member Typedef Documentation

typedef uint8_t FIFE::InstanceRenderer::Effect
private

Definition at line 162 of file instancerenderer.h.

Definition at line 218 of file instancerenderer.h.

Definition at line 207 of file instancerenderer.h.

Definition at line 206 of file instancerenderer.h.

Definition at line 226 of file instancerenderer.h.

Definition at line 205 of file instancerenderer.h.

Member Enumeration Documentation

Enumerator
NOTHING 
OUTLINE 
COLOR 
AREA 

Definition at line 156 of file instancerenderer.h.

Constructor & Destructor Documentation

FIFE::InstanceRenderer::InstanceRenderer ( RenderBackend renderbackend,
int32_t  position 
)

constructor.

Parameters
renderbackendto use
positionposition for this renderer in rendering pipeline

Definition at line 123 of file instancerenderer.cpp.

References check(), FIFE::RenderBackend::getName(), FIFE::RenderBackend::isDepthBufferEnabled(), m_delete_listener, m_interval, m_need_bind_coloring, m_need_sorting, FIFE::RendererBase::m_renderbackend, m_timer, FIFE::Timer::setCallback(), FIFE::RendererBase::setEnabled(), and FIFE::Timer::setInterval().

Referenced by clone().

+ Here is the caller graph for this function:

FIFE::InstanceRenderer::~InstanceRenderer ( )
virtual

Destructor.

Definition at line 175 of file instancerenderer.cpp.

References m_assigned_instances, m_delete_listener, and reset().

Member Function Documentation

void FIFE::InstanceRenderer::addColored ( Instance instance,
int32_t  r,
int32_t  g,
int32_t  b,
int32_t  a = 128 
)
void FIFE::InstanceRenderer::addIgnoreLight ( const std::list< std::string > &  groups)

Add groups(Namespaces) into a list.

All instances, whose namespace is in the list will not lighted from the LightRenderer.

Definition at line 1321 of file instancerenderer.cpp.

References m_unlit_groups.

Referenced by getName().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::addOutlined ( Instance instance,
int32_t  r,
int32_t  g,
int32_t  b,
int32_t  width,
int32_t  threshold = 1 
)
void FIFE::InstanceRenderer::addToCheck ( const ImagePtr image)
void FIFE::InstanceRenderer::addTransparentArea ( Instance instance,
const std::list< std::string > &  groups,
uint32_t  w,
uint32_t  h,
uint8_t  trans,
bool  front = true 
)
void FIFE::InstanceRenderer::check ( )
RendererBase * FIFE::InstanceRenderer::clone ( )
virtual

Makes copy of this renderer.

Implements FIFE::RendererBase.

Definition at line 171 of file instancerenderer.cpp.

References InstanceRenderer().

InstanceRenderer * FIFE::InstanceRenderer::getInstance ( IRendererContainer cnt)
static

Gets instance for interface access.

Definition at line 119 of file instancerenderer.cpp.

References FIFE::IRendererContainer::getRenderer().

Referenced by getName(), and FIFE::MapLoader::load().

+ Here is the caller graph for this function:

uint32_t FIFE::InstanceRenderer::getRemoveInterval ( ) const

Gets the interval in seconds (default is 60).

Definition at line 1368 of file instancerenderer.cpp.

References m_interval.

Referenced by getRenderBackend().

+ Here is the caller graph for this function:

RenderBackend* FIFE::InstanceRenderer::getRenderBackend ( ) const
inline
bool FIFE::InstanceRenderer::isValidImage ( const ImagePtr image)
private
bool FIFE::InstanceRenderer::needColorBinding ( )
inline

Returns true if coloring need binding, otherwise false.

Definition at line 146 of file instancerenderer.h.

References m_need_bind_coloring.

void FIFE::InstanceRenderer::removeAllColored ( )

Removes all coloring.

Definition at line 1285 of file instancerenderer.cpp.

References COLOR, m_assigned_instances, m_delete_listener, and m_instance_colorings.

Referenced by getName(), and reset().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeAllIgnoreLight ( )

Removes all groups(Namespaces)

Definition at line 1343 of file instancerenderer.cpp.

References m_unlit_groups.

Referenced by getName(), and reset().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeAllOutlines ( )

Removes all outlines.

Definition at line 1267 of file instancerenderer.cpp.

References m_assigned_instances, m_delete_listener, m_instance_outlines, and OUTLINE.

Referenced by getName(), and reset().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeAllTransparentAreas ( )

Removes all transparent areas.

Definition at line 1303 of file instancerenderer.cpp.

References AREA, m_assigned_instances, m_delete_listener, and m_instance_areas.

Referenced by getName(), and reset().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeColored ( Instance instance)

Removes instance from coloring list.

Definition at line 1239 of file instancerenderer.cpp.

References COLOR, m_assigned_instances, m_delete_listener, m_instance_colorings, and FIFE::Instance::removeDeleteListener().

Referenced by getName().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeFromCheck ( const ImagePtr image)
private
void FIFE::InstanceRenderer::removeIgnoreLight ( const std::list< std::string > &  groups)

Removes groups(Namespaces) from the list.

Definition at line 1330 of file instancerenderer.cpp.

References m_unlit_groups.

Referenced by getName().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeInstance ( Instance instance)

Removes instance from all effects.

Should only be called by delete listener!

Definition at line 1432 of file instancerenderer.cpp.

References m_assigned_instances, m_delete_listener, m_instance_areas, m_instance_colorings, m_instance_outlines, and FIFE::Instance::removeDeleteListener().

Referenced by getRenderBackend(), and FIFE::InstanceRendererDeleteListener::onInstanceDeleted().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeOutlined ( Instance instance)

Removes instance from outlining list.

Definition at line 1225 of file instancerenderer.cpp.

References m_assigned_instances, m_delete_listener, m_instance_outlines, OUTLINE, and FIFE::Instance::removeDeleteListener().

Referenced by getName().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::removeTransparentArea ( Instance instance)

Removes instance form area list.

Definition at line 1253 of file instancerenderer.cpp.

References AREA, m_assigned_instances, m_delete_listener, m_instance_areas, and FIFE::Instance::removeDeleteListener().

Referenced by getName().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::render ( Camera cam,
Layer layer,
RenderList instances 
)
virtual

This method is called by the view to ask renderer to draw its rendering aspect based on given parameters.

Renderers receive non-clipped instance stack since there is no way to know which information is relevant for the renderer. E.g. effect renderer might need to know offscreen instance locations to be able to draw radiation coming from some instance not visible on the screen.

Parameters
camcamera view to draw
layercurrent layer to be rendered
instancesinstances on the current layer @ see setPipelinePosition

Implements FIFE::RendererBase.

Definition at line 184 of file instancerenderer.cpp.

References FIFE::_log, FL_WARN, FIFE::Layer::getCellGrid(), m_need_sorting, renderAlreadySorted(), and renderUnsorted().

void FIFE::InstanceRenderer::renderAlreadySorted ( Camera cam,
Layer layer,
RenderList instances 
)
private

Definition at line 395 of file instancerenderer.cpp.

References FIFE::ALWAYS, bindColoring(), bindOutline(), FIFE::CELLV_REVEALED, FIFE::RenderBackend::changeRenderInfos(), FIFE::RenderItem::dimensions, FIFE::InstanceRenderer::AreaInfo::front, FIFE::CellCache::getCell(), FIFE::Layer::getCellCache(), FIFE::CellRenderer::getFowLayer(), FIFE::Cell::getFoWType(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::RenderBackend::getLightingModel(), FIFE::Instance::getLocation(), FIFE::Instance::getLocationRef(), FIFE::Location::getMapCoordinates(), FIFE::Object::getNamespace(), FIFE::Instance::getObject(), FIFE::Camera::getRenderer(), FIFE::Instance::getVisual(), FIFE::InstanceRenderer::AreaInfo::groups, FIFE::RectType< T >::h, FIFE::InstanceRenderer::AreaInfo::h, FIFE::RenderItem::image, FIFE::InstanceRenderer::AreaInfo::instance, FIFE::RectType< T >::intersects(), FIFE::CellRenderer::isEnabledFogOfWar(), FIFE::InstanceVisual::isVisible(), FIFE::KEEP, m_area_layer, m_instance_areas, m_instance_colorings, m_instance_outlines, m_need_bind_coloring, FIFE::RenderItem::m_overlay, FIFE::RendererBase::m_renderbackend, m_unlit_groups, FIFE::OVERLAY_TYPE_COLOR, FIFE::OVERLAY_TYPE_NONE, FIFE::Image::render(), FIFE::RENDER_DATA_WITHOUT_Z, renderOverlay(), FIFE::REPLACE, FIFE::RenderItem::screenpoint, FIFE::InstanceVisual::setVisible(), FIFE::Camera::toScreenCoordinates(), FIFE::Camera::toVirtualScreenCoordinates(), FIFE::InstanceRenderer::AreaInfo::trans, FIFE::RenderItem::transparency, FIFE::RectType< T >::w, FIFE::InstanceRenderer::AreaInfo::w, FIFE::RectType< T >::x, FIFE::PointType3D< T >::x, FIFE::RectType< T >::y, FIFE::PointType3D< T >::y, FIFE::InstanceRenderer::AreaInfo::z, FIFE::PointType3D< T >::z, and FIFE::ZERO.

Referenced by render().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::renderUnsorted ( Camera cam,
Layer layer,
RenderList instances 
)
private

Definition at line 199 of file instancerenderer.cpp.

References FIFE::ALWAYS, bindOutline(), FIFE::CELLV_REVEALED, FIFE::RenderBackend::changeRenderInfos(), FIFE::RenderItem::dimensions, FIFE::InstanceRenderer::AreaInfo::front, FIFE::CellCache::getCell(), FIFE::Layer::getCellCache(), FIFE::CellRenderer::getFowLayer(), FIFE::Cell::getFoWType(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::RenderBackend::getLightingModel(), FIFE::Instance::getLocation(), FIFE::Instance::getLocationRef(), FIFE::Location::getMapCoordinates(), FIFE::Object::getNamespace(), FIFE::Instance::getObject(), FIFE::Camera::getRenderer(), FIFE::Instance::getVisual(), FIFE::InstanceRenderer::AreaInfo::groups, FIFE::RectType< T >::h, FIFE::InstanceRenderer::AreaInfo::h, FIFE::RenderItem::image, FIFE::RenderItem::instance, FIFE::InstanceRenderer::AreaInfo::instance, FIFE::RectType< T >::intersects(), FIFE::CellRenderer::isEnabledFogOfWar(), FIFE::InstanceVisual::isVisible(), m_area_layer, m_instance_areas, m_instance_colorings, m_instance_outlines, FIFE::RenderItem::m_overlay, FIFE::RendererBase::m_renderbackend, m_unlit_groups, FIFE::RENDER_DATA_MULTITEXTURE_Z, FIFE::RENDER_DATA_TEXCOLOR_Z, FIFE::RENDER_DATA_TEXTURE_Z, renderOverlay(), FIFE::Image::renderZ(), FIFE::REPLACE, FIFE::RenderItem::screenpoint, FIFE::InstanceVisual::setVisible(), FIFE::Camera::toScreenCoordinates(), FIFE::Camera::toVirtualScreenCoordinates(), FIFE::InstanceRenderer::AreaInfo::trans, FIFE::RenderItem::transparency, FIFE::RenderItem::vertexZ, FIFE::RectType< T >::w, FIFE::InstanceRenderer::AreaInfo::w, FIFE::RectType< T >::x, FIFE::PointType3D< T >::x, FIFE::RectType< T >::y, FIFE::PointType3D< T >::y, FIFE::InstanceRenderer::AreaInfo::z, and FIFE::PointType3D< T >::z.

Referenced by render().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::reset ( )
virtual

Removes all stuff.

Reimplemented from FIFE::RendererBase.

Definition at line 1347 of file instancerenderer.cpp.

References m_check_images, m_timer, m_timer_enabled, removeAllColored(), removeAllIgnoreLight(), removeAllOutlines(), removeAllTransparentAreas(), and FIFE::Timer::stop().

Referenced by getRenderBackend(), and ~InstanceRenderer().

+ Here is the caller graph for this function:

void FIFE::InstanceRenderer::setRemoveInterval ( uint32_t  interval)

Sets the interval in seconds (default is 60).

Definition at line 1361 of file instancerenderer.cpp.

References m_interval, m_timer, and FIFE::Timer::setInterval().

Referenced by getRenderBackend().

+ Here is the caller graph for this function:

Member Data Documentation

bool FIFE::InstanceRenderer::m_area_layer
private

Definition at line 149 of file instancerenderer.h.

Referenced by renderAlreadySorted(), and renderUnsorted().

ImagesToCheck_t FIFE::InstanceRenderer::m_check_images
private

Definition at line 220 of file instancerenderer.h.

Referenced by addToCheck(), check(), removeFromCheck(), and reset().

InstanceToAreas_t FIFE::InstanceRenderer::m_instance_areas
private
InstanceToColoring_t FIFE::InstanceRenderer::m_instance_colorings
private
InstanceToOutlines_t FIFE::InstanceRenderer::m_instance_outlines
private
uint32_t FIFE::InstanceRenderer::m_interval
private

Definition at line 150 of file instancerenderer.h.

Referenced by check(), getRemoveInterval(), InstanceRenderer(), and setRemoveInterval().

bool FIFE::InstanceRenderer::m_need_bind_coloring
private

Definition at line 154 of file instancerenderer.h.

Referenced by InstanceRenderer(), needColorBinding(), and renderAlreadySorted().

bool FIFE::InstanceRenderer::m_need_sorting
private

Definition at line 153 of file instancerenderer.h.

Referenced by InstanceRenderer(), and render().

Timer FIFE::InstanceRenderer::m_timer
private
bool FIFE::InstanceRenderer::m_timer_enabled
private

Definition at line 151 of file instancerenderer.h.

Referenced by addToCheck(), check(), removeFromCheck(), and reset().

std::list<std::string> FIFE::InstanceRenderer::m_unlit_groups
private

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