Commit 8b021578 authored by Jan Möbius's avatar Jan Möbius
Browse files

Splatcloud object now contains the splatcloud itself, not the node

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13896 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 42b3d1e0
...@@ -142,12 +142,7 @@ SplatCloud* splatCloud( BaseObjectData *_object ) ...@@ -142,12 +142,7 @@ SplatCloud* splatCloud( BaseObjectData *_object )
if ( object == 0 ) if ( object == 0 )
return 0; return 0;
SplatCloudNode *node = object->splatCloudNode(); return object->splatCloud();
if( node == 0 )
return 0;
return node->splatCloud();
} }
...@@ -165,8 +160,10 @@ SplatCloudObject* splatCloudObject( BaseObjectData *_object ) ...@@ -165,8 +160,10 @@ SplatCloudObject* splatCloudObject( BaseObjectData *_object )
return dynamic_cast<SplatCloudObject *>( _object ); return dynamic_cast<SplatCloudObject *>( _object );
} }
//---------------------------------------------------------------- //----------------------------------------------------------------
SplatCloudObject* splatCloudObject( int _objectId ) { SplatCloudObject* splatCloudObject( int _objectId ) {
if (_objectId == -1) if (_objectId == -1)
......
...@@ -69,9 +69,9 @@ namespace SceneGraph { ...@@ -69,9 +69,9 @@ namespace SceneGraph {
//== IMPLEMENTATION ============================================== //== IMPLEMENTATION ==============================================
SplatCloudNode::SplatCloudNode( BaseNode *_parent, std::string _name ) : SplatCloudNode::SplatCloudNode( const SplatCloud &_splatCloud, BaseNode *_parent, std::string _name ) :
BaseNode ( _parent, _name ), BaseNode ( _parent, _name ),
splatCloud_ ( 0 ), splatCloud_ ( _splatCloud ),
pointsModified_ ( false ), pointsModified_ ( false ),
normalsModified_ ( false ), normalsModified_ ( false ),
pointsizesModified_ ( false ), pointsizesModified_ ( false ),
...@@ -95,13 +95,6 @@ SplatCloudNode::SplatCloudNode( BaseNode *_parent, std::string _name ) : ...@@ -95,13 +95,6 @@ SplatCloudNode::SplatCloudNode( BaseNode *_parent, std::string _name ) :
vboSelectionsOffset_( -1 ), vboSelectionsOffset_( -1 ),
vboPickColorsOffset_( -1 ) vboPickColorsOffset_( -1 )
{ {
// allocate memory for splat cloud
splatCloud_ = new SplatCloud;
if( !splatCloud_ )
{
std::cerr << "SplatCloudNode::SplatCloudNode() : Out of memory." << std::endl;
}
// add (possibly) new drawmodes // add (possibly) new drawmodes
pointsDrawMode_ = DrawModes::addDrawMode( "Points" ); pointsDrawMode_ = DrawModes::addDrawMode( "Points" );
dotsDrawMode_ = DrawModes::addDrawMode( "Dots" ); dotsDrawMode_ = DrawModes::addDrawMode( "Dots" );
...@@ -118,9 +111,6 @@ SplatCloudNode::SplatCloudNode( BaseNode *_parent, std::string _name ) : ...@@ -118,9 +111,6 @@ SplatCloudNode::SplatCloudNode( BaseNode *_parent, std::string _name ) :
SplatCloudNode::~SplatCloudNode() SplatCloudNode::~SplatCloudNode()
{ {
destroyVBO(); destroyVBO();
delete splatCloud_;
splatCloud_ = 0;
} }
...@@ -129,15 +119,11 @@ SplatCloudNode::~SplatCloudNode() ...@@ -129,15 +119,11 @@ SplatCloudNode::~SplatCloudNode()
void SplatCloudNode::boundingBox( ACG::Vec3d &_bbMin, ACG::Vec3d &_bbMax ) void SplatCloudNode::boundingBox( ACG::Vec3d &_bbMin, ACG::Vec3d &_bbMax )
{ {
// if something went wrong in the initialization, abort
if( !splatCloud_ )
return;
ACG::Vec3f bbMin( FLT_MAX, FLT_MAX, FLT_MAX ); ACG::Vec3f bbMin( FLT_MAX, FLT_MAX, FLT_MAX );
ACG::Vec3f bbMax(-FLT_MAX,-FLT_MAX,-FLT_MAX ); ACG::Vec3f bbMax(-FLT_MAX,-FLT_MAX,-FLT_MAX );
SplatCloud::PointVector::const_iterator pointIter, pointsEnd = splatCloud_->points().end(); SplatCloud::PointVector::const_iterator pointIter, pointsEnd = splatCloud_.points().end();
for ( pointIter = splatCloud_->points().begin(); pointIter != pointsEnd; ++pointIter ) for ( pointIter = splatCloud_.points().begin(); pointIter != pointsEnd; ++pointIter )
{ {
const Point &p = *pointIter; const Point &p = *pointIter;
...@@ -157,10 +143,6 @@ void SplatCloudNode::boundingBox( ACG::Vec3d &_bbMin, ACG::Vec3d &_bbMax ) ...@@ -157,10 +143,6 @@ void SplatCloudNode::boundingBox( ACG::Vec3d &_bbMin, ACG::Vec3d &_bbMax )
void SplatCloudNode::draw( GLState &_state, const DrawModes::DrawMode &_drawMode ) void SplatCloudNode::draw( GLState &_state, const DrawModes::DrawMode &_drawMode )
{ {
// if something went wrong in the initialization, abort
if( !splatCloud_ )
return;
static const int RENDERMODE_POINTS = 0; static const int RENDERMODE_POINTS = 0;
static const int RENDERMODE_DOTS = 1; static const int RENDERMODE_DOTS = 1;
static const int RENDERMODE_SPLATS = 2; static const int RENDERMODE_SPLATS = 2;
...@@ -329,15 +311,11 @@ void SplatCloudNode::enterPick( GLState &_state, PickTarget _target, const DrawM ...@@ -329,15 +311,11 @@ void SplatCloudNode::enterPick( GLState &_state, PickTarget _target, const DrawM
void SplatCloudNode::pick( GLState &_state, PickTarget _target ) void SplatCloudNode::pick( GLState &_state, PickTarget _target )
{ {
// if something went wrong in the initialization, abort
if( !splatCloud_ )
return;
// if pick target is valid... // if pick target is valid...
if( _target == PICK_ANYTHING || _target == PICK_VERTEX ) if( _target == PICK_ANYTHING || _target == PICK_VERTEX )
{ {
// set number of pick colors used (each points gets a unique pick color) // set number of pick colors used (each points gets a unique pick color)
if( !_state.pick_set_maximum( splatCloud_->numPoints() ) ) // number of points could have changed, so use new number of points (*not* the one in VBO memory!) if( !_state.pick_set_maximum( splatCloud_.numPoints() ) ) // number of points could have changed, so use new number of points (*not* the one in VBO memory!)
{ {
std::cerr << "SplatCloudNode::pick() : Color range too small, picking failed." << std::endl; std::cerr << "SplatCloudNode::pick() : Color range too small, picking failed." << std::endl;
return; return;
...@@ -362,21 +340,6 @@ void SplatCloudNode::pick( GLState &_state, PickTarget _target ) ...@@ -362,21 +340,6 @@ void SplatCloudNode::pick( GLState &_state, PickTarget _target )
//---------------------------------------------------------------- //----------------------------------------------------------------
void SplatCloudNode::copySplatCloud( const SplatCloud &_splatCloud )
{
delete splatCloud_;
splatCloud_ = new SplatCloud( _splatCloud );
if( !splatCloud_ )
{
std::cerr << "SplatCloudNode::copySplatCloud() : Out of memory." << std::endl;
}
}
//----------------------------------------------------------------
void SplatCloudNode::createVBO() void SplatCloudNode::createVBO()
{ {
// create new VBO (if *not* already existing) // create new VBO (if *not* already existing)
...@@ -413,7 +376,7 @@ void SplatCloudNode::destroyVBO() ...@@ -413,7 +376,7 @@ void SplatCloudNode::destroyVBO()
void SplatCloudNode::rebuildVBO( GLState &_state ) void SplatCloudNode::rebuildVBO( GLState &_state )
{ {
// if something went wrong in the initialization, make VBO invalid and abort // if something went wrong in the initialization, make VBO invalid and abort
if( vboGlId_ == 0 || !splatCloud_) if( vboGlId_ == 0 )
{ {
vboData_ = 0; vboData_ = 0;
return; return;
...@@ -423,7 +386,7 @@ void SplatCloudNode::rebuildVBO( GLState &_state ) ...@@ -423,7 +386,7 @@ void SplatCloudNode::rebuildVBO( GLState &_state )
ACG::GLState::bindBufferARB( GL_ARRAY_BUFFER_ARB, vboGlId_ ); ACG::GLState::bindBufferARB( GL_ARRAY_BUFFER_ARB, vboGlId_ );
// calculate size of data and offsets // calculate size of data and offsets
unsigned int numPoints = splatCloud_->numPoints(); unsigned int numPoints = splatCloud_.numPoints();
unsigned int size = 0; unsigned int size = 0;
int pointsOffset = -1; int pointsOffset = -1;
...@@ -433,11 +396,11 @@ void SplatCloudNode::rebuildVBO( GLState &_state ) ...@@ -433,11 +396,11 @@ void SplatCloudNode::rebuildVBO( GLState &_state )
int selectionsOffset = -1; int selectionsOffset = -1;
int pickColorsOffset = -1; int pickColorsOffset = -1;
if( splatCloud_->hasPoints() ) { pointsOffset = size; size += numPoints * 12; } if( splatCloud_.hasPoints() ) { pointsOffset = size; size += numPoints * 12; }
if( splatCloud_->hasNormals() ) { normalsOffset = size; size += numPoints * 12; } if( splatCloud_.hasNormals() ) { normalsOffset = size; size += numPoints * 12; }
if( splatCloud_->hasPointsizes() ) { pointsizesOffset = size; size += numPoints * 4; } if( splatCloud_.hasPointsizes() ) { pointsizesOffset = size; size += numPoints * 4; }
if( splatCloud_->hasColors() ) { colorsOffset = size; size += numPoints * 3; } if( splatCloud_.hasColors() ) { colorsOffset = size; size += numPoints * 3; }
if( splatCloud_->hasSelections() ) { selectionsOffset = size; size += numPoints * 4; } if( splatCloud_.hasSelections() ) { selectionsOffset = size; size += numPoints * 4; }
/* has pick colors = true */ { pickColorsOffset = size; size += numPoints * 4; } /* has pick colors = true */ { pickColorsOffset = size; size += numPoints * 4; }
// tell GL that we are seldomly updating the VBO but are often drawing it // tell GL that we are seldomly updating the VBO but are often drawing it
...@@ -544,7 +507,7 @@ static void addUCharToBuffer( unsigned char _value, unsigned char *&_buffer ) ...@@ -544,7 +507,7 @@ static void addUCharToBuffer( unsigned char _value, unsigned char *&_buffer )
void SplatCloudNode::rebuildVBOPoints() void SplatCloudNode::rebuildVBOPoints()
{ {
if( vboPointsOffset_ == -1 || !splatCloud_->hasPoints() ) if( vboPointsOffset_ == -1 || !splatCloud_.hasPoints() )
return; return;
# ifdef REPORT_VBO_UPDATES # ifdef REPORT_VBO_UPDATES
...@@ -555,7 +518,7 @@ void SplatCloudNode::rebuildVBOPoints() ...@@ -555,7 +518,7 @@ void SplatCloudNode::rebuildVBOPoints()
unsigned char *buffer = vboData_ + vboPointsOffset_; unsigned char *buffer = vboData_ + vboPointsOffset_;
// for all points... // for all points...
unsigned int i, num = splatCloud_->numPoints(); unsigned int i, num = splatCloud_.numPoints();
for( i=0; i<num; ++i ) for( i=0; i<num; ++i )
{ {
// add point // add point
...@@ -572,7 +535,7 @@ void SplatCloudNode::rebuildVBOPoints() ...@@ -572,7 +535,7 @@ void SplatCloudNode::rebuildVBOPoints()
void SplatCloudNode::rebuildVBONormals() void SplatCloudNode::rebuildVBONormals()
{ {
if( vboNormalsOffset_ == -1 || !splatCloud_->hasNormals() ) if( vboNormalsOffset_ == -1 || !splatCloud_.hasNormals() )
return; return;
# ifdef REPORT_VBO_UPDATES # ifdef REPORT_VBO_UPDATES
...@@ -583,7 +546,7 @@ void SplatCloudNode::rebuildVBONormals() ...@@ -583,7 +546,7 @@ void SplatCloudNode::rebuildVBONormals()
unsigned char *buffer = vboData_ + vboNormalsOffset_; unsigned char *buffer = vboData_ + vboNormalsOffset_;
// for all points... // for all points...
unsigned int i, num = splatCloud_->numPoints(); unsigned int i, num = splatCloud_.numPoints();
for( i=0; i<num; ++i ) for( i=0; i<num; ++i )
{ {
// add normal // add normal
...@@ -600,7 +563,7 @@ void SplatCloudNode::rebuildVBONormals() ...@@ -600,7 +563,7 @@ void SplatCloudNode::rebuildVBONormals()
void SplatCloudNode::rebuildVBOPointsizes() void SplatCloudNode::rebuildVBOPointsizes()
{ {
if( vboPointsizesOffset_ == -1 || !splatCloud_->hasPointsizes() ) if( vboPointsizesOffset_ == -1 || !splatCloud_.hasPointsizes() )
return; return;
# ifdef REPORT_VBO_UPDATES # ifdef REPORT_VBO_UPDATES
...@@ -611,7 +574,7 @@ void SplatCloudNode::rebuildVBOPointsizes() ...@@ -611,7 +574,7 @@ void SplatCloudNode::rebuildVBOPointsizes()
unsigned char *buffer = vboData_ + vboPointsizesOffset_; unsigned char *buffer = vboData_ + vboPointsizesOffset_;
// for all points... // for all points...
unsigned int i, num = splatCloud_->numPoints(); unsigned int i, num = splatCloud_.numPoints();
for( i=0; i<num; ++i ) for( i=0; i<num; ++i )
{ {
// add pointsize // add pointsize
...@@ -626,7 +589,7 @@ void SplatCloudNode::rebuildVBOPointsizes() ...@@ -626,7 +589,7 @@ void SplatCloudNode::rebuildVBOPointsizes()
void SplatCloudNode::rebuildVBOColors() void SplatCloudNode::rebuildVBOColors()
{ {
if( vboColorsOffset_ == -1 || !splatCloud_->hasColors() ) if( vboColorsOffset_ == -1 || !splatCloud_.hasColors() )
return; return;
# ifdef REPORT_VBO_UPDATES # ifdef REPORT_VBO_UPDATES
...@@ -637,7 +600,7 @@ void SplatCloudNode::rebuildVBOColors() ...@@ -637,7 +600,7 @@ void SplatCloudNode::rebuildVBOColors()
unsigned char *buffer = vboData_ + vboColorsOffset_; unsigned char *buffer = vboData_ + vboColorsOffset_;
// for all points... // for all points...
unsigned int i, num = splatCloud_->numPoints(); unsigned int i, num = splatCloud_.numPoints();
for( i=0; i<num; ++i ) for( i=0; i<num; ++i )
{ {
// add color // add color
...@@ -654,7 +617,7 @@ void SplatCloudNode::rebuildVBOColors() ...@@ -654,7 +617,7 @@ void SplatCloudNode::rebuildVBOColors()
void SplatCloudNode::rebuildVBOSelections() void SplatCloudNode::rebuildVBOSelections()
{ {
if( vboSelectionsOffset_ == -1 || !splatCloud_->hasSelections() ) if( vboSelectionsOffset_ == -1 || !splatCloud_.hasSelections() )
return; return;
# ifdef REPORT_VBO_UPDATES # ifdef REPORT_VBO_UPDATES
...@@ -665,7 +628,7 @@ void SplatCloudNode::rebuildVBOSelections() ...@@ -665,7 +628,7 @@ void SplatCloudNode::rebuildVBOSelections()
unsigned char *buffer = vboData_ + vboSelectionsOffset_; unsigned char *buffer = vboData_ + vboSelectionsOffset_;
// for all points... // for all points...
unsigned int i, num = splatCloud_->numPoints(); unsigned int i, num = splatCloud_.numPoints();
for( i=0; i<num; ++i ) for( i=0; i<num; ++i )
{ {
const bool &s = getSelection( i ); const bool &s = getSelection( i );
...@@ -690,7 +653,7 @@ void SplatCloudNode::rebuildVBOPickColors( GLState &_state ) ...@@ -690,7 +653,7 @@ void SplatCloudNode::rebuildVBOPickColors( GLState &_state )
unsigned char *buffer = vboData_ + vboPickColorsOffset_; unsigned char *buffer = vboData_ + vboPickColorsOffset_;
// for all points... // for all points...
unsigned int i, num = splatCloud_->numPoints(); unsigned int i, num = splatCloud_.numPoints();
for( i=0; i<num; ++i ) for( i=0; i<num; ++i )
{ {
// add pick color // add pick color
......
...@@ -101,7 +101,7 @@ private: ...@@ -101,7 +101,7 @@ private:
public: public:
/// constructor /// constructor
SplatCloudNode( BaseNode *_parent = 0, std::string _name = "<SplatCloudNode>" ); SplatCloudNode( const SplatCloud &_splatCloud, BaseNode *_parent = 0, std::string _name = "<SplatCloudNode>" );
/// destructor /// destructor
~SplatCloudNode(); ~SplatCloudNode();
...@@ -123,10 +123,9 @@ public: ...@@ -123,10 +123,9 @@ public:
// ---- splat cloud ---- // ---- splat cloud ----
void copySplatCloud( const SplatCloud &_splatCloud ); inline const SplatCloud &splatCloud() const { return splatCloud_; }
inline SplatCloud *splatCloud() { return splatCloud_; } // ---- modification tags ----
inline const SplatCloud *splatCloud() const { return splatCloud_; }
inline void modifiedPoints() { pointsModified_ = true; } inline void modifiedPoints() { pointsModified_ = true; }
inline void modifiedNormals() { normalsModified_ = true; } inline void modifiedNormals() { normalsModified_ = true; }
...@@ -147,12 +146,12 @@ public: ...@@ -147,12 +146,12 @@ public:
inline const Pointsize &defaultPointsize() const { return defaultPointsize_; } inline const Pointsize &defaultPointsize() const { return defaultPointsize_; }
inline const Color &defaultColor() const { return defaultColor_; } inline const Color &defaultColor() const { return defaultColor_; }
/// if the data array exists, the entry with the given _index is returned, otherwise the default value is returned (check for splatCloud_ != 0 first) /// if the data array exists, the entry with the given _index is returned, otherwise the default value is returned
inline Point getPoint ( unsigned int _index ) const { return splatCloud_->hasPoints() ? splatCloud_->points() [ _index ] : Point(0.0f,0.0f,0.0f); } inline Point getPoint ( unsigned int _index ) const { return splatCloud_.hasPoints() ? splatCloud_.points() [ _index ] : Point(0.0f,0.0f,0.0f); }
inline Normal getNormal ( unsigned int _index ) const { return splatCloud_->hasNormals() ? splatCloud_->normals() [ _index ] : defaultNormal_ ; } inline Normal getNormal ( unsigned int _index ) const { return splatCloud_.hasNormals() ? splatCloud_.normals() [ _index ] : defaultNormal_ ; }
inline Pointsize getPointsize( unsigned int _index ) const { return splatCloud_->hasPointsizes() ? splatCloud_->pointsizes()[ _index ] : defaultPointsize_ ; } inline Pointsize getPointsize( unsigned int _index ) const { return splatCloud_.hasPointsizes() ? splatCloud_.pointsizes()[ _index ] : defaultPointsize_ ; }
inline Color getColor ( unsigned int _index ) const { return splatCloud_->hasColors() ? splatCloud_->colors() [ _index ] : defaultColor_ ; } inline Color getColor ( unsigned int _index ) const { return splatCloud_.hasColors() ? splatCloud_.colors() [ _index ] : defaultColor_ ; }
inline Selection getSelection( unsigned int _index ) const { return splatCloud_->hasSelections() ? splatCloud_->selections()[ _index ] : false ; } inline Selection getSelection( unsigned int _index ) const { return splatCloud_.hasSelections() ? splatCloud_.selections()[ _index ] : false ; }
//---------------------------------------------------------------- //----------------------------------------------------------------
...@@ -160,8 +159,10 @@ private: ...@@ -160,8 +159,10 @@ private:
// ---- splat cloud ---- // ---- splat cloud ----
/// pointer to class containing all the data /// reference to class containing all the data
SplatCloud *splatCloud_; const SplatCloud &splatCloud_;
// ---- modification tags ----
/// marks if parts of the data has been modified /// marks if parts of the data has been modified
bool pointsModified_; bool pointsModified_;
...@@ -205,14 +206,16 @@ private: ...@@ -205,14 +206,16 @@ private:
int vboSelectionsOffset_; int vboSelectionsOffset_;
int vboPickColorsOffset_; int vboPickColorsOffset_;
/// returns true iff the internal block structure of the VBO has to be changed (check for splatCloud_ != 0 first) /// returns true iff the internal block structure of the VBO has to be changed
inline bool vboStructureModified() const { return inline bool vboStructureModified() const
vboNumPoints_ != splatCloud_->numPoints() || {
(vboPointsOffset_ != -1) != splatCloud_->hasPoints() || return vboNumPoints_ != splatCloud_.numPoints() ||
(vboNormalsOffset_ != -1) != splatCloud_->hasNormals() || (vboPointsOffset_ != -1) != splatCloud_.hasPoints() ||
(vboPointsizesOffset_ != -1) != splatCloud_->hasPointsizes() || (vboNormalsOffset_ != -1) != splatCloud_.hasNormals() ||
(vboColorsOffset_ != -1) != splatCloud_->hasColors() || (vboPointsizesOffset_ != -1) != splatCloud_.hasPointsizes() ||
(vboSelectionsOffset_ != -1) != splatCloud_->hasSelections(); } (vboColorsOffset_ != -1) != splatCloud_.hasColors() ||
(vboSelectionsOffset_ != -1) != splatCloud_.hasSelections();
}
void createVBO(); void createVBO();
void destroyVBO(); void destroyVBO();
......
...@@ -75,8 +75,15 @@ BaseObjectData ( ), ...@@ -75,8 +75,15 @@ BaseObjectData ( ),
backfaceCullingEnabled_( false ), backfaceCullingEnabled_( false ),
pointsizeScale_ ( 1.0f ), pointsizeScale_ ( 1.0f ),
shaderNode_ ( 0 ), shaderNode_ ( 0 ),
splatCloudNode_ ( 0 ) splatCloudNode_ ( 0 )
{ {
// allocate memory for splat cloud
splatCloud_ = new SplatCloud;
if( !splatCloud_ )
{
std::cerr << "SplatCloudObject::SplatCloudObject() : Out of memory." << std::endl;
}
setDataType( DATA_SPLATCLOUD ); setDataType( DATA_SPLATCLOUD );
setTypeIcon( DATA_SPLATCLOUD, "SplatCloudType.png" ); setTypeIcon( DATA_SPLATCLOUD, "SplatCloudType.png" );
init(); init();
...@@ -89,9 +96,9 @@ splatCloudNode_ ( 0 ) ...@@ -89,9 +96,9 @@ splatCloudNode_ ( 0 )
/** /**
* Copy Constructor - generates a copy of the given object * Copy Constructor - generates a copy of the given object
*/ */
SplatCloudObject::SplatCloudObject( const SplatCloudObject &_object) : BaseObjectData( _object ) SplatCloudObject::SplatCloudObject( const SplatCloudObject &_object ) : BaseObjectData( _object )
{ {
init( _object.splatCloudNode_ ); init( _object.splatCloud_ );
setName( name() ); setName( name() );
} }
...@@ -112,8 +119,12 @@ SplatCloudObject::~SplatCloudObject() ...@@ -112,8 +119,12 @@ SplatCloudObject::~SplatCloudObject()
deleteData(); deleteData();
// No need to delete the scenegraph Nodes as this will be managed by baseplugin // No need to delete the scenegraph Nodes as this will be managed by baseplugin
shaderNode_ = 0; shaderNode_ = 0;
splatCloudNode_ = 0; splatCloudNode_ = 0;
// free memory of splat cloud
delete splatCloud_;
splatCloud_ = 0;
} }
...@@ -127,12 +138,9 @@ void SplatCloudObject::cleanup() ...@@ -127,12 +138,9 @@ void SplatCloudObject::cleanup()
{ {
BaseObjectData::cleanup(); BaseObjectData::cleanup();
shaderNode_ = 0; shaderNode_ = 0;
splatCloudNode_ = 0; splatCloudNode_ = 0;
setDataType( DATA_SPLATCLOUD );
setTypeIcon( DATA_SPLATCLOUD, "SplatCloudType.png" );
init(); init();
} }
...@@ -387,23 +395,37 @@ void SplatCloudObject::setPointsizeScale( float _scale ) ...@@ -387,23 +395,37 @@ void SplatCloudObject::setPointsizeScale( float _scale )
/** This function initalizes the SplatCloud object. It creates the scenegraph nodes. /** This function initalizes the SplatCloud object. It creates the scenegraph nodes.
*/ */
void SplatCloudObject::init( SplatCloudNode *_node ) void SplatCloudObject::init( const SplatCloud *_splatCloud )
{ {
if( materialNode() == NULL ) if( materialNode() == NULL )
std::cerr << "Error when creating SplatCloud Object! materialNode is NULL!" << std::endl; std::cerr << "Error when creating SplatCloud Object! materialNode is NULL!" << std::endl;
// create new scenegraph nodes // if _splatCloud is *not* 0, copy it's contents
shaderNode_ = new ShaderNode( materialNode(), "NEW ShaderNode for" ); if( _splatCloud )
splatCloudNode_ = new SplatCloudNode( shaderNode_, "NEW SplatCloudNode" ); {
delete splatCloud_;
// load shaders splatCloud_ = new SplatCloud( *_splatCloud );
reloadShaders(); if( !splatCloud_ )
{
std::cerr << "SplatCloudObject::init() : Out of memory." << std::endl;
}
}
// if _node is *not* 0 we want to have a copy of the scenegraph node, so copy it's contents // if something went wrong during initialization, abort
if( _node && _node->splatCloud() ) if( !splatCloud_ )
{ {
splatCloudNode_->copySplatCloud( *_node->splatCloud() ); shaderNode_ = 0;
splatCloudNode_ = 0;
return;
} }
// create new scenegraph nodes
shaderNode_ = new ShaderNode ( materialNode(), "NEW ShaderNode for" );
splatCloudNode_ = new SplatCloudNode( *splatCloud_, shaderNode_, "NEW SplatCloudNode" );
// load shaders
reloadShaders();
} }