# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

Classes | Public Member Functions | Protected Attributes

# vl::DepthSortCallback Class Reference

The DepthSortCallback class sorts the primitives of the Geometry object bound to the Actor in which the callback is installed. More...

`#include <DepthSortCallback.hpp>`

Inheritance diagram for vl::DepthSortCallback:

List of all members.

## Classes

class | Line
class | Point
class | PrimitiveZ
class | Quad
class | Sorter_Back_To_Front
class | Sorter_Front_To_Back
class | Triangle

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| DepthSortCallback ()
| Constructor.
void | onActorDelete (Actor *)
| Event notifying that an Actor is being deleted.
virtual void | onActorRenderStarted (Actor *actor, Real, const Camera *cam, Renderable *renderable, const Shader *, int pass)
| Performs the actual sorting.
template<typename T , typename deT >
void | sort (deT *polys, std::vector< Point< T > > &sorted_points, std::vector< Line< T > > &sorted_lines, std::vector< Triangle< T > > &sorted_triangles, std::vector< Quad< T > > &sorted_quads)
ESortMode | sortMode () const
void | setSortMode (ESortMode sort_mode)
void | invalidateCache ()
| Forces sorting at the next rendering.

## Protected Attributes

ref< ArrayFloat3 > | mEyeSpaceVerts
std::vector< PrimitiveZ > | mPrimitiveZ
std::vector< PointUInt > | mSortedPointsUInt
std::vector< LineUInt > | mSortedLinesUInt
std::vector< TriangleUInt > | mSortedTrianglesUInt
std::vector< QuadUInt > | mSortedQuadsUInt
std::vector< PointUShort > | mSortedPointsUShort
std::vector< LineUShort > | mSortedLinesUShort
std::vector< TriangleUShort > | mSortedTrianglesUShort
std::vector< QuadUShort > | mSortedQuadsUShort
std::vector< PointUByte > | mSortedPointsUByte
std::vector< LineUByte > | mSortedLinesUByte
std::vector< TriangleUByte > | mSortedTrianglesUByte
std::vector< QuadUByte > | mSortedQuadsUByte
vl::mat4 | mCacheMatrix
ESortMode | mSortMode

## Detailed Description

The DepthSortCallback class sorts the primitives of the Geometry object bound to the Actor in which the callback is installed.

This callback in order to work requires the following conditions:

- The Actor must be bound to a Geometry
- The bound Geometry must have a Geometry::vertexArray() of type ArrayFloat3
- Sorts only DrawElementsUInt/UShort/UByte objects with primitive type: PT_POINTS, PT_LINES, PT_TRIANGLES, PT_QUADS

Despite the fact that the condition list seems to be quite limiting it actually covers the most common usage cases. Furthermore the use of DrawElements* and the primitive types PT_POINTS, PT_LINES, PT_TRIANGLES, PT_QUADS grant the maximum flexibility.

Note:

- This callback works well with different LODs.
- This callback works well with multipassing, the sorting is done only once.

Remarks:

- The sorting is based on the position of the vertices as specified by Geometry::vertexArray() and for obvious reasons cannot take into consideration transformations made in the vertex shader or in the geometry shader.
- The sorting is performed on a per DrawCall basis. For example, if a Geometry has 2 DrawCall A and B bound to it, then the polygons, lines or points of A will alway be rendered before the ones specified by B.

See also:
  Transparency and Polygon Depth Sorting Tutorial

Definition at line 67 of file DepthSortCallback.hpp.

## Constructor & Destructor Documentation

vl::DepthSortCallback::DepthSortCallback | ( | ) | `[inline]`

Constructor.

Definition at line 131 of file DepthSortCallback.hpp.

References mEyeSpaceVerts, setSortMode(), vl::SM_SortBackToFront, and VL_DEBUG_SET_OBJECT_NAME.

## Member Function Documentation

virtual const char* vl::DepthSortCallback::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::Object.

Definition at line 128 of file DepthSortCallback.hpp.

void vl::DepthSortCallback::onActorDelete | ( | Actor * | actor ) | `[inline, virtual]`

Event notifying that an Actor is being deleted.

Implements vl::ActorEventCallback.

Definition at line 138 of file DepthSortCallback.hpp.

virtual void vl::DepthSortCallback::onActorRenderStarted | ( | Actor * | actor,
|  | Real | ,
|  | const Camera * | cam,
|  | Renderable * | renderable,
|  | const Shader * | ,
|  | int | pass
| ) |  | `[inline, virtual]`

Performs the actual sorting.

Implements vl::ActorEventCallback.

Definition at line 141 of file DepthSortCallback.hpp.

References vl::ref< T >::get(), mCacheMatrix, mEyeSpaceVerts, mSortedLinesUByte, mSortedLinesUInt, mSortedLinesUShort, mSortedPointsUByte, mSortedPointsUInt, mSortedPointsUShort, mSortedQuadsUByte, mSortedQuadsUInt, mSortedQuadsUShort, mSortedTrianglesUByte, mSortedTrianglesUInt, mSortedTrianglesUShort, vl::Actor::transform(), vl::Camera::viewMatrix(), and vl::ITransform::worldMatrix().

template<typename T , typename deT >

void vl::DepthSortCallback::sort | ( | deT * | polys,
|  | std::vector< Point< T > > & | sorted_points,
|  | std::vector< Line< T > > & | sorted_lines,
|  | std::vector< Triangle< T > > & | sorted_triangles,
|  | std::vector< Quad< T > > & | sorted_quads
| ) |  | `[inline]`

Definition at line 199 of file DepthSortCallback.hpp.

References vl::BU_DYNAMIC_DRAW, mPrimitiveZ, vl::PT_LINES, vl::PT_POINTS, vl::PT_QUADS, vl::PT_TRIANGLES, vl::SM_SortBackToFront, and sortMode().

ESortMode vl::DepthSortCallback::sortMode | ( | ) | const`[inline]`

Definition at line 331 of file DepthSortCallback.hpp.

References mSortMode.

Referenced by sort().

void vl::DepthSortCallback::setSortMode | ( | ESortMode | sort_mode ) | `[inline]`

Definition at line 332 of file DepthSortCallback.hpp.

References mSortMode.

Referenced by DepthSortCallback().

void vl::DepthSortCallback::invalidateCache | ( | ) | `[inline]`

Forces sorting at the next rendering.

Definition at line 337 of file DepthSortCallback.hpp.

References mCacheMatrix.

## Member Data Documentation

ref<ArrayFloat3> vl::DepthSortCallback::mEyeSpaceVerts`[protected]`

Definition at line 340 of file DepthSortCallback.hpp.

Referenced by DepthSortCallback(), and onActorRenderStarted().

std::vector<PrimitiveZ> vl::DepthSortCallback::mPrimitiveZ`[protected]`

Definition at line 341 of file DepthSortCallback.hpp.

Referenced by sort().

std::vector<PointUInt> vl::DepthSortCallback::mSortedPointsUInt`[protected]`

Definition at line 343 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<LineUInt> vl::DepthSortCallback::mSortedLinesUInt`[protected]`

Definition at line 344 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<TriangleUInt> vl::DepthSortCallback::mSortedTrianglesUInt`[protected]`

Definition at line 345 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<QuadUInt> vl::DepthSortCallback::mSortedQuadsUInt`[protected]`

Definition at line 346 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<PointUShort> vl::DepthSortCallback::mSortedPointsUShort`[protected]`

Definition at line 348 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<LineUShort> vl::DepthSortCallback::mSortedLinesUShort`[protected]`

Definition at line 349 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<TriangleUShort> vl::DepthSortCallback::mSortedTrianglesUShort`[protected]`

Definition at line 350 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<QuadUShort> vl::DepthSortCallback::mSortedQuadsUShort`[protected]`

Definition at line 351 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<PointUByte> vl::DepthSortCallback::mSortedPointsUByte`[protected]`

Definition at line 353 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<LineUByte> vl::DepthSortCallback::mSortedLinesUByte`[protected]`

Definition at line 354 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<TriangleUByte> vl::DepthSortCallback::mSortedTrianglesUByte`[protected]`

Definition at line 355 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

std::vector<QuadUByte> vl::DepthSortCallback::mSortedQuadsUByte`[protected]`

Definition at line 356 of file DepthSortCallback.hpp.

Referenced by onActorRenderStarted().

vl::mat4 vl::DepthSortCallback::mCacheMatrix`[protected]`

Definition at line 358 of file DepthSortCallback.hpp.

Referenced by invalidateCache(), and onActorRenderStarted().

ESortMode vl::DepthSortCallback::mSortMode`[protected]`

Definition at line 360 of file DepthSortCallback.hpp.

Referenced by setSortMode(), and sortMode().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/DepthSortCallback.hpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:37.
Permission is granted to use this page to write and publish articles regarding Visualization Library.