OpenSceneGraph 3.6.5
SegmentPlacer
Go to the documentation of this file.
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_SEGMENT_PLACER
16#define OSGPARTICLE_SEGMENT_PLACER 1
17
18#include <osgParticle/Placer>
19#include <osgParticle/Particle>
20
21#include <osg/CopyOp>
22#include <osg/Object>
23#include <osg/Vec3>
24
25namespace osgParticle {
26
32 class SegmentPlacer: public Placer {
33 public:
34 inline SegmentPlacer();
35 inline SegmentPlacer(const SegmentPlacer& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
36
38
40 inline const osg::Vec3& getVertexA() const;
41
43 inline void setVertexA(const osg::Vec3& v);
44
46 inline void setVertexA(float x, float y, float z);
47
49 inline const osg::Vec3& getVertexB() const;
50
52 inline void setVertexB(const osg::Vec3& v);
53
55 inline void setVertexB(float x, float y, float z);
56
58 inline void setSegment(const osg::Vec3& A, const osg::Vec3& B);
59
61 inline void place(Particle* P) const;
62
64 inline float volume() const;
65
67 inline osg::Vec3 getControlPosition() const;
68
69 protected:
70 virtual ~SegmentPlacer() {}
71 SegmentPlacer& operator=(const SegmentPlacer&) { return *this; }
72
73 private:
74 osg::Vec3 _vertexA;
75 osg::Vec3 _vertexB;
76 };
77
78 // INLINE FUNCTIONS
79
81 : Placer(), _vertexA(-1, 0, 0), _vertexB(1, 0, 0)
82 {
83 }
84
85 inline SegmentPlacer::SegmentPlacer(const SegmentPlacer& copy, const osg::CopyOp& copyop)
86 : Placer(copy, copyop), _vertexA(copy._vertexA), _vertexB(copy._vertexB)
87 {
88 }
89
91 {
92 return _vertexA;
93 }
94
96 {
97 return _vertexB;
98 }
99
100 inline void SegmentPlacer::setSegment(const osg::Vec3& A, const osg::Vec3& B)
101 {
102 _vertexA = A;
103 _vertexB = B;
104 }
105
106 inline void SegmentPlacer::place(Particle* P) const
107 {
108 P->setPosition(rangev3(_vertexA, _vertexB).get_random());
109 }
110
111 inline float SegmentPlacer::volume() const
112 {
113 return (_vertexB - _vertexA).length();
114 }
115
117 {
118 _vertexA = v;
119 }
120
121 inline void SegmentPlacer::setVertexA(float x, float y, float z)
122 {
123 _vertexA.set(x, y, z);
124 }
125
127 {
128 _vertexB = v;
129 }
130
131 inline void SegmentPlacer::setVertexB(float x, float y, float z)
132 {
133 _vertexB.set(x, y, z);
134 }
135
137 {
138 return (_vertexA+_vertexB)*0.5f;
139 }
140
141
142}
143
144#endif
Vec3f Vec3
Definition Vec3:21
The osgParticle library is a NodeKit that extends the core scene graph to support particle effects.
Definition AccelOperator:27
range< osg::Vec3 > rangev3
Range of osg::Vec3s.
Definition range:82
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
void set(value_type x, value_type y, value_type z)
Definition Vec3f:67
Implementation of a particle.
Definition Particle:47
void setPosition(const osg::Vec3 &p)
Set the position vector.
Definition Particle:483
Placer()
Definition Placer:56
const osg::Vec3 & getVertexA() const
get vertex A.
Definition SegmentPlacer:90
virtual ~SegmentPlacer()
Definition SegmentPlacer:70
osg::Vec3 getControlPosition() const
return the control position
Definition SegmentPlacer:136
const osg::Vec3 & getVertexB() const
get vertex B.
Definition SegmentPlacer:95
void setVertexA(const osg::Vec3 &v)
Set vertex A of the segment as a vector.
Definition SegmentPlacer:116
SegmentPlacer()
Definition SegmentPlacer:80
void place(Particle *P) const
Place a particle. This method is called by ModularEmitter, do not call it manually.
Definition SegmentPlacer:106
SegmentPlacer & operator=(const SegmentPlacer &)
Definition SegmentPlacer:71
void setVertexB(const osg::Vec3 &v)
Set vertex B of the segment as a vector.
Definition SegmentPlacer:126
float volume() const
return the length of the segment
Definition SegmentPlacer:111
void setSegment(const osg::Vec3 &A, const osg::Vec3 &B)
Set both vertices.
Definition SegmentPlacer:100
META_Object(osgParticle, SegmentPlacer)

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.