forked from Aeoll/Aelib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VEXpressions.txt
115 lines (100 loc) · 3.8 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
attribwrangle/snippet
[ae] ae_include
include <aevex.vfl>
//include <ease.vfl>
// we should include a bunch of function examples here
// or at least a list of all definitions
attribwrangle/snippet
[ae] Extract packed intrinsic transform and reapply
// extract
int id = point(0,"ptid", @primnum);
matrix3 transform = primintrinsic(1, "transform", id);
vector pivot = primintrinsic(1, "pivot", id);
vector pos = point(1, "P", id);
// reapply
setprimintrinsic(0, "transform", id, transform, "set");
setprimintrinsic(0, "pivot", id, pivot, "set");
setpointattrib(0, "P", id, pos, "set");
// can use packedfulltransform too?
attribwrangle/snippet
[ae] Extract packed intrinsic transform (cracktransform) and reapply
// reconstruct transform
matrix3 mytransform = primintrinsic(0, "transform", @primnum);
vector t = cracktransform(XFORM_TRS, XFORM_XYZ, 0, set(0,0,0), mytransform);
vector r = cracktransform(XFORM_TRS, XFORM_XYZ, 1, set(0,0,0), mytransform);
vector s = cracktransform(XFORM_TRS, XFORM_XYZ, 2, set(0,0,0), mytransform);
float ss = xnoise(0.5*@P);
matrix newxf = maketransform(XFORM_TRS, XFORM_XYZ, t, r, set(ss,ss,ss));
setprimintrinsic(0, "transform", @primnum, matrix3(newxf), "set");
attribwrangle/snippet
[ae] Scale Bullet objects
// set this for geometry wrangle/pop wrangle and not attrib wrangle?
// set the scale amount
float scale_value = 1.0f;
if(@Frame%40<20) {
scale_value = fit(f@dist_from_center, 0, 1, 1.1, 1);
}
else {
scale_value = fit(f@dist_from_center, 0, 1, 0.9, 1);
}
vector scale_amount = set(scale_value, scale_value, scale_value);
// get the current transform from the intrinsics and apply the scale
matrix3 m = primintrinsic(0, "transform", @primnum);
matrix scalem = maketransform(0, 0, {0,0,0}, {0,0,0}, scale_amount, @P);
m *= matrix3(scalem);
setprimintrinsic(0, "transform", @primnum, m);
// delete the id from the points to force the collision hull to regenerate
int pts[] = primpoints(0,i@primnum);
setpointattrib(0,"id",pts[0],-1);
attribwrangle/snippet
[ae] Colour Ramp
float r = rand( @ptnum );
@Cd = vector(chramp("ramp", r));
attribwrangle/snippet
[ae] Edged Window Threshold
// takes an attrib a in 0-1 range, an animation range and edge window size and transitions
float a = 0.5*(1+sin(@P));
int s = 0;
int e = 100;
float edge = 0.5;
float t = fit(@Frame, s, e, 0 ,1);
float t_max = fit(@Frame, s, e, 0, 1+edge);
float t_min = fit(@Frame, s, e, -edge, 1);
@Cd = fit(a, t_min, t_max, 0, 1);
attribwrangle/snippet
[ae] xyzdist-primuv or uvdist-primuv
int prim;
vector primuv;
//float dist = xyzdist(1, @P, prim, primuv);
float dist = uvdist(1, "uv", v@uv, prim, primuv);
vector p = primuv(1, "P", prim, primuv);
attribwrangle/snippet
[ae] Rotate points about axis
float a = @Time * @primnum * 20;
vector4 q = quaternion(radians(a), set(0,1,0));
vector cen = set(0);
@P -= cen;
@P = qrotate(q, @P);
@P += cen;
attribwrangle/snippet
[ae] pt/numpt
f@t = float(@ptnum)/(@numpt-1);
attribwrangle/snippet
[ae] Visualise Pieces
@Cd = rand(opdigits(s@name)+4545);
attribwrangle/snippet
[ae] Nicks distribution (heavy bias towards 1)
float r = rand(@ptnum*555+888 + chi("sd"));
float a = chf("scale")/ (chf("max_limit") + pow( fit01(r, 0, 1) , chf("pow") ));
attribwrangle/snippet
[ae] Modify Multiple Attributes
string str = chs("attribs");
string attrs[] = split(str);
foreach(string s; attrs){
if(haspointattrib(0, s) >= 0){
vector v = point(0, s, @ptnum);
// do something
v = normalize(v)*0.5;
setpointattrib(0, s, @ptnum, v);
}
}