31 #include "WMPointRenderer.h"
32 #include "core/common/WLimits.h"
33 #include "core/common/math/WMath.h"
34 #include "core/dataHandler/WDataSetPoints.h"
35 #include "core/graphicsEngine/WGEColormapping.h"
36 #include "core/graphicsEngine/WGEGeodeUtils.h"
37 #include "core/graphicsEngine/WGEManagedGroupNode.h"
38 #include "core/graphicsEngine/WGEUtils.h"
39 #include "core/graphicsEngine/postprocessing/WGEPostprocessingNode.h"
40 #include "core/graphicsEngine/shaders/WGEShader.h"
41 #include "core/kernel/WKernel.h"
70 return "Point Renderer";
75 return "Render a given point dataset.";
91 m_nbVertices->setMax( std::numeric_limits< int >::max() );
101 m_useCorrectDepth =
m_properties->addProperty(
"Correct Depth",
"If set, the depths of the sprites are calculated correctly. You can disable "
102 "this to get higher framerates at the cost of visual correctness.",
true );
133 m_shader->setParameter( GL_GEOMETRY_VERTICES_OUT_EXT, 4 );
134 m_shader->setParameter( GL_GEOMETRY_INPUT_TYPE_EXT, GL_POINTS );
135 m_shader->setParameter( GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP );
147 m_shader->addBindAttribLocation(
"a_pointSize", 6 );
170 debugLog() <<
"Invalid Data. Disabling.";
177 std::shared_ptr< WValueSet< float > > valueSet;
180 valueSet = std::any_cast< std::shared_ptr< WValueSet< float > > >( points->getData() );
186 osg::ref_ptr< osg::Geometry > geometry = osg::ref_ptr< osg::Geometry >(
new osg::Geometry );
187 osg::ref_ptr< osg::Geode > geode(
new osg::Geode() );
189 osg::StateSet* state = geode->getOrCreateStateSet();
190 state->setMode( GL_BLEND, osg::StateAttribute::ON );
193 osg::ref_ptr< osg::Vec3Array > vertices = osg::ref_ptr< osg::Vec3Array >(
new osg::Vec3Array );
194 osg::ref_ptr< osg::Vec4Array > colors = osg::ref_ptr< osg::Vec4Array >(
new osg::Vec4Array );
195 osg::ref_ptr< osg::FloatArray > sizes = osg::ref_ptr< osg::FloatArray >(
new osg::FloatArray );
199 for(
size_t pointIdx = 0; pointIdx < points->size(); ++pointIdx )
201 osg::Vec3 vert = points->operator[]( pointIdx );
202 osg::Vec4 color = points->getColor( pointIdx );
204 vertices->push_back( vert );
205 colors->push_back( color );
209 sizes->push_back( valueSet->getScalar( pointIdx ) );
214 geometry->addPrimitiveSet(
new osg::DrawArrays( osg::PrimitiveSet::POINTS, 0, vertices->size() ) );
215 geometry->setVertexArray( vertices );
216 geometry->setColorArray( colors );
217 geometry->setColorBinding( osg::Geometry::BIND_PER_VERTEX );
220 geometry->setVertexAttribArray( 6, sizes, osg::Array::BIND_PER_VERTEX );
224 geode->addDrawable( geometry );
233 postNode->insert( geode,
m_shader );
235 debugLog() <<
"Bounding Box: " << points->getBoundingBox();
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
std::shared_ptr< WDataSetPoints > SPtr
Pointer to dataset.
std::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
This callback is useful to en-/disable nodes using the node mask based on properties.
This class enables you to add arbitrary nodes that get post-processed in screen space.
std::shared_ptr< WGEShaderPreprocessor > SPtr
Shared pointer for this class.
This is a WGEShaderDefineOptions class which additionally uses a property to automatically control th...
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
static WKernel * getRunningKernel()
Returns pointer to the currently running kernel.
std::shared_ptr< WGraphicsEngine > getGraphicsEngine() const
Returns pointer to currently running instance of graphics engine.
This module renders the points in a point dataset.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
virtual const std::string getName() const
Gives back the name of this module.
WPropInt m_nbVertices
Info-property showing the number of vertices in the data set.
WPropBool m_useCorrectDepth
Slower but correct depth calculation.
virtual void connectors()
Initialize the connectors this module is using.
virtual const std::string getDescription() const
Gives back a description of this module.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
virtual void moduleMain()
Entry point after loading the module.
WMPointRenderer()
Constructor.
std::shared_ptr< WModuleInputData< WDataSetPoints > > m_pointInput
An input connector used to get points from other modules.
osg::ref_ptr< WGEShader > m_shader
The shader for the points.
WPropBool m_useAttribute
Invisible bool property that decides whether attribute or uniform is used.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
WPropDouble m_size
The size of a point on screen.
virtual void properties()
Initialize the properties for this module.
virtual ~WMPointRenderer()
Destructor.
Class representing a single module of OpenWalnut.
boost::filesystem::path m_localPath
The path where the module binary resides in.
virtual void properties()
Initialize properties in this function.
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
std::shared_ptr< WProperties > m_properties
The property object for the module.
std::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION".
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
WPropBool m_active
True whenever the module should be active.
virtual void connectors()
Initialize connectors in this function.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
Base Class for all value set types.
void enableTransparency(osg::ref_ptr< osg::Node > node)
Enable transparency for the given node.