OpenSceneGraph/include/osg/TransferFunction

78 lines
2.2 KiB
Plaintext
Raw Normal View History

/* -*-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