1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
15#define OSG_LIGHTMODEL 1
17#include <osg/StateAttribute>
22class OSG_EXPORT LightModel : public StateAttribute
28 /** Copy constructor using CopyOp to manage deep vs shallow copy. */
29 LightModel(const LightModel& lw,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
30 StateAttribute(lw,copyop),
31 _ambient(lw._ambient),
32 _colorControl(lw._colorControl),
33 _localViewer(lw._localViewer),
34 _twoSided(lw._twoSided) {}
37 META_StateAttribute(osg, LightModel, LIGHTMODEL);
39 /** Return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. */
40 virtual int compare(const StateAttribute& sa) const
42 // check the types are equal and then create the rhs variable
43 // used by the COMPARE_StateAttribute_Parameter macros below.
44 COMPARE_StateAttribute_Types(LightModel,sa)
46 // compare each parameter in turn against the rhs.
47 COMPARE_StateAttribute_Parameter(_ambient)
48 COMPARE_StateAttribute_Parameter(_colorControl)
49 COMPARE_StateAttribute_Parameter(_localViewer)
50 COMPARE_StateAttribute_Parameter(_twoSided)
52 return 0; // passed all the above comparison macros, must be equal.
56 void setAmbientIntensity(const osg::Vec4& ambient) { _ambient = ambient; }
57 const osg::Vec4& getAmbientIntensity() const { return _ambient; }
62 SEPARATE_SPECULAR_COLOR,
66 void setColorControl(ColorControl cc) { _colorControl = cc; }
67 inline ColorControl getColorControl() const { return _colorControl; }
70 void setLocalViewer(bool localViewer) { _localViewer=localViewer; }
71 inline bool getLocalViewer() const { return _localViewer; }
74 void setTwoSided(bool twoSided) { _twoSided = twoSided; }
75 inline bool getTwoSided() const { return _twoSided; }
79 virtual void apply(State& state) const;
84 virtual ~LightModel();
87 ColorControl _colorControl;