Workspace 6.21.5
Public Member Functions | List of all members
MeshModelInstance Class Reference

Holds a mesh model plus optional sub-items defining its appearance. More...

#include <Rendering/SceneComponents/Models/meshmodelinstance.h>

Inheritance diagram for MeshModelInstance:
[legend]

Public Member Functions

 MeshModelInstance (const MeshModelInstance &pm)
 
 MeshModelInstance (const QString &id="")
 
 ~MeshModelInstance () override
 
void addGlypher (Glypher &item)
 
bool addLod (double distance, const QString &modelId)
 
void clearGlyphers ()
 
MeshModelInstanceclone () const override
 
const QDateTime & getClearCacheIndicator () const
 
double getEdgeBreakAngle () const
 
GlyphergetGlypher (unsigned i)
 
const GlyphergetGlypher (unsigned i) const
 
const QDateTime & getLastUpdated () const
 
double getLodDistance (size_t lod) const
 
const QString & getLodModelId (double distance) const
 
const QString & getLodModelId (size_t lod) const
 
const QString & getModelId () const
 
int getNumLods () const
 
Mesh::MeshModelSourcegetPrivateSource () const
 
ShadergetShader () const
 
const QString & getShaderId ()
 
bool hasLods () const
 
bool haveGlypher (const Glypher &item) const
 
bool haveGlyphers () const
 
bool isDepthTested () const
 
bool isInteractive () const
 
bool isSymbol () const
 
bool localBoundingBoxIsInitialized () const
 
unsigned int numGlyphers () const
 
MeshModelInstanceoperator= (const MeshModelInstance &proxy)
 
void removeGlypher (Glypher &item)
 
void removeLod (const QString &modelId)
 
void removeLod (size_t lod)
 
void setClearCacheIndicator (const QDateTime &timeStamp)
 
void setDepthTested (bool b)
 
void setEdgeBreakAngle (double theta)
 
void setInteractive (bool b)
 
void setLastUpdated (const QDateTime &timeStamp)
 
void setLocalBoundingBox (const Mesh::BoundingBoxMinimal &bb) override
 
void setModelId (const QString &id)
 
void setPrivateSource (Mesh::MeshModelSource *source)
 
void setShader (Shader *shader)
 
void setShaderId (const QString &id)
 
void setSymbol (bool b)
 
bool visit (SceneProcessor &processor) override
 
- Public Member Functions inherited from SceneItem
 ~SceneItem () override
 
SceneItemclone () const override=0
 
bool getEnabled () const
 
const QString & getId () const
 
const Mesh::BoundingBoxMinimalgetLocalBoundingBox () const
 
virtual Mesh::TransformMatrix getMatrixGlobal () const
 
virtual Mesh::TransformMatrix getMatrixLocal () const
 
const QString & getName () const
 
Mesh::TransformMatrix getParentMatrixGlobal () const
 
TransformgetParentTransform ()
 
void setEnabled (bool b)
 
void setId (const QString &itemId)
 
virtual void setLocalBoundingBox (const Mesh::BoundingBoxMinimal &bb)
 
void setName (const QString &name)
 
virtual TransformtoTransform ()
 
virtual const TransformtoTransform () const
 
virtual void updateGlobalMatrix ()
 
virtual bool visit (SceneProcessor &processor)=0
 
- Public Member Functions inherited from Observable
virtual ~Observable ()
 
void attachObserver (Observer &observer)
 
void destroy ()
 
void detachObserver (Observer &observer)
 
void notifyEvent (const ObservableEvent &event)
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()=default
 
virtual Clonableclone () const =0
 

Additional Inherited Members

- Protected Member Functions inherited from SceneItem
 SceneItem (const QString &id)
 
 SceneItem (const SceneItem &item)
 
virtual void addToScene (Scene &scene, const QString &opIdPath="")
 
bool isTransformModified () const
 
SceneItemoperator= (const SceneItem &item)
 
void setTransformModified (bool b)
 
- Protected Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 

Detailed Description

A MeshModelInstance is essentially a thin proxy for a MeshModel. It supplies a String id instead of the MeshModel itself so that the the loading of the MeshModel can be delayed until it is actually needed, or possibly avoided altogether. See setModelId() for more details.

Constructor & Destructor Documentation

◆ MeshModelInstance() [1/2]

MeshModelInstance ( const QString &  id = "")

◆ MeshModelInstance() [2/2]

Parameters
pmThe model instance to copy. All its glyphers are also cloned to ensure that the new copy shares no data with pm.

◆ ~MeshModelInstance()

~MeshModelInstance ( )
override

Member Function Documentation

◆ addGlypher()

void addGlypher ( Glypher item)
Parameters
itemThe glypher to add to this model instance. It must not already have been added to the model instance.
See also
removeGlypher()

◆ addLod()

bool addLod ( double  distance,
const QString &  modelId 
)
Parameters
distance
modelId
Returns

◆ clearGlyphers()

void clearGlyphers ( )

Clears the list of Glyphers associated with this model instance. The items themselves are not deleted, since it is assumed that they are owned by something else, not the model instance.

◆ clone()

MeshModelInstance * clone ( ) const
overridevirtual
Returns
A clone of this object.
Note
Subclasses would normally return their own type rather than the Clonable type. The C++ language rules allow a more derived type to be returned from a virtual function and the compiler will still treat it as a valid override.

Implements SceneItem.

◆ getClearCacheIndicator()

const QDateTime & getClearCacheIndicator ( ) const

◆ getEdgeBreakAngle()

double getEdgeBreakAngle ( ) const
Returns
The edge break angle used by this meshmodel instance.
See also
setEdgeBreakAngle

◆ getGlypher() [1/2]

Glypher & getGlypher ( unsigned  index)
Parameters
indexThe index of the item to retrieve. It must be less than the number of items returned from numGlyphers().

◆ getGlypher() [2/2]

const Glypher & getGlypher ( unsigned  index) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ getLastUpdated()

const QDateTime & getLastUpdated ( ) const

◆ getLodDistance()

double getLodDistance ( size_t  lod) const
Parameters
lod
Returns

◆ getLodModelId() [1/2]

const QString & getLodModelId ( double  distance) const
Parameters
distance
Returns

◆ getLodModelId() [2/2]

const QString & getLodModelId ( size_t  lod) const
Parameters
lod
Returns

◆ getModelId()

const QString & getModelId ( ) const
Returns
The ID string currently assigned to this mesh model instance.
Note
If the model has LOD's defined, this may not be the modelID that is used at visualisation time.
See also
setModelId()

◆ getNumLods()

int getNumLods ( ) const
Returns
The number of levels of detail this instance has; i.e. how many unique meshes (and therefore model ids) does it contain.

◆ getPrivateSource()

Mesh::MeshModelSource * getPrivateSource ( ) const

◆ getShader()

Shader * getShader ( ) const
Returns
The shader directly attached to this MeshModelInstance, if one exists.
Note
A MeshModelInstance may be rendered using a shader retrieved from a ShaderLibrary using its specified ShaderId
See also
setShader
setShaderId
getShaderId

◆ getShaderId()

const QString & getShaderId ( )
Returns
The shaderId being used. See setShaderId for more information.
See also
setShader
setShaderId
getShader

◆ hasLods()

bool hasLods ( ) const
Returns
true if lods are used for this instance, false otherwise.

◆ haveGlypher()

bool haveGlypher ( const Glypher item) const
Parameters
itemThe glypher to look for.
Returns
True if item has been added to the model instance as an glypher.

◆ haveGlyphers()

bool haveGlyphers ( ) const
Returns
True if this model instance has any glyphers added to it.
See also
numGlyphers()

◆ isDepthTested()

bool isDepthTested ( ) const
Returns
True if the instance will be treated as an "overlay" (i.e. depth testing will be turned off).

◆ isInteractive()

bool isInteractive ( ) const
Returns
True if the MeshModelInstance is interactive, i.e. whether it is able to be interacted with via widgets like the WSGLWidget.

◆ isSymbol()

bool isSymbol ( ) const
Returns
True if this instance should be treated as a symbol.

◆ localBoundingBoxIsInitialized()

bool localBoundingBoxIsInitialized ( ) const

◆ numGlyphers()

unsigned numGlyphers ( ) const
Returns
The number of glyphers that have been added to the model instance.
See also
haveGlyphers()

◆ operator=()

MeshModelInstance & operator= ( const MeshModelInstance proxy)
Parameters
proxyThe object to assign to this one.
Returns
A reference to this object.

◆ removeGlypher()

void removeGlypher ( Glypher item)
Parameters
itemThe glypher to remove from this model instance. It must have been added to the model instance. It is an error to ask to remove an item that is not present.
See also
addGlypher()

◆ removeLod() [1/2]

void removeLod ( const QString &  modelId)
Parameters
modelId

◆ removeLod() [2/2]

void removeLod ( size_t  lod)
Parameters
lod

◆ setClearCacheIndicator()

void setClearCacheIndicator ( const QDateTime &  timeStamp)

◆ setDepthTested()

void setDepthTested ( bool  b)
Parameters
bIf true, the instance will be treated as an "overlay" (i.e. depth testing will be turned off).

◆ setEdgeBreakAngle()

void setEdgeBreakAngle ( double  theta)

The edge break angle of this mesh model instance. This edge break angle will be used to calculate the surface normals for the model when it is rendered. The angle is used to determine whether or not an edge is a 'soft' or 'hard' edge on the surface.

Parameters
thetaThe angle to use as the edge break angle.
See also
getEdgeBreakAngle

◆ setInteractive()

void setInteractive ( bool  b)
Parameters
bIf true, the MeshModelInstance will be interactive; it will be able to be interacted with via widgets like the WSGLWidget.

◆ setLastUpdated()

void setLastUpdated ( const QDateTime &  timeStamp)

◆ setLocalBoundingBox()

void setLocalBoundingBox ( const Mesh::BoundingBoxMinimal bb)
overridevirtual
Parameters
bbThe bounding box we are assigning to this model instance (in local (to the source) coordinates).

Reimplemented from SceneItem.

◆ setModelId()

void setModelId ( const QString &  id)
Parameters
idThe ID string for this mesh model instance.

The id string should always be obtained from a MeshModelSource which will supply the appropriate MeshModel when requested. All the hard work of supplying a MeshModel is done by MeshModelLibrary and MeshModelSource. The MeshModelInstance class merely holds the id string as an identifier for SceneProcessor implementations to use with a MeshModelLibrary so that they can request the MeshModel only when it is needed. If a given SceneProcessor doesn't actually need the mesh data, then it simply never requests it from the MeshModelLibrary and potentially the MeshModel never needs to actually be loaded. This can be a significant efficiency gain if the SceneProcessor is intelligent enough to figure out things it doesn't need or if certain parts of the scene have been "switched off". It also allows for efficient caching strategies to be used with the id being a suitable hash key that is also likely to be reasonably human readable.

Note
If the model instance has LODs, then this ModelID may not be the id used at the time that the model is being visualised.

◆ setPrivateSource()

void setPrivateSource ( Mesh::MeshModelSource source)

◆ setShader()

void setShader ( Shader shader)
Parameters
shaderThe shader to attach to this MeshModelInstance for use at render time.

Attaching a shader to a MeshModelInstance modifies the way which it is rendered There are two ways that shaders can be attached to a MeshModelInstance:

  • Directly attaching a shader, via the setShader function
  • Setting a shader ID, which will be used to look up a shader in the Scene's ShaderLibrary
Note
If both a shader ID is set and a shader is directly attached, the directly attached shader will take precedence.
See also
getShader
setShaderId
getShaderId

◆ setShaderId()

void setShaderId ( const QString &  id)
Parameters
idThe shader ID that will be used to retrieve a shader at render time using the ShaderLibrary attached to the scene.

The appearance of a MeshModelInstance can be controlled with a Shader. A shader can be either directly attached to the MeshModelInstance (see setShader) or the shader can be retrieved at render time from a ShaderLibrary using the ShaderId specified here.

See also
setShader
getShader
getShaderId

◆ setSymbol()

void setSymbol ( bool  b)
Parameters
bIf true, the instance will be treated as a symbol in the scene.

◆ visit()

bool visit ( SceneProcessor processor)
overridevirtual

Implements SceneItem.