SegmentPlacer
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_SEGMENT_PLACER
#define OSGPARTICLE_SEGMENT_PLACER 1
#include <osgParticle/Placer>
#include <osgParticle/Particle>
#include <osg/CopyOp>
#include <osg/Object>
#include <osg/Vec3>
namespace osgParticle {
class SegmentPlacer: public Placer {
public:
inline SegmentPlacer();
inline SegmentPlacer(const SegmentPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
META_Object(osgParticle, SegmentPlacer);
inline const osg::Vec3& getVertexA() const;
inline void setVertexA(const osg::Vec3& v);
inline void setVertexA(float x, float y, float z);
inline const osg::Vec3& getVertexB() const;
inline void setVertexB(const osg::Vec3& v);
inline void setVertexB(float x, float y, float z);
inline void setSegment(const osg::Vec3& A, const osg::Vec3& B);
inline void place(Particle* P) const;
inline float volume() const;
inline osg::Vec3 getControlPosition() const;
protected:
virtual ~SegmentPlacer() {}
SegmentPlacer& operator=(const SegmentPlacer&) { return *this; }
private:
osg::Vec3 _vertexA;
osg::Vec3 _vertexB;
};
// INLINE FUNCTIONS
inline SegmentPlacer::SegmentPlacer()
: Placer(), _vertexA(-1, 0, 0), _vertexB(1, 0, 0)
{
}
inline SegmentPlacer::SegmentPlacer(const SegmentPlacer& copy, const osg::CopyOp& copyop)
: Placer(copy, copyop), _vertexA(copy._vertexA), _vertexB(copy._vertexB)
{
}
inline const osg::Vec3& SegmentPlacer::getVertexA() const
{
return _vertexA;
}
inline const osg::Vec3& SegmentPlacer::getVertexB() const
{
return _vertexB;
}
inline void SegmentPlacer::setSegment(const osg::Vec3& A, const osg::Vec3& B)
{
_vertexA = A;
_vertexB = B;
}
inline void SegmentPlacer::place(Particle* P) const
{
P->setPosition(rangev3(_vertexA, _vertexB).get_random());
}
inline float SegmentPlacer::volume() const
{
return (_vertexB - _vertexA).length();
}
inline void SegmentPlacer::setVertexA(const osg::Vec3& v)
{
_vertexA = v;
}
inline void SegmentPlacer::setVertexA(float x, float y, float z)
{
_vertexA.set(x, y, z);
}
inline void SegmentPlacer::setVertexB(const osg::Vec3& v)
{
_vertexB = v;
}
inline void SegmentPlacer::setVertexB(float x, float y, float z)
{
_vertexB.set(x, y, z);
}
inline osg::Vec3 SegmentPlacer::getControlPosition() const
{
return (_vertexA+_vertexB)*0.5f;
}
}
#endif
CopyOp
Object
Particle
Placer
Vec3
osgParticle::Particle
Definition Particle:47
osgParticle::Particle::setPosition
void setPosition(const osg::Vec3 &p)
Set the position vector.
Definition Particle:483
osgParticle::Placer::Placer
Placer()
Definition Placer:56
osgParticle::SegmentPlacer::getVertexA
const osg::Vec3 & getVertexA() const
get vertex A.
Definition SegmentPlacer:90
osgParticle::SegmentPlacer::~SegmentPlacer
virtual ~SegmentPlacer()
Definition SegmentPlacer:70
osgParticle::SegmentPlacer::getControlPosition
osg::Vec3 getControlPosition() const
return the control position
Definition SegmentPlacer:136
osgParticle::SegmentPlacer::getVertexB
const osg::Vec3 & getVertexB() const
get vertex B.
Definition SegmentPlacer:95
osgParticle::SegmentPlacer::setVertexA
void setVertexA(const osg::Vec3 &v)
Set vertex A of the segment as a vector.
Definition SegmentPlacer:116
osgParticle::SegmentPlacer::SegmentPlacer
SegmentPlacer()
Definition SegmentPlacer:80
osgParticle::SegmentPlacer::place
void place(Particle *P) const
Place a particle. This method is called by ModularEmitter, do not call it manually.
Definition SegmentPlacer:106
osgParticle::SegmentPlacer::operator=
SegmentPlacer & operator=(const SegmentPlacer &)
Definition SegmentPlacer:71
osgParticle::SegmentPlacer::setVertexB
void setVertexB(const osg::Vec3 &v)
Set vertex B of the segment as a vector.
Definition SegmentPlacer:126
osgParticle::SegmentPlacer::volume
float volume() const
return the length of the segment
Definition SegmentPlacer:111
osgParticle::SegmentPlacer::setSegment
void setSegment(const osg::Vec3 &A, const osg::Vec3 &B)
Set both vertices.
Definition SegmentPlacer:100
osgParticle::SegmentPlacer::META_Object
META_Object(osgParticle, SegmentPlacer)
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Vec3f::set
void set(value_type x, value_type y, value_type z)
Definition Vec3f:67
osgParticle
Definition AccelOperator:27
osgParticle::rangev3
range< osg::Vec3 > rangev3
Range of osg::Vec3s.
Definition range:82
osg::Vec3
Vec3f Vec3
Definition Vec3:21