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