LightPointNode 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 OSGSIM_LIGHTPOINTNODE
  14. #define OSGSIM_LIGHTPOINTNODE 1
  15. #include <osgSim/Export>
  16. #include <osgSim/LightPoint>
  17. #include <osgSim/LightPointSystem>
  18. #include <osg/Node>
  19. #include <osg/NodeVisitor>
  20. #include <osg/BoundingBox>
  21. #include <osg/Quat>
  22. #include <osg/Vec4>
  23. #include <vector>
  24. #include <set>
  25. namespace osgSim {
  26. class OSGSIM_EXPORT LightPointNode : public osg::Node
  27. {
  28. public :
  29. typedef std::vector< LightPoint > LightPointList;
  30. LightPointNode();
  31. /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
  32. LightPointNode(const LightPointNode&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
  33. META_Node(osgSim,LightPointNode);
  34. virtual void traverse(osg::NodeVisitor& nv);
  35. unsigned int getNumLightPoints() const { return _lightPointList.size(); }
  36. unsigned int addLightPoint(const LightPoint& lp);
  37. void removeLightPoint(unsigned int pos);
  38. LightPoint& getLightPoint(unsigned int pos) { return _lightPointList[pos]; }
  39. const LightPoint& getLightPoint(unsigned int pos) const { return _lightPointList[pos]; }
  40. void setLightPointList(const LightPointList& lpl) { _lightPointList=lpl; }
  41. LightPointList& getLightPointList() { return _lightPointList; }
  42. const LightPointList& getLightPointList() const { return _lightPointList; }
  43. void setMinPixelSize(float minPixelSize) { _minPixelSize = minPixelSize; }
  44. float getMinPixelSize() const { return _minPixelSize; }
  45. void setMaxPixelSize(float maxPixelSize) { _maxPixelSize = maxPixelSize; }
  46. float getMaxPixelSize() const { return _maxPixelSize; }
  47. void setMaxVisibleDistance2(float maxVisibleDistance2) { _maxVisibleDistance2 = maxVisibleDistance2; }
  48. float getMaxVisibleDistance2() const { return _maxVisibleDistance2; }
  49. void setLightPointSystem( osgSim::LightPointSystem* lps) { _lightSystem = lps; }
  50. osgSim::LightPointSystem* getLightPointSystem() { return _lightSystem.get(); }
  51. const osgSim::LightPointSystem* getLightPointSystem() const { return _lightSystem.get(); }
  52. void setPointSprite(bool enable=true) { _pointSprites = enable; }
  53. bool getPointSprite() const { return _pointSprites; }
  54. virtual osg::BoundingSphere computeBound() const;
  55. protected:
  56. ~LightPointNode() {}
  57. // used to cache the bounding box of the lightpoints as a tighter
  58. // view frustum check.
  59. mutable osg::BoundingBox _bbox;
  60. LightPointList _lightPointList;
  61. float _minPixelSize;
  62. float _maxPixelSize;
  63. float _maxVisibleDistance2;
  64. osg::ref_ptr<osgSim::LightPointSystem> _lightSystem;
  65. bool _pointSprites;
  66. };
  67. }
  68. #endif