41 using namespace HDK_Sample;
46 PRM_Name(
"springk",
"Spring Constant"),
48 PRM_Name(
"dampingk",
"Damping Constant"),
50 PRM_Name(
"condfromchan",
"Initial Conditions From Channel"),
51 PRM_Name(
"initpos",
"Initial Position"),
52 PRM_Name(
"initspeed",
"Initial Speed"),
56 static PRM_Name springMethodItems[] = {
93 &springConstantRange),
97 &dampingConstantRange),
115 bool grab = GRAB_INITIAL();
147 myChannelDependent=1;
192 int i,
j,
length, num_tracks, animated_parms;
197 fpreal initial_displacement;
203 bool grab_init = GRAB_INITIAL();
210 force_method = METHOD();
217 myChannelDependent=0;
218 spring_constant = SPRING_CONSTANT(context.
getTime());
219 mass = MASS(context.
getTime());
220 damping_constant = DAMPING_CONSTANT(context.
getTime());
221 animated_parms = myChannelDependent;
230 initial_displacement = INITIAL_DISPLACEMENT(context.
getTime());
231 initial_velocity = INITIAL_VELOCITY(context.
getTime());
248 if(boss->
opStart(
"Calculating Spring"))
256 for (i=0; i<num_tracks; i++)
271 if(grab_init || animated_parms)
277 spring_constant = SPRING_CONSTANT(context.
getTime());
278 mass = MASS(context.
getTime());
281 damping_constant = DAMPING_CONSTANT(context.
getTime());
290 initial_displacement);
295 d1 = initial_displacement;
296 d2 = d1 - initial_velocity * inc;
310 f *= spring_constant;
314 acc = (f - vel*damping_constant - d1*spring_constant)/mass;
346 namespace HDK_Sample {
410 fpreal d1,d2,
f,
t,inc,d, acc,vel,oldp;
416 force_method = METHOD();
422 myChannelDependent=0;
423 spring_constant = SPRING_CONSTANT(context.
getTime());
424 mass = MASS(context.
getTime());
425 damping_constant = DAMPING_CONSTANT(context.
getTime());
426 animated_parms = myChannelDependent;
454 spring_constant = SPRING_CONSTANT(context.
getTime());
455 mass = MASS(context.
getTime());
458 damping_constant = DAMPING_CONSTANT(context.
getTime());
477 f *= spring_constant;
479 oldp /=spring_constant;
483 acc = (f - vel*damping_constant - d1*spring_constant)/mass;
515 if(GRAB_INITIAL() && track)
524 d = INITIAL_DISPLACEMENT(t);
525 v = INITIAL_VELOCITY(t);
const UT_StringHolder & getName() const
static OP_VariablePair myVariablePair
PRM_API const PRM_Type PRM_FLT
static CH_LocalVariable myVariableList[]
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
ut_SpringData(const char *name, fpreal d, fpreal v)
CHOP_Spring(OP_Network *net, const char *name, OP_Operator *op)
virtual bool saveStates(UT_OStream &os)
UT_OStream & write(const char_type *str, int64 count)
OP_ERROR cookMyChop(OP_Context &context) override
static OP_TemplatePair myTemplatePair
static OP_TemplatePair myTemplatePair
CL_Track * getTrack(int index)
PRM_API const PRM_Type PRM_ORD
fpreal getSampleRate() const
GLuint GLsizei GLsizei * length
bool addOperator(OP_Operator *op, std::ostream *err=nullptr)
static OP_VariablePair myVariablePair
bool updateParmsFlags() override
bool updateParmsFlags() override
bool saveStates(UT_OStream &os) override
void evaluateTime(const CL_Track *track, fpreal start_time, fpreal stop_time, fpreal *data, int size) const
int opInterrupt(int percent=-1)
const CL_Clip * inputClip(int idx, OP_Context &context)
~ut_SpringData() override
bool enableParm(int pi, int state, int v=-1)
exint read(bool *array, exint sz=1)
static PRM_Template myTemplateList[]
fpreal evaluateSingle(const CL_Track *track, fpreal index) const
GLuint const GLchar * name
const CL_Clip * copyInput(OP_Context &context, int idx, int data, int slerps)
ut_RealtimeData * newRealtimeDataBlock(const char *name, const CL_Track *track, fpreal t) override
SYS_FORCE_INLINE UT_StringHolder getToken(Add enum_value)
GLenum GLenum GLsizei void * table
PRM_API const PRM_Type PRM_SWITCHER
CHOP_SWITCHER(7,"Spring")
GT_API const UT_StringHolder version
GA_API const UT_StringHolder mass
PRM_API PRM_Default PRMoneDefaults[]
PRM_API PRM_Name PRMswitcherName
**Note that the tasks the is the thread number *for the or if it s being executed by a non pool thread(this *can happen in cases where the whole pool is occupied and the calling *thread contributes to running the work load).**Thread pool.Have fun
ut_RealtimeData * getDataBlock(int n)
bool loadStates(UT_IStream &is, int version) override
UT_API UT_Interrupt * UTgetInterrupt()
Obtain global UT_Interrupt singleton.
fpreal evaluateSingleTime(const CL_Track *track, fpreal t) const
PRM_API const PRM_Type PRM_TOGGLE
int getTrackLength() const
fpreal getIndex(fpreal time) const
virtual bool evalVariableValue(UT_String &val, int index, int thread)
int isScoped(const UT_StringRef &name)
int opStart(const char *opname=0, int npoll=0, int immediate_dialog=0, int *opid=0)
void newChopOperator(OP_OperatorTable *table)
virtual bool loadStates(UT_IStream &is, int version)
OP_ERROR cookMySlice(OP_Context &context, int start, int end) override
bool evalVariableValue(fpreal &val, int i, int thread) override
int getParmIndex(const PRM_Parm *parm) const
PRM_API PRM_Default PRMzeroDefaults[]
SYS_FORCE_INLINE PRM_ParmList * getParmList()
int isSteady() const override
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T clip(const T &p, const Box< T > &box) IMATH_NOEXCEPT
fpreal getTime(fpreal index) const