Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
The EdgeRenderer class implements a special Renderer that automatically extracts and renders the edges of the objects in the scene. More...
#include <EdgeRenderer.hpp>
Classes | |
class | WFInfo |
Public Member Functions | |
EdgeRenderer () | |
const RenderQueue * | render (const RenderQueue *in_render_queue, Camera *camera, real frame_clock) |
Takes as input the render queue to render and returns a possibly filtered render queue for further processing. | |
WFInfo * | declareActor (Actor *act, const fvec4 &color) |
Generates and caches all the information needed to render the edges of the given Actor using the specified color. | |
WFInfo * | declareActor (Actor *act) |
Generates and caches all the information needed to render the edges of the given Actor. | |
void | clearCache () |
Clears the cache containing the Actor and edge information. | |
void | setActorDirty (Actor *actor) |
Removes all the edge/rendering information relative to the specified Actor from the cache. | |
void | setShowHiddenLines (bool show) |
If set to true shows also the hidden lines with a dashed pattern. | |
bool | showHiddenLines () const |
If set to true shows also the hidden lines with a dashed pattern. | |
void | setShowCreases (bool show) |
If set to true shows not only the edges that define the silhouette of an object but also the crease edges. | |
bool | showCreases () const |
If set to true shows not only the edges that define the silhouette of an object but also the crease edges. | |
void | setCreaseAngle (float degrees) |
The minimum angle (in degrees) considered to generate crease-edges (default is 44 degrees). | |
float | creaseAngle () const |
The minimum angle (in degrees) considered to generate crease-edges (default is 44 degrees). | |
void | setSmoothLines (bool smooth) |
If set to true the lines will be rendered using antialiasing. | |
bool | smoothLines () const |
If set to true the lines will be rendered using antialiasing. | |
void | setLineWidth (float width) |
Defines the width of the rendered edges. | |
float | lineWidth () const |
Defines the width of the rendered edges. | |
void | setDefaultLineColor (const fvec4 &c) |
Defines the default color of the rendered edges. You can also define a per-Actor color using the declareActor() method. | |
const fvec4 & | defaultLineColor () const |
Defines the default color of the rendered edges. You can also define a per-Actor color using the declareActor() method. | |
void | setPolygonOffsetFactor (float factor) |
Defines the factor parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information. | |
float | polygonOffsetFactor () const |
Defines the factor parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information. | |
void | setPolygonOffsetUnits (float units) |
Defines the units parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information. | |
float | polygonOffsetUnits () const |
Defines the units parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information. | |
Protected Member Functions | |
void | renderSolids (Camera *camera, real frame_clock) |
void | renderLines (Camera *camera) |
Protected Attributes | |
std::map< ref< Actor >, ref < WFInfo > > | mActorCache |
std::map< ref< Actor >, ref < WFInfo > > | mVisibleActors |
fvec4 | mDefaultLineColor |
float | mLineWidth |
float | mPolygonOffsetFactor |
float | mPolygonOffsetUnits |
float | mCreaseAngle |
bool | mShowHiddenLines |
bool | mShowCreases |
bool | mSmoothLines |
The EdgeRenderer class implements a special Renderer that automatically extracts and renders the edges of the objects in the scene.
In order to efficiently and transparently render the edges of the objects present in the scene the EdgeRenderer class keeps an internal cache of Geometry and Actor objects that contain the extracted edges. For this reason if the Geometry of an Actor changes or if an Actor is removed from the scene you should call the setActorDirty() method. This way the cached information relative to that Actor will be removed and will be recreated only if/when such Actor becomes visible again. Call the clearCache() method to invalidate the whole cache. In order to minimized the amount of memory used by the cache it is important to keep the cache as clean and up to date as possible. The color used to render the edges can be set globally using the setDefaultLineColor() method or by Actor using the declareActor() method.
Definition at line 55 of file EdgeRenderer.hpp.
vl::EdgeRenderer::EdgeRenderer | ( | ) | [inline] |
Definition at line 69 of file EdgeRenderer.hpp.
References VL_DEBUG_SET_OBJECT_NAME.
const RenderQueue * EdgeRenderer::render | ( | const RenderQueue * | in_render_queue, |
Camera * | camera, | ||
real | frame_clock | ||
) | [virtual] |
Takes as input the render queue to render and returns a possibly filtered render queue for further processing.
Renderer's implementation of this function always returns in_render_queue
.
Reimplemented from vl::Renderer.
Definition at line 40 of file EdgeRenderer.cpp.
References vl::Viewport::activate(), vl::Camera::applyProjMatrix(), vl::RenderQueue::at(), vl::OpenGLContext::bindVAS(), declareActor(), vl::Actor::enableMask(), vl::RendererAbstract::enableMask(), vl::Renderer::framebuffer(), vl::globalSettings(), vl::Renderer::isEnabled(), vl::RenderToken::mActor, mLineWidth, mVisibleActors, NULL, vl::Framebuffer::openglContext(), polygonOffsetFactor(), polygonOffsetUnits(), renderLines(), renderSolids(), vl::Viewport::setClearFlags(), showHiddenLines(), vl::RenderQueue::size(), smoothLines(), vl::Camera::viewport(), VL_CHECK, and VL_CHECK_OGL.
Generates and caches all the information needed to render the edges of the given Actor using the specified color.
Definition at line 244 of file EdgeRenderer.cpp.
References creaseAngle(), vl::EdgeExtractor::edges(), vl::EdgeExtractor::extractEdges(), vl::EdgeExtractor::generateEdgeGeometry(), vl::ref< T >::get(), mActorCache, NULL, and vl::EdgeExtractor::setCreaseAngle().
Referenced by render().
EdgeRenderer::WFInfo * EdgeRenderer::declareActor | ( | Actor * | act ) |
Generates and caches all the information needed to render the edges of the given Actor.
Definition at line 272 of file EdgeRenderer.cpp.
References creaseAngle(), vl::EdgeExtractor::edges(), vl::EdgeExtractor::extractEdges(), vl::EdgeExtractor::generateEdgeGeometry(), vl::ref< T >::get(), mActorCache, mDefaultLineColor, NULL, and vl::EdgeExtractor::setCreaseAngle().
void vl::EdgeRenderer::clearCache | ( | ) | [inline] |
Clears the cache containing the Actor and edge information.
Call this function when a significant part of the scene changed or was removed. The cache will be automatically rebuild at the next rendering frames.
Definition at line 84 of file EdgeRenderer.hpp.
void vl::EdgeRenderer::setActorDirty | ( | Actor * | actor ) | [inline] |
Removes all the edge/rendering information relative to the specified Actor from the cache.
Call this function when an Actor's Geometry changed or when you know that an Actor that was previously visible won't be visible anymore, for example because it has been removed from the scene. Note that if the Actor becomes visible at any point later the cache will be automatically rebuilt.
Definition at line 89 of file EdgeRenderer.hpp.
void vl::EdgeRenderer::setShowHiddenLines | ( | bool | show ) | [inline] |
If set to true
shows also the hidden lines with a dashed pattern.
Definition at line 92 of file EdgeRenderer.hpp.
bool vl::EdgeRenderer::showHiddenLines | ( | ) | const [inline] |
If set to true
shows also the hidden lines with a dashed pattern.
Definition at line 94 of file EdgeRenderer.hpp.
Referenced by render().
void vl::EdgeRenderer::setShowCreases | ( | bool | show ) | [inline] |
If set to true
shows not only the edges that define the silhouette of an object but also the crease edges.
Definition at line 97 of file EdgeRenderer.hpp.
bool vl::EdgeRenderer::showCreases | ( | ) | const [inline] |
If set to true
shows not only the edges that define the silhouette of an object but also the crease edges.
Definition at line 99 of file EdgeRenderer.hpp.
Referenced by renderSolids().
void vl::EdgeRenderer::setCreaseAngle | ( | float | degrees ) | [inline] |
The minimum angle (in degrees) considered to generate crease-edges (default is 44 degrees).
Definition at line 102 of file EdgeRenderer.hpp.
References vl::degrees().
float vl::EdgeRenderer::creaseAngle | ( | ) | const [inline] |
The minimum angle (in degrees) considered to generate crease-edges (default is 44 degrees).
Definition at line 104 of file EdgeRenderer.hpp.
Referenced by declareActor().
void vl::EdgeRenderer::setSmoothLines | ( | bool | smooth ) | [inline] |
If set to true
the lines will be rendered using antialiasing.
Definition at line 107 of file EdgeRenderer.hpp.
bool vl::EdgeRenderer::smoothLines | ( | ) | const [inline] |
If set to true
the lines will be rendered using antialiasing.
Definition at line 109 of file EdgeRenderer.hpp.
Referenced by render().
void vl::EdgeRenderer::setLineWidth | ( | float | width ) | [inline] |
Defines the width of the rendered edges.
Definition at line 112 of file EdgeRenderer.hpp.
float vl::EdgeRenderer::lineWidth | ( | ) | const [inline] |
Defines the width of the rendered edges.
Definition at line 114 of file EdgeRenderer.hpp.
void vl::EdgeRenderer::setDefaultLineColor | ( | const fvec4 & | c ) | [inline] |
Defines the default color of the rendered edges. You can also define a per-Actor color using the declareActor() method.
Definition at line 117 of file EdgeRenderer.hpp.
const fvec4& vl::EdgeRenderer::defaultLineColor | ( | ) | const [inline] |
Defines the default color of the rendered edges. You can also define a per-Actor color using the declareActor() method.
Definition at line 119 of file EdgeRenderer.hpp.
void vl::EdgeRenderer::setPolygonOffsetFactor | ( | float | factor ) | [inline] |
Defines the factor
parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information.
Definition at line 122 of file EdgeRenderer.hpp.
float vl::EdgeRenderer::polygonOffsetFactor | ( | ) | const [inline] |
Defines the factor
parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information.
Definition at line 124 of file EdgeRenderer.hpp.
Referenced by render().
void vl::EdgeRenderer::setPolygonOffsetUnits | ( | float | units ) | [inline] |
Defines the units
parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information.
Definition at line 126 of file EdgeRenderer.hpp.
float vl::EdgeRenderer::polygonOffsetUnits | ( | ) | const [inline] |
Defines the units
parameter used to render the lines over the polygons. See also http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml for more information.
Definition at line 128 of file EdgeRenderer.hpp.
Referenced by render().
Definition at line 150 of file EdgeRenderer.cpp.
References vl::Camera::applyViewMatrix(), vl::Renderer::framebuffer(), vl::ref< T >::get(), mVisibleActors, NULL, vl::Framebuffer::openglContext(), vl::Matrix4< T_Scalar >::ptr(), showCreases(), vl::Camera::viewMatrix(), VL_CHECK, VL_glLoadMatrix, VL_glMultMatrix, and vl::Transform::worldMatrix().
Referenced by render().
void EdgeRenderer::renderLines | ( | Camera * | camera ) | [protected] |
Definition at line 199 of file EdgeRenderer.cpp.
References vl::Camera::applyViewMatrix(), vl::Renderer::framebuffer(), vl::ref< T >::get(), mVisibleActors, NULL, vl::Framebuffer::openglContext(), vl::Matrix4< T_Scalar >::ptr(), vl::Camera::viewMatrix(), VL_glLoadMatrix, VL_glMultMatrix, and vl::Transform::worldMatrix().
Referenced by render().
std::map< ref<Actor>, ref<WFInfo> > vl::EdgeRenderer::mActorCache [protected] |
Definition at line 135 of file EdgeRenderer.hpp.
Referenced by declareActor().
std::map< ref<Actor>, ref<WFInfo> > vl::EdgeRenderer::mVisibleActors [protected] |
Definition at line 136 of file EdgeRenderer.hpp.
Referenced by render(), renderLines(), and renderSolids().
fvec4 vl::EdgeRenderer::mDefaultLineColor [protected] |
Definition at line 137 of file EdgeRenderer.hpp.
Referenced by declareActor().
float vl::EdgeRenderer::mLineWidth [protected] |
Definition at line 138 of file EdgeRenderer.hpp.
Referenced by render().
float vl::EdgeRenderer::mPolygonOffsetFactor [protected] |
Definition at line 139 of file EdgeRenderer.hpp.
float vl::EdgeRenderer::mPolygonOffsetUnits [protected] |
Definition at line 140 of file EdgeRenderer.hpp.
float vl::EdgeRenderer::mCreaseAngle [protected] |
Definition at line 141 of file EdgeRenderer.hpp.
bool vl::EdgeRenderer::mShowHiddenLines [protected] |
Definition at line 142 of file EdgeRenderer.hpp.
bool vl::EdgeRenderer::mShowCreases [protected] |
Definition at line 143 of file EdgeRenderer.hpp.
bool vl::EdgeRenderer::mSmoothLines [protected] |
Definition at line 144 of file EdgeRenderer.hpp.