HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_PrimVolume.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: GT_PrimVolume.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 #ifndef GT_PrimVolume_h
11 #define GT_PrimVolume_h
12 
13 #include "GT_API.h"
14 #include "GT_Primitive.h"
15 #include "GT_GEOPrimCollect.h"
16 #include "GT_AttributeList.h"
17 #include <GEO/GEO_PrimVolume.h>
18 #include <GU/GU_DetailHandle.h>
19 #include <UT/UT_Ramp.h>
20 #include <UT/UT_Vector3.h>
21 #include <UT/UT_Vector4.h>
22 #include <UT/UT_VoxelArray.h>
23 
24 
25 class GEO_Primitive;
26 class GU_PrimVolumeCache;
28 
30 {
34 };
35 
36 /// Viewport visualization info for a volume.
38 {
40  float densityScale{};
41  float shadowScale{};
42  float extinctionRatio{};
44  float densityRange[2]{};
47 
48  float ambientShadows{};
49  float ambientMapSize{};
50  float ambientStepRate{};
54 
56  float diffuseRange[2]{};
60 
62  float emissionScale{};
63  float emissionRange[2]{};
66 
68  float emissionColorRange[2]{};
71 
73 };
74 
76 {
77 public:
79  const GEO_Primitive *prim,
80  const GT_DataArrayHandle &mat_id);
82  ~GT_PrimVolume() override;
83 
84  void getVisData(GT_PrimVolumeVisualization& v) const;
85  int getTileCoords(UT_Vector3FArray& coords, UT_Int16Array& masks) const;
86 
87  /// Returns true if the geometry primitive's parent detail has the "gl_wireframe"
88  /// attribute set.
89  bool drawWireframe() const;
90 
91  /// Returns true if the motion vectors are to be drawn for this volume set.
92  bool drawMotionVectors() const;
93  bool drawNormals() const;
94 
95  int getPrimitiveType() const override
96  { return GT_PRIM_VOXEL_VOLUME; }
97 
98  const char *className() const override { return "GT_PrimVolume"; }
99 
100  void enlargeBounds(UT_BoundingBox boxes[],
101  int nsegments) const override;
102  int getMotionSegments() const override { return 1; }
103  int64 getMemoryUsage() const override;
105  { return new GT_PrimVolume(*this); }
106 
107  bool refine(GT_Refine &refiner,
108  const GT_RefineParms *parms) const override;
109  bool refineHeightField(GT_Refine &refiner,
110  const GT_RefineParms *parms) const;
111 
112  // Isosurface
113  bool isIsosurface() const;
114  GT_PrimitiveHandle buildIsosurface(const GT_RefineParms &p,
115  bool as_points) const;
116  GU_ConstDetailHandle getIsosurfaceDetail() const;
117  UT_Vector3 getIsoCd() const;
118 
119  // Height fields
120  bool isHeightField() const;
121  GT_PrimitiveHandle buildHeightField(const GT_RefineParms &p) const;
122 
124  {
125  public:
126  CacheMeshData() : myMeshSize(0,0),
127  myMeshP0(0,0,0), myMeshP1(0,0,0),
128  myMeshP2(0,0,0), myMeshP3(0,0,0),
129  myMeshN0(0,0,0), myMeshN1(0,0,0),
130  myMeshN2(0,0,0), myMeshN3(0,0,0)
131  {}
141  };
142  void buildHeightMesh(const GT_RefineParms &p,
143  GT_PrimitiveHandle &mesh,
144  CacheMeshData &cdata,
145  UT_Vector2i &map_res,
146  bool use_quads) const;
147 
148  void findBlendMasks(UT_Array<const GEO_PrimVolume *> &masks) const;
150  {
154  };
155  gt_BlendMask blendMaskState(int index) const;
156 
157  // 2D/3D volume
158  bool isSmokeVolume() const;
159  bool is3DVolume() const;
160  bool isImage() const;
161  GEO_PrimVolumeXform getVolumeSpace() const;
162 
163  GEO_VolumeBorder getBorder() const;
164  fpreal getVisTiles() const;
165 
166  /// Returns true if this volume stores integer data.
167  bool getStoresIntegers() const;
168  /// Returns the number of components in a native Houdini volume. Returns -1
169  /// for VDBs.
170  int getTupleSize() const;
171  UT_Vector3I getRes() const;
172 
173  /// If remove_padding is true, half a voxel is deleted from each side of the
174  /// bound. This is data window.
175  void get2DBounds(UT_Vector3F &p0, UT_Vector3F &p1,
176  UT_Vector3F &p2, UT_Vector3F &p3,
177  bool remove_padding = false) const;
178  /// Return the display window's bounds, returns true if
179  /// there is a display window.
180  bool get2DDisplayBounds(UT_Vector3F &p0, UT_Vector3F &p1,
181  UT_Vector3F &p2, UT_Vector3F &p3,
182  bool remove_padding = false) const;
183  void get2DNormals(UT_Vector3F &n0, UT_Vector3F &n1,
184  UT_Vector3F &n2, UT_Vector3F &n3) const;
185 
186  const UT_VoxelArray<UT_Vector4> *getVoxels(const GU_PrimVolumeCacheParms &p,
187  int64 version[2]) const;
188 
189  GEO_PrimVolumeXform getVolumeTransform() const;
190  GEO_PrimVolumeXform getVolumeIndexTransform() const;
191  GT_PrimitiveHandle getPointPrimitive();
193  { return getPrimitive(); }
194  const GU_ConstDetailHandle &getDetail() const { return myDetail; }
195 
197  { return myVolumeAttributes.entries(); }
199  { return myVolumeAttributes(i); }
201  { myVolumeAttributes.append(prim); }
202 
203  /// Set the list of uniform attributes.
205  {
206  myUniformList = uniform;
207  }
208 
210  { return myUniformList; }
211  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
212  const GT_RefineParms &refine) override;
213 
214  bool getFlip() const { return myFlip; }
215  bool isVolumeReduced() const { return myVolumeReduced; }
216  void flagVolumeReduced() const { myVolumeReduced = true; }
217 
218 private:
219  const GEO_Primitive *getPrimitive() const;
220 
221  GU_PrimVolumeCache *myCache;
222  GT_AttributeListHandle myUniformList;
223 
224  // Is either VDB or Volume.
225  GU_ConstDetailHandle myDetail;
226  GA_Offset myPrimOffset;
227  int myCollationIndex;
228  UT_Array<const GEO_Primitive *> myVolumeAttributes;
229  mutable int64 myCacheVersion[2];
230  mutable bool myIsosurfaceFlag = false;
231  mutable bool mySmokeVolumeFlag = false;
232  mutable bool myHeightFieldFlag = false;
233  mutable bool myIs3DVolume = true;
234  mutable bool myIsImageVolume = false;
235  mutable bool myFlip = false;
236  mutable UT_Array<gt_BlendMask> myBlendMaskState;
237  mutable bool myVolumeReduced = false;
238  static int64 theMeshDataID;
239  static int64 theMeshTopID;
240 };
241 
242 /// Trivial collector class for Volume - 1 GT_PrimVolume per Volume primitive
243 /// with the visualization set to 'volume'.
245 {
246 public:
249 
251  beginCollecting(const GT_GEODetailListHandle &geometry,
252  const GT_RefineParms *parms) const override;
253 
255  const GEO_Primitive *const* prim_list,
256  int,
257  GT_GEOPrimCollectData *) const override;
258 
260  endCollecting(const GT_GEODetailListHandle &geometry,
261  GT_GEOPrimCollectData *data) const override;
262 };
263 
264 #endif
const GEO_Primitive * emissionColorPrim[3]
Definition: GT_PrimVolume.h:67
virtual bool updateGeoPrim(const GU_ConstDetailHandle &dtl, const GT_RefineParms &parms)
update any cached data for geometry and its attributes
GT_PrimVolumeRampMode densityRampType
Definition: GT_PrimVolume.h:46
const GEO_Primitive * diffusePrim[3]
Definition: GT_PrimVolume.h:55
const GEO_Primitive * getVolumeAttribute(exint i) const
virtual bool refine(GT_Refine &refiner, const GT_RefineParms *parms=NULL) const
GT_PrimVolumeRampMode emissionColorRampType
Definition: GT_PrimVolume.h:70
virtual GT_GEOPrimCollectData * beginCollecting(const GT_GEODetailListHandle &geometry, const GT_RefineParms *parms) const
bool isVolumeReduced() const
const GLdouble * v
Definition: glcorearb.h:837
void flagVolumeReduced() const
#define GT_API
Definition: GT_API.h:13
bool getFlip() const
int64 exint
Definition: SYS_Types.h:125
const GEO_Primitive * densityPrim
Definition: GT_PrimVolume.h:39
GT_PrimVolumeRampMode
Definition: GT_PrimVolume.h:29
Viewport visualization info for a volume.
Definition: GT_PrimVolume.h:37
Collection data container.
const GT_AttributeListHandle & getUniformAttributes() const override
GA_Size GA_Offset
Definition: GA_Types.h:653
int getPrimitiveType() const override
Definition: GT_PrimVolume.h:95
virtual GT_PrimitiveHandle endCollecting(const GT_GEODetailListHandle &geometry, GT_GEOPrimCollectData *data) const
GEO_VolumeBorder
CE_API bool refine(const CE_OSDRefinement &topo, const CE_OSDEvaluator &eval, const cl::Buffer &coarse, CE_FloatArray &refined_data)
virtual GT_PrimitiveHandle collect(const GT_GEODetailListHandle &geometry, const GEO_Primitive *const *prim_list, int nsegments, GT_GEOPrimCollectData *data) const =0
GLuint coords
Definition: glad.h:4091
int getMotionSegments() const override
long long int64
Definition: SYS_Types.h:116
void setUniformAttributes(const GT_AttributeListHandle &uniform)
Set the list of uniform attributes.
void appendVolumeAttribute(const GEO_Primitive *prim)
The base class for all GT primitive types.
Definition: GT_Primitive.h:43
virtual int64 getMemoryUsage() const =0
const GU_ConstDetailHandle & getDetail() const
GT_PrimVolumeRampMode diffuseRampType
Definition: GT_PrimVolume.h:58
const GEO_Primitive * emissionPrim
Definition: GT_PrimVolume.h:61
GT_API const UT_StringHolder version
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
exint getNumVolumeAttributes() const
GA_API const UT_StringHolder parms
~GT_GEOPrimCollectVolume() override
fpreal64 fpreal
Definition: SYS_Types.h:283
Utility class for containing a color ramp.
Definition: UT_Ramp.h:96
GLuint index
Definition: glcorearb.h:786
GT_PrimVolumeRampMode emissionRampType
Definition: GT_PrimVolume.h:65
IMF_EXPORT bool isImage(const std::string &name)
cgltf_primitive * getPrimitive(const cgltf_data &data, const GLTF_Index mesh_id, const GLTF_Index prim_id)
GT_PrimitiveHandle doSoftCopy() const override
UT_SharedPtr< GT_GEODetailList > GT_GEODetailListHandle
virtual void enlargeBounds(UT_BoundingBox boxes[], int nsegments) const =0
const GEO_Primitive * getGeoPrimitive() const
Definition: format.h:1821
const char * className() const override
Definition: GT_PrimVolume.h:98
GLenum src
Definition: glcorearb.h:1793