OpenSceneGraph 3.6.5
BoxPlacer
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//Build by Zach Deedler
14
15#ifndef OSGPARTICLE_BOX_PLACER
16#define OSGPARTICLE_BOX_PLACER 1
17
19#include <osgParticle/Particle>
20#include <osgParticle/range>
21
22#include <osg/CopyOp>
23#include <osg/Object>
24#include <osg/Vec3>
25#include <osg/Math>
26
27namespace osgParticle
28{
29
36 class BoxPlacer: public CenteredPlacer {
37 public:
38 inline BoxPlacer();
39 inline BoxPlacer(const BoxPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
40
42 inline const rangef& getXRange() const;
43
45 inline void setXRange(const rangef& r);
46
48 inline void setXRange(float r1, float r2);
49
51 inline const rangef& getYRange() const;
52
54 inline void setYRange(const rangef& r);
55
57 inline void setYRange(float r1, float r2);
58
60 inline const rangef& getZRange() const;
61
63 inline void setZRange(const rangef& r);
64
66 inline void setZRange(float r1, float r2);
67
69
71 inline void place(Particle* P) const;
72
74 inline float volume() const;
75
77 inline osg::Vec3 getControlPosition() const;
78
79 protected:
80 virtual ~BoxPlacer() {}
81 BoxPlacer& operator=(const BoxPlacer&) { return *this; }
82
83 private:
84 rangef _x_range;
85 rangef _y_range;
86 rangef _z_range;
87 };
88
89 // INLINE FUNCTIONS
90
92 : CenteredPlacer(), _x_range(-1, 1), _y_range(-1, 1), _z_range(-1, 1)
93 {
94 }
95
96 inline BoxPlacer::BoxPlacer(const BoxPlacer& copy, const osg::CopyOp& copyop)
97 : CenteredPlacer(copy, copyop),
98 _x_range(copy._x_range), _y_range(copy._y_range), _z_range(copy._z_range)
99 {
100 }
101
102 inline const rangef& BoxPlacer::getXRange() const
103 {
104 return _x_range;
105 }
106
107 inline void BoxPlacer::setXRange(const rangef& r)
108 {
109 _x_range = r;
110 }
111
112 inline void BoxPlacer::setXRange(float r1, float r2)
113 {
114 _x_range.minimum = r1;
115 _x_range.maximum = r2;
116 }
117
118 inline const rangef& BoxPlacer::getYRange() const
119 {
120 return _y_range;
121 }
122
123 inline void BoxPlacer::setYRange(const rangef& r)
124 {
125 _y_range = r;
126 }
127
128 inline void BoxPlacer::setYRange(float r1, float r2)
129 {
130 _y_range.minimum = r1;
131 _y_range.maximum = r2;
132 }
133
134 inline const rangef& BoxPlacer::getZRange() const
135 {
136 return _z_range;
137 }
138
139 inline void BoxPlacer::setZRange(const rangef& r)
140 {
141 _z_range = r;
142 }
143
144 inline void BoxPlacer::setZRange(float r1, float r2)
145 {
146 _z_range.minimum = r1;
147 _z_range.maximum = r2;
148 }
149
150 inline void BoxPlacer::place(Particle* P) const
151 {
152 osg::Vec3 pos(
153 getCenter().x() + _x_range.get_random(),
154 getCenter().y() + _y_range.get_random(),
155 getCenter().z() + _z_range.get_random());
156
157 P->setPosition(pos);
158 }
159
160 inline float BoxPlacer::volume() const
161 {
162 return (_x_range.maximum - _x_range.minimum) *
163 (_y_range.maximum - _y_range.minimum) *
164 (_z_range.maximum - _z_range.minimum);
165 }
166
168 {
169 return getCenter();
170 }
171
172}
173
174#endif
Vec3f Vec3
Definition Vec3:21
The osgParticle library is a NodeKit that extends the core scene graph to support particle effects.
Definition AccelOperator:27
range< float > rangef
Range of floats.
Definition range:76
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
const rangef & getYRange() const
Get the range of possible values along the Y axis.
Definition BoxPlacer:118
const rangef & getZRange() const
Get the range of possible values along the Z axis.
Definition BoxPlacer:134
META_Object(osgParticle, BoxPlacer)
BoxPlacer()
Definition BoxPlacer:91
const rangef & getXRange() const
Get the range of possible values along the X axis.
Definition BoxPlacer:102
BoxPlacer & operator=(const BoxPlacer &)
Definition BoxPlacer:81
void setXRange(const rangef &r)
Set the range of possible values along the X axis.
Definition BoxPlacer:107
virtual ~BoxPlacer()
Definition BoxPlacer:80
float volume() const
return the volume of the box
Definition BoxPlacer:160
void place(Particle *P) const
Place a particle. Do not call it manually.
Definition BoxPlacer:150
osg::Vec3 getControlPosition() const
return the control position
Definition BoxPlacer:167
void setYRange(const rangef &r)
Set the range of possible values along the Y axis.
Definition BoxPlacer:123
void setZRange(const rangef &r)
Set the range of possible values along the Z axis.
Definition BoxPlacer:139
CenteredPlacer()
Definition CenteredPlacer:56
const osg::Vec3 & getCenter() const
Get the center point.
Definition CenteredPlacer:66
Implementation of a particle.
Definition Particle:47
void setPosition(const osg::Vec3 &p)
Set the position vector.
Definition Particle:483
ValueType minimum
Lower bound.
Definition range:42

osg logo
Generated at Wed Jul 23 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.