1 #include <Engine/Data/VolumeObject.hpp>
3 #include <Core/Geometry/MeshPrimitives.hpp>
4 #include <Core/Geometry/Volume.hpp>
6 #include <Core/Utils/Log.hpp>
7 #include <Engine/Data/ShaderProgram.hpp>
8 #include <Engine/OpenGL.hpp>
13 VolumeObject::VolumeObject(
const std::string& name ) :
14 Displayable( name ), m_tex( {} ), m_mesh( name +
"_internal" ) {}
16 VolumeObject::~VolumeObject() {}
19 if ( volume !=
nullptr && volume->
isDense() ) {
21 m_mesh.loadGeometry( Core::Geometry::makeSharpBox( aabb ) );
23 Core::Vector3Array tex_coords;
24 tex_coords.resize( 24 );
25 tex_coords.getMap() <<
28 Scalar( 1 ), Scalar( 0 ), Scalar( 0 ),
29 Scalar( 1 ), Scalar( 0 ), Scalar( 0 ), Scalar( 1 ),
30 Scalar( 1 ), Scalar( 1 ), Scalar( 1 ), Scalar( 1 ),
31 Scalar( 0 ), Scalar( 0 ), Scalar( 0 ), Scalar( 0 ),
32 Scalar( 1 ), Scalar( 0 ), Scalar( 0 ), Scalar( 1 ),
33 Scalar( 1 ), Scalar( 1 ), Scalar( 0 ), Scalar( 0 ),
35 Scalar( 0 ), Scalar( 1 ), Scalar( 1 ), Scalar( 0 ),
36 Scalar( 0 ), Scalar( 0 ), Scalar( 1 ), Scalar( 1 ),
37 Scalar( 1 ), Scalar( 0 ), Scalar( 0 ), Scalar( 1 ),
38 Scalar( 0 ), Scalar( 1 ), Scalar( 1 ), Scalar( 0 ),
39 Scalar( 0 ), Scalar( 0 ), Scalar( 0 ), Scalar( 0 ),
40 Scalar( 1 ), Scalar( 1 ), Scalar( 1 ), Scalar( 1 ),
42 Scalar( 0 ), Scalar( 0 ), Scalar( 0 ), Scalar( 0 ),
43 Scalar( 1 ), Scalar( 1 ), Scalar( 1 ), Scalar( 1 ),
44 Scalar( 0 ), Scalar( 0 ), Scalar( 1 ), Scalar( 1 ),
45 Scalar( 0 ), Scalar( 0 ), Scalar( 1 ), Scalar( 1 ),
46 Scalar( 0 ), Scalar( 0 ), Scalar( 1 ), Scalar( 1 ),
47 Scalar( 0 ), Scalar( 1 ), Scalar( 1 ), Scalar( 0 );
48 m_mesh.addAttrib( Ra::Core::Geometry::getAttribName( Ra::Core::Geometry::VERTEX_TEXCOORD ),
52 m_volume = std::unique_ptr<Core::Geometry::AbstractVolume>( volume );
54 auto dim = grid->
size();
68 grid->
data().data() };
69 m_tex.setParameters( texparam );
79 void VolumeObject::updateGL() {
93 GLboolean cullEnable = glIsEnabled( GL_CULL_FACE );
95 glGetIntegerv( GL_CULL_FACE_MODE, &culledFaces );
97 glGetIntegerv( GL_FRONT_FACE, &frontFaces );
98 glCullFace( GL_BACK );
99 glEnable( GL_CULL_FACE );
101 m_mesh.render( prog );
103 glCullFace( gl::GLenum( culledFaces ) );
104 glFrontFace( gl::GLenum( frontFaces ) );
105 if ( !cullEnable ) glDisable( GL_CULL_FACE );
const Vector3i & size() const
return the size (number of bins ni each dimension) of the volume
bool isDense() const
Return true if the volume is dense (implies isDiscrete to be true)
Discrete volume data storing values in a regular grid.
const Container & data() const
Direct access to the managed data.
virtual Aabb computeAabb() const =0
Compute bounding box.