From a8c4fd87613093864f3df104dfb8a73a3e30fded Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 20 Apr 2010 10:29:04 +0000 Subject: [PATCH] From Wang Rui, "The new osgShadow and osgFX serializers are attached, and some modifications of the osgShadow header naming styles as well. The osgDB::Serializer header is also changed to add new Vec2 serializer macros because of the needs of osgShadow classes. It should compile fine on both Windows and Linux. But I have only done a few tests to generate .osgb, .osgt and .osgx formats with these new wrappers." --- include/osgDB/Serializer | 12 +++++- include/osgShadow/DebugShadowMap | 2 +- include/osgShadow/MinimalShadowMap | 8 ++-- include/osgShadow/ParallelSplitShadowMap | 25 ++++++++++- include/osgShadow/SoftShadowMap | 4 +- include/osgShadow/StandardShadowMap | 13 +++--- src/osgPlugins/3ds/lib3ds/lib3ds_file.c | 4 +- src/osgShadow/ParallelSplitShadowMap.cpp | 4 +- src/osgShadow/SoftShadowMap.cpp | 4 +- src/osgWrappers/serializers/CMakeLists.txt | 2 + .../serializers/osgFX/AnisotropicLighting.cpp | 33 +++++++++++++++ .../serializers/osgFX/BumpMapping.cpp | 16 ++++++++ .../serializers/osgFX/CMakeLists.txt | 7 ++++ src/osgWrappers/serializers/osgFX/Cartoon.cpp | 14 +++++++ src/osgWrappers/serializers/osgFX/Effect.cpp | 31 ++++++++++++++ .../serializers/osgFX/MultiTextureControl.cpp | 41 +++++++++++++++++++ src/osgWrappers/serializers/osgFX/Outline.cpp | 13 ++++++ src/osgWrappers/serializers/osgFX/Scribe.cpp | 13 ++++++ .../serializers/osgFX/SpecularHighlights.cpp | 15 +++++++ .../serializers/osgShadow/CMakeLists.txt | 7 ++++ .../serializers/osgShadow/DebugShadowMap.cpp | 13 ++++++ .../LightSpacePerspectiveShadowMapCB.cpp | 13 ++++++ .../LightSpacePerspectiveShadowMapDB.cpp | 13 ++++++ .../LightSpacePerspectiveShadowMapVB.cpp | 13 ++++++ .../osgShadow/MinimalCullBoundsShadowMap.cpp | 13 ++++++ .../osgShadow/MinimalDrawBoundsShadowMap.cpp | 13 ++++++ .../osgShadow/MinimalShadowMap.cpp | 21 ++++++++++ .../osgShadow/ParallelSplitShadowMap.cpp | 25 +++++++++++ .../serializers/osgShadow/ShadowMap.cpp | 20 +++++++++ .../serializers/osgShadow/ShadowTechnique.cpp | 11 +++++ .../serializers/osgShadow/ShadowTexture.cpp | 12 ++++++ .../serializers/osgShadow/ShadowVolume.cpp | 18 ++++++++ .../serializers/osgShadow/ShadowedScene.cpp | 14 +++++++ .../serializers/osgShadow/SoftShadowMap.cpp | 15 +++++++ .../osgShadow/StandardShadowMap.cpp | 24 +++++++++++ .../ViewDependentShadowTechnique.cpp | 11 +++++ 36 files changed, 496 insertions(+), 21 deletions(-) create mode 100644 src/osgWrappers/serializers/osgFX/AnisotropicLighting.cpp create mode 100644 src/osgWrappers/serializers/osgFX/BumpMapping.cpp create mode 100644 src/osgWrappers/serializers/osgFX/CMakeLists.txt create mode 100644 src/osgWrappers/serializers/osgFX/Cartoon.cpp create mode 100644 src/osgWrappers/serializers/osgFX/Effect.cpp create mode 100644 src/osgWrappers/serializers/osgFX/MultiTextureControl.cpp create mode 100644 src/osgWrappers/serializers/osgFX/Outline.cpp create mode 100644 src/osgWrappers/serializers/osgFX/Scribe.cpp create mode 100644 src/osgWrappers/serializers/osgFX/SpecularHighlights.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/CMakeLists.txt create mode 100644 src/osgWrappers/serializers/osgShadow/DebugShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapCB.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapDB.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapVB.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/MinimalCullBoundsShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/MinimalDrawBoundsShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/MinimalShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/ParallelSplitShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/ShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/ShadowTechnique.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/ShadowTexture.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/ShadowVolume.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/ShadowedScene.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/SoftShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/StandardShadowMap.cpp create mode 100644 src/osgWrappers/serializers/osgShadow/ViewDependentShadowTechnique.cpp diff --git a/include/osgDB/Serializer b/include/osgDB/Serializer index b56c5584a..f6b2d7739 100644 --- a/include/osgDB/Serializer +++ b/include/osgDB/Serializer @@ -747,7 +747,7 @@ public: // ADDING MANIPULATORS #define ADD_SERIALIZER(S) \ - wrapper->addSerializer(S) + wrapper->addSerializer( (S) ) #define ADD_USER_SERIALIZER(PROP) \ wrapper->addSerializer( new osgDB::UserSerializer( \ @@ -793,6 +793,16 @@ public: wrapper->addSerializer( new osgDB::PropByValSerializer< MyClass, double >( \ #PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP) ) +#define ADD_VEC2F_SERIALIZER(PROP, DEF) \ + wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec2f >( \ + #PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP) ) + +#define ADD_VEC2D_SERIALIZER(PROP, DEF) \ + wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec2d >( \ + #PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP) ) + +#define ADD_VEC2_SERIALIZER(PROP, DEF) ADD_VEC2F_SERIALIZER(PROP, DEF) + #define ADD_VEC3F_SERIALIZER(PROP, DEF) \ wrapper->addSerializer( new osgDB::PropByRefSerializer< MyClass, osg::Vec3f >( \ #PROP, DEF, &MyClass::get##PROP, &MyClass::set##PROP) ) diff --git a/include/osgShadow/DebugShadowMap b/include/osgShadow/DebugShadowMap index 937798b5a..a472bc2dd 100644 --- a/include/osgShadow/DebugShadowMap +++ b/include/osgShadow/DebugShadowMap @@ -69,7 +69,7 @@ class OSGSHADOW_EXPORT DebugShadowMap : public ViewDependentShadowTechnique void setDebugDraw( bool draw ) { _doDebugDraw = draw; } /** Tell if debuging hud & rendering of debug volumes is active */ - bool getDebugDraw( void ) { return _doDebugDraw; } + bool getDebugDraw( void ) const { return _doDebugDraw; } protected: /** Classic protected OSG destructor */ diff --git a/include/osgShadow/MinimalShadowMap b/include/osgShadow/MinimalShadowMap index 9a9963cf3..3612fd133 100644 --- a/include/osgShadow/MinimalShadowMap +++ b/include/osgShadow/MinimalShadowMap @@ -43,16 +43,16 @@ class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap void setModellingSpaceToWorldTransform( const osg::Matrix & modellingSpaceToWorld ) { _modellingSpaceToWorld = modellingSpaceToWorld; } - const osg::Matrix & getModellingSpaceToWorldTransform( void ) + const osg::Matrix & getModellingSpaceToWorldTransform( void ) const { return _modellingSpaceToWorld; } - float getMaxFarPlane( ) + float getMaxFarPlane( ) const { return _maxFarPlane; } void setMaxFarPlane( float maxFarPlane ) { _maxFarPlane = maxFarPlane; } - float getMinLightMargin( ) + float getMinLightMargin( ) const { return _minLightMargin; } void setMinLightMargin( float minLightMargin ) @@ -70,7 +70,7 @@ class OSGSHADOW_EXPORT MinimalShadowMap : public StandardShadowMap { _shadowReceivingCoarseBoundAccuracy = accuracy; } ShadowReceivingCoarseBoundAccuracy - getShadowReceivingCoarseBoundAccuracy() + getShadowReceivingCoarseBoundAccuracy() const { return _shadowReceivingCoarseBoundAccuracy; } protected: diff --git a/include/osgShadow/ParallelSplitShadowMap b/include/osgShadow/ParallelSplitShadowMap index 9a5d95226..d71f6b4f2 100644 --- a/include/osgShadow/ParallelSplitShadowMap +++ b/include/osgShadow/ParallelSplitShadowMap @@ -64,28 +64,46 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique inline void setPolygonOffset(const osg::Vec2f& p) { _polgyonOffset = p;_user_polgyonOffset_set=true;} /** Get the polygon offset osg::Vec2f(factor,unit) */ - inline const osg::Vec2f& getPolygonOffset() { return _polgyonOffset;} + inline const osg::Vec2f& getPolygonOffset() const { return _polgyonOffset;} /** Set the texture resolution */ inline void setTextureResolution(unsigned int resolution) { _resolution = resolution; } + + /** Get the texture resolution */ + inline unsigned int getTextureResolution() const { return _resolution; } /** Set the max far distance */ inline void setMaxFarDistance(double farDist) { _setMaxFarDistance = farDist; _isSetMaxFarDistance = true; } + /** Get the max far distance */ + inline double getMaxFarDistance() const { return _setMaxFarDistance; } + /** Set the factor for moving the virtual camera behind the real camera*/ inline void setMoveVCamBehindRCamFactor(double distFactor ) { _move_vcam_behind_rcam_factor = distFactor; } + /** Get the factor for moving the virtual camera behind the real camera*/ + inline double getMoveVCamBehindRCamFactor() const { return _move_vcam_behind_rcam_factor; } + /** Set min near distance for splits */ inline void setMinNearDistanceForSplits(double nd){ _split_min_near_dist=nd; } + + /** Get min near distance for splits */ + inline double getMinNearDistanceForSplits() const { return _split_min_near_dist; } /** set a user defined light for shadow simulation (sun light, ... ) * when this light get passed to pssm, the scene's light are no longer collected * and simulated. just this user passed light, it needs to be a directional light. */ inline void setUserLight(osg::Light* light) { _userLight = light; } + + /** get the user defined light for shadow simulation */ + inline const osg::Light* getUserLight() const { return _userLight; } /** Set the values for the ambient bias the shader will use.*/ - void setAmbientBias(const osg::Vec2& ambientBias ); + void setAmbientBias(const osg::Vec2d& ambientBias ); + + /** Get the values for the ambient bias the shader will use.*/ + const osg::Vec2d& getAmbientBias() const { return _ambientBias; } /** * you can overwrite the fragment shader if you like to modify it yourself, own fragment shader can be used @@ -111,6 +129,9 @@ class OSGSHADOW_EXPORT ParallelSplitShadowMap : public ShadowTechnique /** set split calculation mode */ inline void setSplitCalculationMode(SplitCalcMode scm=SPLIT_EXP) { _SplitCalcMode = scm; } + + /** get split calculation mode */ + inline SplitCalcMode getSplitCalculationMode() const { return _SplitCalcMode; } protected : diff --git a/include/osgShadow/SoftShadowMap b/include/osgShadow/SoftShadowMap index 6e7e8fd58..cbceb915f 100644 --- a/include/osgShadow/SoftShadowMap +++ b/include/osgShadow/SoftShadowMap @@ -36,7 +36,7 @@ class OSGSHADOW_EXPORT SoftShadowMap : public ShadowMap /** Set the values for width of the soft penumbra the shader will use. * Zero is for hard shadow (no penumbra). 0.01 is already very soft penumbra. * Default is 0.005.*/ - void setSoftnessWidth(const float softnessWidth); + void setSoftnessWidth(float softnessWidth); /** Get the value used for width of the soft penumbra in the shader.*/ float getSoftnessWidth() const { return _softnessWidth; } @@ -46,7 +46,7 @@ class OSGSHADOW_EXPORT SoftShadowMap : public ShadowMap * High values (>64) cause 'pixelization' of the penumbra. * Usually but not necessarily power of two number. * Default is 32. */ - void setJitteringScale(const float jitteringScale); + void setJitteringScale(float jitteringScale); /** Get the value used for jittering scale in the shader.*/ float getJitteringScale() const { return _jitteringScale; } diff --git a/include/osgShadow/StandardShadowMap b/include/osgShadow/StandardShadowMap index f2fbd1daa..a40f79ca0 100644 --- a/include/osgShadow/StandardShadowMap +++ b/include/osgShadow/StandardShadowMap @@ -42,13 +42,13 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap void setBaseTextureUnit( unsigned int unit ) { _baseTextureUnit = unit; dirty(); } - unsigned int getBaseTextureUnit( void ) + unsigned int getBaseTextureUnit( void ) const { return _baseTextureUnit; } void setShadowTextureUnit( unsigned int unit ) { _shadowTextureUnit = unit; dirty(); } - unsigned int getShadowTextureUnit( void ) + unsigned int getShadowTextureUnit( void ) const { return _shadowTextureUnit; } // Texture Indices are changed by search and replace on shader source @@ -72,7 +72,7 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap { updateTextureCoordIndices( _baseTextureCoordIndex, index ); _baseTextureCoordIndex = index; } - unsigned int getBaseTextureCoordIndex( void ) + unsigned int getBaseTextureCoordIndex( void ) const { return _baseTextureCoordIndex; } // Texture Indices are changed by search and replace on shader source @@ -82,13 +82,13 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap { updateTextureCoordIndices( _shadowTextureCoordIndex, index ); _shadowTextureCoordIndex = index; } - unsigned int getShadowTextureCoordIndex( void ) + unsigned int getShadowTextureCoordIndex( void ) const { return _shadowTextureCoordIndex; } void setTextureSize( const osg::Vec2s& textureSize ) { _textureSize = textureSize; dirty(); } - osg::Vec2s getTextureSize( ) + const osg::Vec2s& getTextureSize() const { return _textureSize; } void setLight( osg::Light* light ) @@ -96,6 +96,9 @@ class OSGSHADOW_EXPORT StandardShadowMap : public DebugShadowMap osg::Light* getLight( void ) { return _light.get(); } + + const osg::Light* getLight( void ) const + { return _light.get(); } osg::Shader * getShadowVertexShader() { return _shadowVertexShader.get(); } diff --git a/src/osgPlugins/3ds/lib3ds/lib3ds_file.c b/src/osgPlugins/3ds/lib3ds/lib3ds_file.c index ff57bccbd..355506c9b 100644 --- a/src/osgPlugins/3ds/lib3ds/lib3ds_file.c +++ b/src/osgPlugins/3ds/lib3ds/lib3ds_file.c @@ -446,13 +446,13 @@ mdata_read(Lib3dsFile *file, Lib3dsIo *io) { static int compare_node_id( const void *a, const void *b ) { - return (*((Lib3dsNode**)a))->node_id - (*((Lib3dsNode**)b))->node_id; + return (int)((*((Lib3dsNode**)a))->node_id) - (int)((*((Lib3dsNode**)b))->node_id); } static int compare_node_id2( const void *a, const void *b ) { - return *((unsigned short*)a) - (*((Lib3dsNode**)b))->node_id; + return (int)(*((unsigned short*)a)) - (int)((*((Lib3dsNode**)b))->node_id); } diff --git a/src/osgShadow/ParallelSplitShadowMap.cpp b/src/osgShadow/ParallelSplitShadowMap.cpp index 864149006..738966a96 100644 --- a/src/osgShadow/ParallelSplitShadowMap.cpp +++ b/src/osgShadow/ParallelSplitShadowMap.cpp @@ -275,10 +275,10 @@ ParallelSplitShadowMap::ParallelSplitShadowMap(const ParallelSplitShadowMap& cop { } -void ParallelSplitShadowMap::setAmbientBias(const osg::Vec2& ambientBias) +void ParallelSplitShadowMap::setAmbientBias(const osg::Vec2d& ambientBias) { _ambientBias = ambientBias; - if (_ambientBiasUniform ) _ambientBiasUniform->set(_ambientBias); + if (_ambientBiasUniform ) _ambientBiasUniform->set(osg::Vec2f(_ambientBias.x(), _ambientBias.y())); } void ParallelSplitShadowMap::init(){ diff --git a/src/osgShadow/SoftShadowMap.cpp b/src/osgShadow/SoftShadowMap.cpp index c3a9c87c6..da208cf61 100755 --- a/src/osgShadow/SoftShadowMap.cpp +++ b/src/osgShadow/SoftShadowMap.cpp @@ -177,13 +177,13 @@ ShadowMap(copy,copyop), { } -void SoftShadowMap::setJitteringScale(const float jitteringScale) +void SoftShadowMap::setJitteringScale(float jitteringScale) { _jitteringScale = jitteringScale; if (_jitteringScaleUniform.valid()) _jitteringScaleUniform->set(_jitteringScale); } -void SoftShadowMap::setSoftnessWidth(const float softnessWidth) +void SoftShadowMap::setSoftnessWidth(float softnessWidth) { _softnessWidth = softnessWidth; if (_softnessWidthUniform.valid()) _softnessWidthUniform->set(_softnessWidth); diff --git a/src/osgWrappers/serializers/CMakeLists.txt b/src/osgWrappers/serializers/CMakeLists.txt index b7004a79e..0324a286d 100644 --- a/src/osgWrappers/serializers/CMakeLists.txt +++ b/src/osgWrappers/serializers/CMakeLists.txt @@ -39,6 +39,8 @@ SET(TARGET_COMMON_LIBRARIES ADD_SUBDIRECTORY(osg) ADD_SUBDIRECTORY(osgAnimation) +ADD_SUBDIRECTORY(osgFX) ADD_SUBDIRECTORY(osgParticle) +ADD_SUBDIRECTORY(osgShadow) ADD_SUBDIRECTORY(osgTerrain) ADD_SUBDIRECTORY(osgText) diff --git a/src/osgWrappers/serializers/osgFX/AnisotropicLighting.cpp b/src/osgWrappers/serializers/osgFX/AnisotropicLighting.cpp new file mode 100644 index 000000000..4fb8d2785 --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/AnisotropicLighting.cpp @@ -0,0 +1,33 @@ +#include +#include +#include +#include +#include + +static bool checkLightingMap( const osgFX::AnisotropicLighting& effect ) +{ + if ( !effect.getLightingMap() ) return false; + return !effect.getLightingMap()->getFileName().empty(); +} + +static bool readLightingMap( osgDB::InputStream& is, osgFX::AnisotropicLighting& effect ) +{ + std::string fileName; is.readWrappedString( fileName ); + effect.setLightingMap( osgDB::readImageFile(fileName) ); + return true; +} + +static bool writeLightingMap( osgDB::OutputStream& os, const osgFX::AnisotropicLighting& effect ) +{ + os.writeWrappedString( effect.getLightingMap()->getFileName() ); + os << std::endl; return true; +} + +REGISTER_OBJECT_WRAPPER( osgFX_AnisotropicLighting, + new osgFX::AnisotropicLighting, + osgFX::AnisotropicLighting, + "osg::Object osg::Node osg::Group osgFX::Effect osgFX::AnisotropicLighting" ) +{ + ADD_INT_SERIALIZER( LightNumber, 0 ); // _lightnum + ADD_USER_SERIALIZER( LightingMap ); // _texture +} diff --git a/src/osgWrappers/serializers/osgFX/BumpMapping.cpp b/src/osgWrappers/serializers/osgFX/BumpMapping.cpp new file mode 100644 index 000000000..390d3172b --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/BumpMapping.cpp @@ -0,0 +1,16 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgFX_BumpMapping, + new osgFX::BumpMapping, + osgFX::BumpMapping, + "osg::Object osg::Node osg::Group osgFX::Effect osgFX::BumpMapping" ) +{ + ADD_INT_SERIALIZER( LightNumber, 0 ); // _lightnum + ADD_INT_SERIALIZER( DiffuseTextureUnit, 1 ); // _diffuse_unit + ADD_INT_SERIALIZER( NormalMapTextureUnit, 0 ); // _normal_unit + ADD_OBJECT_SERIALIZER( OverrideDiffuseTexture, osg::Texture2D, NULL ); // _diffuse_tex + ADD_OBJECT_SERIALIZER( OverrideNormalMapTexture, osg::Texture2D, NULL ); // _normal_tex +} diff --git a/src/osgWrappers/serializers/osgFX/CMakeLists.txt b/src/osgWrappers/serializers/osgFX/CMakeLists.txt new file mode 100644 index 000000000..a2ca1a0eb --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/CMakeLists.txt @@ -0,0 +1,7 @@ +FILE(GLOB TARGET_SRC *.cpp) +FILE(GLOB TARGET_H *.h) + +SET(TARGET_ADDED_LIBRARIES osgFX ) + +#### end var setup ### +SETUP_PLUGIN(osgfx) diff --git a/src/osgWrappers/serializers/osgFX/Cartoon.cpp b/src/osgWrappers/serializers/osgFX/Cartoon.cpp new file mode 100644 index 000000000..f6c55378f --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/Cartoon.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgFX_Cartoon, + new osgFX::Cartoon, + osgFX::Cartoon, + "osg::Object osg::Node osg::Group osgFX::Effect osgFX::Cartoon" ) +{ + ADD_VEC4_SERIALIZER( OutlineColor, osg::Vec4() ); + ADD_FLOAT_SERIALIZER( OutlineLineWidth, 0.0f ); + ADD_INT_SERIALIZER( LightNumber, 0 ); // _lightnum +} diff --git a/src/osgWrappers/serializers/osgFX/Effect.cpp b/src/osgWrappers/serializers/osgFX/Effect.cpp new file mode 100644 index 000000000..0528ee38d --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/Effect.cpp @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +static bool checkSelectedTechnique( const osgFX::Effect& effect ) +{ + return effect.getSelectedTechnique()!=osgFX::Effect::AUTO_DETECT; +} + +static bool readSelectedTechnique( osgDB::InputStream& is, osgFX::Effect& effect ) +{ + int sel = 0; is >> sel; + effect.selectTechnique( sel ); + return true; +} + +static bool writeSelectedTechnique( osgDB::OutputStream& os, const osgFX::Effect& effect ) +{ + os << effect.getSelectedTechnique() << std::endl; + return true; +} + +REGISTER_OBJECT_WRAPPER( osgFX_Effect, + /*new osgFX::Effect*/NULL, + osgFX::Effect, + "osg::Object osg::Node osg::Group osgFX::Effect" ) +{ + ADD_BOOL_SERIALIZER( Enabled, true ); // _enabled + ADD_USER_SERIALIZER( SelectedTechnique ); // _global_sel_tech +} diff --git a/src/osgWrappers/serializers/osgFX/MultiTextureControl.cpp b/src/osgWrappers/serializers/osgFX/MultiTextureControl.cpp new file mode 100644 index 000000000..49e7b3149 --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/MultiTextureControl.cpp @@ -0,0 +1,41 @@ +#include +#include +#include +#include + +static bool checkTextureWeights( const osgFX::MultiTextureControl& ctrl ) +{ + return ctrl.getNumTextureWeights()>0; +} + +static bool readTextureWeights( osgDB::InputStream& is, osgFX::MultiTextureControl& ctrl ) +{ + unsigned int size = 0; is >> size >> osgDB::BEGIN_BRACKET; + for ( unsigned int i=0; i> weight; + ctrl.setTextureWeight( i, weight ); + } + is >> osgDB::END_BRACKET; + return true; +} + +static bool writeTextureWeights( osgDB::OutputStream& os, const osgFX::MultiTextureControl& ctrl ) +{ + unsigned int size = ctrl.getNumTextureWeights(); + os << size << osgDB::BEGIN_BRACKET << std::endl; + for ( unsigned int i=0; i +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgFX_Outline, + new osgFX::Outline, + osgFX::Outline, + "osg::Object osg::Node osg::Group osgFX::Effect osgFX::Outline" ) +{ + ADD_FLOAT_SERIALIZER( Width, 0.0f ); // _width + ADD_VEC4_SERIALIZER( Color, osg::Vec4() ); // _color +} diff --git a/src/osgWrappers/serializers/osgFX/Scribe.cpp b/src/osgWrappers/serializers/osgFX/Scribe.cpp new file mode 100644 index 000000000..016a9d98e --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/Scribe.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgFX_Scribe, + new osgFX::Scribe, + osgFX::Scribe, + "osg::Object osg::Node osg::Group osgFX::Effect osgFX::Scribe" ) +{ + ADD_VEC4_SERIALIZER( WireframeColor, osg::Vec4() ); + ADD_FLOAT_SERIALIZER( WireframeLineWidth, 0.0f ); +} diff --git a/src/osgWrappers/serializers/osgFX/SpecularHighlights.cpp b/src/osgWrappers/serializers/osgFX/SpecularHighlights.cpp new file mode 100644 index 000000000..649b0cbf3 --- /dev/null +++ b/src/osgWrappers/serializers/osgFX/SpecularHighlights.cpp @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgFX_SpecularHighlights, + new osgFX::SpecularHighlights, + osgFX::SpecularHighlights, + "osg::Object osg::Node osg::Group osgFX::Effect osgFX::SpecularHighlights" ) +{ + ADD_INT_SERIALIZER( LightNumber, 0 ); // _lightnum + ADD_INT_SERIALIZER( TextureUnit, 0 ); // _unit + ADD_VEC4_SERIALIZER( SpecularColor, osg::Vec4() ); // _color + ADD_FLOAT_SERIALIZER( SpecularExponent, 0.0f ); // _sexp +} diff --git a/src/osgWrappers/serializers/osgShadow/CMakeLists.txt b/src/osgWrappers/serializers/osgShadow/CMakeLists.txt new file mode 100644 index 000000000..699f18aa3 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/CMakeLists.txt @@ -0,0 +1,7 @@ +FILE(GLOB TARGET_SRC *.cpp) +FILE(GLOB TARGET_H *.h) + +SET(TARGET_ADDED_LIBRARIES osgShadow ) + +#### end var setup ### +SETUP_PLUGIN(osgshadow) diff --git a/src/osgWrappers/serializers/osgShadow/DebugShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/DebugShadowMap.cpp new file mode 100644 index 000000000..3001dab56 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/DebugShadowMap.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_DebugShadowMap, + new osgShadow::DebugShadowMap, + osgShadow::DebugShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap" ) +{ + ADD_BOOL_SERIALIZER( DebugDraw, false ); // _doDebugDraw +} diff --git a/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapCB.cpp b/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapCB.cpp new file mode 100644 index 000000000..9f62c00ed --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapCB.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_LightSpacePerspectiveShadowMapCB, + new osgShadow::LightSpacePerspectiveShadowMapCB, + osgShadow::LightSpacePerspectiveShadowMapCB, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap osgShadow::StandardShadowMap osgShadow::MinimalShadowMap " + "osgShadow::MinimalCullBoundsShadowMap osgShadow::LightSpacePerspectiveShadowMapCB" ) +{ +} diff --git a/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapDB.cpp b/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapDB.cpp new file mode 100644 index 000000000..6907fbecf --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapDB.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_LightSpacePerspectiveShadowMapDB, + new osgShadow::LightSpacePerspectiveShadowMapDB, + osgShadow::LightSpacePerspectiveShadowMapDB, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap osgShadow::StandardShadowMap osgShadow::MinimalShadowMap " + "osgShadow::MinimalDrawBoundsShadowMap osgShadow::LightSpacePerspectiveShadowMapDB" ) +{ +} diff --git a/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapVB.cpp b/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapVB.cpp new file mode 100644 index 000000000..98cb8e9af --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/LightSpacePerspectiveShadowMapVB.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_LightSpacePerspectiveShadowMapVB, + new osgShadow::LightSpacePerspectiveShadowMapVB, + osgShadow::LightSpacePerspectiveShadowMapVB, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap osgShadow::StandardShadowMap osgShadow::MinimalShadowMap " + "osgShadow::LightSpacePerspectiveShadowMapVB" ) +{ +} diff --git a/src/osgWrappers/serializers/osgShadow/MinimalCullBoundsShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/MinimalCullBoundsShadowMap.cpp new file mode 100644 index 000000000..ff0a5e519 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/MinimalCullBoundsShadowMap.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_MinimalCullBoundsShadowMap, + new osgShadow::MinimalCullBoundsShadowMap, + osgShadow::MinimalCullBoundsShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap osgShadow::StandardShadowMap osgShadow::MinimalShadowMap " + "osgShadow::MinimalCullBoundsShadowMap" ) +{ +} diff --git a/src/osgWrappers/serializers/osgShadow/MinimalDrawBoundsShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/MinimalDrawBoundsShadowMap.cpp new file mode 100644 index 000000000..19987ddc7 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/MinimalDrawBoundsShadowMap.cpp @@ -0,0 +1,13 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_MinimalDrawBoundsShadowMap, + new osgShadow::MinimalDrawBoundsShadowMap, + osgShadow::MinimalDrawBoundsShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap osgShadow::StandardShadowMap osgShadow::MinimalShadowMap " + "osgShadow::MinimalDrawBoundsShadowMap" ) +{ +} diff --git a/src/osgWrappers/serializers/osgShadow/MinimalShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/MinimalShadowMap.cpp new file mode 100644 index 000000000..094ecfa71 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/MinimalShadowMap.cpp @@ -0,0 +1,21 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_MinimalShadowMap, + new osgShadow::MinimalShadowMap, + osgShadow::MinimalShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap osgShadow::StandardShadowMap osgShadow::MinimalShadowMap" ) +{ + ADD_MATRIX_SERIALIZER( ModellingSpaceToWorldTransform, osg::Matrix() ); // _modellingSpaceToWorld + ADD_FLOAT_SERIALIZER( MaxFarPlane, FLT_MAX ); // _maxFarPlane + ADD_FLOAT_SERIALIZER( MinLightMargin, 0.0f ); // _minLightMargin + + BEGIN_ENUM_SERIALIZER( ShadowReceivingCoarseBoundAccuracy, BOUNDING_BOX ); + ADD_ENUM_VALUE( EMPTY_BOX ); + ADD_ENUM_VALUE( BOUNDING_SPHERE ); + ADD_ENUM_VALUE( BOUNDING_BOX ); + END_ENUM_SERIALIZER(); // _shadowReceivingCoarseBoundAccuracy +} diff --git a/src/osgWrappers/serializers/osgShadow/ParallelSplitShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/ParallelSplitShadowMap.cpp new file mode 100644 index 000000000..bb3e8972e --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/ParallelSplitShadowMap.cpp @@ -0,0 +1,25 @@ +#include +#include +#include +#include + + + +REGISTER_OBJECT_WRAPPER( osgShadow_ParallelSplitShadowMap, + new osgShadow::ParallelSplitShadowMap, + osgShadow::ParallelSplitShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ParallelSplitShadowMap" ) +{ + ADD_VEC2F_SERIALIZER( PolygonOffset, osg::Vec2f() ); // _polgyonOffset + ADD_UINT_SERIALIZER( TextureResolution, 1024 ); // _resolution + ADD_DOUBLE_SERIALIZER( MaxFarDistance, 0.0 ); // _setMaxFarDistance + ADD_DOUBLE_SERIALIZER( MoveVCamBehindRCamFactor, 0.0 ); // _move_vcam_behind_rcam_factor + ADD_DOUBLE_SERIALIZER( MinNearDistanceForSplits, 5.0 ); // _split_min_near_dist + ADD_OBJECT_SERIALIZER( UserLight, osg::Light, NULL ); // _userLight + ADD_VEC2D_SERIALIZER( AmbientBias, osg::Vec2d() ); // _ambientBias + + BEGIN_ENUM_SERIALIZER2( SplitCalculationMode, osgShadow::ParallelSplitShadowMap::SplitCalcMode, SPLIT_EXP ); + ADD_ENUM_VALUE( SPLIT_LINEAR ); + ADD_ENUM_VALUE( SPLIT_EXP ); + END_ENUM_SERIALIZER(); // _SplitCalcMode +} diff --git a/src/osgWrappers/serializers/osgShadow/ShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/ShadowMap.cpp new file mode 100644 index 000000000..c3840be91 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/ShadowMap.cpp @@ -0,0 +1,20 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_ShadowMap, + new osgShadow::ShadowMap, + osgShadow::ShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ShadowMap" ) +{ + ADD_UINT_SERIALIZER( TextureUnit, 1 ); // _shadowTextureUnit + ADD_VEC2_SERIALIZER( PolygonOffset, osg::Vec2f() ); // _polyOffset + ADD_VEC2_SERIALIZER( AmbientBias, osg::Vec2d() ); // _ambientBias + + ADD_SERIALIZER( (new osgDB::PropByRefSerializer + ("TextureSize", osg::Vec2s(1024, 1024), + &osgShadow::ShadowMap::getTextureSize, + &osgShadow::ShadowMap::setTextureSize)) + ); // _textureSize +} diff --git a/src/osgWrappers/serializers/osgShadow/ShadowTechnique.cpp b/src/osgWrappers/serializers/osgShadow/ShadowTechnique.cpp new file mode 100644 index 000000000..277a615af --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/ShadowTechnique.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_ShadowTechnique, + new osgShadow::ShadowTechnique, + osgShadow::ShadowTechnique, + "osg::Object osgShadow::ShadowTechnique" ) +{ +} diff --git a/src/osgWrappers/serializers/osgShadow/ShadowTexture.cpp b/src/osgWrappers/serializers/osgShadow/ShadowTexture.cpp new file mode 100644 index 000000000..c0474c61e --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/ShadowTexture.cpp @@ -0,0 +1,12 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_ShadowTexture, + new osgShadow::ShadowTexture, + osgShadow::ShadowTexture, + "osg::Object osgShadow::ShadowTechnique osgShadow::ShadowTexture" ) +{ + ADD_UINT_SERIALIZER( TextureUnit, 1 ); // _textureUnit +} diff --git a/src/osgWrappers/serializers/osgShadow/ShadowVolume.cpp b/src/osgWrappers/serializers/osgShadow/ShadowVolume.cpp new file mode 100644 index 000000000..5c1a63981 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/ShadowVolume.cpp @@ -0,0 +1,18 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_ShadowVolume, + new osgShadow::ShadowVolume, + osgShadow::ShadowVolume, + "osg::Object osgShadow::ShadowTechnique osgShadow::ShadowVolume" ) +{ + BEGIN_ENUM_SERIALIZER4( osgShadow::ShadowVolumeGeometry, DrawMode, STENCIL_TWO_SIDED ); + ADD_ENUM_CLASS_VALUE( osgShadow::ShadowVolumeGeometry, GEOMETRY ); + ADD_ENUM_CLASS_VALUE( osgShadow::ShadowVolumeGeometry, STENCIL_TWO_PASS ); + ADD_ENUM_CLASS_VALUE( osgShadow::ShadowVolumeGeometry, STENCIL_TWO_SIDED ); + END_ENUM_SERIALIZER(); // _drawMode + + ADD_BOOL_SERIALIZER( DynamicShadowVolumes, false ); // _dynamicShadowVolumes +} diff --git a/src/osgWrappers/serializers/osgShadow/ShadowedScene.cpp b/src/osgWrappers/serializers/osgShadow/ShadowedScene.cpp new file mode 100644 index 000000000..389421614 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/ShadowedScene.cpp @@ -0,0 +1,14 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_ShadowedScene, + new osgShadow::ShadowedScene, + osgShadow::ShadowedScene, + "osg::Object osg::Node osg::Group osgShadow::ShadowedScene" ) +{ + ADD_HEXINT_SERIALIZER( ReceivesShadowTraversalMask, 0xffffffff ); // _receivesShadowTraversalMask + ADD_HEXINT_SERIALIZER( CastsShadowTraversalMask, 0xffffffff ); // _castsShadowTraversalMask + ADD_OBJECT_SERIALIZER( ShadowTechnique, osgShadow::ShadowTechnique, NULL ); // _shadowTechnique +} diff --git a/src/osgWrappers/serializers/osgShadow/SoftShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/SoftShadowMap.cpp new file mode 100644 index 000000000..6da377e43 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/SoftShadowMap.cpp @@ -0,0 +1,15 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_SoftShadowMap, + new osgShadow::SoftShadowMap, + osgShadow::SoftShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ShadowMap osgShadow::SoftShadowMap" ) +{ + ADD_FLOAT_SERIALIZER( SoftnessWidth, 0.0f ); // _softnessWidth + ADD_FLOAT_SERIALIZER( JitteringScale, 32.0f ); // _jitteringScale + ADD_UINT_SERIALIZER( JitterTextureUnit, 2 ); // _jitterTextureUnit + ADD_FLOAT_SERIALIZER( Bias, 0.0f ); +} diff --git a/src/osgWrappers/serializers/osgShadow/StandardShadowMap.cpp b/src/osgWrappers/serializers/osgShadow/StandardShadowMap.cpp new file mode 100644 index 000000000..83f8161e1 --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/StandardShadowMap.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_StandardShadowMap, + new osgShadow::StandardShadowMap, + osgShadow::StandardShadowMap, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique " + "osgShadow::DebugShadowMap osgShadow::StandardShadowMap" ) +{ + ADD_UINT_SERIALIZER( BaseTextureUnit, 0 ); // _baseTextureUnit + ADD_UINT_SERIALIZER( ShadowTextureUnit, 1 ); // _shadowTextureUnit + ADD_UINT_SERIALIZER( BaseTextureCoordIndex, 0 ); // _baseTextureCoordIndex + ADD_UINT_SERIALIZER( ShadowTextureCoordIndex, 1 ); // _shadowTextureCoordIndex + + ADD_SERIALIZER( (new osgDB::PropByRefSerializer + ("TextureSize", osg::Vec2s(1024, 1024), + &osgShadow::StandardShadowMap::getTextureSize, + &osgShadow::StandardShadowMap::setTextureSize)) + ); // _textureSize + + ADD_OBJECT_SERIALIZER( Light, osg::Light, NULL ); // _light +} diff --git a/src/osgWrappers/serializers/osgShadow/ViewDependentShadowTechnique.cpp b/src/osgWrappers/serializers/osgShadow/ViewDependentShadowTechnique.cpp new file mode 100644 index 000000000..e94a2c50e --- /dev/null +++ b/src/osgWrappers/serializers/osgShadow/ViewDependentShadowTechnique.cpp @@ -0,0 +1,11 @@ +#include +#include +#include +#include + +REGISTER_OBJECT_WRAPPER( osgShadow_ViewDependentShadowTechnique, + new osgShadow::ViewDependentShadowTechnique, + osgShadow::ViewDependentShadowTechnique, + "osg::Object osgShadow::ShadowTechnique osgShadow::ViewDependentShadowTechnique" ) +{ +}