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) 2024
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 #include <RE/RE_RenderContext.h>
32 
33 namespace HDK_Sample
34 {
35 
36 /// The primitive render hook which creates GR_PrimTetra objects.
38 {
39 public:
41  ~GR_PrimTetraHook() override;
42 
43  /// This is called when a new GR_Primitive is required for a tetra.
44  /// gt_prim or geo_prim contains the GT or GEO primitive this object is being
45  /// created for, depending on whether this hook is registered to capture
46  /// GT or GEO primitives.
47  /// info and cache_name should be passed down to the GR_Primitive
48  /// constructor.
49  /// processed should return GR_PROCESSED or GR_PROCESSED_NON_EXCLUSIVE if
50  /// a primitive is created. Non-exclusive allows other render hooks or the
51  /// native Houdini primitives to be created for the same primitive, which is
52  /// useful for support hooks (drawing decorations, bounding boxes, etc).
54  const GEO_Primitive *geo_prim,
55  const GR_RenderInfo *info,
56  const char *cache_name,
57  GR_PrimAcceptResult &processed
58  ) override;
59 };
60 
61 /// Primitive object that is created by GR_PrimTetraHook whenever a
62 /// tetrahedron primitive is found. This object can be persistent between
63 /// renders, though display flag changes or navigating though SOPs can cause
64 /// it to be deleted and recreated later.
65 class GR_PrimTetra : public GR_Primitive
66 {
67 public:
68  GR_PrimTetra(const GR_RenderInfo *info,
69  const char *cache_name,
70  const GEO_Primitive *prim);
71  ~GR_PrimTetra() override;
72 
73  const char *className() const override { return "GR_PrimTetra"; }
74 
75  /// See if the tetra primitive can be consumed by this primitive. Only
76  /// tetra from the same detail will ever be passed in.
78  int geo_type,
79  const GT_PrimitiveHandle &ph,
80  const GEO_Primitive *prim) override;
81 
82  /// Called whenever the parent detail is changed, draw modes are changed,
83  /// selection is changed, or certain volatile display options are changed
84  /// (such as level of detail).
86  const GT_PrimitiveHandle &primh,
87  const GR_UpdateParms &p) override;
88 
89  /// Called whenever the primitive is required to render, which may be more
90  /// than one time per viewport redraw (beauty, shadow passes, wireframe-over)
91  /// It also may be called outside of a viewport redraw to do picking of the
92  /// geometry.
94  GR_RenderMode render_mode,
96  GR_DrawParms dp) override;
97  void renderDecoration(
99  GR_Decoration decor,
100  const GR_DecorationParms &parms) override;
102  const GR_DisplayOption *opt,
103  unsigned int pick_type,
104  GR_PickStyle pick_style,
105  bool has_pick_map) override;
106 private:
107  int myID;
108  RE_Geometry *myGeo;
109  bool myInstancedFlag;
110 };
111 
112 
113 
114 } // End HDK_Sample namespace.
115 
116 #endif
GLbitfield flags
Definition: glcorearb.h:1596
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
void renderDecoration(RE_RenderContext r, GR_Decoration decor, const GR_DecorationParms &parms) override
Definition: GR_PrimTetra.C:398
GR_Decoration
Definition: GR_Defines.h:151
Temporary container for either a RV_Render and an RE_Render.
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:80
GR_RenderMode
Definition: GR_Defines.h:47
The primitive render hook which creates GR_PrimTetra objects.
Definition: GR_PrimTetra.h:37
int renderPick(RE_RenderContext r, const GR_DisplayOption *opt, unsigned int pick_type, GR_PickStyle pick_style, bool has_pick_map) override
Definition: GR_PrimTetra.C:409
const char * className() const override
Return a string version of this class's name.
Definition: GR_PrimTetra.h:73
GR_PrimAcceptResult
Definition: GR_Defines.h:345
GR_RenderFlags
Definition: GR_Defines.h:85
void render(RE_RenderContext r, GR_RenderMode render_mode, GR_RenderFlags flags, GR_DrawParms dp) override
Definition: GR_PrimTetra.C:275
GLdouble t
Definition: glad.h:2397
GT_PrimitiveType
void update(RE_RenderContext r, const GT_PrimitiveHandle &primh, const GR_UpdateParms &p) override
Definition: GR_PrimTetra.C:93
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:54
GR_PrimTetra(const GR_RenderInfo *info, const char *cache_name, const GEO_Primitive *prim)
Definition: GR_PrimTetra.C:63
GLboolean r
Definition: glcorearb.h:1222
GR_PickStyle
Definition: GR_Defines.h:240