AnisotropicLighting
Go to the documentation of this file.
/* -*-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.
*/
//osgFX - Copyright (C) 2003 Marco Jez
#ifndef OSGFX_ANISOTROPICLIGHTING_
#define OSGFX_ANISOTROPICLIGHTING_
#include <osgFX/Export>
#include <osgFX/Effect>
#include <osg/ref_ptr>
#include <osg/Texture2D>
namespace osgFX
{
class OSGFX_EXPORT AnisotropicLighting: public Effect {
public:
AnisotropicLighting();
AnisotropicLighting(const AnisotropicLighting& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
META_Effect(osgFX, AnisotropicLighting,
"Anisotropic Lighting",
"This single-pass effect implements a sort of anisotropic "
"lighting that replaces the standard OpenGL lighting model.\n"
"The final color of vertices is not computed directly, it is "
"the result of a texture lookup on a user-supplied lighting "
"image map. A vertex program is used to compute the s and t "
"texture coordinates as follows: s = (N dot H) ; t = (N dot L) "
"where N is the vertex normal, L is the light-to-vertex vector, "
"H is the half-way vector. This is a good example of how you "
"can use the State::getInitialViewMatrix() method to retrieve "
"the view matrix and perform view-dependant effects without "
"fakes of any kind.\n"
"This effect requires the ARB_vertex_program extension.",
"Marco Jez");
inline osg::Image* getLightingMap();
inline const osg::Image* getLightingMap() const;
inline void setLightingMap(osg::Image* image);
inline int getLightNumber() const;
inline void setLightNumber(int n);
protected:
virtual ~AnisotropicLighting() {}
AnisotropicLighting& operator=(const AnisotropicLighting&) { return *this; }
bool define_techniques();
private:
int _lightnum;
osg::ref_ptr<osg::Texture2D> _texture;
};
// INLINE METHODS
inline osg::Image* AnisotropicLighting::getLightingMap()
{
return _texture->getImage();
}
inline const osg::Image* AnisotropicLighting::getLightingMap() const
{
return _texture->getImage();
}
inline void AnisotropicLighting::setLightingMap(osg::Image* image)
{
_texture->setImage(image);
}
inline int AnisotropicLighting::getLightNumber() const
{
return _lightnum;
}
inline void AnisotropicLighting::setLightNumber(int n)
{
_lightnum = n;
dirtyTechniques();
}
}
#endif
Effect
Texture2D
osgFX::AnisotropicLighting::setLightNumber
void setLightNumber(int n)
Definition AnisotropicLighting:114
osgFX::AnisotropicLighting::AnisotropicLighting
AnisotropicLighting()
osgFX::AnisotropicLighting::~AnisotropicLighting
virtual ~AnisotropicLighting()
Definition AnisotropicLighting:82
osgFX::AnisotropicLighting::setLightingMap
void setLightingMap(osg::Image *image)
Definition AnisotropicLighting:104
osgFX::AnisotropicLighting::META_Effect
META_Effect(osgFX, AnisotropicLighting, "Anisotropic Lighting", "This single-pass effect implements a sort of anisotropic " "lighting that replaces the standard OpenGL lighting model.\n" "The final color of vertices is not computed directly, it is " "the result of a texture lookup on a user-supplied lighting " "image map. A vertex program is used to compute the s and t " "texture coordinates as follows: s = (N dot H) ; t = (N dot L) " "where N is the vertex normal, L is the light-to-vertex vector, " "H is the half-way vector. This is a good example of how you " "can use the State::getInitialViewMatrix() method to retrieve " "the view matrix and perform view-dependant effects without " "fakes of any kind.\n" "This effect requires the ARB_vertex_program extension.", "Marco Jez")
osgFX::AnisotropicLighting::define_techniques
bool define_techniques()
osgFX::AnisotropicLighting::AnisotropicLighting
AnisotropicLighting(const AnisotropicLighting &copy, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgFX::AnisotropicLighting::getLightNumber
int getLightNumber() const
Definition AnisotropicLighting:109
osgFX::AnisotropicLighting::operator=
AnisotropicLighting & operator=(const AnisotropicLighting &)
Definition AnisotropicLighting:83
osgFX::AnisotropicLighting::getLightingMap
osg::Image * getLightingMap()
Definition AnisotropicLighting:94
osgFX::Effect::Effect
Effect()
osgFX::Effect::dirtyTechniques
void dirtyTechniques()
Definition Effect:207
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Image
Definition Image:179
osg::Image::setImage
virtual void setImage(int s, int t, int r, GLint internalTextureformat, GLenum pixelFormat, GLenum type, unsigned char *data, AllocationMode mode, int packing=1, int rowLength=0)
osg::ref_ptr
Definition ref_ptr:32
osgFX
Definition AnisotropicLighting:25
Export
OSGFX_EXPORT
#define OSGFX_EXPORT
Definition osgFX/Export:27
ref_ptr