HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CHOP_Spring.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * COMMENTS:
27  * Simulates spring-like action on an input channel.
28  */
29 
30 #ifndef __CHOP_Spring__
31 #define __CHOP_Spring__
32 
33 #include <CHOP/CHOP_Realtime.h>
34 
35 // First Page
36 #define ARG_SPR_SPRING_CONSTANT (myParmBase + 0)
37 #define ARG_SPR_MASS (myParmBase + 1)
38 #define ARG_SPR_DAMPING_CONSTANT (myParmBase + 2)
39 #define ARG_SPR_METHOD (myParmBase + 3)
40 #define ARG_SPR_GRAB_INITIAL (myParmBase + 4)
41 #define ARG_SPR_INITIAL_DISPLACEMENT (myParmBase + 5)
42 #define ARG_SPR_INITIAL_VELOCITY (myParmBase + 6)
43 
44 class UT_Interrupt;
45 
46 namespace HDK_Sample {
47 
48 class CHOP_Spring : public CHOP_Realtime
49 {
50 public:
51 
52  static OP_Node *myConstructor(OP_Network *,
53  const char *,
54  OP_Operator *);
59 
60  OP_ERROR cookMyChop(OP_Context &context);
62  int start, int end);
63 
64  virtual bool updateParmsFlags();
65 
66  virtual bool evalVariableValue(
67  fpreal &val, int index, int thread);
68  // Add virtual overload that delegates to the super class to avoid
69  // shadow warnings.
70  virtual bool evalVariableValue(
71  UT_String &v, int i, int thread)
72  {
74  v, i, thread);
75  }
76 
77  virtual int usesScope() const { return 1; };
78  virtual int usesSampleMatch() const { return 0; };
79  virtual int usesUnits() { return getInput(0) ? 0 : 1; };
80 
81  virtual int isSteady() const;
82  virtual const char * getTimeSliceExtension() { return "spring"; }
83 
84 protected:
85 
86  CHOP_Spring(OP_Network *net,
87  const char *name,
88  OP_Operator *op);
89  virtual ~CHOP_Spring();
90 
91  virtual ut_RealtimeData * newRealtimeDataBlock(const char *name,
92  const CL_Track *track,
93  fpreal t);
94 
95 private:
96 
97  // First Page
98  int METHOD()
99  { return evalInt(ARG_SPR_METHOD, 0, 0); }
100 
101  fpreal SPRING_CONSTANT(fpreal t)
102  { return evalFloat(ARG_SPR_SPRING_CONSTANT, 0, t); }
103 
104  fpreal MASS(fpreal t)
105  { return evalFloat(ARG_SPR_MASS, 0, t); }
106 
107  void SET_MASS(fpreal t, fpreal f)
108  { setFloat(ARG_SPR_MASS, 0, t, f); }
109 
110  fpreal DAMPING_CONSTANT(fpreal t)
111  { return evalFloat(ARG_SPR_DAMPING_CONSTANT, 0, t); }
112 
113  bool GRAB_INITIAL()
114  { return (bool) evalInt(ARG_SPR_GRAB_INITIAL, 0, 0); }
115 
116  fpreal INITIAL_DISPLACEMENT(fpreal t)
117  { return evalFloat(ARG_SPR_INITIAL_DISPLACEMENT, 0, t); }
118 
119  fpreal INITIAL_VELOCITY(fpreal t)
120  { return evalFloat(ARG_SPR_INITIAL_VELOCITY, 0, t); }
121 
122  int my_NC;
123  int my_C;
124  int myChannelDependent;
125  int mySteady;
126 };
127 
128 } // End HDK_Sample namespace
129 
130 #endif
virtual bool updateParmsFlags()
Definition: CHOP_Spring.C:114
static OP_VariablePair myVariablePair
Definition: CHOP_Spring.h:56
static CH_LocalVariable myVariableList[]
Definition: CHOP_Spring.h:58
static OP_Node * myConstructor(OP_Network *, const char *, OP_Operator *)
Definition: CHOP_Spring.C:165
CHOP_Spring(OP_Network *net, const char *name, OP_Operator *op)
Definition: CHOP_Spring.C:173
#define ARG_SPR_DAMPING_CONSTANT
Definition: CHOP_Spring.h:38
const GLdouble * v
Definition: glcorearb.h:836
static OP_TemplatePair myTemplatePair
Definition: CHOP_Spring.h:55
GLuint start
Definition: glcorearb.h:474
OP_ERROR cookMySlice(OP_Context &context, int start, int end)
Definition: CHOP_Spring.C:403
virtual int isSteady() const
Definition: CHOP_Spring.C:394
virtual bool evalVariableValue(fpreal &val, int index, int thread)
Definition: CHOP_Spring.C:142
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
#define ARG_SPR_MASS
Definition: CHOP_Spring.h:37
#define ARG_SPR_METHOD
Definition: CHOP_Spring.h:39
virtual int usesScope() const
Definition: CHOP_Spring.h:77
#define ARG_SPR_INITIAL_VELOCITY
Definition: CHOP_Spring.h:42
png_uint_32 i
Definition: png.h:2877
GLfloat f
Definition: glcorearb.h:1925
virtual int usesSampleMatch() const
Definition: CHOP_Spring.h:78
virtual bool evalVariableValue(UT_String &v, int i, int thread)
Definition: CHOP_Spring.h:70
GLuint GLuint end
Definition: glcorearb.h:474
void setFloat(int parmi, int vectori, fpreal t, fpreal value, int h=0)
static PRM_Template myTemplateList[]
Definition: CHOP_Spring.h:57
OP_Node * getInput(unsigned idx, bool mark_used=false) const
Returns the node connected to a particular input (may be null).
#define ARG_SPR_INITIAL_DISPLACEMENT
Definition: CHOP_Spring.h:41
GLuint const GLchar * name
Definition: glcorearb.h:785
#define ARG_SPR_SPRING_CONSTANT
Definition: CHOP_Spring.h:36
virtual int usesUnits()
Definition: CHOP_Spring.h:79
OP_ERROR cookMyChop(OP_Context &context)
Definition: CHOP_Spring.C:188
virtual ut_RealtimeData * newRealtimeDataBlock(const char *name, const CL_Track *track, fpreal t)
Definition: CHOP_Spring.C:509
double fpreal
Definition: SYS_Types.h:269
GLuint index
Definition: glcorearb.h:785
GLuint GLfloat * val
Definition: glcorearb.h:1607
virtual bool evalVariableValue(UT_String &val, int index, int thread)
#define ARG_SPR_GRAB_INITIAL
Definition: CHOP_Spring.h:40
exint evalInt(int pi, int vi, fpreal t) const
virtual const char * getTimeSliceExtension()
Definition: CHOP_Spring.h:82