Search the Community
Showing results for tags 'mycircle'.
-
I can follow the code written in Tutorial and can be compiled. Parameter can be created. However, there is no way to create an attribute. mycircle.h #include <SOP\SOP_Circle.h> #include <OP/OP_Parameters.h> class SOP_MyCircle : public SOP_Circle { public: SOP_MyCircle(OP_Network *net, const char *, OP_Operator *op); static OP_Node *MyConstructor(OP_Network *net, const char *name, OP_Operator *op); static OP_TemplatePair *buildTemplatePair(); protected: OP_ERROR cookMySop(OP_Context &context); private: fpreal COLORX(fpreal t) { return evalFloat("color", 0, 0); } fpreal COLORY(fpreal t) { return evalFloat("color", 1, 0); } fpreal COLORZ(fpreal t) { return evalFloat("color", 2, 0); } }; mycircle.cpp #include <UT/UT_DSOVersion.h> #include <OP/OP_OperatorTable.h> #include <OP/OP_Operator.h> #include <OP/OP_Context.h> #include <OP/OP_Network.h> #include <SOP/SOP_Node.h> #include "mycircle.h" #include <stdio.h> static PRM_Name colorName("color", "Color"); static PRM_Default colorDefaults[] = { PRM_Default(1), //r PRM_Default(0), //g PRM_Default(2) //b }; static PRM_Template newParmsTemplates[] = { PRM_Template(PRM_RGB, 3, &colorName, colorDefaults), PRM_Template() }; OP_Node *SOP_MyCircle::MyConstructor(OP_Network *net, const char *name, OP_Operator *op) { return new SOP_MyCircle(net, name, op); } SOP_MyCircle::SOP_MyCircle(OP_Network *net, const char *name, OP_Operator *op):SOP_Circle(net, name, op) { } OP_TemplatePair *SOP_MyCircle::buildTemplatePair() { OP_TemplatePair *old, *my; my = new OP_TemplatePair(newParmsTemplates, 0); old = new OP_TemplatePair(SOP_Circle::myTemplateList, my); return old; } OP_ERROR SOP_MyCircle::cookMySop(OP_Context &context) { SOP_Circle::cookMySop(context); fpreal now = context.getTime(); fpreal clr_r = COLORX(now); fpreal clr_g = COLORY(now); fpreal clr_b = COLORZ(now); GA_Attribute *cd_attr = gdp->addFloatTuple(GA_ATTRIB_PRIMITIVE,"Cd",3); GA_RWHandleV3 h(cd_attr); GA_Offset off = 0; h.set(off, UT_Vector3(clr_r, clr_g, clr_b)); return error(); } void newSopOperator(OP_OperatorTable *table) { table->addOperator( new OP_Operator("myCircle", "myCircle", SOP_MyCircle::myConstructor, SOP_MyCircle::buildTemplatePair(), 0, 0) ); } mycircle.cpp