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_GeoRender.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 class GR_VolumeGL3 : public GR_GeoRender
31 {
32 public:
34  ~GR_VolumeGL3() override;
35 
36  const char *className() const override { return "GR_VolumeGL3"; }
37 
38  void update(RE_Render *r,
39  const GT_PrimitiveHandle &primh,
40  const GR_UpdateParms &p,
41  const char *cache_name) override;
42 
43  void viewUpdate(RE_Render *r,
44  const GR_DisplayOption &opts,
45  const char *cache_name,
46  RE_CacheVersion geo_version,
47  RE_CacheVersion select_version) override;
48  void draw(RE_Render *r,
51  GR_DrawParms dp) override;
52 
53  void setTexture(const RE_TextureHolder &tex)
54  {
55  myVolumeTexture = tex;
56  if(tex.isValid())
57  {
58  myVolumeRes.assign(tex->getWidth(),
59  tex->getHeight(),
60  tex->getDepth());
61  }
62  }
63 
64  void updateTexture(const RE_TextureHolder &tex);
65  void clearTexture();
66 
67  static void cleanupSlices();
68 
69  exint getNumGLPrimitives() const override;
70 
71  void setDrawMotionVectors(bool v) { myDrawMotionVectors = v; }
72  void setDrawNormals(bool v) { myDrawNormals = v; }
73 
74  static float getCutoff(int x, int y, int z);
75  static bool useBSplineInterpolation(const GR_CommonDispOption& opt);
77 
78 private:
79  bool updateViewAligned(RE_Render *r,
80  const GR_DisplayOption &drawOpt);
81  static void sliceCube(void *data, int idx, int num, UT_Lock &lock);
82  static void barycenterTriangulateConvexPoly(const UT_Vector3Array &points,
83  float tolerance2,
84  UT_Vector3Array *out_points,
85  int total_depth=1, int d=0);
86  static void sortPolygonCCW(gr_VolumeAngleVector *points, int n);
87  static UT_Vector3 pointAverage(const UT_Vector3Array &points);
88  static void triangulate(const UT_Vector3Array &points,
89  float tolerance2,
90  UT_Vector3Array *out_points,
91  int total_depth=-1, int d=0);
92 
93  bool instanceSlices(RE_Render *r,
94  UT_Matrix4D &view, UT_Matrix4D &object,
95  fpreal zinc);
96  void drawSlices(RE_Render *r,
98  GR_RenderMode render_mode,
99  const GR_DisplayOption *opt);
100  void clearSlices();
101 
102  GU_Detail myBox;
103  GEO_PrimVolumeXform myVolumeSpace;
104  UT_Vector3I myVolumeRes;
105  UT_BoundingBox myVolumeBounds;
106  RE_TextureHolder myVolumeTexture;
107  UT_Matrix4DArray myInstanceTransforms;
108  bool myDrawMotionVectors;
109  bool myDrawNormals;
110 
111  static int theVolumePassID;
112 
113  UT_Array<GR_VolumeSlice *> myGLVolumeSlices;
114  };
115 
116 #endif
void viewUpdate(RE_Render *r, const GR_DisplayOption &opts, const char *cache_name, RE_CacheVersion geo_version, RE_CacheVersion select_version) override
void setDrawMotionVectors(bool v)
Definition: GR_VolumeGL3.h:71
int getWidth() const
const char * className() const override
Definition: GR_VolumeGL3.h:36
void draw(RE_Render *r, GR_RenderMode mode, GR_RenderFlags flags, GR_DrawParms dp) override
Normal drawing method. Only issue rendering commands.
~GR_VolumeGL3() override
int64 exint
Definition: SYS_Types.h:125
GT_API const UT_StringHolder cache_name
int getDepth() const
void setDrawNormals(bool v)
Definition: GR_VolumeGL3.h:72
GLint GLenum GLint x
Definition: glcorearb.h:409
set of parameters sent to GR_Primitive::update()
GR_VolumeGL3(GR_Primitive *prim)
GR_RenderMode
Definition: GR_Defines.h:46
void setTexture(const RE_TextureHolder &tex)
Definition: GR_VolumeGL3.h:53
const GLdouble * v
Definition: glcorearb.h:837
static bool useBSplineInterpolation(const GR_CommonDispOption &opt)
GLuint num
Definition: glew.h:2695
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
GLfloat GLfloat p
Definition: glew.h:16656
GR_RenderFlags
Definition: GR_Defines.h:84
GLbitfield flags
Definition: glcorearb.h:1596
int getHeight() const
static float getCutoff(int x, int y, int z)
bool isValid() const
Definition: RE_TextureMap.h:56
GLenum mode
Definition: glcorearb.h:99
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glew.h:3460
GLdouble n
Definition: glcorearb.h:2008
void assign(T xx=0.0f, T yy=0.0f, T zz=0.0f)
Set the values of the vector components.
Definition: UT_Vector3.h:684
static void cleanupSlices()
fpreal64 fpreal
Definition: SYS_Types.h:277
static RE_Texture * getBSplineWeights(RE_Render *r)
Definition: core.h:982
Simple class for a mutli-integer cache tag.
void clearTexture()
void update(RE_Render *r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p, const char *cache_name) override
exint getNumGLPrimitives() const override
GLboolean r
Definition: glcorearb.h:1222
void updateTexture(const RE_TextureHolder &tex)
GLint y
Definition: glcorearb.h:103
Definition: format.h:895