SectorPlacer
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
//osgParticle - Copyright (C) 2002 Marco Jez
#ifndef OSGPARTICLE_SECTOR_PLACER
#define OSGPARTICLE_SECTOR_PLACER 1
#include <osgParticle/CenteredPlacer>
#include <osgParticle/Particle>
#include <osgParticle/range>
#include <osg/CopyOp>
#include <osg/Object>
#include <osg/Vec3>
#include <osg/Math>
namespace osgParticle
{
class SectorPlacer: public CenteredPlacer {
public:
inline SectorPlacer();
inline SectorPlacer(const SectorPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
inline const rangef& getRadiusRange() const;
inline void setRadiusRange(const rangef& r);
inline void setRadiusRange(float r1, float r2);
inline const rangef& getPhiRange() const;
inline void setPhiRange(const rangef& r);
inline void setPhiRange(float r1, float r2);
META_Object(osgParticle, SectorPlacer);
inline void place(Particle* P) const;
inline float volume() const;
inline osg::Vec3 getControlPosition() const;
protected:
virtual ~SectorPlacer() {}
SectorPlacer& operator=(const SectorPlacer&) { return *this; }
private:
rangef _rad_range;
rangef _phi_range;
};
// INLINE FUNCTIONS
inline SectorPlacer::SectorPlacer()
: CenteredPlacer(), _rad_range(0, 1), _phi_range(0, osg::PI*2)
{
}
inline SectorPlacer::SectorPlacer(const SectorPlacer& copy, const osg::CopyOp& copyop)
: CenteredPlacer(copy, copyop), _rad_range(copy._rad_range), _phi_range(copy._phi_range)
{
}
inline const rangef& SectorPlacer::getRadiusRange() const
{
return _rad_range;
}
inline const rangef& SectorPlacer::getPhiRange() const
{
return _phi_range;
}
inline void SectorPlacer::setRadiusRange(const rangef& r)
{
_rad_range = r;
}
inline void SectorPlacer::setRadiusRange(float r1, float r2)
{
_rad_range.minimum = r1;
_rad_range.maximum = r2;
}
inline void SectorPlacer::setPhiRange(const rangef& r)
{
_phi_range = r;
}
inline void SectorPlacer::setPhiRange(float r1, float r2)
{
_phi_range.minimum = r1;
_phi_range.maximum = r2;
}
inline void SectorPlacer::place(Particle* P) const
{
float rad = _rad_range.get_random_sqrtf();
float phi = _phi_range.get_random();
osg::Vec3 pos(
getCenter().x() + rad * cosf(phi),
getCenter().y() + rad * sinf(phi),
getCenter().z());
P->setPosition(pos);
}
inline float SectorPlacer::volume() const
{
return 0.5f * (_phi_range.maximum - _phi_range.minimum) *
(_rad_range.maximum*_rad_range.maximum - _rad_range.minimum*_rad_range.minimum);
}
inline osg::Vec3 SectorPlacer::getControlPosition() const
{
return getCenter();
}
}
#endif
CenteredPlacer
CopyOp
Math
Object
Particle
Vec3
osgParticle::CenteredPlacer::CenteredPlacer
CenteredPlacer()
Definition CenteredPlacer:56
osgParticle::CenteredPlacer::getCenter
const osg::Vec3 & getCenter() const
Get the center point.
Definition CenteredPlacer:66
osgParticle::Particle
Definition Particle:47
osgParticle::Particle::setPosition
void setPosition(const osg::Vec3 &p)
Set the position vector.
Definition Particle:483
osgParticle::SectorPlacer::~SectorPlacer
virtual ~SectorPlacer()
Definition SectorPlacer:71
osgParticle::SectorPlacer::getRadiusRange
const rangef & getRadiusRange() const
Get the range of possible values for radius.
Definition SectorPlacer:91
osgParticle::SectorPlacer::setPhiRange
void setPhiRange(const rangef &r)
Set the range of possible values for the central angle.
Definition SectorPlacer:112
osgParticle::SectorPlacer::place
void place(Particle *P) const
Place a particle. Do not call it manually.
Definition SectorPlacer:123
osgParticle::SectorPlacer::META_Object
META_Object(osgParticle, SectorPlacer)
osgParticle::SectorPlacer::SectorPlacer
SectorPlacer()
Definition SectorPlacer:81
osgParticle::SectorPlacer::volume
float volume() const
return the area of the sector
Definition SectorPlacer:136
osgParticle::SectorPlacer::operator=
SectorPlacer & operator=(const SectorPlacer &)
Definition SectorPlacer:72
osgParticle::SectorPlacer::getControlPosition
osg::Vec3 getControlPosition() const
return the control position
Definition SectorPlacer:142
osgParticle::SectorPlacer::getPhiRange
const rangef & getPhiRange() const
Get the range of possible values for the central angle.
Definition SectorPlacer:96
osgParticle::SectorPlacer::setRadiusRange
void setRadiusRange(const rangef &r)
Set the range of possible values for radius.
Definition SectorPlacer:101
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osgParticle
Definition AccelOperator:27
osgParticle::rangef
range< float > rangef
Range of floats.
Definition range:76
osg
Definition AlphaFunc:19
osg::Vec3
Vec3f Vec3
Definition Vec3:21
range
osgParticle::range::minimum
ValueType minimum
Lower bound.
Definition range:42