NAP
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
VisualizeNormalsMesh Class Reference

#include <visualizenormalsmesh.h>

Public Member Functions

 VisualizeNormalsMesh (Core &core)
 
virtual bool init (utility::ErrorState &errorState) override
 
virtual MeshInstancegetMeshInstance () override
 
virtual const MeshInstancegetMeshInstance () const override
 
bool calculateNormals (utility::ErrorState &error, bool push=true)
 
bool setReferenceMesh (IMesh &mesh, nap::utility::ErrorState &error)
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

ResourcePtr< IMeshmReferenceMesh = nullptr
 Property: 'ReferenceMesh' link to the mesh that is used as a reference, can be null (ie: nothing) More...
 
float mNormalLength = 1.0f
 Property: 'Length' length of the normals. More...
 
EMemoryUsage mUsage = EMemoryUsage::DynamicWrite
 Property: 'Usage' If the normals are created once or frequently updated. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Protected Member Functions

bool createMeshInstance (utility::ErrorState &error)
 

Protected Attributes

std::unique_ptr< MeshInstancemMeshInstance = nullptr
 
nap::Vec3VertexAttributemPositionAttr = nullptr
 
nap::FloatVertexAttributemTipAttr = nullptr
 
nap::Vec3VertexAttributemNormalsAttr = nullptr
 
std::vector< nap::Vec3VertexAttribute * > mUvAttrs
 
std::vector< nap::Vec4VertexAttribute * > mColorAttrs
 
nap::IMeshmCurrentReferenceMesh = nullptr
 
nap::RenderServicemRenderService = nullptr
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

This mesh builds a line structure based on the vertices of another mesh The line structure represents the normals of the reference mesh and can be drawn to screen. The mesh itself carries multiple attributes of which 'position' and 'típ' are default. Use the tip vertex attribute to identify the bottom / top part of the vertex. the tip value = 1 at the beginning of the normal line and 0 at the end. This resource also copies the color, normal and uv channels as attributes to both points of the normal line. The normal is scaled based on the normal length property and applied to both vertices of the normal line This operator needs a reference mesh to initialize itself, defined by the 'ReferenceMesh' property. It is possible to switch the reference mesh at runtime, although discouraged. When you switch the reference mesh at runtime make sure the new reference mesh has the same number of attributes!

Inheritance diagram for VisualizeNormalsMesh:
[legend]
Collaboration diagram for VisualizeNormalsMesh:
[legend]

Constructor & Destructor Documentation

◆ VisualizeNormalsMesh()

Member Function Documentation

◆ calculateNormals()

bool calculateNormals ( utility::ErrorState error,
bool  push = true 
)

Updates the normals based on the data in the reference mesh

Parameters
errorcontains the error when normals could not be pushed to the GPU.
pushif the new positions should be pushed on to the GPU.

◆ createMeshInstance()

bool createMeshInstance ( utility::ErrorState error)
protected

Creates the mesh instance and single shape associated with that mesh instance Called during init but can be called in derived classes to create the mesh instance

◆ getMeshInstance() [1/2]

virtual const MeshInstance& getMeshInstance ( ) const
overridevirtual
Returns
the mesh that holds the normals

Implements IMesh.

◆ getMeshInstance() [2/2]

virtual MeshInstance& getMeshInstance ( )
overridevirtual
Returns
the mesh that holds the normals

Implements IMesh.

◆ init()

virtual bool init ( utility::ErrorState errorState)
overridevirtual

Creates the normals from the reference mesh

Reimplemented from Object.

◆ setReferenceMesh()

bool setReferenceMesh ( IMesh mesh,
nap::utility::ErrorState error 
)

Set the mesh that is used as a reference to build the normals from. Called on init(). Note that it is not recommended setting this at runtime, if you do, make sure that the mesh you set has the same number of vertex attributes as the original reference mesh! This call automatically calls setup, where storage for the CPU side of the buffer is calculated Call calculateNormals() to actually calculate the normals based on the reference mesh and push the data to the GPU

Member Data Documentation

◆ mColorAttrs

std::vector<nap::Vec4VertexAttribute*> mColorAttrs
protected

◆ mCurrentReferenceMesh

nap::IMesh* mCurrentReferenceMesh = nullptr
protected

◆ mMeshInstance

std::unique_ptr<MeshInstance> mMeshInstance = nullptr
protected

◆ mNormalLength

float mNormalLength = 1.0f

Property: 'Length' length of the normals.

◆ mNormalsAttr

nap::Vec3VertexAttribute* mNormalsAttr = nullptr
protected

◆ mPositionAttr

nap::Vec3VertexAttribute* mPositionAttr = nullptr
protected

◆ mReferenceMesh

ResourcePtr<IMesh> mReferenceMesh = nullptr

Property: 'ReferenceMesh' link to the mesh that is used as a reference, can be null (ie: nothing)

◆ mRenderService

nap::RenderService* mRenderService = nullptr
protected

◆ mTipAttr

nap::FloatVertexAttribute* mTipAttr = nullptr
protected

◆ mUsage

Property: 'Usage' If the normals are created once or frequently updated.

◆ mUvAttrs

std::vector<nap::Vec3VertexAttribute*> mUvAttrs
protected