HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
45 
46 //
47 // Initialization methods
48  void setType(UT_NoiseType type = FAST);
49  void setSeed(unsigned seed = 0);
50  void initialize(unsigned seed, UT_NoiseType type)
51  {
52  if (myType == type)
53  {
54  setSeed(seed);
55  }
56  else
57  {
58  mySeed = seed;
59  setType(type); // will initialize with mySeed
60  }
61  }
62 
63 //
64 // Query methods: Allow us to tell if we need to rebuild.
65  UT_NoiseType getType() const { return myType; }
66  int getSeed() const { return mySeed; }
67 
68 //
69 // Methods for getting noise out
70  fpreal turbulence(
71  const UT_Vector3F &pos,
72  unsigned fractalDepth,
73  fpreal rough = 0.5,
74  fpreal atten = 1.0) const;
75  void turbulence(
76  const UT_Vector3 &pos,
77  unsigned fractalDepth,
79  fpreal rough = 0.5,
80  fpreal atten = 1.0) const;
81  void turbulence(
82  const UT_Vector3D &pos,
83  unsigned fractalDepth,
85  fpreal rough = 0.5,
86  fpreal atten = 1.0) const;
87 
88  const void * getTextureData(
89  int tex_index,
90  int &xsize,
91  int &ysize,
92  int &comps,
93  bool &fp) const;
94 
95 // Exposed only for internal use to avoid additional nesting
96  class ut_NoiseVector;
97 
98 private:
99  unsigned int mySeed;
100  UT_NoiseType myType;
101  ut_NoiseVector * myNoise;
102 };
103 
104 #endif
UT_NoiseType
Definition: UT_Noise.h:33
void
Definition: png.h:1083
#define UT_API
Definition: UT_API.h:14
UT_NoiseType getType() const
Definition: UT_Noise.h:65
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
int getSeed() const
Definition: UT_Noise.h:66
OPENVDB_API void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types. Also initializes blosc (if enabled).
Definition: logging.h:294
ImageBuf OIIO_API noise(string_view noisetype, float A=0.0f, float B=0.1f, bool mono=false, int seed=0, ROI roi={}, int nthreads=0)
fpreal64 fpreal
Definition: SYS_Types.h:277
type
Definition: core.h:1059