HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  // This render name should match the name in the IFD class. That is, this
65  // should be the type of renderer passed in for evaluation.
66  // The label is a string which can be used to describe the renderer.
67  // Typically, this string is used in menus in the UI. For example:
68  //
69  // getRenderName() { return "RIB"; }
70  // getRenderLabel() { return "RenderMan V3.7"; }
71  //
72  virtual const char *getRenderName() const = 0;
73  virtual const char *getRenderLabel() const;
74  virtual const char *getDefaultKeywords() const;
75 
76  virtual int getDialogScriptEnum(SHOP_TYPE type) const;
77 
78  virtual bool generatesString() const;
79  virtual bool requireAutoAdd(SHOP_TYPE type) const;
80 
81  /// @{
82  /// Package the SHOP parameters into shader data.
83  /// - @c shop: Build the shader string for this SHOP
84  /// - @c data/shader/box: Storage for the result of building the shader
85  /// - @c now: The evaluation time
86  /// - @c options: An arbitrary dictionary of options
87  /// - @c interpret_type: Interpret the SHOP as this type of shader. This
88  /// is used for SHOPs which can generate multiple shader types (i.e.
89  /// the material SHOP).
90  ///
91  /// The OP_Node* methods are more general and allow wider selection
92  /// of shader node representation (ie, VOPs too).
93  /// Implementing and overriding them is preferrable to overriding
94  /// the older versions that took SHOP_Node*. However, for better
95  /// compatibility with older plugin sources, the new methods call
96  ///the old ones in this base class (for now).
97  virtual bool buildOpShaderData(OP_Node *node,
98  SHOP_ReData &data, fpreal now,
99  const UT_Options *options,
100  SHOP_TYPE interpret_type);
101  virtual bool buildOpShaderString(OP_Node *node,
102  UT_String &shader, fpreal now,
103  const UT_Options *options,
104  SHOP_TYPE interpret_type);
105  virtual bool buildOpShaderBounds(OP_Node *node,
106  UT_BoundingBox &box, fpreal now,
107  const UT_Options *options,
108  SHOP_TYPE interpret_type);
109 
110  //SYS_DEPRECATED_REPLACE(14.5, buildOpShaderData)
111  virtual bool buildShaderData(SHOP_Node *shop,
112  SHOP_ReData &data,
113  fpreal now,
114  const UT_Options *options,
115  SHOP_TYPE interpret_type);
116  //SYS_DEPRECATED_REPLACE(14.5, buildOpShaderString)
117  virtual bool buildShaderString(SHOP_Node *shop,
118  UT_String &shader,
119  fpreal now,
120  const UT_Options *options,
121  SHOP_TYPE interpret_type);
122  //SYS_DEPRECATED_REPLACE(14.5, buildOpShaderBounds)
123  virtual bool buildShaderBounds(SHOP_Node *shop,
124  UT_BoundingBox &box,
125  fpreal now,
126  const UT_Options *options,
127  SHOP_TYPE interpret_type);
128  /// @}
129 
130  /// Build a shader string given a VOP node. The VOP node will @b always be
131  /// a code generator.
132  virtual bool buildVopShaderString(OP_Node *material,
133  VOP_Node *vop,
134  UT_String &shader,
135  fpreal now,
136  const UT_Options *options,
137  SHOP_TYPE interpret_type);
138 
139 
140  // When evaluating geometry shaders, the clerk may need to evaluate
141  // bounding box information. Particularly for RIB and VMantra.
142  virtual bool getBoundingBox(UT_BoundingBox &box,
143  SHOP_Node &node, OP_Context &ctx);
144 
145  //
146  // When attaching the shader information to a primitive, the shader
147  // information must be able to be stored as a string. In this case, we
148  // need to define the attribute name as well as how to build the string.
149  //
150  // If the attribute cannot be attached to geometry, then the
151  // getGeometryAttribute() function should return a null pointer.
152  // By default, this is what the getGeometryAttribute() does.
153  //
154  // The GeometryIndirect returns the name of an indirect attribute which
155  // causes the SHOP to be evaluated at render time.
156  //
157  virtual const char *getGeometryAttribute(SHOP_TYPE shader_type) const;
158  virtual const char *getGeometryIndirect(SHOP_TYPE shader_type) const;
159 
160  // Return true if we are the VEX clerk. Returns false by default.
161  virtual bool getIsVexClerk() const;
162 
163  // A creation script gets run when the SHOP has it's creation script run.
164  // This allow the clerk to add spare properties to the SHOP if required.
165  virtual const char *getCreationScript(SHOP_TYPE shader_type) const;
166 
167 protected:
168  virtual void buildShaderStart(UT_String &str,
169  const char *shader_name,
170  SHOP_Node *node);
171  virtual void buildShaderEnd(UT_String &str,
172  const char *shader_name,
173  SHOP_Node *node);
174 
175  // Evaluate the bounding box specified by the path to the OP_Node.
176  bool evalSopBoundingBox(UT_BoundingBox &box,
177  SHOP_Node &node,
178  const char *parmname,
179  fpreal now);
180 };
181 
182 #endif
#define SYS_VISIBILITY_EXPORT
#define SHOP_API
Definition: SHOP_API.h:10
SYS_VISIBILITY_EXPORT void newShopClerk()
SHOP_TYPE
GLboolean * data
Definition: glcorearb.h:130
GLuint shader
Definition: glcorearb.h:784
double fpreal
Definition: SYS_Types.h:263
A map of string to various well defined value types.
Definition: UT_Options.h:42
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107