Added preliminary work on osg::TransferFunction

This commit is contained in:
Robert Osfield
2007-03-10 11:53:31 +00:00
parent 16ba0a2fa1
commit bff1b51361
7 changed files with 263 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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 <osg/Texture>
#include <osg/Shader>
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<osg::Vec4> Colors;
Colors _colors;
osg::ref_ptr<osg::Image> _image;
osg::ref_ptr<osg::Texture> _texture;
osg::ref_ptr<osg::Shader> _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

View File

@@ -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)

View File

@@ -113,6 +113,7 @@ CXXFILES =\
Texture.cpp\
TextureCubeMap.cpp\
TextureRectangle.cpp\
TransferFunction.cpp\
Timer.cpp\
Transform.cpp\
Uniform.cpp\

View File

@@ -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 <osg/TransferFunction>
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;
}
}

View File

@@ -0,0 +1,112 @@
// ***************************************************************************
//
// Generated automatically by genwrapper.
// Please DO NOT EDIT this file!
//
// ***************************************************************************
#include <osgIntrospection/ReflectionMacros>
#include <osgIntrospection/TypedMethodInfo>
#include <osgIntrospection/StaticMethodInfo>
#include <osgIntrospection/Attributes>
#include <osg/Image>
#include <osg/Shader>
#include <osg/Texture>
#include <osg/TransferFunction>
#include <osg/Vec4>
// 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