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>
34 class UT_API UT_ValueNoise final
35 {
36 public:
37  explicit UT_ValueNoise(unsigned const seed = 0);
38  ~UT_ValueNoise();
39 
41 
42  void setSeed(unsigned const seed);
43 
44  // Specialised for fpreal32, fpreal64, v4uf
45  template <typename T> T
46  turbulence(const T x[3],
47  unsigned depth,
48  T rough = T(0.5),
49  const T atten = T(1.0)) const;
50  template <typename T> void
51  turbulence(T f[3],
52  const T x[3],
53  unsigned depth,
54  T rough = T(0.5),
55  const T atten = T(1.0)) const;
56 
57  //
58  // Periodic version of the above
59  //
60  // Specialised for:
61  // <fpreal32, int32>
62  // <fpreal64, int64>
63  // <v4uf, v4uu>
64  //
65  template <typename T, typename I> T
66  turbulenceP(const T x[3],
67  const I p[3],
68  unsigned depth,
69  T rough = T(0.5),
70  const T atten = T(1.0)) const;
71  template <typename T, typename I> void
72  turbulenceP(T f[3],
73  const T x[3],
74  const I p[3],
75  unsigned depth,
76  T rough = T(0.5),
77  const T atten = T(1.0)) const;
78 
79 private:
80  unsigned mySeed;
81 
82  // Not storing this on the stack.
83  // Hides some implementation details and avoids blowing up the stack.
84  //
85  // This contains the details of the particular type of noise generator.
86  // Still statically polymorphic.
87  ut_NoiseGenerator<type>* const myGen;
88 };
89 
94 
95 #endif // !__UT_ValueNoise_h__
#define UT_API
Definition: UT_API.h:14
GLfloat f
Definition: glcorearb.h:1926
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
GLint GLenum GLint x
Definition: glcorearb.h:409
GLint GLint GLsizei GLsizei GLsizei depth
Definition: glcorearb.h:476
UT_ValueNoiseType
Definition: UT_ValueNoise.h:22
UT_EXTERN_TEMPLATE(UT_ValueNoise< UT_ValueNoiseType::FAST >)