openscenegraph
Point
Go to the documentation of this file.
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
14#ifndef OSG_POINT
15#define OSG_POINT 1
16
17#include <osg/Vec3>
18#include <osg/StateAttribute>
19
20#ifndef GL_POINT_SMOOTH
21 #define GL_POINT_SMOOTH 0x0B10
22#endif
23
24#ifndef GL_POINT_SMOOTH_HINT
25 #define GL_POINT_SMOOTH_HINT 0x0C51
26#endif
27
28namespace osg {
29
30/** Point - encapsulates the OpenGL point smoothing and size state.*/
31class OSG_EXPORT Point : public StateAttribute
32{
33 public :
34
35 Point();
36
37 Point(float size);
38
39 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
40 Point(const Point& point,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
41 StateAttribute(point,copyop),
42 _size(point._size),
43 _fadeThresholdSize(point._fadeThresholdSize),
44 _distanceAttenuation(point._distanceAttenuation),
45 _minSize(point._minSize),
46 _maxSize(point._maxSize) {}
47
48 META_StateAttribute(osg, Point, POINT);
49
50 /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
51 virtual int compare(const StateAttribute& sa) const
52 {
53 // check the types are equal and then create the rhs variable
54 // used by the COMPARE_StateAttribute_Parameter macros below.
55 COMPARE_StateAttribute_Types(Point,sa)
56
57 // compare each parameter in turn against the rhs.
58 COMPARE_StateAttribute_Parameter(_size)
59 COMPARE_StateAttribute_Parameter(_fadeThresholdSize)
60 COMPARE_StateAttribute_Parameter(_distanceAttenuation)
61 COMPARE_StateAttribute_Parameter(_minSize)
62 COMPARE_StateAttribute_Parameter(_maxSize)
63
64 return 0; // passed all the above comparison macros, must be equal.
65 }
66
67 virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
68 {
69 usage.usesMode(GL_POINT_SMOOTH);
70 return true;
71 }
72
73 void setSize(float size);
74 inline float getSize() const { return _size; }
75
76 void setFadeThresholdSize(float fadeThresholdSize);
77 inline float getFadeThresholdSize() const { return _fadeThresholdSize; }
78
79 void setDistanceAttenuation(const Vec3& distanceAttenuation);
80 inline const Vec3& getDistanceAttenuation() const { return _distanceAttenuation; }
81
82 void setMinSize(float minSize);
83 inline float getMinSize() const {return _minSize;}
84
85 void setMaxSize(float maxSize);
86 inline float getMaxSize() const {return _maxSize;}
87
88 virtual void apply(State& state) const;
89
90 protected :
91
92 virtual ~Point();
93
94 float _size;
95 float _fadeThresholdSize;
96 Vec3 _distanceAttenuation;
97 float _minSize;
98 float _maxSize;
99
100};
101
102}
103
104#endif