00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __SOP_AttribComp_h__
00021 #define __SOP_AttribComp_h__
00022
00023 #include "SOP_API.h"
00024 class GB_Primitive;
00025 class GD_Primitive;
00026
00027 #include <UT/UT_PtrArray.h>
00028
00029 #include "SOP_Node.h"
00030
00031 enum {
00032 SOP_ATTRIBCOMP_SELECTION_SLIDER,
00033 SOP_ATTRIBCOMP_CARD_SWITCHER,
00034 SOP_ATTRIBCOMP_DET_CHECKBOX,
00035 SOP_ATTRIBCOMP_DET_TEXTFIELD,
00036 SOP_ATTRIBCOMP_PRIM_CHECKBOX,
00037 SOP_ATTRIBCOMP_PRIM_TEXTFIELD,
00038 SOP_ATTRIBCOMP_PT_CHECKBOX,
00039 SOP_ATTRIBCOMP_PT_TEXTFIELD,
00040 SOP_ATTRIBCOMP_VTX_CHECKBOX,
00041 SOP_ATTRIBCOMP_VTX_TEXTFIELD,
00042 SOP_ATTRIBCOMP_BLEND_MULTIPARM,
00043 SOP_ATTRIBCOMP_ALPHA_TEXTFIELD,
00044 SOP_ATTRIBCOMP_OP_MENU,
00045
00046 SOP_ATTRIBCOMP_PRM_NUM
00047 };
00048
00049
00050 class SOP_API SOP_AttribComp : public SOP_Node
00051 {
00052 public:
00053 SOP_AttribComp(OP_Network *net, const char *name,
00054 OP_Operator *entry);
00055 virtual ~SOP_AttribComp();
00056
00057 static OP_Node *myConstructor(OP_Network *net, const char *name,
00058 OP_Operator *entry);
00059
00060 void setSelectionOverride(bool selection_override);
00061 void setBlendValue(int i, float value, float t);
00062 void setBlendAlias(int i, const char *alias);
00063 void removeBlend(int i);
00064
00065 static PRM_Template myTemplateList[];
00066
00067 protected:
00068 virtual const char *inputLabel(unsigned) const;
00069 virtual unsigned disableParms();
00070
00071 virtual OP_ERROR cookInputGroups(OP_Context &context, int alone = 0);
00072 virtual OP_ERROR cookMySop(OP_Context &context);
00073
00074 private:
00075 static void buildAlphaMenu(void *data, PRM_Name *entries, int size,
00076 const PRM_SpareData *, PRM_Parm *);
00077
00078 bool parsePointAttribList();
00079 void parseMySop(
00080 UT_PtrArray<GB_Attribute *> &detailattribs,
00081 UT_PtrArray<GB_Attribute *> &primattribs,
00082 UT_PtrArray<GB_Attribute *> &pointattribs,
00083 UT_PtrArray<GB_Attribute *> &vertexattribs);
00084 void syncCapturePathAndData(void);
00085 bool verifyGeometries(void);
00086 bool haveAttribParmsChanged(float t);
00087 void verifyAttribsExist(UT_PtrArray<GB_Attribute *> &attribs,
00088 GEO_AttributeOwner attribclass);
00089 void verifyAttribs(
00090 UT_PtrArray<GB_Attribute *> &detailattribs,
00091 UT_PtrArray<GB_Attribute *> &primattribs,
00092 UT_PtrArray<GB_Attribute *> &pointattribs,
00093 UT_PtrArray<GB_Attribute *> &vertexattribs);
00094 void setupOpFN(void);
00095 void setupWeights(int numWeights, float t);
00096 inline void *tmpAttrib(int index, int size);
00097 void setAlphaAttrib(GEO_AttributeOwner attribclass);
00098 void createAttrib(GEO_AttributeOwner attribclass,
00099 const UT_WorkBuffer &attribname,
00100 int attribsize,
00101 GB_AttribType attribtype,
00102 bool isindexpair);
00103 void cleanAttrib(const UT_WorkBuffer &attribname,
00104 int attribsize,
00105 GB_AttribType attribtype,
00106 GB_AttribTypeInfo attribtype_info,
00107 bool isindexpair);
00108 OP_ERROR compAttrib(GEO_AttributeOwner attribclass,
00109 const UT_WorkBuffer &attribname,
00110 int attribsize,
00111 GB_AttribType attribtype,
00112 bool isindexpair,
00113 const UT_PtrArray<void *> &src,
00114 void *dest);
00115 OP_ERROR compAttribP();
00116 OP_ERROR compGrpAttribs(
00117 UT_PtrArray<GB_Attribute *> &detailattribs,
00118 UT_PtrArray<GB_Attribute *> &primattribs,
00119 UT_PtrArray<GB_Attribute *> &pointattribs,
00120 UT_PtrArray<GB_Attribute *> &vertexattribs);
00121
00122 int SELECTIONIDX(void)
00123 { return evalInt(SOP_ATTRIBCOMP_SELECTION_SLIDER, 0, 0); }
00124 int DETAILATTRIBCOMP()
00125 { return evalInt( SOP_ATTRIBCOMP_DET_CHECKBOX, 0, 0); }
00126 void DETAILATTRIBS(UT_String &str)
00127 { evalString(str, SOP_ATTRIBCOMP_DET_TEXTFIELD, 0, 0);
00128 str.harden();
00129 str.trimSpace(true);
00130 }
00131 int PRIMATTRIBCOMP()
00132 { return evalInt( SOP_ATTRIBCOMP_PRIM_CHECKBOX, 0, 0); }
00133 void PRIMATTRIBS(UT_String &str)
00134 { evalString(str, SOP_ATTRIBCOMP_PRIM_TEXTFIELD, 0, 0);
00135 str.harden();
00136 str.trimSpace(true);
00137 }
00138 int PTATTRIBCOMP()
00139 { return evalInt( SOP_ATTRIBCOMP_PT_CHECKBOX, 0, 0); }
00140 void PTATTRIBS(UT_String &str)
00141 { evalString(str, SOP_ATTRIBCOMP_PT_TEXTFIELD, 0, 0);
00142 str.harden();
00143 str.trimSpace(true);
00144 }
00145 int VTXATTRIBCOMP()
00146 { return evalInt( SOP_ATTRIBCOMP_VTX_CHECKBOX, 0, 0); }
00147 void VTXATTRIBS(UT_String &str)
00148 { evalString(str, SOP_ATTRIBCOMP_VTX_TEXTFIELD, 0, 0);
00149 str.harden();
00150 str.trimSpace(true);
00151 }
00152
00153 int NBLENDS()
00154 { return evalInt( SOP_ATTRIBCOMP_BLEND_MULTIPARM, 0, 0); }
00155 void setNBLENDS(int n)
00156 { setInt( SOP_ATTRIBCOMP_BLEND_MULTIPARM, 0, 0, n); }
00157 float BLEND(int i, float t)
00158 { return evalFloatInst("blend#", &i, 0, t); }
00159
00160 void ALPHAATTRIB(UT_String &str)
00161 { evalString(str, SOP_ATTRIBCOMP_ALPHA_TEXTFIELD, 0, 0); }
00162 int COMPOP()
00163 { return evalInt( SOP_ATTRIBCOMP_OP_MENU, 0, 0); }
00164
00165 int myGdpIdx;
00166 UT_PtrArray<GU_Detail *> mySrcGdps;
00167 UT_IntArray mySrcOffsets;
00168 int myDstOffset;
00169 UT_IntArray myAlphaOffsets;
00170 UT_IntArray myIndexPairSize;
00171 int myTmpIndexPairSize;
00172 GU_DetailGroupPair myDetailGroupPair;
00173 int myCaptOK;
00174 UT_PtrArray<int *> myRemappedIndices;
00175 void (*myOpFN)(float, float*, float);
00176 bool myOverUnder;
00177 UT_FloatArray myWeights;
00178 UT_FloatArray myAttribSum;
00179 UT_String myAlpha;
00180 void *myTmpAttrib;
00181 bool mySelectionOverride;
00182 int myCompPSize;
00183
00184 static PRM_ChoiceList ourDetailAttribMenu;
00185 static PRM_ChoiceList ourPrimAttribMenu;
00186 static PRM_ChoiceList ourPointAttribMenu;
00187 static PRM_ChoiceList ourVertexAttribMenu;
00188 static PRM_ChoiceList ourAlphaAttribMenu;
00189 };
00190
00191 #endif