HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SHOP_Clerk.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: SHOP_Clerk.h ( SHOP Library, C++)
7  *
8  * COMMENTS: Defines a mapping from SHOP parameters to a renderer.
9  *
10  */
11 
12 #ifndef __SHOP_Clerk__
13 #define __SHOP_Clerk__
14 
15 #include "SHOP_API.h"
16 #include "SHOP_NodeTypes.h"
17 #include <UT/UT_BoundingBox.h>
18 #include <UT/UT_String.h>
19 
20 class UT_Options;
21 class OP_Context;
22 class OP_Node;
23 class VOP_Node;
24 class SHOP_Node;
25 class SHOP_ReData;
26 
27 extern "C" {
28  SYS_VISIBILITY_EXPORT extern void newShopClerk();
29 }
30 
32 public:
33  SHOP_Clerk();
34  virtual ~SHOP_Clerk();
35 
36  /// Function that installs the clerks from DSOs.
37  static void installClerks();
38 
39  /// Explicitly registers a new clerk for the given shader type.
40  static bool addShaderClerk(SHOP_TYPE type, SHOP_Clerk *shop);
41 
42  /// Get a list of available clerks for the given shader type.
43  /// It is very good practice not to manipulate this list.
44  static const UT_ValArray<SHOP_Clerk *> &getClerkList(SHOP_TYPE type);
45 
46  /// @{ Fetching a clerk that matches the given shader and render types.
47  static SHOP_Clerk *getClerk( const UT_Options *options,
48  const char *default_clerk, const char*rendermask,
49  SHOP_TYPE shader_type, SHOP_TYPE interpret_type,
50  bool only_string_data, bool accept_badmask = false);
51  static SHOP_Clerk *getClerk(const char *rendertype, const char*rendermask,
52  SHOP_TYPE shader_type, SHOP_TYPE interpret_type,
53  bool accept_badmask = false);
54  static SHOP_Clerk *getAnyClerk( const char *rendermask,
55  SHOP_TYPE shader_type, SHOP_TYPE interpret_type,
56  bool only_string_generators);
57  /// @}
58 
59  /// Utility function for matching render mask.
60  static bool renderMatch(const char *rendertype,
61  const char *rendermask,
62  bool accept_badmask=false);
63 
64  // Applies a create scripts specified by registered clerks for this
65  // render and shader type.
66  static void runCreateScript(const char *node_path,
67  const char *render_mask, SHOP_TYPE shader_type);
68 
69  //
70  // This render name should match the name in the IFD class. That is, this
71  // should be the type of renderer passed in for evaluation.
72  // The label is a string which can be used to describe the renderer.
73  // Typically, this string is used in menus in the UI. For example:
74  //
75  // getRenderName() { return "RIB"; }
76  // getRenderLabel() { return "RenderMan V3.7"; }
77  //
78  virtual const char *getRenderName() const = 0;
79  virtual const char *getRenderLabel() const;
80  virtual const char *getDefaultKeywords() const;
81 
82  virtual int getDialogScriptEnum(SHOP_TYPE type) const;
83 
84  virtual bool generatesString() const;
85  virtual bool requireAutoAdd(SHOP_TYPE type) const;
86 
87  /// @{
88  /// Package the SHOP parameters into shader data.
89  /// - @c shop: Build the shader string for this SHOP
90  /// - @c data/shader/box: Storage for the result of building the shader
91  /// - @c now: The evaluation time
92  /// - @c options: An arbitrary dictionary of options
93  /// - @c interpret_type: Interpret the SHOP as this type of shader. This
94  /// is used for SHOPs which can generate multiple shader types (i.e.
95  /// the material SHOP).
96  ///
97  /// The OP_Node* methods are more general and allow wider selection
98  /// of shader node representation (ie, VOPs too).
99  /// Implementing and overriding them is preferrable to overriding
100  /// the older versions that took SHOP_Node*. However, for better
101  /// compatibility with older plugin sources, the new methods call
102  ///the old ones in this base class (for now).
103  virtual bool buildOpShaderData(OP_Node *node,
104  SHOP_ReData &data, fpreal now,
105  const UT_Options *options,
106  SHOP_TYPE interpret_type);
107  virtual bool buildOpShaderString(OP_Node *node,
108  UT_String &shader, fpreal now,
109  const UT_Options *options,
110  SHOP_TYPE interpret_type);
111  virtual bool buildOpShaderBounds(OP_Node *node,
112  UT_BoundingBox &box, fpreal now,
113  const UT_Options *options,
114  SHOP_TYPE interpret_type);
115 
116  //SYS_DEPRECATED_REPLACE(14.5, buildOpShaderData)
117  virtual bool buildShaderData(SHOP_Node *shop,
118  SHOP_ReData &data,
119  fpreal now,
120  const UT_Options *options,
121  SHOP_TYPE interpret_type);
122  //SYS_DEPRECATED_REPLACE(14.5, buildOpShaderString)
123  virtual bool buildShaderString(SHOP_Node *shop,
124  UT_String &shader,
125  fpreal now,
126  const UT_Options *options,
127  SHOP_TYPE interpret_type);
128  //SYS_DEPRECATED_REPLACE(14.5, buildOpShaderBounds)
129  virtual bool buildShaderBounds(SHOP_Node *shop,
130  UT_BoundingBox &box,
131  fpreal now,
132  const UT_Options *options,
133  SHOP_TYPE interpret_type);
134  /// @}
135 
136  /// Build a shader string given a VOP node. The VOP node will @b always be
137  /// a code generator.
138  virtual bool buildVopShaderString(OP_Node *material,
139  VOP_Node *vop,
140  UT_String &shader,
141  fpreal now,
142  const UT_Options *options,
143  SHOP_TYPE interpret_type);
144 
145 
146  // When evaluating geometry shaders, the clerk may need to evaluate
147  // bounding box information. Particularly for RIB and VMantra.
148  virtual bool getBoundingBox(UT_BoundingBox &box,
149  SHOP_Node &node, OP_Context &ctx);
150 
151  //
152  // When attaching the shader information to a primitive, the shader
153  // information must be able to be stored as a string. In this case, we
154  // need to define the attribute name as well as how to build the string.
155  //
156  // If the attribute cannot be attached to geometry, then the
157  // getGeometryAttribute() function should return a null pointer.
158  // By default, this is what the getGeometryAttribute() does.
159  //
160  // The GeometryIndirect returns the name of an indirect attribute which
161  // causes the SHOP to be evaluated at render time.
162  //
163  virtual const char *getGeometryAttribute(SHOP_TYPE shader_type) const;
164  virtual const char *getGeometryIndirect(SHOP_TYPE shader_type) const;
165 
166  // Return true if we are the VEX clerk. Returns false by default.
167  virtual bool getIsVexClerk() const;
168 
169  // A creation script gets run when the SHOP has it's creation script run.
170  // This allow the clerk to add spare properties to the SHOP if required.
171  virtual const char *getCreationScript(SHOP_TYPE shader_type) const;
172 
173 protected:
174  virtual void buildShaderStart(UT_String &str,
175  const char *shader_name,
176  SHOP_Node *node);
177  virtual void buildShaderEnd(UT_String &str,
178  const char *shader_name,
179  SHOP_Node *node);
180 
181  // Evaluate the bounding box specified by the path to the OP_Node.
182  bool evalSopBoundingBox(UT_BoundingBox &box,
183  SHOP_Node &node,
184  const char *parmname,
185  fpreal now);
186 };
187 
188 #endif
#define SYS_VISIBILITY_EXPORT
#define SHOP_API
Definition: SHOP_API.h:10
SYS_VISIBILITY_EXPORT void newShopClerk()
SHOP_TYPE
GLuint shader
Definition: glcorearb.h:785
A map of string to various well defined value types.
Definition: UT_Options.h:84
fpreal64 fpreal
Definition: SYS_Types.h:277
type
Definition: core.h:1059
Definition: format.h:895