Panda3D

perlinNoise2.h

00001 // Filename: perlinNoise2.h
00002 // Created by:  drose (05Oct05)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PERLINNOISE2_H
00016 #define PERLINNOISE2_H
00017 
00018 #include "pandabase.h"
00019 #include "perlinNoise.h"
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //       Class : PerlinNoise2
00023 // Description : This class provides an implementation of Perlin noise
00024 //               for 2 variables.  This code is loosely based on the
00025 //               reference implementation at
00026 //               http://mrl.nyu.edu/~perlin/noise/ .
00027 ////////////////////////////////////////////////////////////////////
00028 class EXPCL_PANDA_MATHUTIL PerlinNoise2 : public PerlinNoise {
00029 PUBLISHED:
00030   INLINE PerlinNoise2();
00031   INLINE PerlinNoise2(double sx, double sy,
00032                       int table_size = 256,
00033                       unsigned long seed = 0);
00034   INLINE PerlinNoise2(const PerlinNoise2 &copy);
00035   INLINE void operator = (const PerlinNoise2 &copy);
00036 
00037   INLINE void set_scale(double scale);
00038   INLINE void set_scale(double sx, double sy);
00039   INLINE void set_scale(const LVecBase2f &scale);
00040   INLINE void set_scale(const LVecBase2d &scale);
00041 
00042   INLINE double noise(double x, double y) const;
00043   INLINE float noise(const LVecBase2f &value) const;
00044   double noise(const LVecBase2d &value) const;
00045 
00046   INLINE double operator ()(double x, double y) const;
00047   INLINE float operator ()(const LVecBase2f &value) const;
00048   INLINE double operator ()(const LVecBase2d &value) const;
00049   
00050 private:
00051   void init_unscaled_xform();
00052   INLINE static double grad(int hash, double x, double y);
00053 
00054 private:
00055   LMatrix3d _unscaled_xform;
00056   LMatrix3d _input_xform;
00057 };
00058 
00059 #include "perlinNoise2.I"
00060 
00061 #endif
00062 
 All Classes Functions Variables Enumerations