-
Notifications
You must be signed in to change notification settings - Fork 2
/
wristRoll.vfl
54 lines (38 loc) · 1.43 KB
/
wristRoll.vfl
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
//get the roll attribute
//go through all bones with elbow prefix
//divide roll from wrist
//reset wrist
//add rotation to each bone
int pointsofinterest[];
int totalpoints = npoints(0);
//find wrist to extract roll from
int wristpointnum = -1;
for( int j = 0 ; j < totalpoints ; j++ ){
string thisname = point( 1 , "name" , j );
if( thisname == "wrist" ){
wristpointnum = j ;
break;
}
}
if( wristpointnum == -1 ){
printf("no input wrist found");
}
float roll = point( 1 , "roll" , wristpointnum ); //GET ROLL FROM SECOND INPUT.
for( int i = 0 ; i < totalpoints ; i++ ) {
//string matching?
string nameattribute = point( 0 , "name", i);
string nameattributesplits[] = split( nameattribute, "_" );
//FILTER RESULTS
if( len(nameattributesplits)==2 && nameattributesplits[0]=="elbow" && nameattributesplits[1]!="mirror" ){
push( pointsofinterest, i );
}
}
float roll_distribute = roll / len(pointsofinterest);
for( int k = 0 ; k < len(pointsofinterest) ; k++ ){
vector4 newquaternion = eulertoquaternion( set( radians( 0 ) , radians( 0 ) , radians( roll_distribute * k ) ) , 0 );
matrix3 rollMatrix = qconvert( newquaternion );
matrix rollTransform = set( rollMatrix );
matrix3 pointtransform = point( 0 , "transform" , pointsofinterest[k] );
pointtransform *= rollMatrix;
setpointattrib( 0 , "transform" , pointsofinterest[k] , pointtransform , "set" );
}