HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_Noise.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: Noise generator for utility library (C++)
7  *
8  * COMMENTS:
9  * Two types of noise are currently supported. Perlin & Sparse
10  * convolution. This class basically produces space coherent noise
11  * (meaning that points which are close in space will generate
12  * similar noise values).
13  *
14  * To control the noise, you can change the frequency & offset
15  * by scaling space before sending the values to noise...
16  *
17  */
18 
19 #ifndef __UT_Noise_h__
20 #define __UT_Noise_h__
21 
22 #include "UT_API.h"
23 #include "UT_NonCopyable.h"
24 #include "UT_VectorTypes.h"
25 #include <SYS/SYS_Types.h>
26 
27 
29 {
30 public:
31 //
32 // Following is an enumeration of the types of noise supported:
34  {
35  FAST, // Perlin based noise generator
36  SPARSE, // Slower but higher quality noise generator
37  FAST_FIX, // Perlin based noise which was fixed
38  ALLIGATOR // Slight modification on sparse
39  };
40 
41  explicit UT_Noise(unsigned seed = 0, UT_NoiseType type = FAST);
42  ~UT_Noise();
43 
44 //
45 // Initialization methods
46  void setType(UT_NoiseType type = FAST);
47  void setSeed(unsigned seed = 0);
48  void initialize(unsigned seed, UT_NoiseType type)
49  {
50  if (myType == type)
51  {
52  setSeed(seed);
53  }
54  else
55  {
56  mySeed = seed;
57  setType(type); // will initialize with mySeed
58  }
59  }
60 
61 //
62 // Query methods: Allow us to tell if we need to rebuild.
63  UT_NoiseType getType() const { return myType; }
64  int getSeed() const { return mySeed; }
65 
66 //
67 // Methods for getting noise out
68  fpreal turbulence(
69  const UT_Vector3F &pos,
70  unsigned fractalDepth,
71  fpreal rough = 0.5,
72  fpreal atten = 1.0) const;
73  void turbulence(
74  const UT_Vector3 &pos,
75  unsigned fractalDepth,
76  UT_Vector3 &noise,
77  fpreal rough = 0.5,
78  fpreal atten = 1.0) const;
79  void turbulence(
80  const UT_Vector3D &pos,
81  unsigned fractalDepth,
82  UT_Vector3D &noise,
83  fpreal rough = 0.5,
84  fpreal atten = 1.0) const;
85 
86  const void * getTextureData(
87  int tex_index,
88  int &xsize,
89  int &ysize,
90  int &comps,
91  bool &fp) const;
92 
93 // Exposed only for internal use to avoid additional nesting
94  class ut_NoiseVector;
95 
96 private:
97  unsigned int mySeed;
98  UT_NoiseType myType;
99  ut_NoiseVector * myNoise;
100 };
101 
102 #endif
UT_NoiseType
Definition: UT_Noise.h:33
void initialize(unsigned seed, UT_NoiseType type)
Definition: UT_Noise.h:48
#define UT_API
Definition: UT_API.h:12
UT_NoiseType getType() const
Definition: UT_Noise.h:63
png_FILE_p fp
Definition: png.h:2028
int getSeed() const
Definition: UT_Noise.h:64
double fpreal
Definition: SYS_Types.h:263
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107