00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <UT/UT_DSOVersion.h>
00030 #include <GEO/GEO_PointRef.h>
00031 #include <GU/GU_Detail.h>
00032 #include <PRM/PRM_Include.h>
00033 #include <OP/OP_Operator.h>
00034 #include <OP/OP_OperatorTable.h>
00035 #include "SOP_DetailAttrib.h"
00036
00037 using namespace HDK_Sample;
00038 void
00039 newSopOperator(OP_OperatorTable *table)
00040 {
00041 table->addOperator(new OP_Operator("hdk_detailattrib",
00042 "DetailAttrib",
00043 SOP_DetailAttrib::myConstructor,
00044 SOP_DetailAttrib::myTemplateList,
00045 1,
00046 1));
00047 }
00048
00049
00050 static PRM_Name sop_names[] = {
00051 PRM_Name("attribname", "Attribute"),
00052 PRM_Name("value", "Value"),
00053 };
00054
00055 static PRM_Default sop_valueDefault(0.1);
00056 static PRM_Range sop_valueRange(PRM_RANGE_RESTRICTED,0,PRM_RANGE_UI,1);
00057
00058 PRM_Template
00059 SOP_DetailAttrib::myTemplateList[]=
00060 {
00061 PRM_Template(PRM_STRING, 1, &sop_names[0], 0),
00062 PRM_Template(PRM_FLT_J, 1, &sop_names[1], &sop_valueDefault, 0,
00063 &sop_valueRange),
00064 PRM_Template()
00065 };
00066
00067
00068 OP_Node *
00069 SOP_DetailAttrib::myConstructor(OP_Network *net,const char *name,OP_Operator *entry)
00070 {
00071 return new SOP_DetailAttrib(net, name, entry);
00072 }
00073
00074
00075 SOP_DetailAttrib::SOP_DetailAttrib(OP_Network *net, const char *name, OP_Operator *entry)
00076 : SOP_Node(net, name, entry)
00077 {
00078 }
00079
00080 SOP_DetailAttrib::~SOP_DetailAttrib()
00081 {
00082 }
00083
00084
00085 unsigned
00086 SOP_DetailAttrib::disableParms()
00087 {
00088 int changed = 0;
00089
00090 return changed;
00091 }
00092
00093
00094 OP_ERROR
00095 SOP_DetailAttrib::cookMySop(OP_Context &context)
00096 {
00097 float t = context.myTime;
00098 UT_String aname;
00099 int aoff, asize;
00100 GB_AttribType atype;
00101 GB_Attribute *attrib;
00102 static float zero = 0.0;
00103 float *detailattrib;
00104
00105 if (lockInputs(context) >= UT_ERROR_ABORT)
00106 return error();
00107
00108 duplicateSource(0, context);
00109
00110 ATTRIBNAME(aname, t);
00111
00112
00113 atype = GB_ATTRIB_FLOAT;
00114 attrib = gdp->attribs().find(aname, atype);
00115
00116 if (!attrib)
00117 {
00118
00119 gdp->addAttrib(aname, sizeof(float), GB_ATTRIB_FLOAT, &zero);
00120 attrib = gdp->attribs().find(aname, atype);
00121 }
00122
00123 asize = attrib->getSize();
00124 aoff = gdp->attribs().getOffset(aname, atype);
00125
00126 detailattrib = gdp->attribs().castAttribData<float>(aoff);
00127
00128
00129 *detailattrib = VALUE(t);
00130
00131 unlockInputs();
00132 return error();
00133 }
00134