HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DM_SceneHook.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: DM_SceneHook.h ( DM Library, C++)
7  *
8  * COMMENTS:
9  * Base class to hook into various parts of the scene rendering pipeline.
10  */
11 #ifndef DM_SCENE_HOOK_H
12 #define DM_SCENE_HOOK_H
13 
14 #include "DM_API.h"
15 #include "DM_ViewportType.h"
16 
17 #include <UT/UT_Rect.h>
18 #include <UT/UT_String.h>
19 #include <RE/RE_RenderContext.h>
20 #include <GR/GR_Defines.h>
21 #include <GR/GR_PickRecord.h>
22 
23 class DM_VPortAgent;
24 class GUI_DisplayOption;
25 class RE_Light;
26 class RE_Render;
27 class OP_Node;
28 
29 #define DM_SCENE_HOOK_VERSION 3
30 
31 /// The rendering task that the hook performs.
33 {
42 
43  // Replace-only hooks
46 
47  // Pick renders
50 
52 };
53 
54 /// How the hook augments or replaces the native Houdini rendering task.
56 {
60 };
61 
63 {
66 
68 };
69 
70 /// Data structure for rendering scene hooks.
72 {
73 public:
74  // class containing all viewport display options
76 
77  // Size of the viewport in pixels
80 
81  // only non-NULL in DM_HOOK_SHADOW and DM_HQ_LIGHT_PASS
83 
84  // In case this is registered more than once to different spots, this
85  // allows the hook to differentiate the callers.
88 
89  // For picking, what is being requested for picking
90  // (GR_PICK_* in GR_PickRecord.h)
91  int pick_type;
92 
93  // Frustum culling picks only
95  const uint8 *pick_mask;
96 };
97 
98 
99 
100 /// Scene render hook instance, which does the actual rendering for a viewport
102 {
103 public:
104  /// A Scene render hook has a parent viewport and a view type mask which
105  /// determines which viewport types it will display in (eg. perspective,
106  /// ortho, UV, all). The viewer_scope determines which viewer type it will
107  /// appear in (Obj/Sop/Dop, or Lop).
109  DM_ViewportType view_mask);
110  virtual ~DM_SceneRenderHook();
111 
112  /// @brief Restrict hook to only certain Viewport Renderer versions
113  /// This method allows you to restrict this hook to only operate in some of
114  /// the viewport renderers (H11 - GL3). If the viewport is set to a
115  /// a renderer and this method returns false, it will be skipped. The
116  /// default action is to support all viewport renderers.
118  { return true; }
119 
120  /// @brief Render method called when the rendering task is required.
121  /// render() performs the rendering task for the hook, or returns false if
122  /// if it cannot. The RE_Render contains the active GL context and the
123  /// hook_data contains viewport-specific and hook-specific data.
124  virtual bool render(RE_RenderContext r,
125  const DM_SceneHookData &hook_data) = 0;
126 
127  /// @brief Callback method when the viewport is no longer visible.
128  /// Called when the viewport is temporarily closed (quad/single switch, pane
129  /// switch). This gives the hook the opportunity to clean up expensive GL
130  /// objects or caches.
131  virtual void viewportClosed();
132 
133  /// For hooks that register with DM_HOOK_FRAMEBUFFER_PICK, this reports the
134  /// selection back to the hook once it is complete.
135  /// only picks for this hook are returned, and this may be an empty list.
136  virtual void selectionResult(const UT_Array<GR_PickRecord> &selection);
137 
138  /// Viewport this scene render is attached to.
139  DM_VPortAgent &viewport() const { return myAgent; }
140  DM_ViewportType getViewportMask() const { return myViewportMask; }
141  int getID() const { return myID; }
142 
143  /// Get the currently displayed LOP (LOP hook specific)
144  const OP_Node *getDisplayLOP() const;
145 
146  /// Get the current LOP, the LOP that is displaying handles and in the parm
147  /// dialog (LOP hook specific)
148  const OP_Node *getCurrentLOP() const;
149 private:
150  DM_VPortAgent &myAgent;
151  DM_ViewportType myViewportMask;
152  int myID;
153 };
154 
155 
156 
157 /// A Scene Hook creates new scene render hooks when new viewports are created.
159 {
160 public:
161  /// Create a scene hook which creates scene render hook instances for
162  /// specific viewports. Only one scene hook is ever created, and it is
163  /// responsible for managing the scene render hooks for viewports.
164  /// Each hook requires a name (for error reporting) and a priority level
165  /// to resolve multiple scene hook conflicts.
166  DM_SceneHook(const char *hook_name,
167  int priority,
168  DM_SceneHookScope viewer_scope);
169  virtual ~DM_SceneHook();
170 
171  const char *getName() const { return myHookName; }
172  int getPriority() const { return myPriority; }
173  DM_SceneHookScope getViewerScope() const { return myViewerScope; }
174 
175  /// @brief Called when a viewport needs to create a new hook.
176  /// Each viewport has its own scene hook.
177  virtual DM_SceneRenderHook *newSceneRender(DM_VPortAgent &vport,
180 
181  /// @brief Called when a viewport no longer requires the hook.
182  /// When a viewport is destroyed, it retires all its hooks. Because a hook
183  /// could be shared between all viewports, this method gives the scene hook
184  /// the opportunity to delete it, dereference it, etc. The viewport doing
185  /// the retiring is passed in along with the hook it is retiring.
186  virtual void retireSceneRender(DM_VPortAgent &vport,
187  DM_SceneRenderHook *hook) = 0;
188 
189 private:
190  UT_String myHookName;
191  int myPriority;
192  DM_SceneHookScope myViewerScope;
193 };
194 #endif
virtual bool supportsRenderer(GR_RenderVersion version)
Restrict hook to only certain Viewport Renderer versions This method allows you to restrict this hook...
Definition: DM_SceneHook.h:117
GT_API const UT_StringHolder selection
Scene render hook instance, which does the actual rendering for a viewport.
Definition: DM_SceneHook.h:101
hboost::math::policies::policy< hboost::math::policies::domain_error< hboost::math::policies::ignore_error >, hboost::math::policies::pole_error< hboost::math::policies::ignore_error >, hboost::math::policies::overflow_error< hboost::math::policies::ignore_error >, hboost::math::policies::underflow_error< hboost::math::policies::ignore_error >, hboost::math::policies::denorm_error< hboost::math::policies::ignore_error >, hboost::math::policies::rounding_error< hboost::math::policies::ignore_error >, hboost::math::policies::evaluation_error< hboost::math::policies::ignore_error >, hboost::math::policies::indeterminate_result_error< hboost::math::policies::ignore_error > > policy
Definition: SYS_MathCbrt.h:35
DM_ViewportType getViewportMask() const
Definition: DM_SceneHook.h:140
DM_SceneHookScope
Definition: DM_SceneHook.h:62
int getID() const
Definition: DM_SceneHook.h:141
Temporary container for either a RV_Render and an RE_Render.
IFDmantra you can see code vm_image_mplay_direction endcode When SOHO starts a render
Definition: HDK_Image.dox:266
const GUI_DisplayOption * disp_options
Definition: DM_SceneHook.h:75
#define DM_API
Definition: DM_API.h:10
unsigned char uint8
Definition: SYS_Types.h:36
UT_DimRect pick_area
Definition: DM_SceneHook.h:94
DM_SceneHookType
The rendering task that the hook performs.
Definition: DM_SceneHook.h:32
int getPriority() const
Definition: DM_SceneHook.h:172
Data structure for rendering scene hooks.
Definition: DM_SceneHook.h:71
DM_SceneHookScope getViewerScope() const
Definition: DM_SceneHook.h:173
RE_Light * light
Definition: DM_SceneHook.h:82
GR_RenderVersion
Definition: GR_Defines.h:22
GT_API const UT_StringHolder version
A Scene Hook creates new scene render hooks when new viewports are created.
Definition: DM_SceneHook.h:158
const char * getName() const
Definition: DM_SceneHook.h:171
DM_SceneHookPolicy hook_policy
Definition: DM_SceneHook.h:87
GLboolean r
Definition: glcorearb.h:1222
DM_SceneHookPolicy
How the hook augments or replaces the native Houdini rendering task.
Definition: DM_SceneHook.h:55
type
Definition: core.h:1059
DM_SceneHookType hook_type
Definition: DM_SceneHook.h:86
int DM_ViewportType
DM_VPortAgent & viewport() const
Viewport this scene render is attached to.
Definition: DM_SceneHook.h:139
const uint8 * pick_mask
Definition: DM_SceneHook.h:95