Panda3D
|
00001 // Filename: stackedPerlinNoise3.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 STACKEDPERLINNOISE3_H 00016 #define STACKEDPERLINNOISE3_H 00017 00018 #include "pandabase.h" 00019 #include "perlinNoise3.h" 00020 #include "pvector.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : StackedPerlinNoise3 00024 // Description : Implements a multi-layer PerlinNoise, with one or 00025 // more high-frequency noise functions added to a 00026 // lower-frequency base noise function. 00027 //////////////////////////////////////////////////////////////////// 00028 class EXPCL_PANDA_MATHUTIL StackedPerlinNoise3 { 00029 PUBLISHED: 00030 INLINE StackedPerlinNoise3(); 00031 StackedPerlinNoise3(double sx, double sy, double sz, int num_levels = 3, 00032 double scale_factor = 4.0f, double amp_scale = 0.5f, 00033 int table_size = 256, unsigned long seed = 0); 00034 StackedPerlinNoise3(const StackedPerlinNoise3 ©); 00035 void operator = (const StackedPerlinNoise3 ©); 00036 00037 void add_level(const PerlinNoise3 &level, double amp = 1.0); 00038 void clear(); 00039 00040 INLINE double noise(double x, double y, double z); 00041 INLINE float noise(const LVecBase3f &value); 00042 double noise(const LVecBase3d &value); 00043 00044 INLINE double operator ()(double x, double y, double z); 00045 INLINE float operator ()(const LVecBase3f &value); 00046 INLINE double operator ()(const LVecBase3d &value); 00047 00048 private: 00049 class Noise { 00050 public: 00051 PerlinNoise3 _noise; 00052 double _amp; 00053 }; 00054 00055 typedef epvector<Noise> Noises; 00056 Noises _noises; 00057 }; 00058 00059 #include "stackedPerlinNoise3.I" 00060 00061 #endif 00062