OpenSceneGraph 3.6.5
range
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_RANGE
16#define OSGPARTICLE_RANGE 1
17
18// include Export simply to disable Visual Studio silly warnings.
19#include <osgParticle/Export>
20
21#include <stdlib.h>
22
23#include <osg/Vec2>
24#include <osg/Vec3>
25#include <osg/Vec4>
26
27namespace osgParticle
28{
29
38 template<class ValueType> struct range
39 {
40
42 ValueType minimum;
43
45 ValueType maximum;
46
48 range() : minimum(ValueType()), maximum(ValueType()) {}
49
51 range(const ValueType& mn, const ValueType& mx) : minimum(mn), maximum(mx) {}
52
54 void set(const ValueType& mn, const ValueType& mx) { minimum = mn; maximum = mx; }
55
57 ValueType get_random() const
58 {
59 return minimum + (maximum - minimum) * rand() / RAND_MAX;
60 }
61
63 ValueType get_random_sqrtf() const
64 {
65 return minimum + (maximum - minimum) * sqrtf( static_cast<float>(rand()) / static_cast<float>(RAND_MAX) );
66 }
67
68 ValueType mid() const
69 {
70 return (minimum+maximum)*0.5f;
71 }
72
73 };
74
77
80
83
86
87}
88
89#endif
The osgParticle library is a NodeKit that extends the core scene graph to support particle effects.
Definition AccelOperator:27
range< osg::Vec2 > rangev2
Range of osg::Vec2s.
Definition range:79
range< osg::Vec4 > rangev4
Range of osg::Vec4s.
Definition range:85
range< osg::Vec3 > rangev3
Range of osg::Vec3s.
Definition range:82
range< float > rangef
Range of floats.
Definition range:76
A simple struct template useful to store ranges of values as min/max pairs.
Definition range:39
void set(const ValueType &mn, const ValueType &mx)
Set min and max.
Definition range:54
range()
Construct the object by calling default constructors for min and max.
Definition range:48
float maximum
Definition range:45
ValueType get_random_sqrtf() const
Get a random square root value between min and max.
Definition range:63
ValueType get_random() const
Get a random value between min and max.
Definition range:57
ValueType mid() const
Definition range:68
float minimum
Definition range:42
range(const ValueType &mn, const ValueType &mx)
Construct and initialize min and max directly.
Definition range:51

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