I need to randomly generate Ogre::Real
, but I doubt that anyone works with Ogre
, so with a float
it reaches me.
Between 0.01 and 3.0
I need to randomly generate Ogre::Real
, but I doubt that anyone works with Ogre
, so with a float
it reaches me.
Between 0.01 and 3.0
To begin with, Ogre::Real
is an alias of float
, as per You can see it in the documentation:
typedef float Ogre::Real
Software floating point type.
Note
Not valid as a pointer to GPU buffers / parameters
Once this is cleared, use <random>
of C ++ 11. I do not know that distribution you'll need in the range 0.01fa 3.0f, but generally in videogames the desirable is usually a uniform distribution , so you need to use std::uniform_real_distribution
:
std::random_device device;
std::mt19937 generador(device());
std::uniform_real_distribution<> distribucion(.01f, 3.f);
std::cout << "Numero entre 0.01 y 3.00 : " << distribucion(generador) << '\n';