diff --git a/VisualStudio/osg/osg.dsp b/VisualStudio/osg/osg.dsp index fc38bdc52..9c33a51d0 100755 --- a/VisualStudio/osg/osg.dsp +++ b/VisualStudio/osg/osg.dsp @@ -600,6 +600,10 @@ SOURCE=..\..\src\osg\TextureRectangle.cpp # End Source File # Begin Source File +SOURCE=..\..\src\osg\TransferFunction.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\osg\Timer.cpp # End Source File # Begin Source File @@ -1140,6 +1144,10 @@ SOURCE=..\..\Include\Osg\TriangleFunctor # End Source File # Begin Source File +SOURCE=..\..\Include\Osg\TransferFunction +# End Source File +# Begin Source File + SOURCE=..\..\Include\Osg\Uniform # End Source File # Begin Source File diff --git a/VisualStudio/osgWrappers/osg/wrapper_osg.dsp b/VisualStudio/osgWrappers/osg/wrapper_osg.dsp index b496de138..ee36979e3 100644 --- a/VisualStudio/osgWrappers/osg/wrapper_osg.dsp +++ b/VisualStudio/osgWrappers/osg/wrapper_osg.dsp @@ -559,6 +559,10 @@ SOURCE=..\..\..\src\osgWrappers\osg\TextureRectangle.cpp SOURCE=..\..\..\src\osgWrappers\osg\Timer.cpp # End Source File +# Begin Source File +SOURCE=..\..\..\src\osgWrappers\osg\TransferFunction.cpp +# End Source File + # Begin Source File SOURCE=..\..\..\src\osgWrappers\osg\Transform.cpp # End Source File diff --git a/include/osg/TransferFunction b/include/osg/TransferFunction new file mode 100644 index 000000000..685006691 --- /dev/null +++ b/include/osg/TransferFunction @@ -0,0 +1,77 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#ifndef OSG_TRANSFERFUNCTION +#define OSG_TRANSFERFUNCTION 1 + +#include +#include + +namespace osg { + + +/** TransferFunction used to manage the mapping for 1D, 2D or 3D input to output Vec4 values. + */ +class OSG_EXPORT TransferFunction +{ + public : + + TransferFunction(); + virtual ~TransferFunction(); + + osg::Image* getImage() { return _image.get(); } + const osg::Image* getImage() const { return _image.get(); } + + osg::Texture* getTexture() { return _texture.get(); } + const osg::Texture* getTexture() const { return _texture.get(); } + + osg::Shader* getShader() { return _shader.get(); } + const osg::Shader* getShader() const { return _shader.get(); } + + protected: + + typedef std::vector Colors; + Colors _colors; + osg::ref_ptr _image; + osg::ref_ptr _texture; + osg::ref_ptr _shader; + +}; + +class OSG_EXPORT TransferFunction1D : public osg::TransferFunction +{ + public: + + TransferFunction1D(); + + void setInputRange(float minimum, float maximum); + + void allocate(unsigned int numX); + + void clear(const osg::Vec4& color = osg::Vec4(1.0f,1.0f,1.0f,1.0f)); + + unsigned int getNumberCellsX() const { return _colors.size(); } + + osg::Vec4& getValue(unsigned int i) { return _colors[i]; } + const osg::Vec4& getValue(unsigned int i) const { return _colors[i]; } + + protected: + + float _minimum; + float _maximum; + +}; + +} + +#endif diff --git a/src/osg/CMakeLists.txt b/src/osg/CMakeLists.txt index c965e9f97..1d4ce6428 100644 --- a/src/osg/CMakeLists.txt +++ b/src/osg/CMakeLists.txt @@ -134,6 +134,7 @@ SET(LIB_PUBLIC_HEADERS ${HEADER_PATH}/Transform ${HEADER_PATH}/TriangleFunctor ${HEADER_PATH}/TriangleIndexFunctor + ${HEADER_PATH}/TranderFunction ${HEADER_PATH}/Uniform ${HEADER_PATH}/Vec2 ${HEADER_PATH}/Vec2b @@ -277,6 +278,7 @@ ADD_LIBRARY(${LIB_NAME} Texture3D.cpp TextureCubeMap.cpp TextureRectangle.cpp + TransferFunction.cpp Timer.cpp Transform.cpp Uniform.cpp @@ -293,7 +295,4 @@ TARGET_LINK_LIBRARIES(${LIB_NAME} ${OPENGL_LIBRARIES} ) -# This file should not be built, but should be in the project file -# LIST(APPEND LIB_PUBLIC_HEADERS Matrix_implementation.cpp) - INCLUDE(ModuleInstall OPTIONAL) diff --git a/src/osg/GNUmakefile b/src/osg/GNUmakefile index 23609f4cf..9201c0d18 100644 --- a/src/osg/GNUmakefile +++ b/src/osg/GNUmakefile @@ -113,6 +113,7 @@ CXXFILES =\ Texture.cpp\ TextureCubeMap.cpp\ TextureRectangle.cpp\ + TransferFunction.cpp\ Timer.cpp\ Transform.cpp\ Uniform.cpp\ diff --git a/src/osg/TransferFunction.cpp b/src/osg/TransferFunction.cpp new file mode 100644 index 000000000..c9ad121af --- /dev/null +++ b/src/osg/TransferFunction.cpp @@ -0,0 +1,59 @@ +/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield + * + * This library is open source and may be redistributed and/or modified under + * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or + * (at your option) any later version. The full license is in LICENSE file + * included with this distribution, and on the openscenegraph.org website. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * OpenSceneGraph Public License for more details. +*/ + +#include + +using namespace osg; + +/////////////////////////////////////////////////////////////////////// +// +// TransferFunction base class +// +TransferFunction::TransferFunction() +{ +} + +TransferFunction::~TransferFunction() +{ +} + +/////////////////////////////////////////////////////////////////////// +// +// TransferFunction1D class +// +TransferFunction1D::TransferFunction1D() +{ + _minimum = 0.0; + _maximum = 1.0; +} + +void TransferFunction1D::setInputRange(float minimum, float maximum) +{ + _minimum = minimum; + _maximum = maximum; +} + +void TransferFunction1D::allocate(unsigned int numX) +{ + _colors.resize(numX); +} + +void TransferFunction1D::clear(const osg::Vec4& color) +{ + for(Colors::iterator itr = _colors.begin(); + itr != _colors.end(); + ++itr) + { + *itr = color; + } +} diff --git a/src/osgWrappers/osg/TransferFunction.cpp b/src/osgWrappers/osg/TransferFunction.cpp new file mode 100644 index 000000000..93c600f79 --- /dev/null +++ b/src/osgWrappers/osg/TransferFunction.cpp @@ -0,0 +1,112 @@ +// *************************************************************************** +// +// Generated automatically by genwrapper. +// Please DO NOT EDIT this file! +// +// *************************************************************************** + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +// Must undefine IN and OUT macros defined in Windows headers +#ifdef IN +#undef IN +#endif +#ifdef OUT +#undef OUT +#endif + +BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::TransferFunction) + I_BaseType(osg::Object); + I_Constructor0(____TransferFunction, + "", + ""); + I_Method0(osg::Image *, getImage, + Properties::NON_VIRTUAL, + __osg_Image_P1__getImage, + "", + ""); + I_Method0(const osg::Image *, getImage, + Properties::NON_VIRTUAL, + __C5_osg_Image_P1__getImage, + "", + ""); + I_Method0(osg::Texture *, getTexture, + Properties::NON_VIRTUAL, + __osg_Texture_P1__getTexture, + "", + ""); + I_Method0(const osg::Texture *, getTexture, + Properties::NON_VIRTUAL, + __C5_osg_Texture_P1__getTexture, + "", + ""); + I_Method0(osg::Shader *, getShader, + Properties::NON_VIRTUAL, + __osg_Shader_P1__getShader, + "", + ""); + I_Method0(const osg::Shader *, getShader, + Properties::NON_VIRTUAL, + __C5_osg_Shader_P1__getShader, + "", + ""); + I_SimpleProperty(osg::Image *, Image, + __osg_Image_P1__getImage, + 0); + I_SimpleProperty(osg::Shader *, Shader, + __osg_Shader_P1__getShader, + 0); + I_SimpleProperty(osg::Texture *, Texture, + __osg_Texture_P1__getTexture, + 0); +END_REFLECTOR + +BEGIN_ABSTRACT_OBJECT_REFLECTOR(osg::TransferFunction1D) + I_BaseType(osg::TransferFunction); + I_Constructor0(____TransferFunction1D, + "", + ""); + I_Method2(void, setInputRange, IN, float, minimum, IN, float, maximum, + Properties::NON_VIRTUAL, + __void__setInputRange__float__float, + "", + ""); + I_Method1(void, allocate, IN, unsigned int, numX, + Properties::NON_VIRTUAL, + __void__allocate__unsigned_int, + "", + ""); + I_MethodWithDefaults1(void, clear, IN, const osg::Vec4 &, color, osg::Vec4(1.0f, 1.0f, 1.0f, 1.0f), + Properties::NON_VIRTUAL, + __void__clear__C5_osg_Vec4_R1, + "", + ""); + I_Method0(unsigned int, getNumberCellsX, + Properties::NON_VIRTUAL, + __unsigned_int__getNumberCellsX, + "", + ""); + I_MethodWithDefaults3(osg::Vec4 &, getValue, IN, unsigned int, i, , IN, unsigned int, j, 0, IN, unsigned int, k, 0, + Properties::NON_VIRTUAL, + __osg_Vec4_R1__getValue__unsigned_int__unsigned_int__unsigned_int, + "", + ""); + I_MethodWithDefaults3(const osg::Vec4 &, getValue, IN, unsigned int, i, , IN, unsigned int, j, 0, IN, unsigned int, k, 0, + Properties::NON_VIRTUAL, + __C5_osg_Vec4_R1__getValue__unsigned_int__unsigned_int__unsigned_int, + "", + ""); + I_SimpleProperty(unsigned int, NumberCellsX, + __unsigned_int__getNumberCellsX, + 0); +END_REFLECTOR +