range
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_RANGE
#define OSGPARTICLE_RANGE 1
// include Export simply to disable Visual Studio silly warnings.
#include <osgParticle/Export>
#include <stdlib.h>
#include <osg/Vec2>
#include <osg/Vec3>
#include <osg/Vec4>
namespace osgParticle
{
template<class ValueType> struct range
{
ValueType minimum;
ValueType maximum;
range() : minimum(ValueType()), maximum(ValueType()) {}
range(const ValueType& mn, const ValueType& mx) : minimum(mn), maximum(mx) {}
void set(const ValueType& mn, const ValueType& mx) { minimum = mn; maximum = mx; }
ValueType get_random() const
{
return minimum + (maximum - minimum) * rand() / RAND_MAX;
}
ValueType get_random_sqrtf() const
{
return minimum + (maximum - minimum) * sqrtf( static_cast<float>(rand()) / static_cast<float>(RAND_MAX) );
}
ValueType mid() const
{
return (minimum+maximum)*0.5f;
}
};
typedef range<float> rangef;
typedef range<osg::Vec2> rangev2;
typedef range<osg::Vec3> rangev3;
typedef range<osg::Vec4> rangev4;
}
#endif
Vec2
Vec3
Vec4
osgParticle
Definition AccelOperator:27
osgParticle::rangev2
range< osg::Vec2 > rangev2
Range of osg::Vec2s.
Definition range:79
osgParticle::rangev4
range< osg::Vec4 > rangev4
Range of osg::Vec4s.
Definition range:85
osgParticle::rangev3
range< osg::Vec3 > rangev3
Range of osg::Vec3s.
Definition range:82
osgParticle::rangef
range< float > rangef
Range of floats.
Definition range:76
Export
osgParticle::range
Definition range:39
osgParticle::range::set
void set(const ValueType &mn, const ValueType &mx)
Set min and max.
Definition range:54
osgParticle::range::range
range()
Construct the object by calling default constructors for min and max.
Definition range:48
osgParticle::range< float >::maximum
float maximum
Definition range:45
osgParticle::range::get_random_sqrtf
ValueType get_random_sqrtf() const
Get a random square root value between min and max.
Definition range:63
osgParticle::range::get_random
ValueType get_random() const
Get a random value between min and max.
Definition range:57
osgParticle::range::mid
ValueType mid() const
Definition range:68
osgParticle::range< float >::minimum
float minimum
Definition range:42
osgParticle::range::range
range(const ValueType &mn, const ValueType &mx)
Construct and initialize min and max directly.
Definition range:51