34 #include "SOP_Star.proto.h"
48 using namespace UT::Literal;
49 using namespace HDK_Sample;
69 SOP_Star::theSOPTypeName,
71 SOP_Star::myConstructor,
72 SOP_Star::buildTemplates(),
81 static const char *theDsFile = R
"THEDSFILE(
85 name "divs" // Internal parameter name
86 label "Divisions" // Descriptive parameter name for user interface
88 default { "5" } // Default for this parameter on new nodes
89 range { 2! 50 } // The value is prevented from going below 2 at all.
90 // The UI slider goes up to 50, but the value can go higher.
91 export all // This makes the parameter show up in the toolbox
92 // above the viewport when it's in the node's state.
98 size 2 // 2 components in a vector2
99 default { "1" "0.3" } // Outside and inside radius defaults
103 label "Allow Negative Radius"
111 size 3 // 3 components in a vector
112 default { "0" "0" "0" }
118 default { "0" } // Default to first entry in menu, "xy"
129 SOP_Star::buildTemplates()
146 virtual void cook(
const CookParms &cookparms)
const;
158 SOP_Star::cookVerb()
const
167 auto &&sopparms = cookparms.
parms<SOP_StarParms>();
171 exint npoints = sopparms.getDivs()*2;
191 if (detail->getNumPoints() != npoints)
197 detail->clearAndDestroy();
204 detail->appendPrimitivesAndVertices(
GA_PRIMPOLY, 1, npoints, start_vtxoff,
true);
208 start_ptoff = detail->appendPointBlock(npoints);
211 for (
exint i = 0; i < npoints; ++i)
213 detail->setVertexPoint(start_vtxoff+i,start_ptoff+i);
219 detail->bumpDataIdsForAddOrRemove(
true,
true,
true);
226 start_ptoff = detail->pointOffset(
GA_Index(0));
229 detail->getP()->bumpDataId();
234 const SOP_StarParms::Orient plane = sopparms.getOrient();
235 const bool allow_negative_radius = sopparms.getNradius();
239 int xcoord, ycoord, zcoord;
242 case SOP_StarParms::Orient::XY:
247 case SOP_StarParms::Orient::YZ:
252 case SOP_StarParms::Orient::ZX:
265 float outer_radius = sopparms.getRad().x();
266 float inner_radius = sopparms.getRad().y();
269 for (
exint i = 0; i < npoints; i++)
277 float rad = odd ? inner_radius : outer_radius;
278 if (!allow_negative_radius && rad < 0)
281 UT_Vector3 pos(SYScos(angle)*rad, SYSsin(angle)*rad, 0);
283 pos =
UT_Vector3(pos(xcoord), pos(ycoord), pos(zcoord));
290 detail->setPos3(ptoff, pos);
virtual CookMode cookMode(const SOP_NodeParms *parms) const
void newSopOperator(OP_OperatorTable *table)
UT_ErrorSeverity sopAddWarning(int code, const char *msg=0, const UT_SourceLocation *loc=0) const
SIM_API const UT_StringHolder angle
UT_Vector3T< float > UT_Vector3
#define OP_FLAG_GENERATOR
bool addOperator(OP_Operator *op, std::ostream *err=nullptr)
virtual UT_StringHolder name() const
Constructs a PRM_Template list from an embedded .ds file or an istream.
IMATH_NAMESPACE::V2f float
virtual void cook(const CookParms &cookparms) const
This is the function that does the actual work.
static const SOP_NodeVerb::Register< SOP_StarVerb > theVerb
PRM_Template * templates() const
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
GLenum GLenum GLsizei void * table
virtual SOP_NodeParms * allocParms() const
GU_DetailHandle & gdh() const
The initial state of gdh depends on the cookMode()