-
Notifications
You must be signed in to change notification settings - Fork 1
/
Save_Images_and_point_info_from_jeans.mel
103 lines (77 loc) · 3.71 KB
/
Save_Images_and_point_info_from_jeans.mel
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
// Process to save images and interesting points in maya, for jeans 1:
//point1 = 24;
//point2 = 487;
//face1_approach = 918;
//face2_approach = 886;
// Setting drag:
$aire = 0;
drag -pos 0 0 0 -m 0.05 -att 1 -dx 0 -dy 0 -dz 0 -ud 0 -mxd -1 -vsh none -vex 0 -vof 0 0 0 -vsw 360 -tsr 0.5 ;
// Open the file to write the position and orientation of interesting vertices
$fileid = fopen("/Users/ecorona/Documents/Database/"+$cloth2+".csv");
// Start the captures:
for( $x = 0; $x < size($vertics_Jeans1); $x = $x+1){ //Condition: $x<$k[0]
// Move jeans to the middle:
currentTime 1;
string $instruction = $cloth+".vtx[" + $vertics_Jeans1[$x] + "]";
float $pos[] = `pointPosition $instruction`;
select -r $cloth;
move -r (-1*$pos[0]) (58-1*$pos[1]) (-1*$pos[2]) ;
select -r $instruction; //$cloth.vtx[$vertics_T_Shirt_1e[$x]] ;
// Transform constraint:
createNConstraint transform 0;
// Setting drag if there is.
if($aire == 1){
setAttr "dragField1.magnitude" -40;
}
// Move on in time
for( $t=2; $t<500; ++$t){
currentTime $t ;
if ($aire == 1 && $t == 100){
setAttr "dragField1.magnitude" 0;
}
}
// Iterate cameras to take photos and save information:
for( $c=1; $c<=36; ++$c){
string $cam = "camera" + $c;
string $final_name = "/Users/ecorona/Documents/Database/" + $cloth2 + "_" + $x + "_" + $c + ".tif";
$direction = `render $cam`; //render -layer DepthLayer $cam;
sysFile -move $final_name $direction;
//Let's get first point:
// Posicio x,y,z
float $pos1[] = `pointPosition Jeans.vtx[487]`;
// L'orientació, per saber com agafar es pot trobar amb dos vertexs, sabent la diferència de posició del que està més a dins al de més a fora.
float $pos1_2[] = `pointPosition Jeans.vtx[996]`;
$orientation_x1 = $pos1[0]-$pos1_2[0];
$orientation_y1 = $pos1[1]-$pos1_2[1];
$orientation_z1 = $pos1[2]-$pos1_2[2];
// Orientació de la cara que haurem d'agafar, per saber com coloquem la pinça
$Face_orientation = `polyInfo -faceNormals Jeans.f[918]`;
string $buffer[];
tokenize $Face_orientation[0] " " $buffer;
$approach_x1 = float($buffer[2]);
$approach_y1 = float($buffer[3]);
$approach_z1 = float($buffer[4]);
//Let's get second point:
// Posicio x,y,z
float $pos2[] = `pointPosition Jeans.vtx[24]`;
// L'orientació, per saber com agafar es pot trobar amb dos vertexs, sabent la diferència de posició del que està més a dins al de més a fora.
float $pos2_2[] = `pointPosition Jeans.vtx[965]`;
$orientation_x2 = $pos2[0] - $pos2_2[0];
$orientation_y2 = $pos2[1] - $pos2_2[1];
$orientation_z2 = $pos2[2] - $pos2_2[2];
// Orientació de la cara que haurem d'agafar, per saber com coloquem la pinça
$Face_orientation = `polyInfo -faceNormals Jeans.f[886]`;
string $buffer[];
tokenize $Face_orientation[0] " " $buffer;
$approach_x2 = float($buffer[2]);
$approach_y2 = float($buffer[3]);
$approach_z2 = float($buffer[4]);
// Save info in csv file:
fprint $fileid($x+","+$c+","+$pos1[0]+","+$pos1[1]+","+$pos1[2]+","+$orientation_x1+","+$orientation_y1+","+$orientation_z1+","+$approach_x1+","+$approach_y1+","+$approach_z1+","+$pos2[0]+","+$pos2[1]+","+$pos2[2]+","+$orientation_x2+","+$orientation_y2+","+$orientation_z2+","+$approach_x2+","+$approach_y2+","+$approach_z2+"\n");
}
// Delete constraint:
string $instruction = "dynamicConstraint"+1;//+($x+91);
select -r $instruction;
doDelete;
}
fclose $fileid;