Commit 1ef3000a authored by Jan Möbius's avatar Jan Möbius
Browse files

Indentations and automatic setting of at least one correct draw mode for points



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12634 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 1d0c1a5e
......@@ -89,15 +89,23 @@ void SplatCloudNode::boundingBox( ACG::Vec3d &_bbMin, ACG::Vec3d &_bbMax )
//----------------------------------------------------------------
void SplatCloudNode::draw( GLState &_state, const DrawModes::DrawMode &_drawMode )
{
static const int RENDERMODE_POINTS = 0;
static const int RENDERMODE_DOTS = 1;
static const int RENDERMODE_SPLATS = 2;
// check if drawmode is valid
if( _drawMode != splatsDrawMode_ &&
_drawMode != dotsDrawMode_ &&
_drawMode != pointsDrawMode_ )
{
int rendermode;
if( _drawMode.containsAtomicDrawMode( splatsDrawMode_ ) )
rendermode = RENDERMODE_SPLATS;
else if( _drawMode.containsAtomicDrawMode( dotsDrawMode_ ) )
rendermode = RENDERMODE_DOTS;
else if( _drawMode.containsAtomicDrawMode( pointsDrawMode_ ) )
rendermode = RENDERMODE_POINTS;
else
return;
}
// set desired depth function
ACG::GLState::depthFunc( _state.depthFunc() );
......@@ -124,16 +132,20 @@ void SplatCloudNode::draw( GLState &_state, const DrawModes::DrawMode &_drawMode
// Normals are always needed for backface culling, even in drawmode 'Points'!
// Colors are always needed for pointsizes, even in color picking mode!
// enable "pointsize by program" depending on current drawmode
if( _drawMode != pointsDrawMode_ )
ACG::GLState::enable( GL_VERTEX_PROGRAM_POINT_SIZE );
// enable "pointsize by program" depending on current rendermode
if( rendermode != RENDERMODE_POINTS )
{
ACG::GLState::enable( GL_VERTEX_PROGRAM_POINT_SIZE );
}
// draw as points
// draw as GLpoints
glDrawArrays( GL_POINTS, 0, numPoints() );
// disable "pointsize by program" if it was enabled
if( _drawMode != pointsDrawMode_ )
ACG::GLState::disable( GL_VERTEX_PROGRAM_POINT_SIZE );
if( rendermode != RENDERMODE_POINTS )
{
ACG::GLState::disable( GL_VERTEX_PROGRAM_POINT_SIZE );
}
// disable arrays
ACG::GLState::disableClientState( GL_VERTEX_ARRAY );
......
......@@ -90,20 +90,20 @@ public:
//-- TYPEDEFS ----------------------------------------------------
typedef ACG::Vec3f Point;
typedef ACG::Vec3f Normal;
typedef float Pointsize;
typedef ACG::Vec3uc Color;
typedef ACG::Vec3f Point;
typedef ACG::Vec3f Normal;
typedef float Pointsize;
typedef ACG::Vec3uc Color;
typedef std::vector<Point> PointVector;
typedef std::vector<Normal> NormalVector;
typedef std::vector<Pointsize> PointsizeVector;
typedef std::vector<Color> ColorVector;
typedef std::vector<Point> PointVector;
typedef std::vector<Normal> NormalVector;
typedef std::vector<Pointsize> PointsizeVector;
typedef std::vector<Color> ColorVector;
//----------------------------------------------------------------
/// Constructor
SplatCloudNode( BaseNode *_parent = 0, std::string _name = "<SplatCloudNode>" ) :
SplatCloudNode( BaseNode *_parent = 0, std::string _name = "<SplatCloudNode>" ) :
BaseNode ( _parent, _name ),
defaultNormal_ ( Normal(0.0f,0.0f,1.0f) ),
defaultPointsize_( 0.01f ),
......@@ -193,25 +193,25 @@ public:
private:
// ---- draw modes ----
DrawModes::DrawMode splatsDrawMode_;
DrawModes::DrawMode dotsDrawMode_;
DrawModes::DrawMode pointsDrawMode_;
DrawModes::DrawMode splatsDrawMode_;
DrawModes::DrawMode dotsDrawMode_;
DrawModes::DrawMode pointsDrawMode_;
// ---- data vectors ----
PointVector points_;
NormalVector normals_;
PointsizeVector pointsizes_;
ColorVector colors_;
PointVector points_;
NormalVector normals_;
PointsizeVector pointsizes_;
ColorVector colors_;
// ---- default values ----
/// the default values will be used when the specific array is not present
Normal defaultNormal_;
Pointsize defaultPointsize_;
Color defaultColor_;
Normal defaultNormal_;
Pointsize defaultPointsize_;
Color defaultColor_;
// ---- vertex buffer object ----
GLuint vboGlId_;
bool vboValid_;
GLuint vboGlId_;
bool vboValid_;
void createVBO();
void destroyVBO();
......
......@@ -56,6 +56,7 @@
#include "SplatCloud.hh"
#include <OpenFlipper/common/Types.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <QString>
......@@ -180,8 +181,8 @@ void SplatCloudObject::reloadShaders()
// if drawmodes don't exist something went wrong
if( splatsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
dotsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
pointsDrawMode == ACG::SceneGraph::DrawModes::NONE )
dotsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
pointsDrawMode == ACG::SceneGraph::DrawModes::NONE )
{
std::cerr << "Shader DrawModes for SplatCloud not existent!" << std::endl;
return;
......@@ -198,9 +199,9 @@ void SplatCloudObject::reloadShaders()
// load shaders
if( QFile( shaderDir + SPLATS_VERTEXSHADER_FILENAME ).exists() &&
QFile( shaderDir + SPLATS_PICK_VERTEXSHADER_FILENAME ).exists() &&
QFile( shaderDir + SPLATS_FRAGMENTSHADER_FILENAME ).exists() &&
QFile( shaderDir + SPLATS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
QFile( shaderDir + SPLATS_PICK_VERTEXSHADER_FILENAME ).exists() &&
QFile( shaderDir + SPLATS_FRAGMENTSHADER_FILENAME ).exists() &&
QFile( shaderDir + SPLATS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
{
shaderNode_->setShader( splatsDrawMode,
SPLATS_VERTEXSHADER_FILENAME, SPLATS_FRAGMENTSHADER_FILENAME,
......@@ -212,9 +213,9 @@ void SplatCloudObject::reloadShaders()
}
if( QFile( shaderDir + DOTS_VERTEXSHADER_FILENAME ).exists() &&
QFile( shaderDir + DOTS_PICK_VERTEXSHADER_FILENAME ).exists() &&
QFile( shaderDir + DOTS_FRAGMENTSHADER_FILENAME ).exists() &&
QFile( shaderDir + DOTS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
QFile( shaderDir + DOTS_PICK_VERTEXSHADER_FILENAME ).exists() &&
QFile( shaderDir + DOTS_FRAGMENTSHADER_FILENAME ).exists() &&
QFile( shaderDir + DOTS_PICK_FRAGMENTSHADER_FILENAME ).exists() )
{
shaderNode_->setShader( dotsDrawMode,
DOTS_VERTEXSHADER_FILENAME, DOTS_FRAGMENTSHADER_FILENAME,
......@@ -256,8 +257,8 @@ void SplatCloudObject::enableBackfaceCulling( bool _enable )
// if drawmodes don't exist something went wrong
if( splatsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
dotsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
pointsDrawMode == ACG::SceneGraph::DrawModes::NONE )
dotsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
pointsDrawMode == ACG::SceneGraph::DrawModes::NONE )
{
std::cerr << "Shader DrawModes for SplatCloud not existent!" << std::endl;
return;
......@@ -334,7 +335,7 @@ void SplatCloudObject::setPointsizeScale( float _scale )
// if drawmodes don't exist something went wrong
if( splatsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
dotsDrawMode == ACG::SceneGraph::DrawModes::NONE )
dotsDrawMode == ACG::SceneGraph::DrawModes::NONE )
{
std::cerr << "Shader DrawModes for SplatCloud not existent!" << std::endl;
return;
......@@ -398,17 +399,20 @@ void SplatCloudObject::init( SplatCloudNode *_node )
// load shaders
reloadShaders();
// set initial drawmode of shader- and splatcloud-node
ACG::SceneGraph::DrawModes::DrawMode initialDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Points" );
// get drawmodes
ACG::SceneGraph::DrawModes::DrawMode splatsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Splats" );
ACG::SceneGraph::DrawModes::DrawMode dotsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Dots" );
ACG::SceneGraph::DrawModes::DrawMode pointsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Points" );
if( initialDrawMode == ACG::SceneGraph::DrawModes::NONE )
// if drawmodes don't exist something went wrong
if( splatsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
dotsDrawMode == ACG::SceneGraph::DrawModes::NONE ||
pointsDrawMode == ACG::SceneGraph::DrawModes::NONE )
{
std::cerr << "Shader DrawModes for SplatCloud not existent!" << std::endl;
return;
}
setObjectDrawMode( initialDrawMode );
// copy contents
if( _node )
{
......
......@@ -647,6 +647,23 @@ int FilePTSPlugin::loadObject( QString _filename )
emit updatedObject( splatCloud->id(), UPDATE_ALL );
emit openedFile( splatCloud->id() );
// get drawmodes
ACG::SceneGraph::DrawModes::DrawMode splatsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Splats" );
ACG::SceneGraph::DrawModes::DrawMode dotsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Dots" );
ACG::SceneGraph::DrawModes::DrawMode pointsDrawMode = ACG::SceneGraph::DrawModes::getDrawMode( "Points" );
// get global drawmode
ACG::SceneGraph::DrawModes::DrawMode drawmode = PluginFunctions::drawMode();
// if global drawmode does *not* contain any of 'Splats', 'Dots' or 'Points' drawmode, add 'Points'
if( !drawmode.containsAtomicDrawMode( splatsDrawMode ) &&
!drawmode.containsAtomicDrawMode( dotsDrawMode ) &&
!drawmode.containsAtomicDrawMode( pointsDrawMode ) )
{
drawmode |= pointsDrawMode;
PluginFunctions::setDrawMode( drawmode );
}
// return the id of the new splatcloud object
return id;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment