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