Changeset 13041 for OpenSceneGraph/trunk/include/osgParticle/SectorPlacer
- Timestamp:
- 03/21/12 18:36:20 (14 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgParticle/SectorPlacer
r11755 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 29 29 30 30 /** A sector-shaped particle placer. 31 This placer sets the initial position of incoming particle by choosing a random position 32 within a circular sector; this sector is defined by three parameters: a <I>center point</I>, 33 which is inherited directly from <CODE>osgParticle::CenteredPlacer</CODE>, a range of values 34 for <I>radius</I>, and a range of values for the <I>central angle</I> (sometimes called <B>phi</B>). 31 This placer sets the initial position of incoming particle by choosing a random position 32 within a circular sector; this sector is defined by three parameters: a <I>center point</I>, 33 which is inherited directly from <CODE>osgParticle::CenteredPlacer</CODE>, a range of values 34 for <I>radius</I>, and a range of values for the <I>central angle</I> (sometimes called <B>phi</B>). 35 35 */ 36 36 class SectorPlacer: public CenteredPlacer { … … 38 38 inline SectorPlacer(); 39 39 inline SectorPlacer(const SectorPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); 40 40 41 41 /// Get the range of possible values for radius. 42 42 inline const rangef& getRadiusRange() const; 43 43 44 44 /// Set the range of possible values for radius. 45 45 inline void setRadiusRange(const rangef& r); 46 46 47 47 /// Set the range of possible values for radius. 48 48 inline void setRadiusRange(float r1, float r2); 49 49 50 50 /// Get the range of possible values for the central angle. 51 inline const rangef& getPhiRange() const; 52 51 inline const rangef& getPhiRange() const; 52 53 53 /// Set the range of possible values for the central angle. 54 54 inline void setPhiRange(const rangef& r); 55 55 56 56 /// Set the range of possible values for the central angle. 57 inline void setPhiRange(float r1, float r2); 57 inline void setPhiRange(float r1, float r2); 58 58 59 59 META_Object(osgParticle, SectorPlacer); 60 60 61 61 /// Place a particle. Do not call it manually. 62 62 inline void place(Particle* P) const; … … 64 64 /// return the area of the sector 65 65 inline float volume() const; 66 66 67 67 /// return the control position 68 68 inline osg::Vec3 getControlPosition() const; … … 70 70 protected: 71 71 virtual ~SectorPlacer() {} 72 SectorPlacer& operator=(const SectorPlacer&) { return *this; } 73 72 SectorPlacer& operator=(const SectorPlacer&) { return *this; } 73 74 74 private: 75 75 rangef _rad_range; … … 78 78 79 79 // INLINE FUNCTIONS 80 80 81 81 inline SectorPlacer::SectorPlacer() 82 82 : CenteredPlacer(), _rad_range(0, 1), _phi_range(0, osg::PI*2) 83 83 { 84 84 } 85 85 86 86 inline SectorPlacer::SectorPlacer(const SectorPlacer& copy, const osg::CopyOp& copyop) 87 87 : CenteredPlacer(copy, copyop), _rad_range(copy._rad_range), _phi_range(copy._phi_range) 88 88 { 89 89 } 90 90 91 91 inline const rangef& SectorPlacer::getRadiusRange() const 92 92 { … … 103 103 _rad_range = r; 104 104 } 105 105 106 106 inline void SectorPlacer::setRadiusRange(float r1, float r2) 107 107 { … … 109 109 _rad_range.maximum = r2; 110 110 } 111 111 112 112 inline void SectorPlacer::setPhiRange(const rangef& r) 113 113 { 114 114 _phi_range = r; 115 115 } 116 116 117 117 inline void SectorPlacer::setPhiRange(float r1, float r2) 118 118 { … … 125 125 float rad = _rad_range.get_random_sqrtf(); 126 126 float phi = _phi_range.get_random(); 127 127 128 128 osg::Vec3 pos( 129 getCenter().x() + rad * cosf(phi), 130 getCenter().y() + rad * sinf(phi), 129 getCenter().x() + rad * cosf(phi), 130 getCenter().y() + rad * sinf(phi), 131 131 getCenter().z()); 132 132 133 133 P->setPosition(pos); 134 134 } 135 135 136 136 inline float SectorPlacer::volume() const 137 137 {
