HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOP_PrimVOP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  */
27 
28 #ifndef __SOP_PrimVOP__
29 #define __SOP_PrimVOP__
30 
31 #include <SOP/SOP_Node.h>
32 #include <CVEX/CVEX_Value.h>
33 #include <VOP/VOP_CodeGenerator.h>
35 
36 class CVEX_RunData;
37 class CVEX_Context;
38 class OP_Caller;
39 
40 namespace HDK_Sample {
41 class SOP_PrimVOP : public SOP_Node
42 {
43 public:
44  SOP_PrimVOP(OP_Network *net, const char *, OP_Operator *entry);
45  virtual ~SOP_PrimVOP();
46 
47  static OP_Node *myConstructor(OP_Network *net, const char *name,
48  OP_Operator *entry);
50 
51  /// Overriding these are what allow us to contain VOPs
53  virtual const char *getChildType() const;
54  virtual OP_OpTypeId getChildTypeID() const;
55 
57  virtual bool hasVexShaderParameter(const char *parm_name);
58 
59  /// We need special alerts now that we contain VOPs.
60  virtual void opChanged(OP_EventType reason, void *data=0);
61 
62  /// Code generation variables.
63  virtual bool evalVariableValue(
64  UT_String &value, int index, int thread);
65 
66  // Add virtual overload that delegates to the super class to avoid
67  // shadow warnings.
68  virtual bool evalVariableValue(fpreal &v, int i, int thread)
69  { return SOP_Node::evalVariableValue(v,i,thread); }
70 
71  static const char *theChildTableName;
72 
73 protected:
74  virtual OP_ERROR cookMySop (OP_Context &context);
75 
76  void executeVex(int argc, char **argv,
77  fpreal t, OP_Caller &opcaller);
78 
79  void processVexBlock(CVEX_Context &context,
80  CVEX_RunData &rundata,
81  int argc, char **argv,
82  int *primid, int n,
83  fpreal t);
84 
85  int VEXSRC(fpreal t)
86  { return evalInt("vexsrc", 0, t); }
87  void SCRIPT(UT_String &s, fpreal t)
88  { evalString(s, "script", 0, t); }
89 
91  { evalString(path, "shoppath", 0, t); }
92 
93  /// VOP and VEX functions
94  virtual void finishedLoadingNetwork(bool is_child_call=false);
95  virtual void addNode(OP_Node *node, int notify=1, int explicitly=1);
96  virtual void getNodeSpecificInfoText(OP_Context &context,
97  OP_NodeInfoParms &parms);
98 
99  void buildScript(UT_String &script, fpreal t);
100 
101  /// Every operator that has a VOP code generator needs to define
102  /// this method in order for Parameter VOP changes to be reflected
103  /// in the VOP network's parameter interface.
104  ///
105  /// This method requires <VOP/VOP_CodeGenerator.h>
106  /// and <VOP/VOP_ExportedParmsManager.h> to be included.
108  {
109  // Check if the spare parameter templates
110  // are out-of-date.
111  if (getVopCodeGenerator()
113  .requiresUpdate(0.0))
114  {
115  // Call into the code generator to update
116  // the spare parameter templates.
120  }
121  }
122 
124 };
125 } // End HDK_Sample namespace
126 
127 #endif
128 
virtual void getNodeSpecificInfoText(OP_Context &context, OP_NodeInfoParms &parms)
Definition: SOP_PrimVOP.C:776
virtual void addNode(OP_Node *node, int notify=1, int explicitly=1)
Definition: SOP_PrimVOP.C:768
virtual bool evalVariableValue(fpreal &v, int i, int thread)
Definition: SOP_PrimVOP.h:68
const GLdouble * v
Definition: glcorearb.h:836
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
virtual OP_OperatorFilter * getOperatorFilter()
Overriding these are what allow us to contain VOPs.
Definition: SOP_PrimVOP.C:722
SOP_PrimVOP(OP_Network *net, const char *, OP_Operator *entry)
Definition: SOP_PrimVOP.C:118
virtual VOP_CodeGenerator * getVopCodeGenerator()
Definition: SOP_PrimVOP.C:728
UT_ErrorSeverity
Definition: UT_Error.h:25
Parameters for OP_Node::getInfoText()/OP_Node::getNodeSpecificInfoText()
void updateOwnerSpareParmLayout(bool allow_update_while_loading=false)
Update the owner network's spare parameter layout.
static const char * theChildTableName
Definition: SOP_PrimVOP.h:71
virtual OP_ERROR cookMySop(OP_Context &context)
Definition: SOP_PrimVOP.C:144
virtual bool evalVariableValue(fpreal &val, int index, int thread) override
png_uint_32 i
Definition: png.h:2877
Call VEX from C++.
Definition: CVEX_Context.h:147
static PRM_Template myTemplateList[]
Definition: SOP_PrimVOP.h:49
GLdouble n
Definition: glcorearb.h:2007
VOP_ExportedParmsManager * exportedParmsManager() const
Return the exported parameters manager.
void SCRIPT(UT_String &s, fpreal t)
Definition: SOP_PrimVOP.h:87
void evalString(UT_String &val, int pi, int vi, fpreal t) const
void SHOPPATH(UT_String &path, fpreal t)
Definition: SOP_PrimVOP.h:90
virtual const char * getChildType() const
Definition: SOP_PrimVOP.C:740
DEP_MicroNode & eventMicroNode(OP_EventType e)
Definition: OP_Node.h:1544
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual void ensureSpareParmsAreUpdatedSubclass()
Definition: SOP_PrimVOP.h:107
void executeVex(int argc, char **argv, fpreal t, OP_Caller &opcaller)
Definition: SOP_PrimVOP.C:189
virtual OP_OpTypeId getChildTypeID() const
Definition: SOP_PrimVOP.C:746
OP_OpTypeId
Definition: OP_Node.h:263
virtual void opChanged(OP_EventType reason, void *data=0)
We need special alerts now that we contain VOPs.
Definition: SOP_PrimVOP.C:752
Per-run data for CVEX execution.
Definition: CVEX_Context.h:36
virtual bool evalVariableValue(UT_String &value, int index, int thread)
Code generation variables.
Definition: SOP_PrimVOP.C:713
static OP_Node * myConstructor(OP_Network *net, const char *name, OP_Operator *entry)
Definition: SOP_PrimVOP.C:112
GLsizei const GLfloat * value
Definition: glcorearb.h:823
double fpreal
Definition: SYS_Types.h:269
GLuint index
Definition: glcorearb.h:785
OP_EventType
Definition: OP_Value.h:22
virtual void finishedLoadingNetwork(bool is_child_call=false)
VOP and VEX functions.
Definition: SOP_PrimVOP.C:761
exint evalInt(int pi, int vi, fpreal t) const
void processVexBlock(CVEX_Context &context, CVEX_RunData &rundata, int argc, char **argv, int *primid, int n, fpreal t)
Definition: SOP_PrimVOP.C:496
VOP_CodeGenerator myCodeGenerator
Definition: SOP_PrimVOP.h:123
virtual bool hasVexShaderParameter(const char *parm_name)
Definition: SOP_PrimVOP.C:734
int VEXSRC(fpreal t)
Definition: SOP_PrimVOP.h:85
void buildScript(UT_String &script, fpreal t)
Definition: SOP_PrimVOP.C:663