-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMADE_ForceVertexNormalsToFace.mel
More file actions
52 lines (41 loc) · 1.18 KB
/
MADE_ForceVertexNormalsToFace.mel
File metadata and controls
52 lines (41 loc) · 1.18 KB
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
/**
* This script sets the vertex normals of the selected faces to
* the normals of their corresponding face and locks the normals.
*
* @author Manfred Nerurkar
* @date 2016
* @copyright MADE GmbH
*/
global proc MADE_forceVertexNormalsToFace()
{
// save intitial selection
string $select[] = `ls -sl`;
// get array of all selected faces
string $selected_faces[] = `filterExpand -sm 34`;
// clear selections
select -cl;
// iterate through faces
for ($face in $selected_faces) {
// select face, and replace current selection
select -r $face;
// get poly info for selection
// Result: FACE_NORMAL 16: 1.000000 0.000000 0.000000
string $normals[] = `polyInfo -faceNormals`;
// split into array
string $buffer[];
tokenize $normals[0] $buffer;
// convert to float normal
float $normal[3];
$normal[0] = $buffer[2];
$normal[1] = $buffer[3];
$normal[2] = $buffer[4];
// convert face selection to vertices
PolySelectConvert 3;
// set vertex normal
polyNormalPerVertex -xyz $normal[0] $normal[1] $normal[2];
}
// restore initial selection
select -r $select;
// switch back to faces (disable all components, enable faces)
selectType -alc 0 -fc 1;
}