Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 02 January 2011 - 08:37 AM
Posted 02 January 2011 - 08:50 AM
"The right, man, in the wrong, place, can make all the dif-fer-rence in the world..." - GMan, Half-Life 2
A blog of my SEGA Megadrive development adventures: http://www.bigevilcorporation.co.uk
Posted 02 January 2011 - 08:57 AM
Posted 02 January 2011 - 09:59 AM
Posted 02 January 2011 - 10:35 AM
#define RANDOM_IA 16807
#define RANDOM_IM 2147483647
#define RANDOM_AM (1.0f/float(RANDOM_IM))
#define RANDOM_IQ 127773
#define RANDOM_IR 2836
#define RANDOM_MASK 123459876
int random_x;
float random ()
{
int k;
float ans;
random_x ^= RANDOM_MASK;
k = random_x / RANDOM_IQ;
random_x = RANDOM_IA * (random_x - k * RANDOM_IQ ) - RANDOM_IR * k;
if ( random_x < 0 )
random_x += RANDOM_IM;
ans = RANDOM_AM * random_x;
random_x ^= RANDOM_MASK;
return ans;
}
float random ( float low, float high )
{
float v = random();
return low * ( 1.0f - v ) + high * v;
}
float2 random ( float2 low, float2 high )
{
float2 v = float2( random(), random() );
return low * ( 1.0f - v ) + high * v;
}
float3 random ( float3 low, float3 high )
{
float3 v = float3( random(), random(), random() );
return low * ( 1.0f - v ) + high * v;
}
void seed ( int value )
{
random_x = value;
random();
}
Posted 03 January 2011 - 01:46 AM
Posted 03 January 2011 - 02:29 AM
Posted 03 January 2011 - 07:24 AM
Posted 03 January 2011 - 08:06 AM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.