VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Attributes
makVrv::DtDecalProjectorRenderer Class Reference

A class responsible for rendering decal projectors for a camera context.

Decal projector components are registered with this renderer. The renderer does not own the components and the components should be unregistered when no longer in use.

The basic rendering algorithm is as follows: This renderer creates a unit cube geometry that is used as a render proxy for the bounds of decal primitives. If the camera is inside the decal projection bounds, then cull face is reversed for the cube so that the inside of the cube is rendered. The unit cube is rendered and in the vertex shader the cube is expanded to the actual bounds of the decal projector space. The decal primitives are sent to the fragment shader in a uniform buffer. The fragment shader reads the scene depth buffer and computes the viewspace position from the depth. The depth viewspace position is then transformed to the decal projector space. It is first clipped against the projector bounds. If it's inside the bounds, then for triangles rendering, the position is checked to see if it's in any triangle and if so, then the decal frament is rendered. For line rendering, the nearest line distance is computed and if the distance is within the line width, then the decal fragment is rendered.

This class creates a specific set of shaders used for drawing the primitives. This base class renderer handles triangle primitives. There is a derived class DtDecalProjectorLineRenderer that overides a few items in order to handle line primitives.

Inheritance diagram for makVrv::DtDecalProjectorRenderer:
Inheritance graph
[legend]

Classes

struct  DrawItemInfo
 
struct  StippleKey
 

Public Member Functions

virtual ~DtDecalProjectorRenderer ()
 
 DtDecalProjectorRenderer ()=delete
 
 DtDecalProjectorRenderer (const DtDecalProjectorRenderer &other)=delete
 
DtDecalProjectorRendereroperator= (const DtDecalProjectorRenderer &other)=delete
 
virtual void releaseResources ()
 
virtual void releaseShaderResources ()
 
virtual DtCoordinateSystemfindCoordinateSystem ()
 
virtual const unsigned int maxDrawPassPoints () const
 
virtual const unsigned int topologyPointCount () const
 
virtual bool cull (const DtDecalProjectorRendererDrawSettings &drawSettings)
 
virtual void draw (const DtDecalProjectorRendererDrawSettings &drawSettings)
 
virtual DtDecalProjectorComponentcreateComponent ()
 
virtual void registerComponent (DtDecalProjectorComponent *component)
 
virtual void unregisterComponent (DtDecalProjectorComponent *component)
 
virtual size_t registeredComponentCount () const
 

Protected Types

typedef std::map< std::string,
unsigned int
TextureMap
 
typedef std::map< StippleKey,
unsigned int
StippleMap
 

Protected Member Functions

 DtDecalProjectorRenderer (DtDe &de)
 
virtual bool initializeShaders ()
 
virtual void initializeBox ()
 
virtual int evaluateAabbVsSphere (const DtVector3< double > &boxCenter, const DtVector3< double > &boxExtent, const DtVector3< double > &sphereCenter, const double sphereRadius) const
 
virtual bool isCameraOutsideBox (const DtVector3< double > &camPos, const float camFrustum[6], const DtVector3< double > &boxPos, const DtMatrix4< float > &boxRot, const DtVector3< float > &boxOffset, const DtVector3< float > &boxSize) const
 
virtual unsigned int setStipple (const unsigned int stipplePattern[32], DtOverlayResourceProvider *resourceProvider, unsigned int lastSetTextureId)
 
virtual unsigned int setTexture (DtTextureInterface *textureId, DtOverlayResourceProvider *resourceProvider, unsigned int lastSetTextureId)
 
virtual unsigned int computeStipplePatternSortId (const unsigned int pattern[32])
 
virtual void slot_coordinateSystemChanged ()
 
virtual void slot_reloadShaders ()
 

Static Protected Member Functions

static bool theSortByMaterial (const DrawItemInfo &arg0, const DrawItemInfo &arg1)
 

Protected Attributes

DtDemyDe
 
DtCoordinateSystemmyCoordinateSystem = nullptr
 
DtBufferObjectmyBufferObject
 
bool myEnabled
 
float myClipBoxExpand
 
std::string myVertexShaderFileName
 
std::string myFragmentShaderFileName
 
DtGlProgrammyGlProgram
 
DtBufferObjectmyShaderUboPoints
 
DtBufferObjectmyShaderUboPointsUVs
 
int myShaderUboPointsBinding
 
int myShaderUboPointsUVsBinding
 
int myUnfmLocModelViewMatrix
 
int myUnfmLocProjectionMatrix
 
int myUnfmLocProjectionMatrixInv
 
int myUnfmLocClipBoxPos
 
int myUnfmLocClipBoxRot
 
int myUnfmLocClipBoxCenter
 
int myUnfmLocClipBoxSize
 
int myUnfmLocPointCount
 
int myUnfmLocColor
 
int myUnfmLocCoordTileRate
 
int myUnfmLocPersMatrixReverseZ
 
int myUnfmLocViewport
 
TextureMap myTextureMap
 
float myMaxTextureAnisotropy
 
StippleMap myStippleMap
 
unsigned int myNextStippleSortId
 
std::vector
< DtDecalProjectorComponent * > 
myComponents
 
std::vector< DrawItemInfomyDrawItems
 
DtSignalConnectionManager myConnections
 

Static Protected Attributes

static const unsigned int thePointsMax = 192
 

Private Attributes

friend DtDecalProjectorRendererCreator
 

Member Typedef Documentation

typedef std::map<std::string, unsigned int> makVrv::DtDecalProjectorRenderer::TextureMap
protected

This is a map that contains stipple pattern id's used with draw items for faster material sorting. The id's are only used for sorting.

Constructor & Destructor Documentation

virtual makVrv::DtDecalProjectorRenderer::~DtDecalProjectorRenderer ( )
virtual
makVrv::DtDecalProjectorRenderer::DtDecalProjectorRenderer ( )
delete

Default Constructor not implemented.

makVrv::DtDecalProjectorRenderer::DtDecalProjectorRenderer ( const DtDecalProjectorRenderer other)
delete

Copy Constructor not implemented - Copy not allowed.

makVrv::DtDecalProjectorRenderer::DtDecalProjectorRenderer ( DtDe de)
protected

Protected CTOR Create using DtDecalProjectorRendererCreator.

Member Function Documentation

DtDecalProjectorRenderer& makVrv::DtDecalProjectorRenderer::operator= ( const DtDecalProjectorRenderer other)
delete

Assignment Operator not implemented - Assignment not allowed.

virtual void makVrv::DtDecalProjectorRenderer::releaseResources ( )
virtual

Release all rendering resources.

virtual void makVrv::DtDecalProjectorRenderer::releaseShaderResources ( )
virtual

Release shader specific rendering resources.

virtual DtCoordinateSystem* makVrv::DtDecalProjectorRenderer::findCoordinateSystem ( )
virtual

Returns the cloned coordinate system.

virtual const unsigned int makVrv::DtDecalProjectorRenderer::maxDrawPassPoints ( ) const
virtual

Returns the maximum supported points per draw pass.

virtual const unsigned int makVrv::DtDecalProjectorRenderer::topologyPointCount ( ) const
virtual

Returns the number of points per primitive. For example a triangle = 3, a line = 2.

Reimplemented in makVrv::DtDecalProjectorLineRenderer.

virtual bool makVrv::DtDecalProjectorRenderer::cull ( const DtDecalProjectorRendererDrawSettings drawSettings)
virtual

Culls all decals. Returns true if there is anything to draw.

virtual void makVrv::DtDecalProjectorRenderer::draw ( const DtDecalProjectorRendererDrawSettings drawSettings)
virtual

Draws all decals.

virtual DtDecalProjectorComponent* makVrv::DtDecalProjectorRenderer::createComponent ( )
virtual

Creates and returns a component that is compatible with this system. The component will register itself with this system on creation. The component will un-register itself with this system on destruction. The system does not own the component. The caller of this createComponent() method will own the component and should destroy it when done with it.

virtual void makVrv::DtDecalProjectorRenderer::registerComponent ( DtDecalProjectorComponent component)
virtual

Registers the given component with this system. The system does not own the component. The system will perform operations on the component while it is registered.

virtual void makVrv::DtDecalProjectorRenderer::unregisterComponent ( DtDecalProjectorComponent component)
virtual

Un-Registers the given component with this system. The system does not own the component.

virtual size_t makVrv::DtDecalProjectorRenderer::registeredComponentCount ( ) const
virtual

Returns the number of registered components.

virtual bool makVrv::DtDecalProjectorRenderer::initializeShaders ( )
protectedvirtual

Loads and creates shaders for the program.

virtual void makVrv::DtDecalProjectorRenderer::initializeBox ( )
protectedvirtual

Initializes a unit cube box used to render a proxy box. The box is scaled inside of the vertex shader to be the size of the decal clipping box.

virtual int makVrv::DtDecalProjectorRenderer::evaluateAabbVsSphere ( const DtVector3< double > &  boxCenter,
const DtVector3< double > &  boxExtent,
const DtVector3< double > &  sphereCenter,
const double  sphereRadius 
) const
protectedvirtual

Tests for an intersection betweenan axis-align bounding box and a sphere. Returns 1 if the sphere is outside of the box. Returns -1 if the sphere is inside of the box. Returns 0 if the sphere is intersecting with the box.

virtual bool makVrv::DtDecalProjectorRenderer::isCameraOutsideBox ( const DtVector3< double > &  camPos,
const float  camFrustum[6],
const DtVector3< double > &  boxPos,
const DtMatrix4< float > &  boxRot,
const DtVector3< float > &  boxOffset,
const DtVector3< float > &  boxSize 
) const
protectedvirtual

Tests whether the camera is outside of the given box. Accounts for the near clip of the camera.

virtual unsigned int makVrv::DtDecalProjectorRenderer::setStipple ( const unsigned int  stipplePattern[32],
DtOverlayResourceProvider resourceProvider,
unsigned int  lastSetTextureId 
)
protectedvirtual

Gets the stipple pattern texture from the resource provider. Sets the stipple pattern texture as the current texture. Returns the texture id that was set (0 if error).

Parameters
stipplePatternThe pattern for the resource provider
resourceProviderThe resource provider to get the texture from
lastSetTextureIdThe last texture id that was set (used to prevent state change)
virtual unsigned int makVrv::DtDecalProjectorRenderer::setTexture ( DtTextureInterface textureId,
DtOverlayResourceProvider resourceProvider,
unsigned int  lastSetTextureId 
)
protectedvirtual

Creates a texture from the given texture interface handle if needed. The texture interface handle comes from the 2D overlay system and therefore needs duplicated for 3D so mip-maps can be generated and mip-map sampling can be used. Sets the texture as the current texture. Returns the texture id that was set (0 if error).

Parameters
textureIdThe texture handle for the resource provider
resourceProviderThe resource provider to get the texture from
lastSetTextureIdThe last texture id that was set (used to prevent state change)
virtual unsigned int makVrv::DtDecalProjectorRenderer::computeStipplePatternSortId ( const unsigned int  pattern[32])
protectedvirtual

Computes and returns a sorting id unique to the given stipple pattern. This is used for sorting draw items by material.

virtual void makVrv::DtDecalProjectorRenderer::slot_coordinateSystemChanged ( )
protectedvirtual

slot for when the coordinate system changes

virtual void makVrv::DtDecalProjectorRenderer::slot_reloadShaders ( )
protectedvirtual

slot to handle shader reloading

static bool makVrv::DtDecalProjectorRenderer::theSortByMaterial ( const DrawItemInfo arg0,
const DrawItemInfo arg1 
)
staticprotected

sort function used for sorting draw items by material

Member Data Documentation

friend makVrv::DtDecalProjectorRenderer::DtDecalProjectorRendererCreator
private
const unsigned int makVrv::DtDecalProjectorRenderer::thePointsMax = 192
staticprotected

This is the maximum number of primitive points that the fragment shader can support. If the shader is changed, then this value needs to change. It's in both the triangle and line fragment shaders.

DtDe& makVrv::DtDecalProjectorRenderer::myDe
protected
DtCoordinateSystem* makVrv::DtDecalProjectorRenderer::myCoordinateSystem = nullptr
protected

local clone of the system wide coordinate system. for thread safety.

DtBufferObject* makVrv::DtDecalProjectorRenderer::myBufferObject
protected
bool makVrv::DtDecalProjectorRenderer::myEnabled
protected
float makVrv::DtDecalProjectorRenderer::myClipBoxExpand
protected
std::string makVrv::DtDecalProjectorRenderer::myVertexShaderFileName
protected
std::string makVrv::DtDecalProjectorRenderer::myFragmentShaderFileName
protected
DtGlProgram* makVrv::DtDecalProjectorRenderer::myGlProgram
protected
DtBufferObject* makVrv::DtDecalProjectorRenderer::myShaderUboPoints
protected
DtBufferObject* makVrv::DtDecalProjectorRenderer::myShaderUboPointsUVs
protected
int makVrv::DtDecalProjectorRenderer::myShaderUboPointsBinding
protected
int makVrv::DtDecalProjectorRenderer::myShaderUboPointsUVsBinding
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocModelViewMatrix
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocProjectionMatrix
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocProjectionMatrixInv
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocClipBoxPos
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocClipBoxRot
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocClipBoxCenter
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocClipBoxSize
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocPointCount
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocColor
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocCoordTileRate
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocPersMatrixReverseZ
protected
int makVrv::DtDecalProjectorRenderer::myUnfmLocViewport
protected
TextureMap makVrv::DtDecalProjectorRenderer::myTextureMap
protected
float makVrv::DtDecalProjectorRenderer::myMaxTextureAnisotropy
protected
StippleMap makVrv::DtDecalProjectorRenderer::myStippleMap
protected
unsigned int makVrv::DtDecalProjectorRenderer::myNextStippleSortId
protected
std::vector<DtDecalProjectorComponent*> makVrv::DtDecalProjectorRenderer::myComponents
protected
std::vector<DrawItemInfo> makVrv::DtDecalProjectorRenderer::myDrawItems
protected
DtSignalConnectionManager makVrv::DtDecalProjectorRenderer::myConnections
protected

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

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)