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;
44  float densityRange[2];
47 
54 
56  float diffuseRange[2];
60 
63  float emissionRange[2];
66 
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  GT_PrimitiveHandle buildHeightMesh(const GT_RefineParms &p,
123  UT_Vector2i &map_res,
124  bool use_quads) const;
126  {
130  };
131  gt_BlendMask blendMaskState(int index) const;
132 
133  // 2D/3D volume
134  bool isSmokeVolume() const;
135  bool is3DVolume() const;
136  bool isImage() const;
137  GEO_PrimVolumeXform getVolumeSpace() const;
138 
139  GEO_VolumeBorder getBorder() const;
140  fpreal getVisTiles() const;
141 
142  /// Returns true if this volume stores integer data.
143  bool getStoresIntegers() const;
144  /// Returns the number of components in a native Houdini volume. Returns -1
145  /// for VDBs.
146  int getTupleSize() const;
147  UT_Vector3I getRes() const;
148 
149  /// If remove_padding is true, half a voxel is deleted from each side of the
150  /// bound.
151  void get2DBounds(UT_Vector3F &p0, UT_Vector3F &p1,
152  UT_Vector3F &p2, UT_Vector3F &p3,
153  bool remove_padding = false) const;
154  void get2DNormals(UT_Vector3F &n0, UT_Vector3F &n1,
155  UT_Vector3F &n2, UT_Vector3F &n3) const;
156 
157  const UT_VoxelArray<UT_Vector4> *getVoxels(const GU_PrimVolumeCacheParms &p,
158  int64 version[2]) const;
159 
160  GEO_PrimVolumeXform getVolumeTransform() const;
161  GEO_PrimVolumeXform getVolumeIndexTransform() const;
162  GT_PrimitiveHandle getPointPrimitive();
164  { return getPrimitive(); }
165  const GU_ConstDetailHandle &getDetail() const { return myDetail; }
166 
168  { return myVolumeAttributes.entries(); }
170  { return myVolumeAttributes(i); }
172  { myVolumeAttributes.append(prim); }
173 
174  /// Set the list of uniform attributes.
176  {
177  myUniformList = uniform;
178  }
179 
181  { return myUniformList; }
182  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
183  const GT_RefineParms &refine) override;
184 
185  bool getFlip() const { return myFlip; }
186  bool isVolumeReduced() const { return myVolumeReduced; }
187  void flagVolumeReduced() const { myVolumeReduced = true; }
188 
189 private:
190  const GEO_Primitive *getPrimitive() const;
191 
192  GU_PrimVolumeCache *myCache;
193  GT_AttributeListHandle myUniformList;
194 
195  // Is either VDB or Volume.
196  GU_ConstDetailHandle myDetail;
197  GA_Offset myPrimOffset;
198  int myCollationIndex;
199  UT_Array<const GEO_Primitive *> myVolumeAttributes;
200  mutable int64 myCacheVersion[2];
201  mutable bool myIsosurfaceFlag = false;
202  mutable bool mySmokeVolumeFlag = false;
203  mutable bool myHeightFieldFlag = false;
204  mutable bool myIs3DVolume = true;
205  mutable bool myIsImageVolume = false;
206  mutable bool myFlip = false;
207  mutable GT_PrimitiveHandle myMesh;
208  mutable UT_Vector2i myMeshSize;
209  mutable UT_Vector3F myMeshP0;
210  mutable UT_Vector3F myMeshP1;
211  mutable UT_Vector3F myMeshP2;
212  mutable UT_Vector3F myMeshP3;
213  mutable UT_Vector3F myMeshN0;
214  mutable UT_Vector3F myMeshN1;
215  mutable UT_Vector3F myMeshN2;
216  mutable UT_Vector3F myMeshN3;
217  mutable UT_Array<gt_BlendMask> myBlendMaskState;
218  mutable bool myVolumeReduced = false;
219  static int64 theMeshDataID;
220  static int64 theMeshTopID;
221 };
222 
223 /// Trivial collector class for Volume - 1 GT_PrimVolume per Volume primitive
224 /// with the visualization set to 'volume'.
226 {
227 public:
230 
232  beginCollecting(const GT_GEODetailListHandle &geometry,
233  const GT_RefineParms *parms) const override;
234 
236  const GEO_Primitive *const* prim_list,
237  int,
238  GT_GEOPrimCollectData *) const override;
239 
241  endCollecting(const GT_GEODetailListHandle &geometry,
242  GT_GEOPrimCollectData *data) const override;
243 };
244 
245 #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:646
int getPrimitiveType() const override
Definition: GT_PrimVolume.h:95
virtual GT_PrimitiveHandle endCollecting(const GT_GEODetailListHandle &geometry, GT_GEOPrimCollectData *data) const
GEO_VolumeBorder
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
~GT_GEOPrimCollectVolume() override
fpreal64 fpreal
Definition: SYS_Types.h:277
Utility class for containing a color ramp.
Definition: UT_Ramp.h:92
GLuint index
Definition: glcorearb.h:786
GT_PrimVolumeRampMode emissionRampType
Definition: GT_PrimVolume.h:65
IMF_EXPORT bool isImage(const std::string &name)
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:895
const char * className() const override
Definition: GT_PrimVolume.h:98
GLenum src
Definition: glcorearb.h:1793