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 
52 
54  float diffuseRange[2];
58 
61  float emissionRange[2];
64 
69 
71 };
72 
74 {
75 public:
77  const GEO_Primitive *prim,
78  const GT_DataArrayHandle &mat_id);
80  ~GT_PrimVolume() override;
81 
82  void getVisData(GT_PrimVolumeVisualization& v) const;
83  int getTileCoords(UT_Vector3FArray& coords, UT_Int16Array& masks) const;
84 
85  /// Returns true if the geometry primitive's parent detail has the "gl_wireframe"
86  /// attribute set.
87  bool drawWireframe() const;
88 
89  /// Returns true if the motion vectors are to be drawn for this volume set.
90  bool drawMotionVectors() const;
91  bool drawNormals() const;
92 
93  int getPrimitiveType() const override
94  { return GT_PRIM_VOXEL_VOLUME; }
95 
96  const char *className() const override { return "GT_PrimVolume"; }
97 
98  void enlargeBounds(UT_BoundingBox boxes[],
99  int nsegments) const override;
100  int getMotionSegments() const override { return 1; }
101  int64 getMemoryUsage() const override;
103  { return new GT_PrimVolume(*this); }
104 
105  bool refine(GT_Refine &refiner,
106  const GT_RefineParms *parms) const override;
107  bool refineHeightField(GT_Refine &refiner,
108  const GT_RefineParms *parms) const;
109 
110  // Isosurface
111  bool isIsosurface() const;
112  GT_PrimitiveHandle buildIsosurface(const GT_RefineParms &p,
113  bool as_points) const;
114  GU_ConstDetailHandle getIsosurfaceDetail() const;
115  UT_Vector3 getIsoCd() const;
116 
117  // Height fields
118  bool isHeightField() const;
119  GT_PrimitiveHandle buildHeightField(const GT_RefineParms &p) const;
120  GT_PrimitiveHandle buildHeightMesh(const GT_RefineParms &p,
121  UT_Vector2i &map_res) const;
123  {
127  };
128  gt_BlendMask blendMaskState(int index) const;
129 
130  // 2D/3D volume
131  bool isSmokeVolume() const;
132  bool is3DVolume() const;
133  GEO_PrimVolumeXform getVolumeSpace() const;
134 
135  UT_Vector3I getRes() const;
136 
137  void get2DBounds(UT_Vector3F &p0, UT_Vector3F &p1,
138  UT_Vector3F &p2, UT_Vector3F &p3) const;
139 
140  const UT_VoxelArray<UT_Vector4> *getVoxels(const GU_PrimVolumeCacheParms &p,
141  int64 version[2]) const;
142 
143  GEO_PrimVolumeXform getVolumeTransform() const;
144  GEO_PrimVolumeXform getVolumeIndexTransform() const;
145  GT_PrimitiveHandle getPointPrimitive();
147  { return getPrimitive(); }
148 
150  { return myVolumeAttributes.entries(); }
152  { return myVolumeAttributes(i); }
154  { myVolumeAttributes.append(prim); }
155 
156  /// Set the list of uniform attributes.
158  {
159  myUniformList = uniform;
160  }
161 
163  { return myUniformList; }
164  bool updateGeoPrim(const GU_ConstDetailHandle &dtl,
165  const GT_RefineParms &refine) override;
166 
167  bool getFlip() const { return myFlip; }
168  bool isVolumeReduced() const { return myVolumeReduced; }
169  void flagVolumeReduced() const { myVolumeReduced = true; }
170 
171 private:
172  const GEO_Primitive *getPrimitive() const;
173 
174  GU_PrimVolumeCache *myCache;
175  GT_AttributeListHandle myUniformList;
176 
177  // Is either VDB or Volume.
178  GU_ConstDetailHandle myDetail;
179  GA_Offset myPrimOffset;
180  int myCollationIndex;
181  UT_Array<const GEO_Primitive *> myVolumeAttributes;
182  mutable int64 myCacheVersion[2];
183  mutable bool myIsosurfaceFlag;
184  mutable bool mySmokeVolumeFlag;
185  mutable bool myHeightFieldFlag;
186  mutable bool myIs3DVolume;
187  mutable bool myFlip;
188  mutable GT_PrimitiveHandle myMesh;
189  mutable UT_Vector2i myMeshSize;
190  mutable UT_Vector3F myMeshP0;
191  mutable UT_Vector3F myMeshP1;
192  mutable UT_Vector3F myMeshP2;
193  mutable UT_Vector3F myMeshP3;
194  mutable UT_Array<gt_BlendMask> myBlendMaskState;
195  mutable bool myVolumeReduced;
196  static int64 theMeshDataID;
197  static int64 theMeshTopID;
198 };
199 
200 /// Trivial collector class for Volume - 1 GT_PrimVolume per Volume primitive
201 /// with the visualization set to 'volume'.
203 {
204 public:
207 
209  beginCollecting(const GT_GEODetailListHandle &geometry,
210  const GT_RefineParms *parms) const override;
211 
213  const GEO_Primitive *const* prim_list,
214  int,
215  GT_GEOPrimCollectData *) const override;
216 
218  endCollecting(const GT_GEODetailListHandle &geometry,
219  GT_GEOPrimCollectData *data) const override;
220 };
221 
222 #endif
const GEO_Primitive * emissionColorPrim[3]
Definition: GT_PrimVolume.h:65
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:53
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:68
virtual GT_GEOPrimCollectData * beginCollecting(const GT_GEODetailListHandle &geometry, const GT_RefineParms *parms) const
bool isVolumeReduced() const
void flagVolumeReduced() const
#define GT_API
Definition: GT_API.h:11
bool getFlip() const
int64 exint
Definition: SYS_Types.h:125
const GEO_Primitive * densityPrim
Definition: GT_PrimVolume.h:39
GLenum src
Definition: glcorearb.h:1792
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:640
int getPrimitiveType() const override
Definition: GT_PrimVolume.h:93
virtual GT_PrimitiveHandle endCollecting(const GT_GEODetailListHandle &geometry, GT_GEOPrimCollectData *data) const
const GLdouble * v
Definition: glcorearb.h:836
virtual GT_PrimitiveHandle collect(const GT_GEODetailListHandle &geometry, const GEO_Primitive *const *prim_list, int nsegments, GT_GEOPrimCollectData *data) const =0
int getMotionSegments() const override
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat p
Definition: glew.h:16656
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
GT_PrimVolumeRampMode diffuseRampType
Definition: GT_PrimVolume.h:56
const GEO_Primitive * emissionPrim
Definition: GT_PrimVolume.h:59
GT_API const UT_StringHolder version
Processes primitives generated by refinement process.
Definition: GT_Refine.h:20
GLboolean * data
Definition: glcorearb.h:130
exint getNumVolumeAttributes() const
~GT_GEOPrimCollectVolume() override
Utility class for containing a color ramp.
Definition: UT_Ramp.h:84
GLuint index
Definition: glcorearb.h:785
GT_PrimVolumeRampMode emissionRampType
Definition: GT_PrimVolume.h:63
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
GLenum GLuint coords
Definition: glew.h:7936
const char * className() const override
Definition: GT_PrimVolume.h:96