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,
72  UT_Matrix4D &object,
73  const GR_DisplayOption &drawOpt);
74 
75 private:
76 
77  static void sliceCube(void *data, int idx, int num, UT_Lock &lock);
78  static void barycenterTriangulateConvexPoly(const UT_Vector3Array &points,
79  float tolerance2,
80  UT_Vector3Array *out_points,
81  int total_depth=1, int d=0);
82  static void sortPolygonCCW(gr_VolumeAngleVector *points, int n);
83  static UT_Vector3 pointAverage(const UT_Vector3Array &points);
84  static void triangulate(const UT_Vector3Array &points,
85  float tolerance2,
86  UT_Vector3Array *out_points,
87  int total_depth=-1, int d=0);
88 
89  static constexpr int getMaxVolumeSilces();
90 
91  bool instanceSlices(UT_Matrix4D &proj,
92  UT_Matrix4D &view, UT_Matrix4D &object,
93  fpreal zinc);
94 
95  void clearSlices();
96 
97  GU_Detail myBox;
98  GEO_PrimVolumeXform myVolumeSpace;
99  UT_Vector3I myVolumeRes;
100  UT_BoundingBox myVolumeBounds;
101  GR_TextureRef myVolumeTexture;
102  UT_Matrix4DArray myInstanceTransforms;
103  bool myDrawMotionVectors;
104  bool myDrawNormals;
105  bool myIsSelected;
106 
107  static int theVolumePassID;
108 
109  UT_Array<GR_VolumeSlice *> myGLVolumeSlices;
110  };
111 
112 
113 // Class for rendering volume slices in GL3, using slices generated by GR_VolumeBase
115 {
116 public:
118  ~GR_VolumeGL3() override;
119 
120  const char *className() const override { return "GR_VolumeGL3"; }
121 
123  const GT_PrimitiveHandle &primh,
124  const GR_UpdateParms &p,
125  const char *cache_name) override;
126 
128  const GR_DisplayOption &opts,
129  const char *cache_name,
130  RE_CacheVersion geo_version,
131  RE_CacheVersion select_version) override;
132  void draw(RE_RenderContext r,
135  GR_DrawParms dp) override;
136 
137  exint getNumGLPrimitives() const override;
138 
140 
141 private:
142  void drawSlices(RE_Render *r,
144  bool draw_normals,
145  GR_RenderMode render_mode,
146  const GR_DisplayOption *opt);
147 
148  GR_VolumeBase* myVolume;
149 };
150 
151 #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:120
~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()
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:86
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:277
static RE_Texture * getBSplineWeights(RE_Render *r)
static void cleanupSlices()
Definition: core.h:982
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:895