HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_VolumeGL3.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: GR_VolumeGL3.h ( GR Library, C++)
7  *
8  * COMMENTS:
9  * Volume rendering in GL3.
10  */
11 #ifndef GR_VolumeGL3_h
12 #define GR_VolumeGL3_h
13 
14 class UT_Color;
15 class RE_OGLTexture;
16 class GU_PrimVolume;
17 struct gr_VolumeAngleVector;
18 class GR_VolumeSlice;
19 
20 #include "GR_GeoRenderGL.h"
21 
22 #include <RE/RE_Geometry.h>
23 #include <UT/UT_BoundingBox.h>
24 #include <UT/UT_Lock.h>
25 #include <UT/UT_Array.h>
26 #include <UT/UT_Vector3.h>
27 #include <GU/GU_Detail.h>
28 #include <GEO/GEO_PrimVolume.h>
29 
30 #include "GR_TextureRef.h" // for GR_TextureRef
31 
32 // Base class for volume slice rendering
33 // Creates a set of slices with individual properties
34 // and assigned texture, based on the volume bounds
36 {
37 public:
38  GR_VolumeBase();
40 
41 
42  void setTexture(GR_TextureRef tex);
43 
44  void updateTexture(GR_TextureRef tex);
45  void clearTexture();
46  const GR_TextureRef &getTexture() const { return myVolumeTexture; }
47 
48  UT_Array<GR_VolumeSlice *> &slices() { return myGLVolumeSlices; }
49 
50  static void cleanupSlices();
51 
52  void setDrawMotionVectors(bool v) { myDrawMotionVectors = v; }
53  bool getDrawMotionVectors() const
54  { return myDrawMotionVectors; }
55 
56  void setDrawNormals(bool v) { myDrawNormals = v; }
57  bool getDrawNormals() const { return myDrawNormals; }
58 
59  void setIsSelected(bool v) { myIsSelected = v; }
60  bool getIsSelected() const { return myIsSelected; }
61 
62 
63  static float getCutoff(int x, int y, int z);
64  static void fillBSplineData(const UT_Span<fpreal32> &out_values);
65  static bool useBSplineInterpolation(const GR_CommonDispOption& opt);
66 
67  bool update( const GT_PrimitiveHandle &primh,
68  const GR_UpdateParms &p);
69  void setInstanceTransforms(const UT_Matrix4DArray& inst);
70  bool updateViewAligned(UT_Matrix4D &proj,
71  UT_Matrix4D &view,
72  UT_Matrix4D &object,
73  const GR_DisplayOption &drawOpt);
74 
75  const UT_Matrix4DArray& getInstanceTransforms() const { return myInstanceTransforms; }
76 
77 private:
78 
79  static void sliceCube(void *data, int idx, int num, UT_Lock &lock);
80  static void barycenterTriangulateConvexPoly(const UT_Vector3Array &points,
81  float tolerance2,
82  UT_Vector3Array *out_points,
83  int total_depth=1, int d=0);
84  static void sortPolygonCCW(gr_VolumeAngleVector *points, int n);
85  static UT_Vector3 pointAverage(const UT_Vector3Array &points);
86  static void triangulate(const UT_Vector3Array &points,
87  float tolerance2,
88  UT_Vector3Array *out_points,
89  int total_depth=-1, int d=0);
90 
91  static constexpr int getMaxVolumeSilces();
92 
93  bool instanceSlices(UT_Matrix4D &proj,
94  UT_Matrix4D &view, UT_Matrix4D &object,
95  fpreal zinc);
96 
97  void clearSlices(bool free);
98 
99  GU_Detail myBox;
100  GEO_PrimVolumeXform myVolumeSpace;
101  UT_Vector3I myVolumeRes;
102  UT_BoundingBox myVolumeBounds;
103  GR_TextureRef myVolumeTexture;
104  UT_Matrix4DArray myInstanceTransforms;
105  bool myDrawMotionVectors;
106  bool myDrawNormals;
107  bool myIsSelected;
108 
109  static int theVolumePassID;
110 
111  UT_Array<GR_VolumeSlice *> myGLVolumeSlices;
112  UT_Array<GR_VolumeSlice *> myCachedSlices;
113  };
114 
115 
116 // Class for rendering volume slices in GL3, using slices generated by GR_VolumeBase
118 {
119 public:
121  ~GR_VolumeGL3() override;
122 
123  const char *className() const override { return "GR_VolumeGL3"; }
124 
126  const GT_PrimitiveHandle &primh,
127  const GR_UpdateParms &p,
128  const char *cache_name) override;
129 
131  const GR_DisplayOption &opts,
132  const char *cache_name,
133  RE_CacheVersion geo_version,
134  RE_CacheVersion select_version) override;
135  void draw(RE_RenderContext r,
138  GR_DrawParms dp) override;
139 
140  exint getNumGLPrimitives() const override;
141 
143 
144 private:
145  void drawSlices(RE_Render *r,
147  bool draw_normals,
148  GR_RenderMode render_mode,
149  const GR_DisplayOption *opt);
150 
151  GR_VolumeBase* myVolume;
152 };
153 
154 #endif
GR_VolumeGL3(GR_Primitive *prim, GR_VolumeBase *base)
GLbitfield flags
Definition: glcorearb.h:1596
void setInstanceTransforms(const UT_Matrix4DArray &inst)
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
static float getCutoff(int x, int y, int z)
const GLdouble * v
Definition: glcorearb.h:837
static bool useBSplineInterpolation(const GR_CommonDispOption &opt)
const char * className() const override
Definition: GR_VolumeGL3.h:123
~GR_VolumeGL3() override
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
UT_Array< GR_VolumeSlice * > & slices()
Definition: GR_VolumeGL3.h:48
int64 exint
Definition: SYS_Types.h:125
GT_API const UT_StringHolder cache_name
void setIsSelected(bool v)
Definition: GR_VolumeGL3.h:59
void updateTexture(GR_TextureRef tex)
GLint y
Definition: glcorearb.h:103
void setTexture(GR_TextureRef tex)
Temporary container for either a RV_Render and an RE_Render.
set of parameters sent to GR_Primitive::update()
const UT_Matrix4DArray & getInstanceTransforms() const
Definition: GR_VolumeGL3.h:75
void clearTexture()
void draw(RE_RenderContext r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms dp) override
Normal drawing method. Only issue rendering commands.
GLdouble n
Definition: glcorearb.h:2008
void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p, const char *cache_name) override
GR_RenderMode
Definition: GR_Defines.h:48
void viewUpdate(RE_RenderContext r, const GR_DisplayOption &opts, const char *cache_name, RE_CacheVersion geo_version, RE_CacheVersion select_version) override
bool getDrawNormals() const
Definition: GR_VolumeGL3.h:57
GR_RenderFlags
Definition: GR_Defines.h:88
GLint GLenum GLint x
Definition: glcorearb.h:409
const GR_TextureRef & getTexture() const
Definition: GR_VolumeGL3.h:46
void setDrawNormals(bool v)
Definition: GR_VolumeGL3.h:56
GLenum mode
Definition: glcorearb.h:99
static void fillBSplineData(const UT_Span< fpreal32 > &out_values)
bool update(const GT_PrimitiveHandle &primh, const GR_UpdateParms &p)
bool getIsSelected() const
Definition: GR_VolumeGL3.h:60
bool getDrawMotionVectors() const
Definition: GR_VolumeGL3.h:53
void setDrawMotionVectors(bool v)
Definition: GR_VolumeGL3.h:52
fpreal64 fpreal
Definition: SYS_Types.h:278
static RE_Texture * getBSplineWeights(RE_Render *r)
static void cleanupSlices()
Simple class for a mutli-integer cache tag.
bool updateViewAligned(UT_Matrix4D &proj, UT_Matrix4D &view, UT_Matrix4D &object, const GR_DisplayOption &drawOpt)
GLboolean r
Definition: glcorearb.h:1222
exint getNumGLPrimitives() const override
Definition: format.h:1821