-
Notifications
You must be signed in to change notification settings - Fork 118
/
VEXpressions.txt
218 lines (171 loc) · 5.78 KB
/
VEXpressions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#
# @file VEXpressions.txt
# @author xy
#
# @since 2018-09-02
#
# @brief Varions VEXpression presets for nodes.
#
#
groupexpression/snippet
[qL] Curve Endpoints
neighbourcount(0, @ptnum)==1
groupexpression/snippet
[qL] Curve(s), Start Point
vertexprimindex(0, @vtxnum)==0
groupexpression/snippet
[qL] Curve(s), End Point
vertexprimindex(0, @vtxnum)==@numvtx-1
groupexpression/snippet
[qL] Open Primitives (e.g. Curves)
primintrinsic(0, "closed", @elemnum)==0
groupexpression/snippet
[qL] Closed Primitives
primintrinsic(0, "closed", @elemnum)==1
groupexpression/snippet
[qL] Prim Area: Smaller than
chf("tolerance") > primintrinsic(0, "measuredarea", @elemnum)
groupexpression/snippet
[qL] Prim Area: Larger than
chf("tolerance") < primintrinsic(0, "measuredarea", @elemnum)
groupexpression/snippet
[qL] Prim Length: Shorter than
chf("tolerance") > primintrinsic(0, "measuredperimeter", @elemnum)
groupexpression/snippet
[qL] Prim Length: Longer than
chf("tolerance") < primintrinsic(0, "measuredperimeter", @elemnum)
groupexpression/snippet
[qL] Prim Volume: Smaller than
chf("tolerance") > primintrinsic(0, "measuredvolume", @elemnum)
groupexpression/snippet
[qL] Prim Volume: Larger than
chf("tolerance") < primintrinsic(0, "measuredvolume", @elemnum)
groupexpression/snippet
[qL] Group by Normal/Lookat Point
degrees( acos(dot(@N, normalize(chv("position")-@P))) ) < chf("angle")
groupexpression/snippet
[qL] Group by Same ids as in Second Input
findattribval(1, chs("grouptype"), "id", @id)>=0
attribexpression/snippet
[qL] Element number
@elemnum
attribexpression/snippet
[qL] Element number (float [0..1])
@elemnum/(@numelem-1.0)
attribexpression/snippet
[qL] Random Distribution (elemnum)
chramp("distribution", random(@elemnum*12+34))
attribexpression/snippet
[qL] Random Distribution (id)
chramp("distribution", random(@id*76+19))
attribexpression/snippet
[qL] Vector to 2nd Input Point Positions
@opinput1_P - @P
attribexpression/snippet
[qL] Vector to 2nd Input Point Positions (Normalized)
normalize(@opinput1_P - @P)
attribexpression/snippet
[qL] Number of Nearby Points
len(nearpoints(0, v@P, chf('maxdist'), chi('maxpts')))
attribexpression/snippet
[qL] Number of Nearby Points (Normalized)
len(nearpoints(0, v@P, chf('maxdist'), chi('maxpts'))) / float(chi('maxpts'))
attribexpression/snippet
[qL] id to string attribute
sprintf("piece%d", i@id)
attribexpression/snippet
[qL] "name" piece numbers to int attribute
opdigits(s@name)
attribwrangle/snippet
[qL] Number of Nearby Points
float maxdist = chf('maxdist');
int maxpts = chi('maxpts');
i@numnear = len(nearpoints(0, v@P, maxdist, maxpts));
attribwrangle/snippet
[qL] Number of Nearby Points (Normalized)
float maxdist = chf('maxdist');
int maxpts = chi('maxpts');
f@numnear = len(nearpoints(0, v@P, maxdist, maxpts)) / float(maxpts);
attribwrangle/snippet
[qL] Snap to 2nd Input SDF Boundary
// Snaps points of 1st input to the SDF boundary of 2nd input
// 1st input: geometry
// 2nd input: SDF volume to snap to
// NOTE: make sure the exterior voxel band is large enough
// on the 2nd SDF volume
vector
d = volumegradient(1, 0, v@P),
v = 0;
float
sdf = volumesample(1, 0, v@P);
//if (sdf<0)
{
v = normalize(d) * -sdf;
}
v@P += v;
attribwrangle/snippet
[qL] Extract packed prim full transform (Transform-by-Attrib)
// Use the 'xform' attribute with a Transform by Attrib SOP
4@xform = primintrinsic(0, "packedfulltransform", @primnum);
attribwrangle/snippet
[qL] Extract packed prim full transform (Copy-to-Points)
// "transform" the full transformation attribute supported by Copy to Points SOP
4@transform = primintrinsic(0, "packedfulltransform", @primnum);
// P is zeroed out as "transform" already contains the transformation
v@P = 0;
attribwrangle/snippet
[qL] id attribute to name ("pieceNNN")
s@name = sprintf("piece%d", i@id);
attribwrangle/snippet
[qL] name ("pieceNNN") numbering to id attrib
i@id = opdigits(s@name);
attribwrangle/snippet
[qL] Point (element) number to id attribute
i@id = @elemnum;
popforce/localforceexpression
[qL] Magnitude by Ramp over Lifespan
force *= chramp("force_by_age", @nage);
popforce/localforceexpression
[qL] Random Magnitude from id
// random magnitude from id (exp, min, max)
force *= fit01( pow(rand(@id*12+34), 1.0), 0.25, 1.0 );
popforce/localnoiseexpression
[qL] Amplitude by Ramp over Lifespan
amp *= chramp("amp_by_age", @nage);
popforce/localnoiseexpression
[qL] Random Amplitude from id
// random amplitude from id (exp, min, max)
amp *= fit01( pow(rand(@id*12+34), 1.0), 0.25, 1.0 );
popadvectbyvolumes/localexpression
[qL] Random Velocity Scale from id
//
velscale *= fit01( random(@id*12+34), 0.25, 1.0 );
// update velscale correctly for negative aged particles
//
if (@age<0.0) {
velscale *= (@age+@TimeInc) / @TimeInc;
}
popadvectbyvolumes/localexpression
[qL] Update velscale correctly for negative aged particles
//
if (@age<0.0) {
velscale *= (@age+@TimeInc) / @TimeInc;
}
popwrangle/snippet
[qL] Snap to 2nd Input SDF Boundary
// [qL] Snap to 2nd Input SDF Boundary
// Snaps points of 1st input to the SDF boundary of 2nd input
// 1st input: geometry
// 2nd input: SDF volume to snap to
// NOTE: make sure the exterior voxel band is large enough
// on the 2nd SDF volume
vector
d = volumegradient(1, 0, v@P),
v = 0;
float
sdf = volumesample(1, 0, v@P);
//if (sdf<0)
{
v = normalize(d) * -sdf;
}
v@P += v;