HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ValueNoise.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ValueNoise.h ( UT Library, C++ )
7  *
8  * COMMENTS: For a description of value noise, see Wikipedia.
9  * This is a renovation of the old noise routine from UT_Noise.h
10  *
11  */
12 
13 #ifndef __UT_ValueNoise_h__
14 #define __UT_ValueNoise_h__
15 
16 #include "UT_API.h"
17 #include "UT_NonCopyable.h"
18 #include <SYS/SYS_Types.h>
19 #include <VM/VM_SIMD.h>
20 
21 
23 {
24  FAST, // Perlin based noise generator
25  SPARSE, // Slower but higher quality noise generator
26  FAST_FIX, // Perlin based noise which was fixed
27  ALLIGATOR // Slight modification on sparse
28 };
29 
30 template <UT_ValueNoiseType type>
32 
33 template <UT_ValueNoiseType type = UT_ValueNoiseType::FAST>
35 {
36 public:
37  explicit UT_ValueNoise(unsigned const seed = 0);
38  ~UT_ValueNoise();
39 
40  void setSeed(unsigned const seed);
41 
42  // Specialised for fpreal32, fpreal64, v4uf
43  template <typename T> T
44  turbulence(const T x[3],
45  unsigned depth,
46  T rough = T(0.5),
47  const T atten = T(1.0)) const;
48  template <typename T> void
49  turbulence(T f[3],
50  const T x[3],
51  unsigned depth,
52  T rough = T(0.5),
53  const T atten = T(1.0)) const;
54 
55  //
56  // Periodic version of the above
57  //
58  // Specialised for:
59  // <fpreal32, int32>
60  // <fpreal64, int64>
61  // <v4uf, v4uu>
62  //
63  template <typename T, typename I> T
64  turbulenceP(const T x[3],
65  const I p[3],
66  unsigned depth,
67  T rough = T(0.5),
68  const T atten = T(1.0)) const;
69  template <typename T, typename I> void
70  turbulenceP(T f[3],
71  const T x[3],
72  const I p[3],
73  unsigned depth,
74  T rough = T(0.5),
75  const T atten = T(1.0)) const;
76 
77 private:
78  unsigned mySeed;
79 
80  // Not storing this on the stack.
81  // Hides some implementation details and avoids blowing up the stack.
82  //
83  // This contains the details of the particular type of noise generator.
84  // Still statically polymorphic.
85  ut_NoiseGenerator<type>* const myGen;
86 };
87 
92 
93 #endif // !__UT_ValueNoise_h__
#define UT_API
Definition: UT_API.h:13
GLclampf f
Definition: glew.h:3499
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLfloat GLfloat p
Definition: glew.h:16321
UT_ValueNoiseType
Definition: UT_ValueNoise.h:22
UT_EXTERN_TEMPLATE(UT_ValueNoise< UT_ValueNoiseType::FAST >)
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glew.h:1254