-
Notifications
You must be signed in to change notification settings - Fork 1
/
GUI_Neutron.h
111 lines (94 loc) · 4.29 KB
/
GUI_Neutron.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef __GUI_PolySoupBox__
#define __GUI_PolySoupBox__
#include <GUI/GUI_PrimitiveHook.h>
#include <GR/GR_Primitive.h>
//forward declarations. Include is in cpp file
class RE_Geometry;
class RE_OGLFramebuffer;
class RE_OGLTexture;
class mySim;
namespace HDK_Sample
{
/// The primitive render hook which creates GUI_PolySoupBox objects.
class GUI_NeutronHook : public GUI_PrimitiveHook
{
public:
GUI_NeutronHook();
virtual ~GUI_NeutronHook();
/// This is called when a new GR_Primitive is required for a polysoup.
/// In this case, the hook is augmenting the rendering of the polysoup by
/// drawing a bounding box and a centroid around it.
virtual GR_Primitive *createPrimitive(const GT_PrimitiveHandle >_prim,
const GEO_Primitive *geo_prim,
const GR_RenderInfo *info,
const char *cache_name,
GR_PrimAcceptResult &processed);
};
/// Primitive object that is created by GUI_PolySoupBoxHook whenever a
/// polysoup primitive is found. This object can be persistent between
/// renders, though display flag changes or navigating though SOPs can cause
/// it to be deleted and recreated later.
class GUI_Neutron : public GR_Primitive
{
public:
GUI_Neutron(const GR_RenderInfo *info,
const char *cache_name,
const GEO_Primitive *prim);
virtual ~GUI_Neutron();
virtual const char *className() const { return "GUI_Neutron"; }
/// See if the primitive can be consumed by this GR_Primitive. Only
/// primitives from the same detail will ever be passed in. If the
/// primitive hook specifies GUI_HOOK_COLLECT_PRIMITIVES then it is
/// possible to have this called more than once for different GR_Primitives.
/// A GR_Primitive that collects multiple GT or GEO primitives is
/// responsible for keeping track of them (in a list, table, tree, etc).
virtual GR_PrimAcceptResult acceptPrimitive(GT_PrimitiveType t,
int geo_type,
const GT_PrimitiveHandle &ph,
const GEO_Primitive *prim);
/// Called whenever the parent detail is changed, draw modes are changed,
/// selection is changed, or certain volatile display options are changed
/// (such as level of detail).
virtual void update(RE_Render *r,
const GT_PrimitiveHandle &primh,
const GR_UpdateParms &p);
/// For this primitive hook, which only renders decorations, the render
/// methods do nothing, allowing the native Houdini code to do the work.
/// @{
virtual void render(RE_Render *r,
GR_RenderMode render_mode,
GR_RenderFlags flags,
GR_DrawParms dp);
virtual int renderPick(RE_Render *r,
const GR_DisplayOption *opt,
unsigned int pick_type,
GR_PickStyle pick_style,
bool has_pick_map);
virtual void renderDecoration(RE_Render *r,
GR_Decoration decor,
const GR_DecorationParms &p);
/// @}
//virtual bool requiresAlphaPass() const { return true; }
//virtual bool renderInAlphaPass(GR_AlphaPass a) { return false; }
private:
RE_Geometry *myGeometry;
RE_Shader *sh;
RE_Shader *shMain;
RE_OGLFramebuffer *frontPosition;
RE_OGLFramebuffer *backPosition;
RE_Texture *frontTexture;
RE_Texture *backTexture;
RE_Texture *volumeTexture;
//bind points for shader
int fT;
int bT;
int vT;
//so we can track viewport size changes
int lastWidth = -1;
int lastHeight = -1;
void setupFrameBuffers(RE_Render *r, int width, int height);
void setup3dVolume(RE_Render *r, float textureScale);
void compileShader(RE_Render *r, mySim& simObject);
};
} // End HDK_Sample namespace.
#endif