HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GR_PrimTetra.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef __GR_PrimTetra__
27 #define __GR_PrimTetra__
28 
29 #include <GUI/GUI_PrimitiveHook.h>
30 #include <GR/GR_Primitive.h>
31 
32 namespace HDK_Sample
33 {
34 
35 /// The primitive render hook which creates GR_PrimTetra objects.
37 {
38 public:
40  ~GR_PrimTetraHook() override;
41 
42  /// This is called when a new GR_Primitive is required for a tetra.
43  /// gt_prim or geo_prim contains the GT or GEO primitive this object is being
44  /// created for, depending on whether this hook is registered to capture
45  /// GT or GEO primitives.
46  /// info and cache_name should be passed down to the GR_Primitive
47  /// constructor.
48  /// processed should return GR_PROCESSED or GR_PROCESSED_NON_EXCLUSIVE if
49  /// a primitive is created. Non-exclusive allows other render hooks or the
50  /// native Houdini primitives to be created for the same primitive, which is
51  /// useful for support hooks (drawing decorations, bounding boxes, etc).
53  const GEO_Primitive *geo_prim,
54  const GR_RenderInfo *info,
55  const char *cache_name,
56  GR_PrimAcceptResult &processed
57  ) override;
58 };
59 
60 /// Primitive object that is created by GR_PrimTetraHook whenever a
61 /// tetrahedron primitive is found. This object can be persistent between
62 /// renders, though display flag changes or navigating though SOPs can cause
63 /// it to be deleted and recreated later.
64 class GR_PrimTetra : public GR_Primitive
65 {
66 public:
67  GR_PrimTetra(const GR_RenderInfo *info,
68  const char *cache_name,
69  const GEO_Primitive *prim);
70  ~GR_PrimTetra() override;
71 
72  const char *className() const override { return "GR_PrimTetra"; }
73 
74  /// See if the tetra primitive can be consumed by this primitive. Only
75  /// tetra from the same detail will ever be passed in.
77  int geo_type,
78  const GT_PrimitiveHandle &ph,
79  const GEO_Primitive *prim) override;
80 
81  /// Called whenever the parent detail is changed, draw modes are changed,
82  /// selection is changed, or certain volatile display options are changed
83  /// (such as level of detail).
84  void update(RE_Render *r,
85  const GT_PrimitiveHandle &primh,
86  const GR_UpdateParms &p) override;
87 
88  /// Called whenever the primitive is required to render, which may be more
89  /// than one time per viewport redraw (beauty, shadow passes, wireframe-over)
90  /// It also may be called outside of a viewport redraw to do picking of the
91  /// geometry.
92  void render(RE_Render *r,
93  GR_RenderMode render_mode,
95  GR_DrawParms dp) override;
96  void renderDecoration(
97  RE_Render *r,
98  GR_Decoration decor,
99  const GR_DecorationParms &parms) override;
100  int renderPick(RE_Render *r,
101  const GR_DisplayOption *opt,
102  unsigned int pick_type,
103  GR_PickStyle pick_style,
104  bool has_pick_map) override;
105 private:
106  int myID;
107  RE_Geometry *myGeo;
108  bool myInstancedFlag;
109 };
110 
111 
112 
113 } // End HDK_Sample namespace.
114 
115 #endif
void render(RE_Render *r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp) override
Definition: GR_PrimTetra.C:271
GLenum GLsizei GLsizei GLsizei GLsizei GLbitfield flags
Definition: glew.h:2864
A collection of vertex arrays defining a geometry object. This class acts as a wrapper around multipl...
Definition: RE_Geometry.h:53
GT_API const UT_StringHolder cache_name
GR_Decoration
Definition: GR_Defines.h:142
int renderPick(RE_Render *r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map) override
Definition: GR_PrimTetra.C:405
set of parameters sent to GR_Primitive::update()
GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t, int geo_type, const GT_PrimitiveHandle &ph, const GEO_Primitive *prim) override
Definition: GR_PrimTetra.C:79
GR_RenderMode
Definition: GR_Defines.h:44
The primitive render hook which creates GR_PrimTetra objects.
Definition: GR_PrimTetra.h:36
void update(RE_Render *r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p) override
Definition: GR_PrimTetra.C:92
const char * className() const override
Return a string version of this class's name.
Definition: GR_PrimTetra.h:72
GR_PrimAcceptResult
Definition: GR_Defines.h:332
GR_RenderFlags
Definition: GR_Defines.h:81
GT_PrimitiveType
GLfloat GLfloat p
Definition: glew.h:16321
void renderDecoration(RE_Render *r, GR_Decoration decor, const GR_DecorationParms &parms) override
Definition: GR_PrimTetra.C:394
GR_Primitive * createPrimitive(const GT_PrimitiveHandle &gt_prim, const GEO_Primitive *geo_prim, const GR_RenderInfo *info, const char *cache_name, GR_PrimAcceptResult &processed) override
Definition: GR_PrimTetra.C:53
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
GR_PrimTetra(const GR_RenderInfo *info, const char *cache_name, const GEO_Primitive *prim)
Definition: GR_PrimTetra.C:62
GLdouble GLdouble t
Definition: glew.h:1398
GR_PickStyle
Definition: GR_Defines.h:231