1 |
function d3d_model_draw(argument0, argument1, argument2, argument3, argument4) //gml_Script_d3d_model_draw |
2 |
{ |
3 |
var m = argument0 |
4 |
var tex = argument4 |
5 |
var vertsize = 36 |
6 |
var vertuvoffset = 28 |
7 |
if (tex != -1 && tex != m[(9 << 0)]) |
8 |
{ |
9 |
var texuvs = texture_get_uvs(tex) |
10 |
var uspan = texuvs[2] - texuvs[0] |
11 |
var vspan = texuvs[3] - texuvs[1] |
12 |
var ubase = texuvs[0] |
13 |
var vbase = texuvs[1] |
14 |
if (m[(0 << 0)] != undefined && m[(3 << 0)] != undefined) |
15 |
{ |
16 |
var numverts = (buffer_tell(m[(3 << 0)])) / 8 |
17 |
buffer_seek(m[(3 << 0)], buffer_seek_start, 0) |
18 |
var __uvpos = vertuvoffset |
19 |
var __src = m[(3 << 0)] |
20 |
var __dest = m[(0 << 0)] |
21 |
for (var __i = 0; __i < numverts; __i++) |
22 |
{ |
23 |
var __u = buffer_read(__src, buffer_f32) |
24 |
var __v = buffer_read(__src, buffer_f32) |
25 |
__u = __u * uspan + ubase |
26 |
__v = __v * vspan + vbase |
27 |
buffer_poke(__dest, __uvpos, buffer_f32, __u) |
28 |
buffer_poke(__dest, (__uvpos + 4), buffer_f32, __v) |
29 |
__uvpos += vertsize |
30 |
} |
31 |
} |
32 |
if (m[(1 << 0)] != undefined && m[(4 << 0)] != undefined) |
33 |
{ |
34 |
numverts = (buffer_tell(m[(4 << 0)])) / 8 |
35 |
buffer_seek(m[(4 << 0)], buffer_seek_start, 0) |
36 |
__uvpos = vertuvoffset |
37 |
__src = m[(4 << 0)] |
38 |
__dest = m[(1 << 0)] |
39 |
for (__i = 0; __i < numverts; __i++) |
40 |
{ |
41 |
__u = buffer_read(__src, buffer_f32) |
42 |
__v = buffer_read(__src, buffer_f32) |
43 |
__u = __u * uspan + ubase |
44 |
__v = __v * vspan + vbase |
45 |
buffer_poke(__dest, __uvpos, buffer_f32, __u) |
46 |
buffer_poke(__dest, (__uvpos + 4), buffer_f32, __v) |
47 |
__uvpos += vertsize |
48 |
} |
49 |
} |
50 |
if (m[(2 << 0)] != undefined && m[(5 << 0)] != undefined) |
51 |
{ |
52 |
numverts = (buffer_tell(m[(5 << 0)])) / 8 |
53 |
buffer_seek(m[(5 << 0)], buffer_seek_start, 0) |
54 |
__uvpos = vertuvoffset |
55 |
__src = m[(5 << 0)] |
56 |
__dest = m[(2 << 0)] |
57 |
for (__i = 0; __i < numverts; __i++) |
58 |
{ |
59 |
__u = buffer_read(__src, buffer_f32) |
60 |
__v = buffer_read(__src, buffer_f32) |
61 |
__u = __u * uspan + ubase |
62 |
__v = __v * vspan + vbase |
63 |
buffer_poke(__dest, __uvpos, buffer_f32, __u) |
64 |
buffer_poke(__dest, (__uvpos + 4), buffer_f32, __v) |
65 |
__uvpos += vertsize |
66 |
} |
67 |
} |
68 |
array_set(m, (9 << 0), tex) |
69 |
if (m[(6 << 0)] != undefined) |
70 |
{ |
71 |
vertex_delete_buffer(m[(6 << 0)]) |
72 |
array_set(m, (6 << 0), undefined) |
73 |
} |
74 |
if (m[(7 << 0)] != undefined) |
75 |
{ |
76 |
vertex_delete_buffer(m[(7 << 0)]) |
77 |
array_set(m, (7 << 0), undefined) |
78 |
} |
79 |
if (m[(8 << 0)] != undefined) |
80 |
{ |
81 |
vertex_delete_buffer(m[(8 << 0)]) |
82 |
array_set(m, (8 << 0), undefined) |
83 |
} |
84 |
} |
85 |
var currColour = draw_get_colour() | ((draw_get_alpha() * 255) << 24) |
86 |
if (currColour != m[(10 << 0)] && (m[(13 << 0)] > 0 || m[(14 << 0)] > 0 || m[(15 << 0)] > 0)) |
87 |
{ |
88 |
var __numPointCols = m[(13 << 0)] |
89 |
var __numLineCols = m[(14 << 0)] |
90 |
var __numTriCols = m[(15 << 0)] |
91 |
if (m[(0 << 0)] != undefined) |
92 |
{ |
93 |
var __offsets = m[(16 << 0)] |
94 |
__dest = m[(0 << 0)] |
95 |
for (__i = 0; __i < __numPointCols; __i++) |
96 |
buffer_poke(__dest, __offsets[__i], buffer_u32, currColour) |
97 |
} |
98 |
if (m[(1 << 0)] != undefined) |
99 |
{ |
100 |
__offsets = m[(17 << 0)] |
101 |
__dest = m[(1 << 0)] |
102 |
for (__i = 0; __i < __numLineCols; __i++) |
103 |
buffer_poke(__dest, __offsets[__i], buffer_u32, currColour) |
104 |
} |
105 |
if (m[(2 << 0)] != undefined) |
106 |
{ |
107 |
__offsets = m[(18 << 0)] |
108 |
__dest = m[(2 << 0)] |
109 |
for (__i = 0; __i < __numTriCols; __i++) |
110 |
buffer_poke(__dest, __offsets[__i], buffer_u32, currColour) |
111 |
} |
112 |
if (m[(6 << 0)] != undefined) |
113 |
{ |
114 |
vertex_delete_buffer(m[(6 << 0)]) |
115 |
array_set(m, (6 << 0), undefined) |
116 |
} |
117 |
if (m[(7 << 0)] != undefined) |
118 |
{ |
119 |
vertex_delete_buffer(m[(7 << 0)]) |
120 |
array_set(m, (7 << 0), undefined) |
121 |
} |
122 |
if (m[(8 << 0)] != undefined) |
123 |
{ |
124 |
vertex_delete_buffer(m[(8 << 0)]) |
125 |
array_set(m, (8 << 0), undefined) |
126 |
} |
127 |
array_set(m, (10 << 0), currColour) |
128 |
} |
129 |
var mW = matrix_get(2) |
130 |
var mT = matrix_build(argument1, argument2, argument3, 0, 0, 0, 1, 1, 1) |
131 |
var mNew = matrix_multiply(mT, mW) |
132 |
matrix_set(2, mNew) |
133 |
var __oldrep = gpu_get_texrepeat() |
134 |
gpu_set_texrepeat(true) |
135 |
if (m[(2 << 0)] != undefined) |
136 |
{ |
137 |
if (m[(8 << 0)] == undefined) |
138 |
{ |
139 |
array_set(m, (8 << 0), vertex_create_buffer_from_buffer(m[(2 << 0)], global.__d3dPrimVF)) |
140 |
vertex_freeze(m[(8 << 0)]) |
141 |
} |
142 |
vertex_submit(m[(8 << 0)], 4, argument4) |
143 |
} |
144 |
if (m[(1 << 0)] != undefined) |
145 |
{ |
146 |
if (m[(7 << 0)] == undefined) |
147 |
{ |
148 |
array_set(m, (7 << 0), vertex_create_buffer_from_buffer(m[(1 << 0)], global.__d3dPrimVF)) |
149 |
vertex_freeze(m[(7 << 0)]) |
150 |
} |
151 |
vertex_submit(m[(7 << 0)], 2, argument4) |
152 |
} |
153 |
if (m[(0 << 0)] != undefined) |
154 |
{ |
155 |
if (m[(6 << 0)] == undefined) |
156 |
{ |
157 |
array_set(m, (6 << 0), vertex_create_buffer_from_buffer(m[(0 << 0)], global.__d3dPrimVF)) |
158 |
vertex_freeze(m[(6 << 0)]) |
159 |
} |
160 |
vertex_submit(m[(6 << 0)], 1, argument4) |
161 |
} |
162 |
matrix_set(2, mW) |
163 |
gpu_set_texrepeat(__oldrep) |
164 |
} |