HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_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  */
7 
8 #ifndef __SIM_Noise_h__
9 #define __SIM_Noise_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_DataUtils.h"
13 #include "SIM_OptionsUser.h"
14 #include "SIM_PhysicalParms.h"
15 
16 class SIM_NoiseResolver;
17 class SIM_NoiseResolverGeneric;
18 
19 /// This class defines the interface for noise generation functions.
20 class SIM_API SIM_Noise : public SIM_Data,
21  public SIM_OptionsUser
22 {
23 public:
27 
28  /// Gets the 1D value of the noise field at the specified position.
29  /// The returned value is between the minvalue and the maxvalue.
30  fpreal getNoise(const UT_Vector3 &pos) const;
31  /// Gets the 3D value of the noise field at the specified position.
32  /// The returned value is between the minvalue and the maxvalue.
33  void getNoise(const UT_Vector3 &pos,
34  UT_Vector3 &noise) const;
35 
36  /// Returns an accelerated property resolver to get the noise
37  /// at any given place in a hopefully threadsafe manner.
38  SIM_PropertyResolver *getNoiseResolver() const;
39 
40 protected:
41  explicit SIM_Noise(const SIM_DataFactory *factory);
42  ~SIM_Noise() override;
43 
44  /// Get the extents of the values generated by the noise function.
45  /// These values are required to properly scale the returned values.
46  void getNoiseLimits(fpreal &min, fpreal &max) const;
47 
48  /// Override this function to return the actual bounds of the noise.
49  virtual void getNoiseLimitsSubclass(fpreal &min,
50  fpreal &max) const = 0;
51  /// Override this function to implement a new noise function.
52  /// The returned value must be in the range [0..1].
53  /// The default implementation returns the X component of the 3D noise.
54  virtual fpreal getNoiseSubclass(const UT_Vector3 &pos) const;
55  /// Override this function to implement a new noise function.
56  /// The returned values must all be in the range [0..1].
57  /// The default implementation returns the 1D noise value for all
58  /// three components.
59  virtual void getNoiseSubclass(const UT_Vector3 &pos,
60  UT_Vector3 &noise) const;
61  /// Create a SIM_PropertyResolver to quickly compute the noise,
62  /// defaults to a generic one that just calls back to SIM_Noise.
63  virtual SIM_PropertyResolver *getNoiseResolverSubclass() const;
64 
65 private:
68 
69  friend class SIM_NoiseResolverGeneric;
70  friend class SIM_NoiseResolver;
71 };
72 
74 {
75 public:
77 
78  /// Handles the resizing to the given range using the min/max,
79  /// and proper support of scalar fields being set.
80  fpreal getF(const UT_Vector3 &pos) override;
81  UT_Vector3 getV3(const UT_Vector3 &pos) override;
82 
83  /// These are the methods to override with the noise-specific
84  /// behaviour. They should behave like SIM_Noise::getNoiseSubclass
85  virtual fpreal getNoiseF(const UT_Vector3 &pos) = 0;
86  virtual UT_Vector3 getNoiseV3(const UT_Vector3 &pos) = 0;
87 
88 protected:
89  bool myIsScalar;
90  UT_Vector3 myMaxValue, myMinValue;
91  fpreal myNoiseLimitsMin, myNoiseLimitsMax;
92 };
93 
94 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#define DECLARE_CLASSNAME(DataClass, SuperClass)
Definition: SIM_DataUtils.h:20
#define GETSET_DATA_FUNCS_B(DataName, FuncName)
#define SIM_NAME_SCALARNOISE
Definition: SIM_Names.h:182
virtual UT_Vector3 getV3(const UT_Vector3 &pos)=0
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define SIM_NAME_MINVALUE
Definition: SIM_Names.h:149
#define SIM_NAME_MAXVALUE
Definition: SIM_Names.h:146
#define GETSET_DATA_FUNCS_V3(DataName, FuncName)
This class defines the interface for noise generation functions.
Definition: SIM_Noise.h:20
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)
UT_Vector3 myMinValue
Definition: SIM_Noise.h:90
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual fpreal getF(const UT_Vector3 &pos)=0
#define SIM_API
Definition: SIM_API.h:12
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
fpreal myNoiseLimitsMin
Definition: SIM_Noise.h:91