openscenegraph
ScalarsToColors
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGSIM_SCALARSTCOLORS
15#define OSGSIM_SCALARSTCOLORS 1
16
17#include <osgSim/Export>
18
19#include <osg/Vec4>
20#include <osg/Referenced>
21
22namespace osgSim
23{
24/**
25ScalarsToColors defines the interface to map a scalar value to a color,
26and provides a default implementation of the mapping functionaltity,
27with colors ranging from black to white across the min - max scalar
28range.
29*/
30class OSGSIM_EXPORT ScalarsToColors: public osg::Referenced
31{
32public:
33
34 ScalarsToColors(float scalarMin, float scalarMax);
35 virtual ~ScalarsToColors() {}
36
37 /** Get the color for a given scalar value. */
38 virtual osg::Vec4 getColor(float scalar) const;
39
40 /** Get the minimum scalar value. */
41 float getMin() const;
42
43 /** Get the maximum scalar value. */
44 float getMax() const;
45
46private:
47
48 float _min, _max;
49};
50
51}
52
53#endif