source file REDRandom.h

Go to the documentation of this file.

#ifndef RED_RANDOM_H
#define RED_RANDOM_H

//******************************************************************************
// Copyright (c) 2005 Redway. All rights reserved.
//
// Redway3d is a registered trademark. Any reproduction and / or utilization
// of any material from this document without Redway?s express authorization
// are prohibited.
//******************************************************************************

#include "RED.h"
#include "REDObject.h"
#include "REDCID.h"


namespace RED
{

  class REDFullExp RNG : public RED::Object
  {
  public:
    
    // Typing information:
    // -------------------
    
    SET_CID( CID_class_REDRNG ) IMPLEMENT_AS();
    
    
    virtual void Init( unsigned int iSeed ) = 0;


    virtual unsigned int Rand32() = 0;


  public:

    static const unsigned int Max32;
  };


  class REDFullExp Random : public RNG
  {
  public:
    
    // Typing information:
    // -------------------
    
    SET_CID( CID_class_REDRandom ) IMPLEMENT_AS();
    
    
    Random( unsigned int iSeed = 24091975 );

    
    void Init( unsigned int iSeed );


    unsigned int Rand32();


  private:

    void GenState();


  private:
    
    unsigned int _state[624];
    
    unsigned int* _curstate;
    
    unsigned int* _endstate;
  };


  class REDFullExp FastRandom : public RNG
  {
  public:
    
    // Typing information:
    // -------------------
    
    SET_CID( CID_class_REDFastRandom ) IMPLEMENT_AS();
    
    
    FastRandom( unsigned int iSeed = 24091975 );

    
    void Init( unsigned int iSeed );


    unsigned int Rand32();


  private:
  
    unsigned int _x;
  };

};

#endif