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//osgParticle - Copyright (C) 2002 Marco Jez
14
15#ifndef OSGPARTICLE_POINT_PLACER
16#define OSGPARTICLE_POINT_PLACER 1
17
18#include <osgParticle/CenteredPlacer>
19#include <osgParticle/Particle>
20
21#include <osg/CopyOp>
22#include <osg/Object>
23
24namespace osgParticle
25{
26
27    /**    A point-shaped particle placer.
28        This placer class uses the center point defined in its base class <CODE>CenteredPlacer</CODE>
29        to place there all incoming particles.
30    */
31    class PointPlacer: public CenteredPlacer {
32    public:
33        inline PointPlacer();
34        inline PointPlacer(const PointPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
35
36        META_Object(osgParticle, PointPlacer);
37
38        /** Place a particle.
39            This method is called automatically by <CODE>ModularEmitter</CODE> and should not be called
40            manually.
41        */
42        inline void place(Particle* P) const;
43
44        /// return the control position
45        inline osg::Vec3 getControlPosition() const;
46
47    protected:
48        virtual ~PointPlacer() {}
49        PointPlacer& operator=(const PointPlacer&) { return *this; }
50    };
51
52    // INLINE FUNCTIONS
53
54    inline PointPlacer::PointPlacer()
55    : CenteredPlacer()
56    {
57    }
58
59    inline PointPlacer::PointPlacer(const PointPlacer& copy, const osg::CopyOp& copyop)
60    : CenteredPlacer(copy, copyop)
61    {
62    }
63
64    inline void PointPlacer::place(Particle* P) const
65    {
66        P->setPosition(getCenter());
67    }
68
69
70    inline osg::Vec3 PointPlacer::getControlPosition() const
71    {
72        return getCenter();
73    }
74
75}
76
77
78#endif
79