Point 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 OSG_POINT
  14. #define OSG_POINT 1
  15. #include <osg/Vec3>
  16. #include <osg/StateAttribute>
  17. #ifndef GL_POINT_SMOOTH
  18. #define GL_POINT_SMOOTH 0x0B10
  19. #endif
  20. #ifndef GL_POINT_SMOOTH_HINT
  21. #define GL_POINT_SMOOTH_HINT 0x0C51
  22. #endif
  23. namespace osg {
  24. /** Point - encapsulates the OpenGL point smoothing and size state.*/
  25. class OSG_EXPORT Point : public StateAttribute
  26. {
  27. public :
  28. Point();
  29. Point(float size);
  30. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  31. Point(const Point& point,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  32. StateAttribute(point,copyop),
  33. _size(point._size),
  34. _fadeThresholdSize(point._fadeThresholdSize),
  35. _distanceAttenuation(point._distanceAttenuation),
  36. _minSize(point._minSize),
  37. _maxSize(point._maxSize) {}
  38. META_StateAttribute(osg, Point, POINT);
  39. /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
  40. virtual int compare(const StateAttribute& sa) const
  41. {
  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(Point,sa)
  45. // compare each parameter in turn against the rhs.
  46. COMPARE_StateAttribute_Parameter(_size)
  47. COMPARE_StateAttribute_Parameter(_fadeThresholdSize)
  48. COMPARE_StateAttribute_Parameter(_distanceAttenuation)
  49. COMPARE_StateAttribute_Parameter(_minSize)
  50. COMPARE_StateAttribute_Parameter(_maxSize)
  51. return 0; // passed all the above comparison macros, must be equal.
  52. }
  53. virtual bool getModeUsage(StateAttribute::ModeUsage& usage) const
  54. {
  55. usage.usesMode(GL_POINT_SMOOTH);
  56. return true;
  57. }
  58. void setSize(float size);
  59. inline float getSize() const { return _size; }
  60. void setFadeThresholdSize(float fadeThresholdSize);
  61. inline float getFadeThresholdSize() const { return _fadeThresholdSize; }
  62. void setDistanceAttenuation(const Vec3& distanceAttenuation);
  63. inline const Vec3& getDistanceAttenuation() const { return _distanceAttenuation; }
  64. void setMinSize(float minSize);
  65. inline float getMinSize() const {return _minSize;}
  66. void setMaxSize(float maxSize);
  67. inline float getMaxSize() const {return _maxSize;}
  68. virtual void apply(State& state) const;
  69. protected :
  70. virtual ~Point();
  71. float _size;
  72. float _fadeThresholdSize;
  73. Vec3 _distanceAttenuation;
  74. float _minSize;
  75. float _maxSize;
  76. };
  77. }
  78. #endif