Commit 444bc070 authored by Dirk Albrecht's avatar Dirk Albrecht

[CHANGE] Using osg::Switch to change shading.

parent 7884caa8
......@@ -25,9 +25,16 @@
#ifndef WMFIBERDISPLAY_H
#define WMFIBERDISPLAY_H
// This is the number of the attribute channel used
// to pass the second vertex attributes for morphing.
// According to NVidia spec not all channels are free,
// but number 6 is guaranteed to be free.
#define VERTEXBIND 6
#include <string>
#include <osg/Geode>
#include <osg/Switch>
#include "../../../dataHandler/datastructures/WFiberCluster.h"
#include "../../../dataHandler/WDataSetFibers.h"
......@@ -37,6 +44,7 @@
#include "../../WModule.h"
#include "../../WModuleInputData.h"
#include "WTubeDrawable.h"
#include "WTubeGeometry.h"
#include "../../WExportKernel.h"
......@@ -156,6 +164,13 @@ private:
WPropFilename m_saveFileName; //!< the filename for saving
WPropTrigger m_updateOC; //!< updates the output connector
WPropBool m_depthCueing;
WPropBool m_lightModel;
WPropBool m_usePointSprites;
WPropBool m_useQuadStripes;
WPropDouble m_lowDepthCueingFactor;
WPropDouble m_upperDepthCueingFactor;
WBoolFlag m_noData; //!< Flag indicating whether there is data to display.
WPropGroup m_cullBoxGroup; //!< property group for box culling
......@@ -163,7 +178,7 @@ private:
WPropBool m_showCullBox; //!< Enable/Disable showing of the cull box
WPropBool m_insideCullBox; //!< if true fibers inside the cull box are shown, outside if false
/**
/**
* Input connector for a fiber dataset.
*/
boost::shared_ptr< WModuleInputData< const WDataSetFibers > > m_fiberInput;
......@@ -182,10 +197,30 @@ private:
* OSG node for this module. All other OSG nodes of this module should be
* placed as child to this node.
*/
osg::ref_ptr< osg::Group > m_osgNode;
osg::ref_ptr< osg::Group > m_osgNode;
/**
* OSG node for this module. All other OSG nodes of this module should be
* placed as child to this node.
*/
osg::ref_ptr< osg::Switch > m_osgSwitch;
osg::ref_ptr< osg::Vec3Array > m_tubeVerts;
osg::ref_ptr< osg::Vec3Array > m_tubeTangents;
osg::ref_ptr< osg::Vec2Array > m_tubeTexCoords;
osg::ref_ptr< osg::Vec3Array > m_tubeColors;
osg::ref_ptr< osg::Vec2Array > m_pointTexCoords;
osg::ref_ptr< osg::Vec3Array > m_pointVerts;
osg::ref_ptr< osg::Vec3Array > m_pointTangents;
osg::ref_ptr< osg::Vec3Array > m_pointColors;
osg::ref_ptr< osg::VectorGLuint > m_fiberQuadStartIndexes;
osg::ref_ptr< osg::VectorGLuint > m_fiberPointStartIndexes;
osg::ref_ptr< osg::Geode > m_geodeTubeDrawable;
osg::ref_ptr< osg::Geode > m_geodePointSprite;
osg::ref_ptr< osg::Geode > m_geodeQuadStripes;
osg::ref_ptr<osg::Geode> m_geodeTubeDrawable;
osg::ref_ptr<osg::Geode> m_geodePointSprite;
/**
* stores pointer to the fiber drawer
*/
......@@ -194,9 +229,14 @@ private:
/**
* stores pointer to the fiber drawer
*/
osg::ref_ptr< WTubeDrawable > m_tubeDrawablePointSprite;
osg::ref_ptr< WTubeGeometry > m_tubeGeometryPointSprite;
/**
/**
* stores pointer to the fiber drawer
*/
osg::ref_ptr< WTubeGeometry > m_tubeGeometryQuadStripes;
/**
* lock to prevent concurrent threads trying to update the osg node
*/
boost::shared_mutex m_updateLock;
......@@ -263,6 +303,14 @@ private:
osg::ref_ptr<osg::Uniform> m_uniformViewportHeight;
osg::ref_ptr<osg::Uniform> m_uniformViewportWidth;
osg::ref_ptr<osg::Uniform> m_uniformDepthCueing;
osg::ref_ptr<osg::Uniform> m_uniformLightModel;
osg::ref_ptr<osg::Uniform> m_uniformUsePointSprites;
osg::ref_ptr<osg::Uniform> m_uniformUseQuadStripes;
osg::ref_ptr<osg::Uniform> m_uniformLowDepthCueingFactor;
osg::ref_ptr<osg::Uniform> m_uniformUpperDepthCueingFactor;
/**
* To avoid multiple instances of the fiber display.
*/
......@@ -297,6 +345,28 @@ private:
*/
void initCullBox();
/**
* Creates a texture to simmulate diffuse and specular lightning
* of a tube from aside
*/
void create1DTextureRectLightning(osg::StateSet* rootState) const;
/**
* Creates a texture to simmulate diffuse and specular lightning
* of a tube from top or bottom
*/
void create2DTextureCycleLightning(osg::StateSet* rootState) const;
void create2DTexDiffuseLightning(osg::StateSet* rootState) const;
void create2DTexSpecularLightning(osg::StateSet* rootState) const;
void createTextures(osg::StateSet* rootState) const;
void createTubeData();
/**
* Wrapper class for userData to prevent cyclic destructor calls
*/
......
......@@ -126,34 +126,8 @@ public:
*/
bool getColoringMode() const;
/**
* Creates a texture to simmulate diffuse and specular lightning
* of a tube from aside
*/
void create1DTextureRectLightning(osg::StateSet* m_rootState) const;
/**
* Set the bounding box of all fibers.
* \param bb The new bounding box.
*/
void setBoundingBox( const osg::BoundingBox & bb );
/**
* Creates a texture to simmulate diffuse and specular lightning
* of a tube from top or bottom
*/
void create2DTextureCycleLightning(osg::StateSet* m_rootState) const;
void create2DTexDiffuseLightning(osg::StateSet* m_rootState) const;
void create2DTexSpecularLightning(osg::StateSet* m_rootState) const;
void createTextures(osg::StateSet* m_rootState) const;
void setRootState(osg::StateSet* m_rootState);
void setWShader(osg::ref_ptr< WShader > m_shaderTubes);
void setWShaders(osg::ref_ptr< WShader > shaderTubesPS, osg::ref_ptr< WShader > shaderTubesQS);
void setOSGNode(osg::ref_ptr< osg::Group > osgNode);
void setActiveRenderingMode(bool usePointSprite, bool useQuadStrips);
protected:
private:
......@@ -170,30 +144,8 @@ private:
osg::StateSet* m_rootState;
osg::Vec3Array* m_tubeVerts;
osg::Vec3Array* m_tubeTangents;
osg::Vec2Array* m_tubeTexCoords;
osg::Vec2Array* m_pointTexCoords;
osg::Vec3Array* m_tubeColors;
osg::VectorGLuint* m_tubeStartIndexes;
osg::ref_ptr< WShader > m_shaderTubes;
osg::ref_ptr< WShader > m_shaderTubesPS;
osg::ref_ptr< WShader > m_shaderTubesQS;
bool m_usePointSprite;
bool m_useQuadStrips;
/*
boost::shared_ptr< std::vector< float > > m_tubeVerts;
boost::shared_ptr< std::vector< float > > m_tubeTangents;
boost::shared_ptr< std::vector< float > > m_tubeTexCoords;
boost::shared_ptr< std::vector< float > > m_pointTexCoords;
boost::shared_ptr< std::vector< float > > m_tubeColors;
*/
osg::ref_ptr< osg::Group > m_osgNode;
boost::shared_ptr< const WDataSetFibers > m_dataset; //!< stores pointer to dataset
......
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