1 |
function d3d_model_save(argument0, argument1) //gml_Script_d3d_model_save |
2 |
{ |
3 |
var __ind = argument0 |
4 |
var __fname = argument1 |
5 |
var __file = file_text_open_write(__fname) |
6 |
if (__file == -1) |
7 |
return -1; |
8 |
var __vertexsize = 36 |
9 |
var __numthings = 0 |
10 |
var __numpointverts = 0 |
11 |
var __numlineverts = 0 |
12 |
var __numtriverts = 0 |
13 |
if (__ind[(0 << 0)] != undefined) |
14 |
{ |
15 |
var __buffpos = buffer_tell(__ind[(0 << 0)]) |
16 |
if (__buffpos > 0) |
17 |
__numthings += 2 |
18 |
__numpointverts = __buffpos / __vertexsize |
19 |
__numthings += __numpointverts |
20 |
} |
21 |
if (__ind[(1 << 0)] != undefined) |
22 |
{ |
23 |
__buffpos = buffer_tell(__ind[(1 << 0)]) |
24 |
if (__buffpos > 0) |
25 |
__numthings += 2 |
26 |
__numlineverts = __buffpos / __vertexsize |
27 |
__numthings += __numlineverts |
28 |
} |
29 |
if (__ind[(2 << 0)] != undefined) |
30 |
{ |
31 |
__buffpos = buffer_tell(__ind[(2 << 0)]) |
32 |
if (__buffpos > 0) |
33 |
__numthings += 2 |
34 |
__numtriverts = __buffpos / __vertexsize |
35 |
__numthings += __numtriverts |
36 |
} |
37 |
file_text_write_string(__file, "100") |
38 |
file_text_writeln(__file) |
39 |
file_text_write_string(__file, string_format(__numthings, 0, 0)) |
40 |
file_text_writeln(__file) |
41 |
if (__ind[(0 << 0)] != undefined) |
42 |
{ |
43 |
var __buf = __ind[(0 << 0)] |
44 |
if (__numpointverts > 0) |
45 |
{ |
46 |
file_text_write_string(__file, ("0 " + (string_format(1, 10, 4)) + " 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000")) |
47 |
file_text_writeln(__file) |
48 |
buffer_seek(__buf, buffer_seek_start, 0) |
49 |
for (var __i = 0; __i < __numpointverts; __i++) |
50 |
{ |
51 |
var __x = buffer_read(__buf, buffer_f32) |
52 |
var __y = buffer_read(__buf, buffer_f32) |
53 |
var __z = buffer_read(__buf, buffer_f32) |
54 |
var __nx = buffer_read(__buf, buffer_f32) |
55 |
var __ny = buffer_read(__buf, buffer_f32) |
56 |
var __nz = buffer_read(__buf, buffer_f32) |
57 |
var __colalpha = buffer_read(__buf, buffer_u32) |
58 |
var __u = buffer_read(__buf, buffer_f32) |
59 |
var __v = buffer_read(__buf, buffer_f32) |
60 |
var __col = __colalpha & 16777215 |
61 |
var __alpha = ((__colalpha >> 24) & 255) / 255 |
62 |
file_text_write_string(__file, ("9 " + (string_format(__x, 10, 4)) + " " + (string_format(__y, 10, 4)) + " " + (string_format(__z, 10, 4)) + " " + (string_format(__nx, 10, 4)) + " " + (string_format(__ny, 10, 4)) + " " + (string_format(__nz, 10, 4)) + " " + (string_format(__u, 10, 4)) + " " + (string_format(__v, 10, 4)) + " " + (string_format(__col, 10, 4)) + " " + (string_format(__alpha, 10, 4)))) |
63 |
file_text_writeln(__file) |
64 |
} |
65 |
file_text_write_string(__file, "1 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000") |
66 |
file_text_writeln(__file) |
67 |
} |
68 |
} |
69 |
if (__ind[(1 << 0)] != undefined) |
70 |
{ |
71 |
__buf = __ind[(1 << 0)] |
72 |
if (__numlineverts > 0) |
73 |
{ |
74 |
file_text_write_string(__file, ("0 " + (string_format(2, 10, 4)) + " 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000")) |
75 |
file_text_writeln(__file) |
76 |
buffer_seek(__buf, buffer_seek_start, 0) |
77 |
for (__i = 0; __i < __numlineverts; __i++) |
78 |
{ |
79 |
__x = buffer_read(__buf, buffer_f32) |
80 |
__y = buffer_read(__buf, buffer_f32) |
81 |
__z = buffer_read(__buf, buffer_f32) |
82 |
__nx = buffer_read(__buf, buffer_f32) |
83 |
__ny = buffer_read(__buf, buffer_f32) |
84 |
__nz = buffer_read(__buf, buffer_f32) |
85 |
__colalpha = buffer_read(__buf, buffer_u32) |
86 |
__u = buffer_read(__buf, buffer_f32) |
87 |
__v = buffer_read(__buf, buffer_f32) |
88 |
__col = __colalpha & 16777215 |
89 |
__alpha = ((__colalpha >> 24) & 255) / 255 |
90 |
file_text_write_string(__file, ("9 " + (string_format(__x, 10, 4)) + " " + (string_format(__y, 10, 4)) + " " + (string_format(__z, 10, 4)) + " " + (string_format(__nx, 10, 4)) + " " + (string_format(__ny, 10, 4)) + " " + (string_format(__nz, 10, 4)) + " " + (string_format(__u, 10, 4)) + " " + (string_format(__v, 10, 4)) + " " + (string_format(__col, 10, 4)) + " " + (string_format(__alpha, 10, 4)))) |
91 |
file_text_writeln(__file) |
92 |
} |
93 |
file_text_write_string(__file, "1 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000") |
94 |
file_text_writeln(__file) |
95 |
} |
96 |
} |
97 |
if (__ind[(2 << 0)] != undefined) |
98 |
{ |
99 |
__buf = __ind[(2 << 0)] |
100 |
if (__numtriverts > 0) |
101 |
{ |
102 |
file_text_write_string(__file, ("0 " + (string_format(4, 10, 4)) + " 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000")) |
103 |
file_text_writeln(__file) |
104 |
buffer_seek(__buf, buffer_seek_start, 0) |
105 |
for (__i = 0; __i < __numtriverts; __i++) |
106 |
{ |
107 |
__x = buffer_read(__buf, buffer_f32) |
108 |
__y = buffer_read(__buf, buffer_f32) |
109 |
__z = buffer_read(__buf, buffer_f32) |
110 |
__nx = buffer_read(__buf, buffer_f32) |
111 |
__ny = buffer_read(__buf, buffer_f32) |
112 |
__nz = buffer_read(__buf, buffer_f32) |
113 |
__colalpha = buffer_read(__buf, buffer_u32) |
114 |
__u = buffer_read(__buf, buffer_f32) |
115 |
__v = buffer_read(__buf, buffer_f32) |
116 |
__col = __colalpha & 16777215 |
117 |
__alpha = ((__colalpha >> 24) & 255) / 255 |
118 |
file_text_write_string(__file, ("9 " + (string_format(__x, 10, 4)) + " " + (string_format(__y, 10, 4)) + " " + (string_format(__z, 10, 4)) + " " + (string_format(__nx, 10, 4)) + " " + (string_format(__ny, 10, 4)) + " " + (string_format(__nz, 10, 4)) + " " + (string_format(__u, 10, 4)) + " " + (string_format(__v, 10, 4)) + " " + (string_format(__col, 10, 4)) + " " + (string_format(__alpha, 10, 4)))) |
119 |
file_text_writeln(__file) |
120 |
} |
121 |
file_text_write_string(__file, "1 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000 0000000000.0000") |
122 |
file_text_writeln(__file) |
123 |
} |
124 |
} |
125 |
file_text_close(__file) |
126 |
} |