-
Notifications
You must be signed in to change notification settings - Fork 7
/
dump_static_mesh_ply.1sc
61 lines (54 loc) · 2.08 KB
/
dump_static_mesh_ply.1sc
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
//--------------------------------------
//--- 010 Editor v3.2 Script File
//
// File:
// Author:
// Revision:
// Purpose:
//--------------------------------------
void printVertex(int f, Vertex &v) {
FPrintf(f, "%f %f %f\n", v.X, v.Y, v.Z);
}
int vertex_count;
int triangle_count;
int e;
int i;
int j;
int triangle_offset;
int this_file = GetFileNum();
int file;
string name;
for (e = 0; e < h.export_count; ++e) {
if (FClassRead(export_table[e].class) == "Core.Class'StaticMesh'") {
file = FileNew();
FileSelect(this_file);
triangle_count = 0;
for (i = 0; i < IndexReadInt(export_data[e].surfaces.count); ++i) {
triangle_count += export_data[e].surfaces.data[i].triangle_count;
}
if (triangle_count * 3 > IndexReadInt(export_data[e].vertex_indices_1.count))
continue;
vertex_count = IndexReadInt(export_data[e].vertexes.count);
FPrintf(file, "ply\nformat ascii 1.0\nelement vertex %d\nproperty float x\nproperty float y\nproperty float z\nelement face %d\nproperty list uchar int vertex_indices\nend_header\n",
vertex_count,
triangle_count
);
for (i = 0; i < vertex_count; ++i) {
printVertex(file, export_data[e].vertexes.data[i].point);
}
triangle_offset = 0;
for (i = 0; i < IndexReadInt(export_data[e].surfaces.count); ++i) {
for (j = 0; j < export_data[e].surfaces.data[i].triangle_count; ++j) {
FPrintf(file, "3 %d %d %d\n", export_data[e].vertex_indices_1.data[triangle_offset++]
, export_data[e].vertex_indices_1.data[triangle_offset++]
, export_data[e].vertex_indices_1.data[triangle_offset++]
);
}
}
name = "C:\\Users\\Michael\\Projects\\open-source\\l2j\\extract\\" + FNameRead(export_table[e].name) + ".ply";
FileSelect(file);
FileSave(name);
FileClose();
FileSelect(this_file);
}
}