openscenegraph
LightPointNode
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 OSGSIM_LIGHTPOINTNODE
15#define OSGSIM_LIGHTPOINTNODE 1
16
17#include <osgSim/Export>
18#include <osgSim/LightPoint>
19#include <osgSim/LightPointSystem>
20
21#include <osg/Node>
22#include <osg/NodeVisitor>
23#include <osg/BoundingBox>
24#include <osg/Quat>
25#include <osg/Vec4>
26
27#include <vector>
28#include <set>
29
30namespace osgSim {
31
32
33class OSGSIM_EXPORT LightPointNode : public osg::Node
34{
35 public :
36
37 typedef std::vector< LightPoint > LightPointList;
38
39 LightPointNode();
40
41 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
42 LightPointNode(const LightPointNode&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
43
44 META_Node(osgSim,LightPointNode);
45
46 virtual void traverse(osg::NodeVisitor& nv);
47
48
49 unsigned int getNumLightPoints() const { return _lightPointList.size(); }
50
51
52 unsigned int addLightPoint(const LightPoint& lp);
53
54 void removeLightPoint(unsigned int pos);
55
56
57 LightPoint& getLightPoint(unsigned int pos) { return _lightPointList[pos]; }
58
59 const LightPoint& getLightPoint(unsigned int pos) const { return _lightPointList[pos]; }
60
61
62 void setLightPointList(const LightPointList& lpl) { _lightPointList=lpl; }
63
64 LightPointList& getLightPointList() { return _lightPointList; }
65
66 const LightPointList& getLightPointList() const { return _lightPointList; }
67
68
69 void setMinPixelSize(float minPixelSize) { _minPixelSize = minPixelSize; }
70
71 float getMinPixelSize() const { return _minPixelSize; }
72
73 void setMaxPixelSize(float maxPixelSize) { _maxPixelSize = maxPixelSize; }
74
75 float getMaxPixelSize() const { return _maxPixelSize; }
76
77 void setMaxVisibleDistance2(float maxVisibleDistance2) { _maxVisibleDistance2 = maxVisibleDistance2; }
78
79 float getMaxVisibleDistance2() const { return _maxVisibleDistance2; }
80
81 void setLightPointSystem( osgSim::LightPointSystem* lps) { _lightSystem = lps; }
82
83 osgSim::LightPointSystem* getLightPointSystem() { return _lightSystem.get(); }
84 const osgSim::LightPointSystem* getLightPointSystem() const { return _lightSystem.get(); }
85
86 void setPointSprite(bool enable=true) { _pointSprites = enable; }
87
88 bool getPointSprite() const { return _pointSprites; }
89
90 virtual osg::BoundingSphere computeBound() const;
91
92 protected:
93
94 ~LightPointNode() {}
95
96 // used to cache the bounding box of the lightpoints as a tighter
97 // view frustum check.
98 mutable osg::BoundingBox _bbox;
99
100 LightPointList _lightPointList;
101
102 float _minPixelSize;
103 float _maxPixelSize;
104 float _maxVisibleDistance2;
105
106 osg::ref_ptr<osgSim::LightPointSystem> _lightSystem;
107
108 bool _pointSprites;
109
110};
111
112}
113
114#endif