Visual Computing Library
|
The MeshRenderSettings class allows an easy management of render settings of a Mesh. This class stores the rendering status of a Mesh, the rendering capability of a Mesh and a series of other data like user colors used for the mesh primitives. More...
#include <vclib/render/drawable/mesh/mesh_render_settings.h>
Public Member Functions | |
MeshRenderSettings ()=default | |
Construct a new MeshRenderSettings object with capabilities set to false. | |
template<MeshConcept MeshType> | |
MeshRenderSettings (const MeshType &m) | |
Construct a new MeshRenderSettings object from a Mesh. | |
MeshRenderInfo | drawMode () const |
Returns the current draw mode as a MeshRenderInfo object. | |
bool | operator== (const MeshRenderSettings &) const =default |
bool | operator!= (const MeshRenderSettings &) const =default |
bool | canBeVisible () const |
Returns whether the mesh can be visible. | |
template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum > | |
bool | can (Enum val) const |
Returns the capability of a given option for the given primitive. | |
bool | canPoints (MeshRenderInfo::Points p) const |
Returns the capability of a given option for the points primitive. | |
bool | canSurface (MeshRenderInfo::Surface s) const |
Returns the capability of a given option for the surface primitive. | |
bool | canWireframe (MeshRenderInfo::Wireframe w) const |
Returns the capability of a given option for the wireframe primitive. | |
bool | canEdges (MeshRenderInfo::Edges e) const |
Returns the capability of a given option for the edges primitive. | |
bool | isVisible () const |
Returns whether the mesh is visible. | |
template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum > | |
bool | is (Enum val) const |
Returns whether the given option for the given primitive is set. | |
bool | isPoints (MeshRenderInfo::Points p) const |
Returns whether the given points option is set. | |
float | pointWidth () const |
vcl::Color | pointUserColor () const |
const float * | pointUserColorData () const |
bool | isSurface (MeshRenderInfo::Surface s) const |
Returns whether the given surface option is set. | |
vcl::Color | surfaceUserColor () const |
const uint * | surfaceUserColorData () const |
bool | isWireframe (MeshRenderInfo::Wireframe w) const |
Returns whether the given wireframe option is set. | |
int | wireframeWidth () const |
vcl::Color | wireframeUserColor () const |
const float * | wireframeUserColorData () const |
bool | isEdges (MeshRenderInfo::Edges e) const |
Returns whether the given edges option is set. | |
int | edgesWidth () const |
vcl::Color | edgesUserColor () const |
const uint * | edgesUserColorData () const |
bool | setVisibility (bool b) |
Sets the visibility of the mesh. | |
template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum > | |
bool | set (Enum val, bool b=true) |
Sets given the shading option of the given primitive. | |
bool | setPoints (MeshRenderInfo::Points p, bool b=true) |
Sets the given shading option of the points. | |
bool | setPointsWidth (float width) |
bool | setPointsUserColor (float r, float g, float b, float a=1) |
bool | setPointsUserColor (const vcl::Color &c) |
bool | setSurface (MeshRenderInfo::Surface s, bool b=true) |
Sets the given shading option of the surface. | |
bool | setSurfaceUserColor (float r, float g, float b, float a=1) |
bool | setSurfaceUserColor (const vcl::Color &c) |
bool | setWireframe (MeshRenderInfo::Wireframe w, bool b=true) |
Sets the given shading option of the wireframe. | |
bool | setWireframeUserColor (float r, float g, float b, float a=1) |
bool | setWireframeUserColor (const vcl::Color &c) |
bool | setWireframeWidth (int width) |
bool | setEdges (MeshRenderInfo::Edges e, bool b=true) |
Sets the given shading option of the edges. | |
bool | setEdgesUserColor (float r, float g, float b, float a=1) |
bool | setEdgesUserColor (const vcl::Color &c) |
bool | setEdgesWidth (int width) |
template<MeshConcept MeshType> | |
void | setRenderCapabilityFrom (const MeshType &m) |
void | setDefaultSettingsFromCapability () |
Private Types | |
using | MRI = MeshRenderInfo |
Private Member Functions | |
template<MeshRenderInfo::Primitive PRIMITIVE, typename Enum > | |
void | setCapability (Enum val, bool b=true) |
void | setPointsCapability (MeshRenderInfo::Points p, bool b=true) |
void | setSurfaceCapability (MeshRenderInfo::Surface s, bool b=true) |
void | setWireframeCapability (MeshRenderInfo::Wireframe w, bool b=true) |
void | setEdgesCapability (MeshRenderInfo::Edges e, bool b=true) |
void | setDefaultPointSettingsFromCapability () |
void | setDefaultSurfaceSettingsFromCapability () |
void | setDefaultWireframeSettingsFromCapability () |
void | setDefaultEdgeSettingsFromCapability () |
Private Attributes | |
MeshRenderInfo | mCapability |
MeshRenderInfo | mDrawMode |
float | mPointWidth = 3 |
float | mPointUserColor [4] = {1, 1, 0, 1} |
uint | mSurfUserColor = 0xFF808080 |
int | mWrfWidth = 1 |
float | mWrfUserColor [4] = {0, 0, 0, 1} |
int | mEdgesWidth = 1 |
uint | mEdgesUserColor = 0xFF000000 |
The MeshRenderSettings class allows an easy management of render settings of a Mesh. This class stores the rendering status of a Mesh, the rendering capability of a Mesh and a series of other data like user colors used for the mesh primitives.
Render capabilities store what can be actually rendered of a vcl::Mesh (e.g. it will be possible to render the surface of the mesh if the Mesh has Faces, or it will be possible to render per Face colors only if the Mesh has enabled per face colors).
The render status of this class is guaranteed to be consistent to the render capabilities.
An instance of this class must be initialized with a vcl::Mesh at first, in order to initialize the render capabilites. Render settings won't be possible to set if this class is not first initialized using a vcl::Mesh, trough the constructor or the setRenderCapabilityFrom()
member function.
Render capabilities can be get by calling the member functions can*()
for each primitive, and providing the according enum value for the option to query.
The memeber functions is*()
allow to get the current render status for each primitive, providing the according enum value for the option to query.
The render status can be modified using the set*()
member functions for each primitive. They return a boolean indicating if the operation has been performed (if the capabilities allows it, the operation will be always performed).
The set*()
functions are guaranteed to keep the state of the draw mode consistent. This means that if the user sets an option that belongs to a range (e.g. SHADING_*), the other options of the range will be automatically set to false.
|
default |
Construct a new MeshRenderSettings object with capabilities set to false.
An object created with this constructor will not be able to set any rendering option until the setRenderCapabilityFrom()
member function is called.
|
inline |
Construct a new MeshRenderSettings object from a Mesh.
This constructor initializes the render capabilities from the given Mesh object. The render settings are then set to the default values.
MeshType | the type of the Mesh object. |
m | the Mesh object to initialize the render capabilities. |
|
inline |
Returns the capability of a given option for the given primitive.
The primitive is a template parameter that specifies the primitive to query. The Enum parameter specifies the option to query.
PRIMTIVE | the primitive for which to get the capability. |
[in] | val | the option to query. |
true
if the option can be set, false
otherwise.
|
inline |
Returns whether the mesh can be visible.
true
if the mesh can be visible, false
otherwise.
|
inline |
Returns the capability of a given option for the edges primitive.
[in] | e | the edges option to query. |
true
if the option can be set, false
otherwise.
|
inline |
Returns the capability of a given option for the points primitive.
[in] | p | the points option to query. |
true
if the option can be set, false
otherwise.
|
inline |
Returns the capability of a given option for the surface primitive.
[in] | s | the surface option to query. |
true
if the option can be set, false
otherwise.
|
inline |
Returns the capability of a given option for the wireframe primitive.
[in] | w | the wireframe option to query. |
true
if the option can be set, false
otherwise.
|
inline |
Returns the current draw mode as a MeshRenderInfo object.
|
inline |
Returns whether the given option for the given primitive is set.
The primitive is a template parameter that specifies the primitive to query. The Enum parameter specifies the option to query.
PRIMTIVE | the primitive for which to get the option. |
[in] | val | the option to query. |
true
if the option is set, false
otherwise.
|
inline |
Returns whether the given edges option is set.
[in] | e | the edges option to query. |
true
if the option is set, false
otherwise.
|
inline |
Returns whether the given points option is set.
[in] | p | the points option to query. |
true
if the option is set, false
otherwise.
|
inline |
Returns whether the given surface option is set.
[in] | s | the surface option to query. |
true
if the option is set, false
otherwise.
|
inline |
Returns whether the mesh is visible.
true
if the mesh is visible, false
otherwise.
|
inline |
Returns whether the given wireframe option is set.
[in] | w | the wireframe option to query. |
true
if the option is set, false
otherwise.
|
inline |
Sets given the shading option of the given primitive.
The primitive is a template parameter that specifies the primitive to query. The Enum parameter specifies the option to query.
If the capability does not allow to set the given option, the function does nothing and it returns false
. Otherwise, it returns true
.
If the option does not have a range (e.g. VISIBLE), the
b | parameter will be used to set the option to the primitive. |
If the option has a range (e.g. the range SHADING_*), the
b | is not considered. The given option is set to true , and all the other options of the range are automatically set to false . |
PRIMTIVE | the primitive for which to set the option. |
[in] | val | the primitive option to set |
[in] | b | boolean value to set to the option (if it is not a range). |
true
if the option has been set, false otherwise.
|
inline |
Sets the given shading option of the edges.
If the capability does not allow to set the given option, the function does nothing and it returns false
. Otherwise, it returns true
.
If the option does not have a range (e.g. VISIBLE), the
b | parameter will be used to set the option to the edges. |
If the option has a range (e.g. the range SHADING_*), the
b | is not considered. The given option is set to true , and all the other options of the range are automatically set to false . | |
[in] | e | the edges option to set |
[in] | b | boolean value to set to the option (if it is not a range). |
true
if the option has been set, false otherwise.
|
inline |
Sets the given shading option of the points.
If the capability does not allow to set the given option, the function does nothing and it returns false
. Otherwise, it returns true
.
If the option does not have a range (e.g. VISIBLE), the
b | parameter will be used to set the option to the points. |
If the option has a range (e.g. the range SHADING_*), the
b | is not considered. The given option is set to true , and all the other options of the range are automatically set to false . | |
[in] | p | the points option to set |
[in] | b | boolean value to set to the option (if it is not a range). |
true
if the option has been set, false otherwise.
|
inline |
Sets the given shading option of the surface.
If the capability does not allow to set the given option, the function does nothing and it returns false
. Otherwise, it returns true
.
If the option does not have a range (e.g. VISIBLE), the
b | parameter will be used to set the option to the surface. |
If the option has a range (e.g. the range SHADING_*), the
b | is not considered. The given option is set to true , and all the other options of the range are automatically set to false . | |
[in] | s | the surface option to set |
[in] | b | boolean value to set to the option (if it is not a range). |
true
if the option has been set, false otherwise. Sets the visibility of the mesh.
The visibility status can be set only if the capability allows it.
[in] | b | the visibility status to set. |
true
if the visibility status has been set, false
otherwise.
|
inline |
Sets the given shading option of the wireframe.
If the capability does not allow to set the given option, the function does nothing and it returns false
. Otherwise, it returns true
.
If the option does not have a range (e.g. VISIBLE), the
b | parameter will be used to set the option to the wireframe. |
If the option has a range (e.g. the range SHADING_*), the
b | is not considered. The given option is set to true , and all the other options of the range are automatically set to false . | |
[in] | w | the wireframe option to set |
[in] | b | boolean value to set to the option (if it is not a range). |
true
if the option has been set, false otherwise.