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 <SYS/SYS_Math.h>
00031 #include <GU/GU_Detail.h>
00032 #include <GEO/GEO_AttributeHandle.h>
00033 #include <PRM/PRM_Include.h>
00034 #include <OP/OP_Director.h>
00035 #include <OP/OP_Operator.h>
00036 #include <OP/OP_OperatorTable.h>
00037 #include "SOP_CPPWave.h"
00038
00039 using namespace HDK_Sample;
00040
00041 void
00042 newSopOperator(OP_OperatorTable *table)
00043 {
00044 table->addOperator(new OP_Operator("cpp_wave",
00045 "CPP Wave ",
00046 SOP_CPPWave::myConstructor,
00047 SOP_CPPWave::myTemplateList,
00048 1,
00049 1,
00050 0));
00051 }
00052
00053 PRM_Template
00054 SOP_CPPWave::myTemplateList[] = {
00055 PRM_Template(),
00056 };
00057
00058
00059 OP_Node *
00060 SOP_CPPWave::myConstructor(OP_Network *net, const char *name, OP_Operator *op)
00061 {
00062 return new SOP_CPPWave(net, name, op);
00063 }
00064
00065 SOP_CPPWave::SOP_CPPWave(OP_Network *net, const char *name, OP_Operator *op)
00066 : SOP_Node(net, name, op)
00067 {
00068 }
00069
00070 SOP_CPPWave::~SOP_CPPWave()
00071 {
00072 }
00073
00074 OP_ERROR
00075 SOP_CPPWave::cookMySop(OP_Context &context)
00076 {
00077 double frame;
00078 int i, npts;
00079
00080
00081
00082 if (lockInputs(context) >= UT_ERROR_ABORT)
00083 return error();
00084
00085
00086 duplicateSource(0, context);
00087
00088
00089 flags().timeDep = 1;
00090
00091 frame = OPgetDirector()->getChannelManager()->getSample(context.getTime());
00092 frame *= 0.03;
00093 npts = gdp->points().entries();
00094
00095 GEO_AttributeHandle Phandle;
00096 UT_Vector4 Pvalue;
00097 Phandle = gdp->getAttribute(GEO_POINT_DICT, "P");
00098 for (i = 0; i < npts; i++)
00099 {
00100 Phandle.setElement(gdp->points()(i));
00101 Pvalue = Phandle.getV4();
00102 Pvalue.y() = sin(Pvalue.x()*.2 + Pvalue.z()*.3 + frame);
00103 Phandle.setV4(Pvalue);
00104 }
00105
00106 unlockInputs();
00107 return error();
00108 }