BoxPlacer
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.
*/
//Build by Zach Deedler
#ifndef OSGPARTICLE_BOX_PLACER
#define OSGPARTICLE_BOX_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 BoxPlacer: public CenteredPlacer {
public:
inline BoxPlacer();
inline BoxPlacer(const BoxPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
inline const rangef& getXRange() const;
inline void setXRange(const rangef& r);
inline void setXRange(float r1, float r2);
inline const rangef& getYRange() const;
inline void setYRange(const rangef& r);
inline void setYRange(float r1, float r2);
inline const rangef& getZRange() const;
inline void setZRange(const rangef& r);
inline void setZRange(float r1, float r2);
META_Object(osgParticle, BoxPlacer);
inline void place(Particle* P) const;
inline float volume() const;
inline osg::Vec3 getControlPosition() const;
protected:
virtual ~BoxPlacer() {}
BoxPlacer& operator=(const BoxPlacer&) { return *this; }
private:
rangef _x_range;
rangef _y_range;
rangef _z_range;
};
// INLINE FUNCTIONS
inline BoxPlacer::BoxPlacer()
: CenteredPlacer(), _x_range(-1, 1), _y_range(-1, 1), _z_range(-1, 1)
{
}
inline BoxPlacer::BoxPlacer(const BoxPlacer& copy, const osg::CopyOp& copyop)
: CenteredPlacer(copy, copyop),
_x_range(copy._x_range), _y_range(copy._y_range), _z_range(copy._z_range)
{
}
inline const rangef& BoxPlacer::getXRange() const
{
return _x_range;
}
inline void BoxPlacer::setXRange(const rangef& r)
{
_x_range = r;
}
inline void BoxPlacer::setXRange(float r1, float r2)
{
_x_range.minimum = r1;
_x_range.maximum = r2;
}
inline const rangef& BoxPlacer::getYRange() const
{
return _y_range;
}
inline void BoxPlacer::setYRange(const rangef& r)
{
_y_range = r;
}
inline void BoxPlacer::setYRange(float r1, float r2)
{
_y_range.minimum = r1;
_y_range.maximum = r2;
}
inline const rangef& BoxPlacer::getZRange() const
{
return _z_range;
}
inline void BoxPlacer::setZRange(const rangef& r)
{
_z_range = r;
}
inline void BoxPlacer::setZRange(float r1, float r2)
{
_z_range.minimum = r1;
_z_range.maximum = r2;
}
inline void BoxPlacer::place(Particle* P) const
{
osg::Vec3 pos(
getCenter().x() + _x_range.get_random(),
getCenter().y() + _y_range.get_random(),
getCenter().z() + _z_range.get_random());
P->setPosition(pos);
}
inline float BoxPlacer::volume() const
{
return (_x_range.maximum - _x_range.minimum) *
(_y_range.maximum - _y_range.minimum) *
(_z_range.maximum - _z_range.minimum);
}
inline osg::Vec3 BoxPlacer::getControlPosition() const
{
return getCenter();
}
}
#endif
CenteredPlacer
CopyOp
Math
Object
Particle
Vec3
osgParticle::BoxPlacer::getYRange
const rangef & getYRange() const
Get the range of possible values along the Y axis.
Definition BoxPlacer:118
osgParticle::BoxPlacer::getZRange
const rangef & getZRange() const
Get the range of possible values along the Z axis.
Definition BoxPlacer:134
osgParticle::BoxPlacer::META_Object
META_Object(osgParticle, BoxPlacer)
osgParticle::BoxPlacer::BoxPlacer
BoxPlacer()
Definition BoxPlacer:91
osgParticle::BoxPlacer::getXRange
const rangef & getXRange() const
Get the range of possible values along the X axis.
Definition BoxPlacer:102
osgParticle::BoxPlacer::operator=
BoxPlacer & operator=(const BoxPlacer &)
Definition BoxPlacer:81
osgParticle::BoxPlacer::setXRange
void setXRange(const rangef &r)
Set the range of possible values along the X axis.
Definition BoxPlacer:107
osgParticle::BoxPlacer::~BoxPlacer
virtual ~BoxPlacer()
Definition BoxPlacer:80
osgParticle::BoxPlacer::volume
float volume() const
return the volume of the box
Definition BoxPlacer:160
osgParticle::BoxPlacer::place
void place(Particle *P) const
Place a particle. Do not call it manually.
Definition BoxPlacer:150
osgParticle::BoxPlacer::getControlPosition
osg::Vec3 getControlPosition() const
return the control position
Definition BoxPlacer:167
osgParticle::BoxPlacer::setYRange
void setYRange(const rangef &r)
Set the range of possible values along the Y axis.
Definition BoxPlacer:123
osgParticle::BoxPlacer::setZRange
void setZRange(const rangef &r)
Set the range of possible values along the Z axis.
Definition BoxPlacer:139
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
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::Vec3
Vec3f Vec3
Definition Vec3:21
range
osgParticle::range::minimum
ValueType minimum
Lower bound.
Definition range:42