ReflectionMapGenerator 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 OSGUTIL_REFLECTIONMAPGENERATOR_
  14. #define OSGUTIL_REFLECTIONMAPGENERATOR_
  15. #include <osgUtil/CubeMapGenerator>
  16. namespace osgUtil
  17. {
  18. /** This is the most simple cube map generator. It performs a direct association
  19. between reflection vector and RGBA color (C = R).
  20. */
  21. class ReflectionMapGenerator: public CubeMapGenerator {
  22. public:
  23. inline ReflectionMapGenerator(int texture_size = 64);
  24. inline ReflectionMapGenerator(const ReflectionMapGenerator &copy, const osg::CopyOp &copyop = osg::CopyOp::SHALLOW_COPY);
  25. protected:
  26. virtual ~ReflectionMapGenerator() {}
  27. ReflectionMapGenerator &operator=(const ReflectionMapGenerator &) { return *this; }
  28. inline virtual osg::Vec4 compute_color(const osg::Vec3 &R) const;
  29. };
  30. // INLINE METHODS
  31. inline ReflectionMapGenerator::ReflectionMapGenerator(int texture_size)
  32. : CubeMapGenerator(texture_size)
  33. {
  34. }
  35. inline ReflectionMapGenerator::ReflectionMapGenerator(const ReflectionMapGenerator &copy, const osg::CopyOp &copyop)
  36. : CubeMapGenerator(copy, copyop)
  37. {
  38. }
  39. inline osg::Vec4 ReflectionMapGenerator::compute_color(const osg::Vec3 &R) const
  40. {
  41. return vector_to_color(R / R.length());
  42. }
  43. }
  44. #endif