ScalarsToColors 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef OSGSIM_SCALARSTCOLORS
  14. #define OSGSIM_SCALARSTCOLORS 1
  15. #include <osgSim/Export>
  16. #include <osg/Vec4>
  17. #include <osg/Referenced>
  18. namespace osgSim
  19. {
  20. /**
  21. ScalarsToColors defines the interface to map a scalar value to a color,
  22. and provides a default implementation of the mapping functionaltity,
  23. with colors ranging from black to white across the min - max scalar
  24. range.
  25. */
  26. class OSGSIM_EXPORT ScalarsToColors: public osg::Referenced
  27. {
  28. public:
  29. ScalarsToColors(float scalarMin, float scalarMax);
  30. virtual ~ScalarsToColors() {}
  31. /** Get the color for a given scalar value. */
  32. virtual osg::Vec4 getColor(float scalar) const;
  33. /** Get the minimum scalar value. */
  34. float getMin() const;
  35. /** Get the maximum scalar value. */
  36. float getMax() const;
  37. private:
  38. float _min, _max;
  39. };
  40. }
  41. #endif