Radium Engine  1.5.0
VolumeObject.hpp
1 #pragma once
2 
3 #include <Engine/Data/DisplayableObject.hpp>
4 #include <Engine/Data/Mesh.hpp>
5 #include <Engine/Data/Texture.hpp>
6 #include <Engine/RaEngine.hpp>
7 
8 namespace Ra {
9 namespace Core {
10 namespace Geometry {
11 class AbstractVolume;
12 } // namespace Geometry
13 } // namespace Core
14 namespace Engine {
15 namespace Data {
22 class RA_ENGINE_API VolumeObject : public Displayable
23 {
24 
25  public:
26  explicit VolumeObject( const std::string& name );
27  VolumeObject( const VolumeObject& rhs ) = delete;
28  void operator=( const VolumeObject& rhs ) = delete;
29 
30  ~VolumeObject() override;
31 
33 
36  inline const Core::Geometry::AbstractGeometry& getAbstractGeometry() const override;
37  inline Core::Geometry::AbstractGeometry& getAbstractGeometry() override;
38 
40  inline const Core::Geometry::AbstractVolume& getVolume() const;
41  inline Core::Geometry::AbstractVolume& getVolume();
42 
44  void loadGeometry( Core::Geometry::AbstractVolume* volume );
45 
48  void loadGeometry( Core::Geometry::AbstractVolume* volume, const Core::Aabb& aabb );
49 
51  inline void setDirty() { m_isDirty = true; }
52 
54  const Texture& getDataTexture() { return m_tex; }
55 
60  void updateGL() override;
61 
63  void render( const ShaderProgram* prog ) override;
64 
66  size_t getNumFaces() const override { return 12; }
68  inline size_t getNumVertices() const override { return 8; }
69 
70  private:
71  std::unique_ptr<Core::Geometry::AbstractVolume> m_volume;
72  Texture m_tex;
74  Mesh m_mesh;
75 
77  bool m_isDirty { false };
78 };
79 
81  CORE_ASSERT( m_volume, "Volume is not initialized" );
82  return *(Core::Geometry::AbstractGeometry*)( m_volume.get() );
83 }
84 
86  CORE_ASSERT( m_volume, "Volume is not initialized" );
87  return *(Core::Geometry::AbstractGeometry*)( m_volume.get() );
88 }
89 
92  CORE_ASSERT( m_volume, "Volume is not initialized" );
93  return *m_volume.get();
94 }
95 
97  CORE_ASSERT( m_volume, "Volume is not initialized" );
98  return *m_volume.get();
99 }
100 
101 } // namespace Data
102 } // namespace Engine
103 } // namespace Ra
const std::string & getName() const
Returns the name of the mesh.
Mesh, own a Core::Geometry::TriangleMesh.
Definition: Mesh.hpp:414
const Texture & getDataTexture()
get read access to the 3d texture storing the data
const Core::Geometry::AbstractGeometry & getAbstractGeometry() const override
const Core::Geometry::AbstractVolume & getVolume() const
Returns the underlying AbstractVolume.
void setDirty()
Mark the data types as dirty, forcing an update of the openGL buffer.
size_t getNumFaces() const override
6 quad faces of the cube, thus 12 triangles.
size_t getNumVertices() const override
8 vertices of the cube
Definition: Cage.cpp:3