Workspace 6.21.5
Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
WSGLModelProcessor Class Reference

Model processor which converts a MeshModelInterface into an OpenGL instance of a model (WSGLRenderItem).

#include <Rendering/OpenGL/wsglmodelprocessor.h>

Inheritance diagram for WSGLModelProcessor:
[legend]

Public Types

enum class  ProcessResult {
  ProcessSuccess = 0x1 , ModelSourceUpdateRequested , ModelProcessingQueued , ModelSourceIdMismatch ,
  ModelEmpty , ModelInstanceInvisible , ErrorCacheCapacityExceeded , ErrorModelIdInvalid ,
  ErrorModelInvalid , ErrorModelLibraryInvalid , ErrorOpenGLOperationInvalid
}
 

Signals

void glDataUpdateFinished ()
 
void glDataUpdateStarted ()
 

Public Member Functions

 WSGLModelProcessor (WSGLContext &context, const Shader &defaultShader=LambertShader())
 
 ~WSGLModelProcessor () override
 
const WSGLBufferObjectCachegetBufferObjectCache () const
 
bool getForceDefaultShader () const
 
const WSGLGlyphSetCachegetGlyphSetCache () const
 
Mesh::MeshModelLibrarygetMeshModelLibrary ()
 
const Mesh::MeshModelLibrarygetMeshModelLibrary () const
 
ShaderLibrarygetShaderLibrary ()
 
const ShaderLibrarygetShaderLibrary () const
 
bool getViewFrustumCullingEnabled () const
 
ProcessResult process (MeshModelInstance &modelInstance, WSGLRenderItem &renderItem, const Mesh::TransformMatrix &worldMatrix)
 
void setDefaultShader (const Shader &defaultShader)
 
void setEnableViewFrustumCulling (bool b)
 
void setForceDefaultShader (bool b)
 
void setFrustumInfo (const Camera &viewCamera, const Mesh::TransformMatrix &projMatrix, const Mesh::TransformMatrix &viewMatrix)
 
void setMeshModelLibrary (Mesh::MeshModelLibrary &meshModelLibrary)
 
void setShaderLibrary (ShaderLibrary &shaderLibrary)
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 

Static Public Member Functions

static QString getProcessResultString (ProcessResult result)
 

Protected Member Functions

void logText (const QString &text)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Member Enumeration Documentation

◆ ProcessResult

enum class ProcessResult
strong
Enumerator
ProcessSuccess 
ModelSourceUpdateRequested 
ModelProcessingQueued 
ModelSourceIdMismatch 
ModelEmpty 
ModelInstanceInvisible 
ErrorCacheCapacityExceeded 
ErrorModelIdInvalid 
ErrorModelInvalid 
ErrorModelLibraryInvalid 
ErrorOpenGLOperationInvalid 

Constructor & Destructor Documentation

◆ WSGLModelProcessor()

WSGLModelProcessor ( WSGLContext context,
const Shader defaultShader = LambertShader() 
)

◆ ~WSGLModelProcessor()

~WSGLModelProcessor ( )
override

Member Function Documentation

◆ getBufferObjectCache()

const WSGLBufferObjectCache & getBufferObjectCache ( ) const

◆ getForceDefaultShader()

bool getForceDefaultShader ( ) const
Returns
true if the render queue builder always assigns the default shader, false otherwise.

◆ getGlyphSetCache()

const WSGLGlyphSetCache & getGlyphSetCache ( ) const

◆ getMeshModelLibrary() [1/2]

Mesh::MeshModelLibrary & getMeshModelLibrary ( )

◆ getMeshModelLibrary() [2/2]

const Mesh::MeshModelLibrary & getMeshModelLibrary ( ) const

◆ getProcessResultString()

QString getProcessResultString ( ProcessResult  result)
static

◆ getShaderLibrary() [1/2]

ShaderLibrary & getShaderLibrary ( )

◆ getShaderLibrary() [2/2]

const ShaderLibrary & getShaderLibrary ( ) const

◆ getViewFrustumCullingEnabled()

bool getViewFrustumCullingEnabled ( ) const
Returns
True if view frustum culling is enabled, false otherwise.
See also
setEnableViewFrustumCulling()

◆ glDataUpdateFinished

void glDataUpdateFinished ( )
signal

◆ glDataUpdateStarted

void glDataUpdateStarted ( )
signal

◆ logText()

void logText ( const QString &  text)
protected
Parameters
textThe text to send to the log.

◆ process()

WSGLModelProcessor::ProcessResult process ( MeshModelInstance modelInstance,
WSGLRenderItem renderItem,
const Mesh::TransformMatrix worldMatrix 
)
Parameters
modelInstanceThe MeshModelInstance to be prepared for rendering. In essense, the renderer-agnostic information that it contains is going to be processed into OpenGL-specific information stored in renderItem.
Note
some aspects of modelInstance may be modified during the processing, such as the computation of the localBoundingBox. This is necessary because of the way that mesh data is delay-loaded by Workspace.
Parameters
renderItemThe WSGLRenderItem in which to store all of the relevant information for rendering, such as the OpenGL geometry and shader data.
worldMatrixThe current world transformation matrix that transforms local coordinates into world-space coordinates. This is needed to compute the world-space axis-aligned bounding box of modelInstance, also needed for LOD level computation.
Returns
true if the processing was successful, false if an error occurred, such as a MeshModelSource not being up-to-date. In this specific case, the caller should check the sourceUpdateRequested() flag.

Processes modelInstance for rendering, creating the relevant OpenGL buffers and other necessary information for rendering and storing it in renderItem.

◆ setDefaultShader()

void setDefaultShader ( const Shader defaultShader)
Parameters
defaultShaderThe shader to use as the default if an item does not have a shader applied. Alternatively, if setForceDefaultShader() is enabled, the shader will be used for all items in the scene.

◆ setEnableViewFrustumCulling()

void setEnableViewFrustumCulling ( bool  b)
Parameters
bWhether or not to enable view frustum culling, which is where objects are not processed if they are outside the region encompassed by the view frustum.

◆ setForceDefaultShader()

void setForceDefaultShader ( bool  b)
Parameters
bForce the render queue builder to always assign the default shader.

◆ setFrustumInfo()

void setFrustumInfo ( const Camera viewCamera,
const Mesh::TransformMatrix projMatrix,
const Mesh::TransformMatrix viewMatrix 
)
Parameters
viewCamera
projMatrix
viewMatrix

◆ setMeshModelLibrary()

void setMeshModelLibrary ( Mesh::MeshModelLibrary meshModelLibrary)
Parameters
meshModelLibraryThe mesh model library that will supply all mesh model data.

This function should be called before making a pass through the scene from which the models belong to. The scene's library can change, hence why it needs to be set for each pass.

◆ setShaderLibrary()

void setShaderLibrary ( ShaderLibrary shaderLibrary)
Parameters
shaderLibraryThe ShaderLibrary that will be used by the model processor for retrieving shaders for MeshModelInstances.

MeshModelInstances may have a ShaderId attached to them. This ID is used by the WSGLMeshModelProcessor to retrieve a shader and attach it to the WSGLRenderItem currently being processed.