Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Data::CoreGeometryDisplayable< T > Class Template Reference

Template class to manage the Displayable aspect of a Core Geomertry, such as TriangleMesh. More...

#include <Engine/Data/Mesh.hpp>

+ Inheritance diagram for Ra::Engine::Data::CoreGeometryDisplayable< T >:
+ Collaboration diagram for Ra::Engine::Data::CoreGeometryDisplayable< T >:

Public Types

using base = AttribArrayDisplayable
 
using CoreGeometry = T
 
- Public Types inherited from Ra::Engine::Data::AttribArrayDisplayable
enum  MeshRenderMode : uint {
  RM_POINTS = 0x0000 , RM_LINES = 0x0001 , RM_LINE_LOOP = 0x0002 , RM_LINE_STRIP = 0x0003 ,
  RM_TRIANGLES = 0x0004 , RM_TRIANGLE_STRIP = 0x0005 , RM_TRIANGLE_FAN = 0x0006 , RM_QUADS = 0x0007 ,
  RM_QUAD_STRIP = 0x0008 , RM_POLYGON = 0x0009 , RM_LINES_ADJACENCY = 0x000A , RM_LINE_STRIP_ADJACENCY = 0x000B ,
  RM_TRIANGLES_ADJACENCY = 0x000C , RM_TRIANGLE_STRIP_ADJACENCY = 0x000D , RM_PATCHES = 0x000E
}
 
- Public Types inherited from Ra::Engine::Data::Displayable
enum  PickingRenderMode {
  PKM_POINTS = 0 , PKM_LINES = 1 , PKM_LINE_ADJ = 2 , PKM_TRI = 3 ,
  NO_PICKING
}
 

Public Member Functions

 CoreGeometryDisplayable (const std::string &name, MeshRenderMode renderMode=RM_TRIANGLES)
 
template<typename A >
Ra::Core::Utils::AttribHandle< A > addAttrib (const std::string &name, const typename Core::VectorArray< A > &data)
 Helper function that calls Ra::Core::CoreGeometry::addAttrib()
 
size_t getNumVertices () const override
 
virtual void loadGeometry (CoreGeometry &&mesh)
 
void updateGL () override
 Update (i.e. send to GPU) the buffers marked as dirty.
 
void setAttribNameCorrespondance (const std::string &meshAttribName, const std::string &shaderAttribName)
 

Core::Geometry getters

const Core::Geometry::AbstractGeometrygetAbstractGeometry () const override
 
Core::Geometry::AbstractGeometrygetAbstractGeometry () override
 
const Core::Geometry::AttribArrayGeometrygetAttribArrayGeometry () const override
 
Core::Geometry::AttribArrayGeometrygetAttribArrayGeometry () override
 
const CoreGeometry & getCoreGeometry () const
 
CoreGeometry & getCoreGeometry ()
 
- Public Member Functions inherited from Ra::Engine::Data::AttribArrayDisplayable
 AttribArrayDisplayable (const std::string &name, MeshRenderMode renderMode=RM_TRIANGLES)
 
 AttribArrayDisplayable (const AttribArrayDisplayable &rhs)=delete
 
void operator= (const AttribArrayDisplayable &rhs)=delete
 
void setRenderMode (MeshRenderMode mode)
 Set the render mode.
 
MeshRenderMode getRenderMode () const
 Get the render mode.
 
Ra::Core::Utils::optional< gl::GLuint > getVboHandle (const std::string &name)
 Get opengl's vbo handle (uint) corresponding to attrib name.
 
Ra::Core::Utils::optional< gl::GLuint > getVaoHandle ()
 Get opengl's vao handle (uint).
 
const std::stringgetName () const
 Returns the name of the mesh.
 
void setDirty (const Core::Geometry::MeshAttrib &type)
 
void setDirty (const std::string &name)
 
void setDirty (unsigned int index)
 
- Public Member Functions inherited from Ra::Engine::Data::Displayable
 Displayable (const std::string &name)
 
 Displayable (const Displayable &rhs)=delete
 
void operator= (const Displayable &rhs)=delete
 
PickingRenderMode pickingRenderMode () const
 Returns the picking rendermode advised by the object (default PickingRenderMode::NO_PICKING)
 
const std::stringgetName () const
 Returns the name of the mesh.
 
virtual void render (const ShaderProgram *prog)=0
 
virtual size_t getNumFaces () const
 

Protected Member Functions

virtual void updateGL_specific_impl ()
 
void loadGeometry_common (CoreGeometry &&mesh)
 
void setupCoreMeshObservers ()
 
void autoVertexAttribPointer (const ShaderProgram *prog)
 assume m_vao is bound.
 
void addAttribObserver (const std::string &name)
 
void addToTranslationTable (const std::string &name)
 
- Protected Member Functions inherited from Ra::Engine::Data::AttribArrayDisplayable
void updatePickingRenderMode ()
 Update the picking render mode according to the object render mode.
 

Protected Attributes

BijectiveAssociation< std::string, std::stringm_translationTable {}
 
CoreGeometry m_mesh
 
- Protected Attributes inherited from Ra::Engine::Data::AttribArrayDisplayable
std::unique_ptr< globjects::VertexArray > m_vao
 
MeshRenderMode m_renderMode { MeshRenderMode::RM_TRIANGLES }
 
std::vector< std::unique_ptr< globjects::Buffer > > m_vbos
 
std::vector< bool > m_dataDirty
 
std::map< std::string, unsigned int > m_handleToBuffer
 
bool m_isDirty { false }
 General dirty bit of the mesh.
 
- Protected Attributes inherited from Ra::Engine::Data::Displayable
PickingRenderMode m_pickingRenderMode { NO_PICKING }
 

Detailed Description

template<typename T>
class Ra::Engine::Data::CoreGeometryDisplayable< T >

Template class to manage the Displayable aspect of a Core Geomertry, such as TriangleMesh.

Definition at line 228 of file Mesh.hpp.

Member Typedef Documentation

◆ base

template<typename T >
using Ra::Engine::Data::CoreGeometryDisplayable< T >::base = AttribArrayDisplayable

Definition at line 231 of file Mesh.hpp.

◆ CoreGeometry

template<typename T >
using Ra::Engine::Data::CoreGeometryDisplayable< T >::CoreGeometry = T

Definition at line 232 of file Mesh.hpp.

Constructor & Destructor Documentation

◆ CoreGeometryDisplayable()

template<typename CoreGeometry >
Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::CoreGeometryDisplayable ( const std::string & name,
MeshRenderMode renderMode = RM_TRIANGLES )
explicit

Definition at line 679 of file Mesh.hpp.

Member Function Documentation

◆ addAttrib()

template<typename CoreGeometry >
template<typename A >
Ra::Core::Utils::AttribHandle< A > Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::addAttrib ( const std::string & name,
const typename Core::VectorArray< A > & data )
inline

Helper function that calls Ra::Core::CoreGeometry::addAttrib()

Definition at line 822 of file Mesh.hpp.

◆ addAttribObserver()

template<typename CoreGeometry >
void Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::addAttribObserver ( const std::string & name)
protected

m_mesh Observer method, called whenever an attrib is added or removed from m_mesh. it adds an observer to the new attrib.

Definition at line 724 of file Mesh.hpp.

+ Here is the call graph for this function:

◆ addToTranslationTable()

template<typename CoreGeometry >
void Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::addToTranslationTable ( const std::string & name)
protected

Definition at line 719 of file Mesh.hpp.

◆ autoVertexAttribPointer()

template<typename CoreGeometry >
void Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::autoVertexAttribPointer ( const ShaderProgram * prog)
protected

assume m_vao is bound.

Definition at line 747 of file Mesh.hpp.

◆ getAbstractGeometry() [1/2]

template<typename CoreGeometry >
const Ra::Core::Geometry::AbstractGeometry & Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::getAbstractGeometry ( ) const
inlineoverridevirtual

Returns the underlying AbstractGeometry, which is in fact a TriangleMesh

See also
getTriangleMesh
Todo
not sure the displayable must have an abstract geometry ...

Implements Ra::Engine::Data::Displayable.

Definition at line 687 of file Mesh.hpp.

◆ getAbstractGeometry() [2/2]

template<typename CoreGeometry >
Ra::Core::Geometry::AbstractGeometry & Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::getAbstractGeometry ( )
inlineoverridevirtual

Implements Ra::Engine::Data::Displayable.

Definition at line 692 of file Mesh.hpp.

◆ getAttribArrayGeometry() [1/2]

template<typename CoreGeometry >
const Ra::Core::Geometry::AttribArrayGeometry & Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::getAttribArrayGeometry ( ) const
inlineoverridevirtual

Implements Ra::Engine::Data::AttribArrayDisplayable.

Definition at line 698 of file Mesh.hpp.

◆ getAttribArrayGeometry() [2/2]

template<typename CoreGeometry >
Ra::Core::Geometry::AttribArrayGeometry & Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::getAttribArrayGeometry ( )
inlineoverridevirtual

Implements Ra::Engine::Data::AttribArrayDisplayable.

Definition at line 704 of file Mesh.hpp.

◆ getCoreGeometry() [1/2]

template<typename CoreGeometry >
CoreGeometry & Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::getCoreGeometry ( )
inline

Definition at line 714 of file Mesh.hpp.

◆ getCoreGeometry() [2/2]

template<typename CoreGeometry >
const CoreGeometry & Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::getCoreGeometry ( ) const
inline

Definition at line 709 of file Mesh.hpp.

◆ getNumVertices()

template<typename CoreGeometry >
size_t Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::getNumVertices ( ) const
inlineoverridevirtual

Reimplemented from Ra::Engine::Data::Displayable.

Definition at line 828 of file Mesh.hpp.

◆ loadGeometry()

template<typename CoreGeometry >
void Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::loadGeometry ( CoreGeometry && mesh)
virtual

Use the given geometry as base for a display mesh. This will move mesh and *this will take the ownership of the data. The currently owned mesh is deleted, if any. This method should be called to set or replace the CoreGeometry, if you want to update attributes or indices, use getCoreGeometry and Core::Geometry::AttribArrayGeometry setters instead.

Warning
For indices, you must call setIndicesDirty after modification.
Todo
add observer mecanism for indices.

Reimplemented in Ra::Engine::Data::IndexedGeometry< T >, Ra::Engine::Data::IndexedGeometry< Core::Geometry::LineMesh >, Ra::Engine::Data::IndexedGeometry< Core::Geometry::TriangleMesh >, and Ra::Engine::Data::MultiIndexedGeometry< T >.

Definition at line 833 of file Mesh.hpp.

◆ loadGeometry_common()

template<typename T >
void Ra::Engine::Data::CoreGeometryDisplayable< T >::loadGeometry_common ( CoreGeometry && mesh)
protected

Definition at line 788 of file Mesh.hpp.

◆ setAttribNameCorrespondance()

template<typename CoreGeometry >
void Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::setAttribNameCorrespondance ( const std::string & meshAttribName,
const std::string & shaderAttribName )

Bind meshAttribName to shaderAttribName. meshAttribName is a vertex attrib added to the underlying CoreGeometry shaderAttribName is the name of the input paramter of the shader. By default the same name is used, but this mecanism allows to override this behavior. Only one shaderAttribName can be bound to a meshAttribName and the other way round.

Parameters
meshAttribNamename of the attribute on the CoreGeomtry side
shaderAttribNamename of the input vertex attribute on the shader side.

Definition at line 905 of file Mesh.hpp.

◆ setupCoreMeshObservers()

template<typename T >
void Ra::Engine::Data::CoreGeometryDisplayable< T >::setupCoreMeshObservers ( )
protected

Definition at line 795 of file Mesh.hpp.

◆ updateGL()

template<typename CoreGeometry >
void Ra::Engine::Data::CoreGeometryDisplayable< CoreGeometry >::updateGL ( )
overridevirtual

Update (i.e. send to GPU) the buffers marked as dirty.

Implements Ra::Engine::Data::AttribArrayDisplayable.

Definition at line 838 of file Mesh.hpp.

+ Here is the call graph for this function:

◆ updateGL_specific_impl()

Member Data Documentation

◆ m_mesh

template<typename T >
CoreGeometry Ra::Engine::Data::CoreGeometryDisplayable< T >::m_mesh
protected

Definition at line 306 of file Mesh.hpp.

◆ m_translationTable

template<typename T >
BijectiveAssociation<std::string, std::string> Ra::Engine::Data::CoreGeometryDisplayable< T >::m_translationTable {}
protected

Core::Mesh attrib name to Render::Mesh attrib name key: core mesh name, value: shader name

Definition at line 304 of file Mesh.hpp.


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