57 #define SPLATCLOUDOBJECT_C
85 backfaceCullingEnabled_( false ),
86 pointsizeScale_ ( 1.0f ),
94 std::cerr <<
"SplatCloudObject::SplatCloudObject() : Out of memory." << std::endl;
180 static const char SPLATS_VERTEXSHADER_FILENAME[] =
"SplatCloud_Splats/Vertex.glsl";
181 static const char SPLATS_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Splats/Fragment.glsl";
182 static const char DOTS_VERTEXSHADER_FILENAME[] =
"SplatCloud_Dots/Vertex.glsl";
183 static const char DOTS_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Dots/Fragment.glsl";
184 static const char POINTS_VERTEXSHADER_FILENAME[] =
"SplatCloud_Points/Vertex.glsl";
185 static const char POINTS_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Points/Fragment.glsl";
188 static const char SPLATS_PICK_VERTEXSHADER_FILENAME[] =
"SplatCloud_Splats/PickVertex.glsl";
189 static const char SPLATS_PICK_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Splats/Fragment.glsl";
190 static const char DOTS_PICK_VERTEXSHADER_FILENAME[] =
"SplatCloud_Dots/PickVertex.glsl";
191 static const char DOTS_PICK_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Dots/Fragment.glsl";
192 static const char POINTS_PICK_VERTEXSHADER_FILENAME[] =
"SplatCloud_Points/PickVertex.glsl";
193 static const char POINTS_PICK_FRAGMENTSHADER_FILENAME[] =
"SplatCloud_Points/Fragment.glsl";
205 std::cerr <<
"Shader DrawModes for SplatCloud not existent!" << std::endl;
210 QString shaderDir = OpenFlipper::Options::shaderDirStr() + OpenFlipper::Options::dirSeparator();
211 std::string shaderDirectory = std::string( shaderDir.toUtf8() );
218 if( QFile( shaderDir + SPLATS_VERTEXSHADER_FILENAME ).exists() &&
219 QFile( shaderDir + SPLATS_PICK_VERTEXSHADER_FILENAME ).exists() &&
220 QFile( shaderDir + SPLATS_FRAGMENTSHADER_FILENAME ).exists() &&
221 QFile( shaderDir + SPLATS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
224 SPLATS_VERTEXSHADER_FILENAME, SPLATS_FRAGMENTSHADER_FILENAME,
225 SPLATS_PICK_VERTEXSHADER_FILENAME, SPLATS_PICK_FRAGMENTSHADER_FILENAME );
229 std::cerr <<
"Shader Files for SplatCloud/Splats not found!" << std::endl;
232 if( QFile( shaderDir + DOTS_VERTEXSHADER_FILENAME ).exists() &&
233 QFile( shaderDir + DOTS_PICK_VERTEXSHADER_FILENAME ).exists() &&
234 QFile( shaderDir + DOTS_FRAGMENTSHADER_FILENAME ).exists() &&
235 QFile( shaderDir + DOTS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
238 DOTS_VERTEXSHADER_FILENAME, DOTS_FRAGMENTSHADER_FILENAME,
239 DOTS_PICK_VERTEXSHADER_FILENAME, DOTS_PICK_FRAGMENTSHADER_FILENAME );
243 std::cerr <<
"Shader Files for SplatCloud/Dots not found!" << std::endl;
246 if( QFile( shaderDir + POINTS_VERTEXSHADER_FILENAME ).exists() &&
247 QFile( shaderDir + POINTS_PICK_VERTEXSHADER_FILENAME ).exists() &&
248 QFile( shaderDir + POINTS_FRAGMENTSHADER_FILENAME ).exists() &&
249 QFile( shaderDir + POINTS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
252 POINTS_VERTEXSHADER_FILENAME, POINTS_FRAGMENTSHADER_FILENAME,
253 POINTS_PICK_VERTEXSHADER_FILENAME, POINTS_PICK_FRAGMENTSHADER_FILENAME );
257 std::cerr <<
"Shader Files for SplatCloud/Points not found!" << std::endl;
280 std::cerr <<
"Shader DrawModes for SplatCloud not existent!" << std::endl;
294 backfaceCullingEnabled_ = _enable;
295 GLint backfaceCulling = (GLint) _enable;
300 splatsShader->
setUniform(
"backfaceCulling", backfaceCulling );
304 if( splatsPickShader )
306 splatsPickShader->
use();
307 splatsPickShader->
setUniform(
"backfaceCulling", backfaceCulling );
314 dotsShader->
setUniform(
"backfaceCulling", backfaceCulling );
320 dotsPickShader->
use();
321 dotsPickShader->
setUniform(
"backfaceCulling", backfaceCulling );
328 pointsShader->
setUniform(
"backfaceCulling", backfaceCulling );
332 if( pointsPickShader )
334 pointsPickShader->
use();
335 pointsPickShader->
setUniform(
"backfaceCulling", backfaceCulling );
357 std::cerr <<
"Shader DrawModes for SplatCloud not existent!" << std::endl;
369 pointsizeScale_ = _scale;
370 GLfloat pointsizeScale = (GLfloat) _scale;
375 splatsShader->
setUniform(
"pointsizeScale", pointsizeScale );
379 if( splatsPickShader )
381 splatsPickShader->
use();
382 splatsPickShader->
setUniform(
"pointsizeScale", pointsizeScale );
389 dotsShader->
setUniform(
"pointsizeScale", pointsizeScale );
395 dotsPickShader->
use();
396 dotsPickShader->
setUniform(
"pointsizeScale", pointsizeScale );
410 std::cerr <<
"Error when creating SplatCloud Object! materialNode is NULL!" << std::endl;
420 std::cerr <<
"SplatCloudObject::init() : Out of memory." << std::endl;
451 # ifdef REPORT_UPDATE_TYPE
452 std::cout <<
"SplatCloudObject::update() : UPDATE_ALL" << std::endl;
453 std::cout << std::endl;
463 # ifdef REPORT_UPDATE_TYPE
464 std::cout <<
"SplatCloudObject::update() : UPDATE_GEOMETRY" << std::endl;
473 # ifdef REPORT_UPDATE_TYPE
474 std::cout <<
"SplatCloudObject::update() : UPDATE_COLOR" << std::endl;
483 # ifdef REPORT_UPDATE_TYPE
484 std::cout <<
"SplatCloudObject::update() : UPDATE_Normals" << std::endl;
493 # ifdef REPORT_UPDATE_TYPE
494 std::cout <<
"SplatCloudObject::update() : UPDATE_Pointsizes" << std::endl;
503 # ifdef REPORT_UPDATE_TYPE
504 std::cout <<
"SplatCloudObject::update() : UPDATE_Indices" << std::endl;
510 # ifdef REPORT_UPDATE_TYPE
511 std::cout <<
"SplatCloudObject::update() : UPDATE_SELECTION" << std::endl;
518 # ifdef REPORT_UPDATE_TYPE
519 std::cout << std::endl;
536 std::string nodename;
538 nodename = std::string(
"ShaderNode for SplatCloud " + _name.toUtf8() );
541 nodename = std::string(
"SplatCloudNode for SplatCloud " + _name.toUtf8() );
560 output +=
"========================================================================\n";
565 output +=
"Object Contains SplatCloud: ";
571 output +=
"; Splat-Properties: ";
581 output += splatPropertyIter->first.c_str();
590 output +=
"; Cloud-Properties: ";
600 output += cloudPropertyIter->first.c_str();
613 output +=
"========================================================================\n";
SplatCloudNode * splatCloudNode_
Get Shader's scenegraph Node.
ACG::SceneGraph::ShaderNode ShaderNode
Simple Name for ShaderNode.
bool pickingEnabled()
Check if picking is enabled for this Object.
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
std::string name() const
Returns: name of node (needs not be unique)
void setName(QString _name)
Set the name of the Object.
ShaderNode * shaderNode_
Get Shader's scenegraph Node.
virtual QString getObjectinfo()
Get all Info for the Object as a string.
QString name() const
return the name of the object. The name defaults to NONAME if unset.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
SplatCloudObject()
Constructor.
void deleteData()
Delete all data attached to this object ( calls delete on each object )
const SplatPropertyMap & splatProperties() const
Get all splat-properties.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
virtual void setName(QString _name)
path to the file from which the object is loaded ( defaults to "." )
const DrawMode & getDrawMode(const std::string &_name)
Get a custom DrawMode.
MaterialNode * materialNode()
get a pointer to the materialnode
DataType dataType() const
void update(UpdateType _type=UPDATE_ALL)
Called by the core if the object has to be updated.
unsigned int numSplats() const
Get the number of splats.
virtual void cleanup()
Reset current Object, including all related Nodes.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
void enableBackfaceCulling(bool _enable)
Enable or disable backface culling for all Shaders.
void use()
Enables the program object for using.
void setShader(DrawModes::DrawMode _drawmode, std::string _vertexShader, std::string _fragmentShader, std::string _pickVertexShader="", std::string _pickFragmentShader="")
void reloadShaders()
Reload standard and picking Shaders from file.
SplatCloud * splatCloud_
Get SplatCloud.
void enablePicking(bool _enable)
Enable or disable picking for this Object.
QString getObjectinfo()
Get all Info for the Object as a string.
void setDataType(DataType _type)
void setUniform(const char *_name, GLint _value)
Set int uniform to specified value.
GLSL::PtrProgram getShader(DrawModes::DrawMode _drawmode, bool _pick=false)
Get the shader for the given drawMode.
void setShaderDir(std::string _shaderDir)
Sets the shader dir.
virtual ~SplatCloudObject()
Destructor.
virtual void init(const SplatCloud *_splatCloud=0)
Initialise current Object, including all related Nodes.
const UpdateType UPDATE_COLOR(UpdateTypeSet(1)<< 10)
Colors have changed.
UpdateType updateType(QString _name)
Get the id of a type with given name.
bool picked(uint _node_idx)
Detect if the node has been picked.
void disable()
Resets to standard rendering pipeline.
const CloudPropertyMap & cloudProperties() const
Get all cloud-properties.
ACG::SceneGraph::SplatCloudNode SplatCloudNode
Simple Name for SplatCloudNode.
void setPointsizeScale(float _scale)
Set the scaling factor for pointsizes for all Shaders.
DrawMode NONE
not a valid draw mode
void enablePicking(bool _enable)