51 #define SPLATCLOUDOBJECT_C 61 #include <ACG/Scenegraph/ShaderNode.hh> 62 #include <ACG/Scenegraph/MaterialNode.hh> 81 backfaceCullingEnabled_( false ),
82 pointsizeScale_ ( 1.0f ),
90 std::cerr <<
"SplatCloudObject::SplatCloudObject() : Out of memory." << std::endl;
176 static const char SPLATS_VERTEXSHADER_FILENAME[] =
"SplatCloud_Splats/Vertex.glsl";
177 static const char SPLATS_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Splats/Fragment.glsl";
178 static const char DOTS_VERTEXSHADER_FILENAME[] =
"SplatCloud_Dots/Vertex.glsl";
179 static const char DOTS_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Dots/Fragment.glsl";
180 static const char POINTS_VERTEXSHADER_FILENAME[] =
"SplatCloud_Points/Vertex.glsl";
181 static const char POINTS_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Points/Fragment.glsl";
184 static const char SPLATS_PICK_VERTEXSHADER_FILENAME[] =
"SplatCloud_Splats/PickVertex.glsl";
185 static const char SPLATS_PICK_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Splats/Fragment.glsl";
186 static const char DOTS_PICK_VERTEXSHADER_FILENAME[] =
"SplatCloud_Dots/PickVertex.glsl";
187 static const char DOTS_PICK_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Dots/Fragment.glsl";
188 static const char POINTS_PICK_VERTEXSHADER_FILENAME[] =
"SplatCloud_Points/PickVertex.glsl";
189 static const char POINTS_PICK_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Points/Fragment.glsl";
201 std::cerr <<
"Shader DrawModes for SplatCloud not existent!" << std::endl;
206 QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
207 std::string shaderDirectory = std::string( shaderDir.toUtf8() );
214 if( QFile( shaderDir + SPLATS_VERTEXSHADER_FILENAME ).exists() &&
215 QFile( shaderDir + SPLATS_PICK_VERTEXSHADER_FILENAME ).exists() &&
216 QFile( shaderDir + SPLATS_FRAGMENTSHADER_FILENAME ).exists() &&
217 QFile( shaderDir + SPLATS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
220 SPLATS_VERTEXSHADER_FILENAME, SPLATS_FRAGMENTSHADER_FILENAME,
221 SPLATS_PICK_VERTEXSHADER_FILENAME, SPLATS_PICK_FRAGMENTSHADER_FILENAME );
225 std::cerr <<
"Shader Files for SplatCloud/Splats not found!" << std::endl;
228 if( QFile( shaderDir + DOTS_VERTEXSHADER_FILENAME ).exists() &&
229 QFile( shaderDir + DOTS_PICK_VERTEXSHADER_FILENAME ).exists() &&
230 QFile( shaderDir + DOTS_FRAGMENTSHADER_FILENAME ).exists() &&
231 QFile( shaderDir + DOTS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
234 DOTS_VERTEXSHADER_FILENAME, DOTS_FRAGMENTSHADER_FILENAME,
235 DOTS_PICK_VERTEXSHADER_FILENAME, DOTS_PICK_FRAGMENTSHADER_FILENAME );
239 std::cerr <<
"Shader Files for SplatCloud/Dots not found!" << std::endl;
242 if( QFile( shaderDir + POINTS_VERTEXSHADER_FILENAME ).exists() &&
243 QFile( shaderDir + POINTS_PICK_VERTEXSHADER_FILENAME ).exists() &&
244 QFile( shaderDir + POINTS_FRAGMENTSHADER_FILENAME ).exists() &&
245 QFile( shaderDir + POINTS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
248 POINTS_VERTEXSHADER_FILENAME, POINTS_FRAGMENTSHADER_FILENAME,
249 POINTS_PICK_VERTEXSHADER_FILENAME, POINTS_PICK_FRAGMENTSHADER_FILENAME );
253 std::cerr <<
"Shader Files for SplatCloud/Points not found!" << std::endl;
278 std::cerr <<
"Shader DrawModes for SplatCloud not existent!" << std::endl;
292 backfaceCullingEnabled_ = _enable;
293 GLint backfaceCulling = (GLint) _enable;
298 splatsShader->
setUniform(
"backfaceCulling", backfaceCulling );
302 if( splatsPickShader )
304 splatsPickShader->
use();
305 splatsPickShader->
setUniform(
"backfaceCulling", backfaceCulling );
312 dotsShader->
setUniform(
"backfaceCulling", backfaceCulling );
318 dotsPickShader->
use();
319 dotsPickShader->
setUniform(
"backfaceCulling", backfaceCulling );
326 pointsShader->
setUniform(
"backfaceCulling", backfaceCulling );
330 if( pointsPickShader )
332 pointsPickShader->
use();
333 pointsPickShader->
setUniform(
"backfaceCulling", backfaceCulling );
369 std::cerr <<
"Shader DrawModes for SplatCloud not existent!" << std::endl;
381 pointsizeScale_ = _scale;
382 GLfloat pointsizeScale = (GLfloat) _scale;
387 splatsShader->
setUniform(
"pointsizeScale", pointsizeScale );
391 if( splatsPickShader )
393 splatsPickShader->
use();
394 splatsPickShader->
setUniform(
"pointsizeScale", pointsizeScale );
401 dotsShader->
setUniform(
"pointsizeScale", pointsizeScale );
407 dotsPickShader->
use();
408 dotsPickShader->
setUniform(
"pointsizeScale", pointsizeScale );
422 std::cerr <<
"Error when creating SplatCloud Object! materialNode is NULL!" << std::endl;
432 std::cerr <<
"SplatCloudObject::init() : Out of memory." << std::endl;
463 # ifdef REPORT_UPDATE_TYPE 464 std::cout <<
"SplatCloudObject::update() : UPDATE_ALL" << std::endl;
465 std::cout << std::endl;
475 # ifdef REPORT_UPDATE_TYPE 476 std::cout <<
"SplatCloudObject::update() : UPDATE_GEOMETRY" << std::endl;
485 # ifdef REPORT_UPDATE_TYPE 486 std::cout <<
"SplatCloudObject::update() : UPDATE_COLOR" << std::endl;
495 # ifdef REPORT_UPDATE_TYPE 496 std::cout <<
"SplatCloudObject::update() : UPDATE_Normals" << std::endl;
505 # ifdef REPORT_UPDATE_TYPE 506 std::cout <<
"SplatCloudObject::update() : UPDATE_Pointsizes" << std::endl;
515 # ifdef REPORT_UPDATE_TYPE 516 std::cout <<
"SplatCloudObject::update() : UPDATE_Indices" << std::endl;
522 # ifdef REPORT_UPDATE_TYPE 523 std::cout <<
"SplatCloudObject::update() : UPDATE_SELECTION" << std::endl;
530 # ifdef REPORT_UPDATE_TYPE 531 std::cout << std::endl;
548 std::string nodename;
550 nodename = std::string(
"ShaderNode for SplatCloud " + _name.toUtf8() );
553 nodename = std::string(
"SplatCloudNode for SplatCloud " + _name.toUtf8() );
572 output +=
"========================================================================\n";
577 output +=
"Object Contains SplatCloud: ";
583 output +=
"; Splat-Properties: ";
593 output += splatPropertyIter->first.c_str();
602 output +=
"; Cloud-Properties: ";
612 output += cloudPropertyIter->first.c_str();
625 output +=
"========================================================================\n";
virtual QString getObjectinfo()
Get all Info for the Object as a string.
void setPointsizeScale(float _scale)
Set the scaling factor for pointsizes for all Shaders.
void deleteData()
Delete all data attached to this object ( calls delete on each object )
virtual void setName(QString _name) override
path to the file from which the object is loaded ( defaults to "." )
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
unsigned int numSplats() const
Get the number of splats.
void use()
Enables the program object for using.
const CloudPropertyMap & cloudProperties() const
Get all cloud-properties.
std::string name() const
Returns: name of node (needs not be unique)
const UpdateType UPDATE_SELECTION(UpdateTypeSet(16))
Selection updated.
void enablePicking(bool _enable)
SplatCloudNode * splatCloudNode_
Get Shader's scenegraph Node.
void update(UpdateType _type=UPDATE_ALL)
Called by the core if the object has to be updated.
void setName(QString _name)
Set the name of the Object.
const SplatPropertyMap & splatProperties() const
Get all splat-properties.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(4))
Geometry updated.
void setShader(DrawModes::DrawMode _drawmode, const std::string &_vertexShader, const std::string &_fragmentShader, std::string _pickVertexShader="", std::string _pickFragmentShader="")
virtual void cleanup() override
bool picked(uint _node_idx)
Detect if the node has been picked.
const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
virtual void cleanup()
Reset current Object, including all related Nodes.
void setUniform(const char *_name, GLint _value)
Set int uniform to specified value.
void enableBackfaceCulling(bool _enable)
Enable or disable backface culling for all Shaders.
SplatCloud * splatCloud_
Get SplatCloud.
void disable()
Resets to standard rendering pipeline.
DrawMode NONE
not a valid draw mode
virtual void init(const SplatCloud *_splatCloud=0)
Initialise current Object, including all related Nodes.
void reloadShaders()
Reload standard and picking Shaders from file.
virtual ~SplatCloudObject()
Destructor.
MaterialNode * materialNode()
get a pointer to the materialnode
QString getObjectinfo()
Get all Info for the Object as a string.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
void setShaderDir(std::string _shaderDir)
Sets the shader dir.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1024))
Colors have changed.
GLSL::PtrProgram getShader(DrawModes::DrawMode _drawmode, bool _pick=false)
Get the shader for the given drawMode.
ACG::SceneGraph::SplatCloudNode SplatCloudNode
Simple Name for SplatCloudNode.
SplatCloudObject()
Constructor.
void setDataType(DataType _type)
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
ShaderNode * shaderNode_
Get Shader's scenegraph Node.
void enableGeometryShaderQuads(bool _enable)
Enable or disable quad extrusion in geometry shader (shader pipeline)
bool pickingEnabled()
Check if picking is enabled for this Object.
DataType dataType() const
UpdateType updateType(QString _name)
Get the id of a type with given name.
void enablePicking(bool _enable)
Enable or disable picking for this Object.