00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Side Effects Software Inc 00008 * 477 Richmond Street West 00009 * Toronto, Ontario 00010 * Canada M5V 3E7 00011 * 416-504-9876 00012 * 00013 * NAME: SHOP_Clerk.h ( SHOP Library, C++) 00014 * 00015 * COMMENTS: Defines a mapping from SHOP parameters to a renderer. 00016 * 00017 */ 00018 00019 #ifndef __SHOP_Clerk__ 00020 #define __SHOP_Clerk__ 00021 00022 #include "SHOP_API.h" 00023 #include <UT/UT_String.h> 00024 #include "SHOP_NodeTypes.h" 00025 00026 class UT_WorkBuffer; 00027 class UT_Options; 00028 class UT_BoundingBox; 00029 class PRM_Template; 00030 class OP_Context; 00031 class SHOP_Node; 00032 class SHOP_Data; 00033 class SHOP_ReData; 00034 00035 class SHOP_API SHOP_Clerk { 00036 public: 00037 SHOP_Clerk(); 00038 virtual ~SHOP_Clerk(); 00039 00040 // 00041 // This render name should match the name in the IFD class. That is, this 00042 // should be the type of renderer passed in for evaluation. 00043 // The label is a string which can be used to describe the renderer. 00044 // Typically, this string is used in menus in the UI. For example: 00045 // 00046 // getRenderName() { return "RIB"; } 00047 // getRenderLabel() { return "RenderMan V3.7"; } 00048 // 00049 virtual const char *getRenderName() const = 0; 00050 virtual const char *getRenderLabel() const; 00051 virtual const char *getDefaultKeywords() const; 00052 00053 virtual int getDialogScriptEnum(SHOP_TYPE type) const; 00054 00055 virtual bool generatesString() const; 00056 virtual bool requireAutoAdd(SHOP_TYPE type) const; 00057 00058 // Typically this data is a string. However, there are no restrictions. 00059 // The data returned is owned by the SHOP and should be destroyed when the 00060 // SHOP_Clerk is destroyed. The renderer will not destruct it. 00061 virtual SHOP_Data *buildRenderData(SHOP_Node *node, 00062 fpreal now, 00063 int fprecision); 00064 00065 // By default, the buildGeometryData will just return the buildRenderData. 00066 // In the case where the render data is string data, this is ok. However, 00067 // if something different needs to be built, the method can be overridden. 00068 virtual SHOP_Data *buildGeometryData(SHOP_Node *node, 00069 fpreal now, 00070 int fprecision); 00071 00072 virtual bool buildShaderData(SHOP_Node *node, 00073 SHOP_ReData &data, 00074 fpreal now, 00075 const UT_Options *options); 00076 virtual bool buildShaderString(SHOP_Node *node, 00077 UT_String &shader, 00078 fpreal now, 00079 const UT_Options *options); 00080 virtual bool buildShaderBounds(SHOP_Node *node, 00081 UT_BoundingBox &box, 00082 fpreal now, 00083 const UT_Options *options); 00084 00085 // If the geometry data is different than the render data, the 00086 // differentGeometryData() method MUST return 1 (it returns 0 by default). 00087 virtual bool differentGeometryData() const; 00088 00089 // When evaluating geometry shaders, the clerk may need to evaluate 00090 // bounding box information. Particularly for RIB and VMantra. 00091 virtual bool getBoundingBox(UT_BoundingBox &box, 00092 SHOP_Node &node, OP_Context &ctx); 00093 00094 // 00095 // When attaching the shader information to a primitive, the shader 00096 // information must be able to be stored as a string. In this case, we 00097 // need to define the attribute name as well as how to build the string. 00098 // 00099 // If the attribute cannot be attached to geometry, then the 00100 // getGeometryAttribute() function should return a null pointer. 00101 // By default, this is what the getGeometryAttribute() does. 00102 // 00103 // The GeometryIndirect returns the name of an indirect attribute which 00104 // causes the SHOP to be evaluated at render time. 00105 // 00106 virtual const char *getGeometryAttribute(SHOP_TYPE shader_type) const; 00107 virtual const char *getGeometryIndirect(SHOP_TYPE shader_type) const; 00108 00109 // Return true if we are the VEX clerk. Returns false by default. 00110 virtual bool getIsVexClerk() const; 00111 00112 // A creation script gets run when the SHOP has it's creation script run. 00113 // This allow the clerk to add spare properties to the SHOP if required. 00114 virtual const char *getCreationScript(SHOP_TYPE shader_type) const; 00115 00116 protected: 00117 virtual void buildShaderStart(UT_String &str, 00118 const char *shader_name, 00119 SHOP_Node *node); 00120 virtual void buildShaderEnd(UT_String &str, 00121 const char *shader_name, 00122 SHOP_Node *node); 00123 00124 // Evaluate the bounding box specified by the path to the OP_Node. 00125 bool evalSopBoundingBox(UT_BoundingBox &box, 00126 SHOP_Node &node, 00127 const char *parmname, 00128 fpreal now); 00129 00130 // This function is used by the default "buildRenderData()" method to build 00131 // data for a string representation of the shader data. It generates data 00132 // of the form: 00133 // parm_name ( parm_value1 parm_value2 ... ) 00134 // This is the type of data expected by VEX. 00135 // The string generated should be for the parameter specified only (not 00136 // include other parameters). 00137 // This should return 1 on success or 0 on failure. 00138 // The template passed in will be the template for the parameter desired 00139 // parameter (not the start of the list). 00140 virtual int buildParmCommand(UT_WorkBuffer &parm_data, 00141 SHOP_Node *node, 00142 PRM_Template *tplate, 00143 fpreal now, 00144 int fprecision); 00145 00146 00147 // This utility function will generate parameter definitions using the 00148 // RenderMan syntax. By overriding the buildParmCommand() function and 00149 // simply calling this function, you will get a RenderMan parameter string 00150 // built. 00151 int buildRenderManParm(UT_WorkBuffer &parm_data, 00152 SHOP_Node *node, 00153 PRM_Template *tplate, 00154 fpreal now, 00155 int fprecision); 00156 }; 00157 00158 #endif
1.5.9