Mercurial > mm7
annotate IndoorCameraD3D.cpp @ 1394:8ea496564034
Some LightmapBuilder renames.
author | Nomad |
---|---|
date | Thu, 18 Jul 2013 16:51:35 +0200 |
parents | cc9a3a24d61d |
children | 934074e7fcc1 |
rev | line source |
---|---|
0 | 1 #include "IndoorCameraD3D.h" |
2 #include "VectorTypes.h" | |
3 #include "Game.h" | |
4 #include "Indoor.h" | |
5 #include "Viewport.h" | |
6 #include "IndoorCamera.h" | |
7 #include "OutdoorCamera.h" | |
8 #include "Render.h" | |
9 #include "LOD.h" | |
10 #include "mm7_data.h" | |
11 | |
1016 | 12 #include "stru9.h" |
13 | |
781 | 14 //----- (004361EF) -------------------------------------------------------- |
15 IndoorCameraD3D::IndoorCameraD3D() | |
16 { | |
17 IndoorCameraD3D *v1; // esi@1 | |
18 //double v2; // st7@1 | |
19 //double v3; // st6@1 | |
20 //double v4; // st5@1 | |
21 //double v5; // st7@1 | |
22 //double v6; // st6@1 | |
23 //double v7; // st5@1 | |
0 | 24 |
781 | 25 v1 = this; |
26 //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&this->field_4); | |
27 //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v1->field_14); | |
28 //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v1->field_24); | |
29 /*_eh_vector_constructor_iterator_(v1->std__vector_000034_prolly_frustrum, | |
30 24, | |
31 6, | |
32 (void (__thiscall *)(void *))IndoorCameraD3D_Vec4::IndoorCameraD3D_Vec4, | |
33 (void (__thiscall *)(void *))IndoorCameraD3D_Vec4::dtor);*/ | |
34 //v2 = 0;//(double)pBLVRenderParams->vPartyPos.z; | |
35 //v3 = 0;//(double)pBLVRenderParams->vPartyPos.y; | |
36 //v4 = 0;//(double)pBLVRenderParams->vPartyPos.x; | |
37 v1->field_108 = 0.0; | |
38 v1->blv_party_x = 0; | |
39 v1->blv_party_y = 0; | |
40 v1->blv_party_z = 0; | |
41 //v5 = 0;//(double)pBLVRenderParams->vPartyPos.z; | |
42 //v6 = 0;//(double)pBLVRenderParams->vPartyPos.y; | |
43 //v7 = 300;//(double)(pBLVRenderParams->vPartyPos.x + 300); | |
44 v1->field_138 = 0.0; | |
45 v1->blv_party_x_2 = 300; | |
46 v1->blv_party_y_2 = 0; | |
47 v1->blv_party_z_2 = 0; | |
48 v1->field_168 = 0.0; | |
49 v1->field_198 = 0.0; | |
50 v1->field_1C8 = 0.0; | |
51 v1->field_1F8 = 0.0; | |
52 v1->field_228 = 0.0; | |
53 v1->field_258 = 0.0; | |
54 v1->field_288 = 0.0; | |
55 v1->field_2B8 = 0.0; | |
56 v1->field_2E8 = 0.0; | |
57 v1->field_2BC = 0.0; | |
58 v1->field_2C0 = 0.0; | |
59 v1->field_2C4 = 0.0; | |
60 v1->field_318 = 0.0; | |
61 v1->field_2EC = 0.0; | |
62 v1->field_2F0 = 0.0; | |
63 v1->field_2F4 = 0.0; | |
64 v1->field_348 = 0.0; | |
65 v1->field_31C = 0.0; | |
66 v1->field_320 = 0.0; | |
67 v1->field_324 = 0.0; | |
68 v1->field_378 = 0.0; | |
69 v1->field_34C = 0.0; | |
70 v1->field_350 = 0.0; | |
71 v1->field_354 = 0.0; | |
72 for (uint i = 0; i < 16384; ++i) | |
73 { | |
74 list_0037C[i].field_0 = 0; | |
75 list_0037C[i].flt_30 = 0.0f; | |
76 } | |
77 | |
78 list_0037C_size = 0; | |
79 for (uint i = 0; i < 256; ++i) | |
80 list_E0380[i].mm7__vector_000004_size = 0; | |
81 /*v10 = v1->list_E0380; | |
82 v12 = 256; | |
83 do | |
84 { | |
85 v10->mm7__vector_000004_size = 0; | |
86 //mm7__vector_constructor( | |
87 // v10->mm7__vector_000004, | |
88 // 48, | |
89 // 64, | |
90 // (int (__thiscall *)(int))IndoorCameraD3D_stru1::IndoorCameraD3D_stru1); | |
91 //++v10; | |
92 --v12; | |
93 } | |
94 while ( v12 );*/ | |
95 list_E0380_size = 0; | |
96 //v1->vdestructor_ptr = &stru8_pvdtor; | |
97 } | |
0 | 98 |
871 | 99 |
100 //----- (0043643E) -------------------------------------------------------- | |
101 float IndoorCameraD3D::GetPickDepth() | |
102 { | |
103 if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) | |
104 return pOutdoorCamera->uPickDepth; | |
105 else | |
106 return 16192.0; | |
107 } | |
108 | |
109 | |
0 | 110 //----- (004364C5) -------------------------------------------------------- |
111 void IndoorCameraD3D::ViewTransfrom_OffsetUV(RenderVertexSoft *pVertices, unsigned int uNumVertices, RenderVertexSoft *pOutVertices, stru320 *a5) | |
112 { | |
113 for (uint i = 0; i < uNumVertices; ++i) | |
114 { | |
115 pOutVertices[i].vWorldPosition.x = pVertices[i].vWorldPosition.x; | |
116 pOutVertices[i].vWorldPosition.y = pVertices[i].vWorldPosition.y; | |
117 pOutVertices[i].vWorldPosition.z = pVertices[i].vWorldPosition.z; | |
118 | |
119 pOutVertices[i].u = pVertices[i].u + a5->pDeltaUV[0]; | |
120 pOutVertices[i].v = pVertices[i].v + a5->pDeltaUV[1]; | |
121 } | |
122 ViewTransform(pOutVertices, uNumVertices); | |
123 } | |
124 | |
125 //----- (0043669D) -------------------------------------------------------- | |
126 char IndoorCameraD3D::ApplyViewTransform_TrueIfStillVisible(int x, int y, int z, signed int *pOutX, int *pOutZ, int *pOutY, char bDoNotShow) | |
127 { | |
128 int to_z; // esi@2 | |
129 int v9; // ecx@3 | |
130 signed int *v10; // esi@5 | |
131 int pOutY_; // ecx@5 | |
132 signed int v12; // esi@7 | |
133 int v14; // [sp+8h] [bp-4h]@3 | |
134 int to_x; // [sp+14h] [bp+8h]@1 | |
135 int to_y; // [sp+18h] [bp+Ch]@1 | |
136 int a2b; // [sp+18h] [bp+Ch]@5 | |
137 int a3a; // [sp+1Ch] [bp+10h]@5 | |
138 | |
1370 | 139 to_x = x - pBLVRenderParams->vPartyPos.x; |
140 to_y = y - pBLVRenderParams->vPartyPos.y; | |
0 | 141 if ( pBLVRenderParams->sPartyRotX ) |
142 { | |
143 to_z = (z - pBLVRenderParams->vPartyPos.z) << 16; | |
144 if ( pRenderer->pRenderD3D ) | |
145 { | |
1370 | 146 v14 = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) |
147 + (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY); | |
148 v9 = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) | |
149 - (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY); | |
0 | 150 } |
151 else | |
152 { | |
153 v14 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) | |
154 - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16); | |
155 v9 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16) | |
156 + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); | |
157 } | |
158 a3a = (z - pBLVRenderParams->vPartyPos.z) << 16; | |
159 a2b = (unsigned __int64)(to_z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; | |
160 v10 = pOutX; | |
161 *pOutX = ((unsigned __int64)(v14 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - a2b; | |
162 *pOutZ = v9; | |
163 pOutY_ = ((unsigned __int64)(v14 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) | |
164 + ((unsigned __int64)(a3a * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); | |
165 } | |
166 else | |
167 { | |
168 pOutY_ = (z - pBLVRenderParams->vPartyPos.z) << 16; | |
169 if ( pRenderer->pRenderD3D ) | |
170 { | |
171 v10 = pOutX; | |
1370 | 172 *pOutX = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) |
173 + (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY); | |
174 *pOutZ = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) | |
175 - (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY); | |
0 | 176 } |
177 else | |
178 { | |
179 v10 = pOutX; | |
180 *pOutX = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) | |
181 - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16); | |
182 *pOutZ = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16) | |
183 + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); | |
184 } | |
185 } | |
186 *pOutY = pOutY_; | |
187 return !bDoNotShow || (v12 = *v10, v12 >= (signed int)0x40000u) && v12 <= (signed int)0x1F400000u; | |
188 } | |
189 | |
190 //----- (00436455) -------------------------------------------------------- | |
191 bool IndoorCameraD3D::IsCulled(BLVFace *pFace) | |
192 { | |
193 RenderVertexSoft v; // [sp+8h] [bp-30h]@1 | |
194 | |
195 Vec3_short__to_RenderVertexSoft(&v, &pIndoor->pVertices[*pFace->pVertexIDs]); | |
196 return is_face_faced_to_camera(pFace, &v); | |
197 } | |
198 | |
199 //----- (00436523) -------------------------------------------------------- | |
200 void IndoorCameraD3D::ViewTransform(RenderVertexSoft *a1a, unsigned int uNumVertices) | |
201 { | |
202 if (byte_4D864C && pGame->uFlags & 0x80 || | |
203 uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
204 { | |
205 float sin_x = pIndoorCamera->fRotationXSine, | |
206 cos_x = pIndoorCamera->fRotationXCosine; | |
207 float sin_y = pIndoorCamera->fRotationYSine, | |
208 cos_y = pIndoorCamera->fRotationYCosine; | |
209 | |
210 //v4 = uNumVertices; | |
211 //v7 = pIndoorCamera->fRotationXSine; | |
212 if ( pIndoorCamera->sRotationX ) | |
213 { | |
214 | |
215 //_EAX = a1a; | |
216 for (uint i = 0; i < uNumVertices; ++i) | |
217 { | |
218 float st0, st1, st2; | |
219 if ( pRenderer->pRenderD3D ) | |
220 { | |
221 /*__asm | |
222 { | |
223 fld [ebp+uNumVertices] // [(a1a[i].y - pIndoorCamera->pos.y)] [(a1a[i].z - pIndoorCamera->pos.z)] [pIndoorCamera->fRotationXCosine] [pIndoorCamera->fRotationYSine] [pIndoorCamera->fRotationYCosine] | |
224 fmul st, st(3) // [pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] [(a1a[i].z - pIndoorCamera->pos.z)] [pIndoorCamera->fRotationXCosine] [pIndoorCamera->fRotationYSine] [pIndoorCamera->fRotationYCosine] | |
225 fld [ebp+a1] // [(a1a[i].x - pIndoorCamera->pos.x)] [pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] [(a1a[i].z - pIndoorCamera->pos.z)] [pIndoorCamera->fRotationXCosine] [pIndoorCamera->fRotationYSine] [pIndoorCamera->fRotationYCosine] | |
226 fmul st, st(5) // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)] | |
227 // 1[pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
228 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
229 // 3[pIndoorCamera->fRotationXCosine] | |
230 // 4[pIndoorCamera->fRotationYSine] | |
231 // 5[pIndoorCamera->fRotationYCosine] | |
232 faddp st(1), st // [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] [(a1a[i].z - pIndoorCamera->pos.z)] [pIndoorCamera->fRotationXCosine] [pIndoorCamera->fRotationYSine] [pIndoorCamera->fRotationYCosine] | |
233 fld [ebp+a1] // [(a1a[i].x - pIndoorCamera->pos.x)] [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] [(a1a[i].z - pIndoorCamera->pos.z)] [pIndoorCamera->fRotationXCosine] [pIndoorCamera->fRotationYSine] [pIndoorCamera->fRotationYCosine] | |
234 fmul st, st(4) // [pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)] [pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] [(a1a[i].z - pIndoorCamera->pos.z)] [pIndoorCamera->fRotationXCosine] [pIndoorCamera->fRotationYSine] [pIndoorCamera->fRotationYCosine] | |
235 | |
236 fld [ebp+uNumVertices] // 0[a1a[i].y - pIndoorCamera->pos.y] | |
237 // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)] | |
238 // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
239 // 3[(a1a[i].z - pIndoorCamera->pos.z)] | |
240 // 4[pIndoorCamera->fRotationXCosine] | |
241 // 5[pIndoorCamera->fRotationYSine] | |
242 // 6[pIndoorCamera->fRotationYCosine] | |
243 | |
244 fmul st, st(6) // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)] | |
245 // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)] | |
246 // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
247 // 3[(a1a[i].z - pIndoorCamera->pos.z)] | |
248 // 4[pIndoorCamera->fRotationXCosine] | |
249 // 5[pIndoorCamera->fRotationYSine] | |
250 // 6[pIndoorCamera->fRotationYCosine] | |
251 | |
252 fsubp st(1), st // 0[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)] | |
253 // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) + pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
254 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
255 // 3[pIndoorCamera->fRotationXCosine] | |
256 // 4[pIndoorCamera->fRotationYSine] | |
257 // 5[pIndoorCamera->fRotationYCosine] | |
258 }*/ | |
259 st0 = sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y); | |
260 st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) + sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y); | |
261 st2 = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z); | |
262 } | |
263 else | |
264 { | |
265 /*__asm | |
266 { | |
267 fld [ebp+a1] // 0[(a1a[i].x - pIndoorCamera->pos.x)] | |
268 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
269 // 2[pIndoorCamera->fRotationXCosine] | |
270 // 3[pIndoorCamera->fRotationYSine] | |
271 // 4[pIndoorCamera->fRotationYCosine] | |
272 fmul st, st(4) // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)] | |
273 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
274 // 2[pIndoorCamera->fRotationXCosine] | |
275 // 3[pIndoorCamera->fRotationYSine] | |
276 // 4[pIndoorCamera->fRotationYCosine] | |
277 fld [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)] | |
278 // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)] | |
279 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
280 // 3[pIndoorCamera->fRotationXCosine] | |
281 // 4[pIndoorCamera->fRotationYSine] | |
282 // 5[pIndoorCamera->fRotationYCosine] | |
283 fmul st, st(4) // 0[pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
284 // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x)] | |
285 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
286 // 3[pIndoorCamera->fRotationXCosine] | |
287 // 4[pIndoorCamera->fRotationYSine] | |
288 // 5[pIndoorCamera->fRotationYCosine] | |
289 fsubp st(1), st // 0[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
290 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
291 // 2[pIndoorCamera->fRotationXCosine] | |
292 // 3[pIndoorCamera->fRotationYSine] | |
293 // 4[pIndoorCamera->fRotationYCosine] | |
294 fld [ebp+a1] // 0[(a1a[i].x - pIndoorCamera->pos.x)] | |
295 // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
296 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
297 // 3[pIndoorCamera->fRotationXCosine] | |
298 // 4[pIndoorCamera->fRotationYSine] | |
299 // 5[pIndoorCamera->fRotationYCosine] | |
300 fmul st, st(4) // 0[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)] | |
301 // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
302 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
303 // 3[pIndoorCamera->fRotationXCosine] | |
304 // 4[pIndoorCamera->fRotationYSine] | |
305 // 5[pIndoorCamera->fRotationYCosine] | |
306 fld [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)] | |
307 // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)] | |
308 // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
309 // 3[(a1a[i].z - pIndoorCamera->pos.z)] | |
310 // 4[pIndoorCamera->fRotationXCosine] | |
311 // 5[pIndoorCamera->fRotationYSine] | |
312 // 6[pIndoorCamera->fRotationYCosine] | |
313 fmul st, st(6) // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y)] | |
314 // 1[pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)] | |
315 // 2[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
316 // 3[(a1a[i].z - pIndoorCamera->pos.z)] | |
317 // 4[pIndoorCamera->fRotationXCosine] | |
318 // 5[pIndoorCamera->fRotationYSine] | |
319 // 6[pIndoorCamera->fRotationYCosine] | |
320 faddp st(1), st // 0[pIndoorCamera->fRotationYCosine * (a1a[i].y - pIndoorCamera->pos.y) + pIndoorCamera->fRotationYSine * (a1a[i].x - pIndoorCamera->pos.x)] | |
321 // 1[pIndoorCamera->fRotationYCosine * (a1a[i].x - pIndoorCamera->pos.x) - pIndoorCamera->fRotationYSine * (a1a[i].y - pIndoorCamera->pos.y)] | |
322 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
323 // 3[pIndoorCamera->fRotationXCosine] | |
324 // 4[pIndoorCamera->fRotationYSine] | |
325 // 5[pIndoorCamera->fRotationYCosine] | |
326 }*/ | |
327 st0 = cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y) + sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x); | |
328 st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y); | |
329 st2 = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z); | |
330 } | |
331 | |
332 a1a[i].vWorldViewPosition.x = st1*cos_x - st2*sin_x; | |
333 a1a[i].vWorldViewPosition.y = st0; | |
334 a1a[i].vWorldViewPosition.z = st2*cos_x + st1*sin_x; | |
335 } | |
336 } | |
337 else | |
338 { | |
339 for (uint i = 0; i < uNumVertices; ++i) | |
340 { | |
341 if ( pRenderer->pRenderD3D ) | |
342 { | |
343 /*__asm | |
344 { | |
345 fld [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)] | |
346 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
347 // 2[sin_y] | |
348 // 3[cos_y] | |
349 fmul st, st(2) // 0[sin_y * (a1a[i].y - pIndoorCamera->pos.y)] | |
350 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
351 // 2[sin_y] | |
352 // 3[cos_y] | |
353 fld [ebp+a1] // 0[(a1a[i].x - pIndoorCamera->pos.x)] | |
354 // 1[sin_y * (a1a[i].y - pIndoorCamera->pos.y)] | |
355 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
356 // 3[sin_y] | |
357 // 4[cos_y] | |
358 fmul st, st(4) // 0[cos_y * (a1a[i].x - pIndoorCamera->pos.x)] | |
359 // 1[sin_y * (a1a[i].y - pIndoorCamera->pos.y)] | |
360 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
361 // 3[sin_y] | |
362 // 4[cos_y] | |
363 faddp st(1), st // 0[cos_y * (a1a[i].x - pIndoorCamera->pos.x) + sin_y * (a1a[i].y - pIndoorCamera->pos.y)] | |
364 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
365 // 2[sin_y] | |
366 // 3[cos_y] | |
367 fstp dword ptr [eax+0Ch] | |
368 fld [ebp+a1] // 0[(a1a[i].x - pIndoorCamera->pos.x)] | |
369 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
370 // 2[sin_y] | |
371 // 3[cos_y] | |
372 fmul st, st(2) // 0[sin_y * (a1a[i].x - pIndoorCamera->pos.x)] | |
373 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
374 // 2[sin_y] | |
375 // 3[cos_y] | |
376 fld [ebp+uNumVertices] // 0[(a1a[i].y - pIndoorCamera->pos.y)] | |
377 // 1[sin_y * (a1a[i].x - pIndoorCamera->pos.x)] | |
378 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
379 // 3[sin_y] | |
380 // 4[cos_y] | |
381 fmul st, st(4) // 0[cos_y * (a1a[i].y - pIndoorCamera->pos.y)] | |
382 // 1[sin_y * (a1a[i].x - pIndoorCamera->pos.x)] | |
383 // 2[(a1a[i].z - pIndoorCamera->pos.z)] | |
384 // 3[sin_y] | |
385 // 4[cos_y] | |
386 fsubp st(1), st // 0[sin_y * (a1a[i].x - pIndoorCamera->pos.x) - cos_y * (a1a[i].y - pIndoorCamera->pos.y)] | |
387 // 1[(a1a[i].z - pIndoorCamera->pos.z)] | |
388 // 2[sin_y] | |
389 // 3[cos_y] | |
390 fstp dword ptr [eax+10h] | |
391 fstp dword ptr [eax+14h] | |
392 }*/ | |
393 a1a[i].vWorldViewPosition.x = cos_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) + sin_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y); | |
394 a1a[i].vWorldViewPosition.y = sin_y * (a1a[i].vWorldPosition.x - pIndoorCamera->pos.x) - cos_y * (a1a[i].vWorldPosition.y - pIndoorCamera->pos.y); | |
395 a1a[i].vWorldViewPosition.z = (a1a[i].vWorldPosition.z - pIndoorCamera->pos.z); | |
396 } | |
397 else | |
398 { | |
399 __debugbreak(); | |
400 /*__asm | |
401 { | |
402 fld [ebp+a1] | |
403 fmul st, st(3) | |
404 fld [ebp+uNumVertices] | |
405 fmul st, st(3) | |
406 fsubp st(1), st | |
407 fstp dword ptr [eax+0Ch] | |
408 fld [ebp+a1] | |
409 fmul st, st(2) | |
410 fld [ebp+uNumVertices] | |
411 fmul st, st(4) | |
412 faddp st(1), st | |
413 | |
414 fstp dword ptr [eax+10h] | |
415 fstp dword ptr [eax+14h] | |
416 }*/ | |
417 } | |
418 } | |
419 } | |
420 } | |
421 else for (uint i = 0; i < uNumVertices; ++i) | |
422 pIndoorCamera->ViewTransform(a1a + i); | |
423 } | |
424 | |
425 //----- (00436932) -------------------------------------------------------- | |
426 bool IndoorCameraD3D::GetFacetOrientation(char polyType, Vec3_float_ *a2, Vec3_float_ *a3, Vec3_float_ *a4) | |
427 { | |
428 switch ((PolygonType)polyType) | |
429 { | |
430 case POLYGON_VerticalWall: | |
431 { | |
432 a4->x = -a2->y; | |
433 a4->y = a2->x; | |
434 a4->z = 0.0; | |
435 | |
436 a3->x = 0.0; | |
437 a3->y = 0.0; | |
438 a3->z = 1.0f; | |
439 } | |
440 return true; | |
441 | |
442 case POLYGON_Floor: | |
443 case POLYGON_Ceiling: | |
444 { | |
445 a4->x = 1.0; | |
446 a4->y = 0.0; | |
447 a4->z = 0.0; | |
448 | |
449 a3->x = 0.0; | |
450 a3->y = 1.0; | |
451 a3->z = 0.0; | |
452 } | |
453 return true; | |
454 | |
455 case POLYGON_InBetweenFloorAndWall: | |
456 case POLYGON_InBetweenCeilingAndWall: | |
457 { | |
458 if (fabs(a2->z) < 0.70811361) | |
459 { | |
460 a4->x = -a2->y; | |
461 a4->y = a2->x; | |
462 a4->z = 0.0; | |
463 a4->Normalize(); | |
464 | |
465 a3->x = 0.0; | |
466 a3->y = 0.0; | |
467 a3->z = 1.0; | |
468 } | |
469 else | |
470 { | |
471 a4->x = 1.0; | |
472 a4->y = 0.0; | |
473 a4->z = 0.0; | |
474 | |
475 a3->x = 0.0; | |
476 a3->y = 1.0; | |
477 a3->z = 0.0; | |
478 } | |
479 } | |
480 return true; | |
481 | |
482 default: | |
483 return false; | |
484 } | |
485 } | |
486 | |
487 //----- (00438258) -------------------------------------------------------- | |
488 bool IndoorCameraD3D::is_face_faced_to_camera(BLVFace *pFace, RenderVertexSoft *a2) | |
489 { | |
676
ecfb1b3c9a39
BLV: when standing right on the portal (orange wall) everything looks fine
Nomad
parents:
168
diff
changeset
|
490 if (pFace->Portal()) |
0 | 491 return false; |
492 | |
493 //really strange cull; dot(to_cam, normal) < 0 means we see the BACK face, not font %_% | |
494 if ( (a2->vWorldPosition.z - (double)pIndoorCamera->pos.z) * (double)pFace->pFacePlane_old.vNormal.z | |
495 + (a2->vWorldPosition.y - (double)pIndoorCamera->pos.y) * (double)pFace->pFacePlane_old.vNormal.y | |
496 + (a2->vWorldPosition.x - (double)pIndoorCamera->pos.x) * (double)pFace->pFacePlane_old.vNormal.x < 0.0) | |
497 return false; | |
498 | |
499 return true; | |
500 } | |
501 | |
502 //----- (00437C96) -------------------------------------------------------- | |
503 void IndoorCameraD3D::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, unsigned int uDiffuseBegin, const RenderVertexD3D3 *pLineEnd, unsigned int uDiffuseEnd, float z_stuff) | |
504 { | |
505 double v6; // st7@2 | |
506 IDirect3DDevice3 *v7; // eax@2 | |
507 HRESULT v8; // eax@2 | |
508 std::string v9; // [sp-18h] [bp-60h]@3 | |
509 const char *v10; // [sp-Ch] [bp-54h]@2 | |
510 const char *v11; // [sp-8h] [bp-50h]@2 | |
511 int v12; // [sp-4h] [bp-4Ch]@2 | |
512 RenderVertexD3D3 v13[2]; // [sp+8h] [bp-40h]@2 | |
513 | |
514 if ( pRenderer->pRenderD3D ) | |
515 { | |
516 v6 = 0.001 - z_stuff; | |
517 memcpy(v13, pLineBegin, 0x20u); | |
518 memcpy(&v13[1], pLineEnd, sizeof(v13[1])); | |
519 v13[0].pos.z = v6; | |
520 v13[1].pos.z = v6; | |
521 v12 = 0; | |
522 v13[0].diffuse = uDiffuseBegin; | |
523 v13[1].diffuse = uDiffuseEnd; | |
524 v7 = pRenderer->pRenderD3D->pDevice; | |
525 v11 = 0; | |
526 //v10 = (const char *)v7; | |
527 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
528 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
529 D3DPT_LINELIST, | |
530 452, | |
531 v13, | |
532 2, | |
533 16)); | |
534 } | |
535 else | |
536 { | |
537 MessageBoxW(nullptr, L"draw_debug_line() not implemented for SW rendering", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Core3D.cpp:1415", 0); | |
538 } | |
539 } | |
540 | |
541 //----- (00437AB5) -------------------------------------------------------- | |
542 void IndoorCameraD3D::do_draw_debug_line_sw(RenderVertexSoft *pLineBegin, unsigned int uStartDiffuse, RenderVertexSoft *pLineEnd, unsigned int uEndDiffuse, unsigned int uOutNumVertices, float z_stuff) | |
543 { | |
544 char *v7; // eax@2 | |
545 signed int v8; // edx@2 | |
546 float v9; // ecx@5 | |
547 float v10; // eax@5 | |
548 char *v11; // eax@6 | |
549 signed int v12; // edx@6 | |
550 float v13; // edx@8 | |
551 float v14; // eax@8 | |
552 float v15; // eax@8 | |
553 double v16; // st7@11 | |
554 HRESULT v17; // eax@11 | |
555 std::string v18; // [sp-18h] [bp-7E4h]@12 | |
556 IDirect3DDevice3 *v19; // [sp-Ch] [bp-7D8h]@8 | |
557 const char *v20; // [sp-8h] [bp-7D4h]@8 | |
558 int v21; // [sp-4h] [bp-7D0h]@8 | |
559 RenderVertexSoft a1[20]; // [sp+8h] [bp-7C4h]@6 | |
560 RenderVertexSoft pVertices[20]; // [sp+3C8h] [bp-404h]@2 | |
561 RenderVertexD3D3 v24[2]; // [sp+788h] [bp-44h]@11 | |
562 IndoorCameraD3D *v25; // [sp+7C8h] [bp-4h]@1 | |
563 | |
564 v25 = this; | |
565 if ( pRenderer->pRenderD3D ) | |
566 { | |
567 v7 = (char *)&pVertices[0].flt_2C; | |
568 v8 = 20; | |
569 do | |
570 { | |
571 *(float *)v7 = 0.0; | |
572 v7 += 48; | |
573 --v8; | |
574 } | |
575 while ( v8 ); | |
576 if ( (char)uOutNumVertices ) | |
577 { | |
578 v9 = pLineBegin->vWorldViewProjX; | |
579 pVertices[0].vWorldViewProjY = pLineBegin->vWorldViewProjY; | |
580 pVertices[0].vWorldViewProjX = v9; | |
581 v10 = pLineEnd->vWorldViewProjY; | |
582 pVertices[1].vWorldViewProjX = pLineEnd->vWorldViewProjX; | |
583 pVertices[1].vWorldViewProjY = v10; | |
584 LABEL_11: | |
585 v16 = 0.001 - z_stuff; | |
586 v24[0].specular = 0; | |
587 v24[0].pos.x = pVertices[0].vWorldViewProjX; | |
588 v24[0].pos.y = pVertices[0].vWorldViewProjY; | |
589 v24[0].pos.z = v16; | |
590 v24[0].diffuse = uStartDiffuse; | |
591 v24[0].rhw = 0.001; | |
592 v24[1].pos.x = pVertices[1].vWorldViewProjX; | |
593 v24[0].texcoord.x = 0.0; | |
594 v24[1].pos.y = pVertices[1].vWorldViewProjY; | |
595 v24[0].texcoord.y = 0.0; | |
596 v24[1].diffuse = uEndDiffuse; | |
597 v24[1].pos.z = v16; | |
598 v24[1].specular = 0; | |
599 v21 = 0; | |
600 v24[1].rhw = 0.001; | |
601 v20 = 0; | |
602 v24[1].texcoord.x = 0.0; | |
603 v24[1].texcoord.y = 0.0; | |
604 //v19 = pRenderer->pRenderD3D->pDevice; | |
605 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
606 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive( | |
607 D3DPT_LINELIST, | |
608 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
609 v24, | |
610 2, | |
611 16)); | |
612 return; | |
613 } | |
614 v11 = (char *)&a1[0].flt_2C; | |
615 v12 = 20; | |
616 do | |
617 { | |
618 *(float *)v11 = 0.0; | |
619 v11 += 48; | |
620 --v12; | |
621 } | |
622 while ( v12 ); | |
623 v21 = 0; | |
624 v20 = (const char *)1; | |
625 v19 = (IDirect3DDevice3 *)4; | |
626 v13 = pLineBegin->vWorldPosition.x; | |
627 uOutNumVertices = 2; | |
628 a1[0].vWorldPosition.x = v13; | |
629 v14 = pLineBegin->vWorldPosition.z; | |
630 a1[0].vWorldPosition.y = pLineBegin->vWorldPosition.y; | |
631 a1[0].vWorldPosition.z = v14; | |
632 a1[1].vWorldPosition.x = pLineEnd->vWorldPosition.x; | |
633 v15 = pLineEnd->vWorldPosition.z; | |
634 a1[1].vWorldPosition.y = pLineEnd->vWorldPosition.y; | |
635 a1[1].vWorldPosition.z = v15; | |
795 | 636 if ( CalcPortalShape( |
0 | 637 a1, |
638 &uOutNumVertices, | |
639 pVertices, | |
640 this->std__vector_000034_prolly_frustrum, | |
641 4, | |
642 1, | |
643 0) != 1 | |
644 || (signed int)uOutNumVertices >= 2 ) | |
645 { | |
646 ViewTransform(pVertices, 2u); | |
647 Project(pVertices, 2u, 0); | |
648 goto LABEL_11; | |
649 } | |
650 } | |
651 else | |
652 MessageBoxW(nullptr, L"draw_debug_line() not implemented for SW rendering", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Core3D.cpp:1383", 0); | |
653 } | |
654 | |
655 //----- (00437A55) -------------------------------------------------------- | |
656 void IndoorCameraD3D::debug_outline_d3d(const RenderVertexD3D3 *pLineVertices, unsigned int uNumLines, int uDiffuse, float z_stuff) | |
657 { | |
658 unsigned int v5; // esi@1 | |
659 const RenderVertexD3D3 *v6; // ecx@2 | |
660 unsigned int v7; // ebx@2 | |
661 const RenderVertexD3D3 *v8; // edi@3 | |
662 IndoorCameraD3D *thisa; // [sp+10h] [bp-4h]@1 | |
663 | |
664 v5 = 0; | |
665 thisa = this; | |
666 if ( (signed int)(uNumLines - 1) > 0 ) | |
667 { | |
668 v6 = pLineVertices; | |
669 v7 = uNumLines - 1; | |
670 v5 = uNumLines - 1; | |
671 do | |
672 { | |
673 v8 = v6 + 1; | |
674 do_draw_debug_line_d3d(v6, uDiffuse, v6 + 1, uDiffuse, z_stuff); | |
675 --v7; | |
676 v6 = v8; | |
677 } | |
678 while ( v7 ); | |
679 } | |
680 do_draw_debug_line_d3d(&pLineVertices[v5], uDiffuse, pLineVertices, uDiffuse, z_stuff); | |
681 } | |
682 | |
683 //----- (004379EE) -------------------------------------------------------- | |
684 void IndoorCameraD3D::debug_outline_sw(RenderVertexSoft *a2, unsigned int uNumVertices, unsigned int uDiffuse, float a5) | |
685 { | |
686 unsigned int v5; // esi@1 | |
687 RenderVertexSoft *v6; // eax@2 | |
688 RenderVertexSoft *v7; // edi@3 | |
689 char v8; // zf@3 | |
690 IndoorCameraD3D *v9; // [sp+10h] [bp-4h]@1 | |
691 unsigned int uNumVerticesa; // [sp+20h] [bp+Ch]@2 | |
692 | |
693 v9 = this; | |
694 v5 = 0; | |
695 if ( (signed int)(uNumVertices - 1) > 0 ) | |
696 { | |
697 v6 = a2; | |
698 v5 = uNumVertices - 1; | |
699 uNumVerticesa = uNumVertices - 1; | |
700 do | |
701 { | |
702 v7 = v6 + 1; | |
703 do_draw_debug_line_sw(v6, uDiffuse, v6 + 1, uDiffuse, 0, a5); | |
704 v8 = uNumVerticesa-- == 1; | |
705 v6 = v7; | |
706 } | |
707 while ( !v8 ); | |
708 } | |
709 do_draw_debug_line_sw(&a2[v5], uDiffuse, a2, uDiffuse, 0, a5); | |
710 } | |
711 | |
791 | 712 |
713 void IndoorCameraD3D::DebugDrawPortal(BLVFace *pFace) | |
714 { | |
715 assert(pFace->uNumVertices <= 32); | |
716 | |
717 RenderVertexSoft sw[32]; | |
718 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
719 { | |
720 sw[i].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[i]].x; | |
721 sw[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y; | |
722 sw[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z; | |
723 } | |
724 ViewTransform(sw, pFace->uNumVertices); | |
725 Project(sw, pFace->uNumVertices, 0); | |
726 | |
727 | |
728 | |
729 RenderVertexD3D3 v[32]; | |
730 for (uint i = 0; i < pFace->uNumVertices; ++i) | |
731 { | |
732 v[i].pos.x = sw[i].vWorldViewProjX; | |
733 v[i].pos.y = sw[i].vWorldViewProjY; | |
734 v[i].pos.z = 1.0 - 1.0 / (sw[i].vWorldViewPosition.x * 0.061758894); | |
735 v[i].rhw = 1.0 / sw[i].vWorldViewPosition.x; | |
736 v[i].diffuse = 0x80F020F0; | |
737 v[i].specular = 0; | |
738 //v[i].texcoord.x = pFace->pVertexUIDs[i] / (double)pTex->uTextureWidth; | |
739 //v[i].texcoord.y = pFace->pVertexUIDs[i] / (double)pTex->uTextureHeight; | |
740 v[i].texcoord.x = 0; | |
741 v[i].texcoord.y = 0; | |
742 } | |
743 | |
744 | |
745 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); | |
746 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, false)); | |
747 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); | |
748 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA)); | |
749 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA)); | |
750 | |
751 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); | |
752 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, | |
753 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, | |
754 v, | |
755 pFace->uNumVertices, | |
756 28)); | |
757 | |
758 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); | |
759 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); | |
760 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); | |
761 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE)); | |
762 //ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); | |
763 } | |
764 | |
0 | 765 //----- (00437906) -------------------------------------------------------- |
766 void IndoorCameraD3D::PrepareAndDrawDebugOutline(BLVFace *pFace, unsigned int uDiffuse) | |
767 { | |
768 char *v3; // eax@2 | |
769 signed int v4; // ecx@2 | |
770 signed int v5; // ebx@5 | |
771 Vec3_short_ *v6; // edx@6 | |
772 char *v7; // esi@6 | |
773 signed int v8; // ecx@7 | |
774 IndoorCameraD3D *thisa; // [sp+8h] [bp-4h]@1 | |
775 | |
776 thisa = this; | |
777 | |
778 | |
779 static RenderVertexSoft static_sub_437906_array_50CDD0[64]; | |
780 static bool __init_flag1 = false; | |
781 if (!__init_flag1) | |
782 { | |
783 __init_flag1 = true; | |
784 | |
785 for (uint i = 0; i < 64; ++i) | |
786 static_sub_437906_array_50CDD0[i].flt_2C = 0.0f; | |
787 } | |
788 | |
789 v5 = 0; | |
790 if ( pFace->uNumVertices ) | |
791 { | |
792 v6 = pIndoor->pVertices; | |
793 v7 = (char *)&static_sub_437906_array_50CDD0[0].vWorldPosition.y; | |
794 do | |
795 { | |
796 v8 = v5++; | |
797 *((float *)v7 - 1) = (double)v6[pFace->pVertexIDs[v8]].x; | |
798 *(float *)v7 = (double)v6[pFace->pVertexIDs[v8]].y; | |
799 v7 += 48; | |
800 *((float *)v7 - 11) = (double)v6[pFace->pVertexIDs[v8]].z; | |
801 *((float *)v7 - 4) = (double)pFace->pVertexUIDs[v8]; | |
802 *((float *)v7 - 3) = (double)pFace->pVertexVIDs[v8]; | |
803 } | |
804 while ( v5 < pFace->uNumVertices ); | |
805 } | |
806 debug_outline_sw(static_sub_437906_array_50CDD0, pFace->uNumVertices, uDiffuse, 0.0); | |
807 } | |
808 // 50D9D0: using guessed type char static_sub_437906_byte_50D9D0_init_flag; | |
809 | |
810 //----- (004378BA) -------------------------------------------------------- | |
811 void IndoorCameraD3D::MatrixMultiply(Matrix3x3_float_ *a1, Matrix3x3_float_ *a2, Matrix3x3_float_ *out) | |
812 { | |
813 float *v4; // ecx@1 | |
814 float *v5; // eax@1 | |
815 signed int v6; // ebx@1 | |
816 float *v7; // edx@2 | |
817 float *v8; // ecx@2 | |
818 signed int v9; // edi@2 | |
819 double v10; // st7@3 | |
820 double v11; // st6@3 | |
821 | |
822 v4 = (float *)out; | |
823 v5 = &a1->_12; | |
824 v6 = 3; | |
825 do | |
826 { | |
827 v7 = v4; | |
828 v8 = &a2->_21; | |
829 v9 = 3; | |
830 do | |
831 { | |
832 v10 = v8[3] * v5[1] + *(v8 - 3) * *(v5 - 1); | |
833 v11 = *v8 * *v5; | |
834 ++v8; | |
835 *v7 = v10 + v11; | |
836 ++v7; | |
837 --v9; | |
838 } | |
839 while ( v9 ); | |
840 v5 += 3; | |
841 --v6; | |
842 v4 = v7; | |
843 } | |
844 while ( v6 ); | |
845 } | |
846 | |
847 //----- (004376E7) -------------------------------------------------------- | |
848 void IndoorCameraD3D::CreateWorldMatrixAndSomeStuff() | |
849 { | |
850 //IndoorCameraD3D *v1; // esi@1 | |
851 double v2; // st7@1 | |
852 //signed int v3; // edi@1 | |
853 //int v4; // eax@1 | |
854 //double v5; // st7@2 | |
855 //double v6; // st7@3 | |
856 Matrix3x3_float_ m1; // [sp+10h] [bp-B8h]@1 | |
857 Matrix3x3_float_ m2; // [sp+34h] [bp-94h]@1 | |
858 Matrix3x3_float_ m3; // [sp+58h] [bp-70h]@1 | |
859 Matrix3x3_float_ m4; // [sp+7Ch] [bp-4Ch]@1 | |
860 Matrix3x3_float_ m5; // [sp+A0h] [bp-28h]@1 | |
861 float v12; // [sp+C4h] [bp-4h]@1 | |
862 | |
863 //RotationZ(0) | |
864 m5._11 = cosf(0); m5._12 = sinf(0); m5._13 = 0; | |
865 m5._21 = -sinf(0); m5._22 = cosf(0); m5._23 = 0; | |
866 m5._31 = 0; m5._32 = 0; m5._33 = 1; | |
867 | |
868 float cos_x1 = pIndoorCamera->fRotationXCosine, | |
869 sin_x1 = pIndoorCamera->fRotationXSine; | |
870 //RotationX(x) | |
871 m4._11 = 1; m4._12 = 0; m4._13 = 0; | |
872 m4._21 = 0; m4._22 = cos_x1; m4._23 = sin_x1; | |
873 m4._31 = 0; m4._32 = -sin_x1; m4._33 = cos_x1; | |
874 | |
875 float cos_y1 = pIndoorCamera->fRotationYCosine, | |
876 sin_y1 = pIndoorCamera->fRotationYSine; | |
877 //RotationY(some_angle) | |
878 m3._11 = cos_y1; m3._12 = 0; m3._13 = -sin_y1; | |
879 m3._21 = 0; m3._22 = 1; m3._23 = 0; | |
880 m3._31 = sin_y1; m3._32 = 0; m3._33 = cos_y1; | |
881 | |
882 MatrixMultiply(&m5, &m3, &m1); | |
883 MatrixMultiply(&m4, &m1, &m2); | |
884 | |
885 for (uint i = 0; i < 3; ++i) | |
886 { | |
887 field_4[0].v[i] = m2.v[1][i]; | |
888 field_4[1].v[i] = m2.v[0][i]; | |
889 field_4[2].v[i] = m2.v[2][i]; | |
890 } | |
891 | |
892 inv_fov = 1.1344639; | |
893 fov_x = (double)pViewport->uScreenWidth * 0.8814736; | |
894 | |
895 fov_y = 0.8814736 * (double)pViewport->uScreenHeight; | |
896 fov = fov_y; | |
897 if ( fov_x > fov ) | |
898 fov = fov_x; | |
899 screenCenterX = (double)pViewport->uScreenCenterX; | |
692 | 900 screenCenterY = (double)(pViewport->uScreenCenterY - pViewport->uScreen_TL_Y); |
0 | 901 } |
902 | |
903 //----- (00437691) -------------------------------------------------------- | |
904 void IndoorCameraD3D::Vec3Transform(const IndoorCameraD3D_Vec3 *pVector, IndoorCameraD3D_Vec3 *pOut) | |
905 { | |
906 pOut->y = field_4[1].x * pVector->x + field_4[0].x * pVector->y + field_4[2].x * pVector->z; | |
907 pOut->z = field_4[1].y * pVector->x + field_4[0].y * pVector->y + field_4[2].y * pVector->z; | |
908 pOut->x = field_4[1].z * pVector->x + field_4[0].z * pVector->y + field_4[2].z * pVector->z; | |
909 } | |
910 | |
911 //----- (00437607) -------------------------------------------------------- | |
912 void IndoorCameraD3D::_437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2) | |
913 { | |
914 double v4; // st7@1 | |
915 IndoorCameraD3D_Vec3 v8; // [sp+8h] [bp-1Ch]@1 | |
916 | |
917 v8.x = (double)pIndoorCamera->pos.x; | |
918 v8.y = (double)pIndoorCamera->pos.y; | |
919 v8.z = (double)pIndoorCamera->pos.z; | |
920 Vec3Transform(a1, a2); | |
921 | |
922 v4 = v8.x * a2->x + v8.y * a2->y + v8.z * a2->z; | |
923 a2->dot = v4 + 0.000099999997; | |
924 } | |
925 | |
926 //----- (004374E8) -------------------------------------------------------- | |
927 void IndoorCameraD3D::_4374E8_ProllyBuildFrustrum() | |
928 { | |
929 //IndoorCameraD3D *v1; // esi@1 | |
930 //double v2; // st7@1 | |
931 double v3; // st7@1 | |
932 //double v4; // st7@1 | |
933 double v5; // st7@1 | |
934 //double v6; // st7@1 | |
935 IndoorCameraD3D_Vec3 v7; // [sp+Ch] [bp-24h]@1 | |
936 //float v8; // [sp+10h] [bp-20h]@1 | |
937 //float v9; // [sp+14h] [bp-1Ch]@1 | |
938 //float v10; // [sp+18h] [bp-18h]@1 | |
939 //float v11; // [sp+1Ch] [bp-14h]@1 | |
940 //float v12; // [sp+20h] [bp-10h]@1 | |
941 //int v13; // [sp+2Ch] [bp-4h]@1 | |
942 | |
943 //v1 = this; | |
944 //IndoorCameraD3D_Vec3::IndoorCameraD3D_Vec3(&v7); | |
945 //v2 = 2.0 / inv_fov; | |
946 //v13 = 0; | |
947 v3 = atan(2.0 / inv_fov * fov / fov_x); | |
948 //v12 = v3; | |
949 //v11 = sin(v3); | |
950 //v4 = cos(v3); | |
951 v7.x = -sin(v3); | |
952 v7.y = 0.0; | |
953 v7.z = cos(v3); | |
954 _437607(&v7, std__vector_000034_prolly_frustrum); | |
955 v7.x = sin(v3); | |
956 _437607(&v7, &std__vector_000034_prolly_frustrum[1]); | |
957 v5 = atan(2.0 / inv_fov * fov / (fov_y + 0.5)); | |
958 //v12 = v5; | |
959 //v11 = sin(v5); | |
960 //v6 = cos(v5); | |
961 v7.y = sin(v5); | |
962 v7.x = 0.0; | |
963 v7.z = cos(v5); | |
964 _437607(&v7, &std__vector_000034_prolly_frustrum[2]); | |
965 v7.y = -sin(v5); | |
966 _437607(&v7, &std__vector_000034_prolly_frustrum[3]); | |
967 //v13 = -1; | |
968 //IndoorCameraD3D_Vec3::dtor(&v7); | |
969 } | |
970 | |
971 //----- (00437376) -------------------------------------------------------- | |
972 char IndoorCameraD3D::_437376(stru154 *thisa, RenderVertexSoft *a2, unsigned int *pOutNumVertices) | |
973 { | |
974 unsigned int v4; // ebx@1 | |
975 RenderVertexSoft *v5; // edx@2 | |
976 double v6; // st7@3 | |
977 unsigned int v7; // edi@5 | |
978 signed int v8; // esi@6 | |
979 int v9; // ebx@8 | |
980 int v10; // eax@8 | |
981 int v11; // ecx@14 | |
982 int v12; // eax@14 | |
983 int v13; // eax@15 | |
984 signed int v14; // ebx@17 | |
985 RenderVertexSoft *v15; // eax@18 | |
986 unsigned int *v16; // eax@20 | |
987 char result; // al@24 | |
988 RenderVertexSoft v18; // [sp+Ch] [bp-34h]@2 | |
989 int v19; // [sp+3Ch] [bp-4h]@8 | |
990 signed int thisb; // [sp+48h] [bp+8h]@6 | |
991 char a2_3; // [sp+4Fh] [bp+Fh]@5 | |
992 | |
993 v4 = *pOutNumVertices; | |
994 if ( (signed int)*pOutNumVertices <= 3 | |
995 || ((v5 = a2, | |
996 memcpy(&v18, a2, sizeof(v18)), | |
997 (v18.vWorldPosition.z - (double)pBLVRenderParams->vPartyPos.z) * thisa->face_plane.vNormal.z | |
998 + (v18.vWorldPosition.y - (double)pBLVRenderParams->vPartyPos.y) * thisa->face_plane.vNormal.y | |
999 + (v18.vWorldPosition.x - (double)pBLVRenderParams->vPartyPos.x) * thisa->face_plane.vNormal.x < 0.0) ? (v6 = 1.0) : (v6 = -1.0), | |
1000 a2_3 = 0, | |
1001 memcpy(&v5[v4], v5, sizeof(v5[v4])), | |
1002 memcpy(&v5[*pOutNumVertices + 1], &v5[1], sizeof(v5[*pOutNumVertices + 1])), | |
1003 v7 = *pOutNumVertices, | |
1004 (signed int)*pOutNumVertices <= 0) ) | |
1005 goto LABEL_28; | |
1006 v8 = 1; | |
1007 for ( thisb = 1; ; v8 = thisb ) | |
1008 { | |
1009 v9 = v8 - 1; | |
1010 v10 = v8 + 1; | |
1011 v19 = v8 + 1; | |
1012 if ( v8 - 1 >= (signed int)v7 ) | |
1013 v9 -= v7; | |
1014 if ( v8 >= (signed int)v7 ) | |
1015 v8 -= v7; | |
1016 if ( v19 >= (signed int)v7 ) | |
1017 v10 = v19 - v7; | |
1018 v11 = (int)&v5[v10]; | |
1019 v12 = (int)&v5[v9]; | |
1020 if ( -0.009999999776482582 > ((v5[v8].vWorldViewProjX - *(float *)(v12 + 24)) | |
1021 * (*(float *)(v11 + 28) - *(float *)(v12 + 28)) | |
1022 - (v5[v8].vWorldViewProjY - *(float *)(v12 + 28)) | |
1023 * (*(float *)(v11 + 24) - *(float *)(v12 + 24))) | |
1024 * v6 ) | |
1025 { | |
1026 thisb = v19; | |
1027 v16 = pOutNumVertices; | |
1028 } | |
1029 else | |
1030 { | |
1031 v13 = thisb; | |
1032 if ( thisb >= (signed int)v7 ) | |
1033 v13 = thisb - v7; | |
1034 v14 = v13; | |
1035 if ( v13 < (signed int)v7 ) | |
1036 { | |
1037 v15 = &v5[v13]; | |
1038 do | |
1039 { | |
1040 memcpy(v15, &v15[1], 0x30u); | |
1041 ++v14; | |
1042 ++v15; | |
1043 } | |
1044 while ( v14 < (signed int)*pOutNumVertices ); | |
1045 } | |
1046 v16 = pOutNumVertices; | |
1047 a2_3 = 1; | |
1048 --*v16; | |
1049 } | |
1050 v7 = *v16; | |
1051 if ( thisb - 1 >= (signed int)*v16 ) | |
1052 break; | |
1053 } | |
1054 if ( a2_3 ) | |
1055 result = 1; | |
1056 else | |
1057 LABEL_28: | |
1058 result = 0; | |
1059 return result; | |
1060 } | |
1061 | |
1062 //----- (00437285) -------------------------------------------------------- | |
795 | 1063 bool IndoorCameraD3D::CalcPortalShape(RenderVertexSoft *a1, unsigned int *pOutNumVertices, RenderVertexSoft *pVertices, IndoorCameraD3D_Vec4 *a4, signed int uNumVertices, char a6, int _unused) |
0 | 1064 { |
1065 char *v8; // eax@2 | |
1066 signed int v9; // ecx@2 | |
1067 //bool result; // eax@5 | |
1068 int v11; // ecx@5 | |
1069 //signed int v12; // ecx@6 | |
1070 //char *v13; // esi@6 | |
1071 RenderVertexSoft *v14; // eax@8 | |
1072 RenderVertexSoft *v15; // edx@8 | |
1073 Vec3_float_ a5; // [sp+18h] [bp-3Ch]@12 | |
1317 | 1074 //float v17; // [sp+44h] [bp-10h]@1 |
1075 //int v18; // [sp+48h] [bp-Ch]@5 | |
0 | 1076 //stru9 *thisa; // [sp+4Ch] [bp-8h]@1 |
1077 int a7a; // [sp+53h] [bp-1h]@5 | |
1078 //bool a6a; // [sp+70h] [bp+1Ch]@5 | |
1079 | |
1317 | 1080 //v17 = 0.0; |
0 | 1081 //thisa = pGame->pStru9Instance; |
1082 | |
1083 static RenderVertexSoft sr_vertices_50D9D8[64]; | |
1084 | |
1085 //result = 0; | |
1086 a7a = 0; | |
1087 v11 = 2 * (a6 == 0) + 1; | |
1088 //a6a = 0; | |
1317 | 1089 //v18 = v11; |
0 | 1090 if (uNumVertices <= 0) |
1091 return false; | |
1092 | |
1093 //v12 = *pOutNumVertices; | |
1094 //v13 = (char *)&a4->y; | |
1317 | 1095 |
1096 //while ( 1 ) | |
1097 for ( uint i = 0; i < uNumVertices; ++i ) | |
1098 { | |
1099 if (i % 2) | |
1100 { | |
1101 v14 = a1; | |
1102 v15 = sr_vertices_50D9D8; | |
1103 } | |
1104 else | |
0 | 1105 { |
1317 | 1106 v15 = a1; |
1107 v14 = sr_vertices_50D9D8; | |
0 | 1108 } |
1317 | 1109 if (i == uNumVertices - 1) |
1110 v14 = pVertices; | |
1111 a5.x = a4[i].x; | |
1112 a5.y = a4[i].y; | |
1113 a5.z = a4[i].z; | |
1114 pGame->pStru9Instance->CalcPortalShape(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused); | |
1115 //v12 = *pOutNumVertices; | |
1116 if (*pOutNumVertices < v11) | |
1117 { | |
1118 *pOutNumVertices = 0; | |
1119 return true; | |
1120 } | |
1121 //result = a6a; | |
1122 //v13 += 24; | |
1123 //if (++i >= uNumVertices) | |
1124 // | |
1125 } | |
1126 return a7a; | |
0 | 1127 } |
1128 | |
1129 //----- (004371C3) -------------------------------------------------------- | |
1130 bool IndoorCameraD3D::_4371C3(RenderVertexSoft *pVertices, unsigned int *pOutNumVertices, int _unused) | |
1131 { | |
1132 char *v4; // eax@2 | |
1133 signed int v5; // ecx@2 | |
1134 RenderVertexSoft *v6; // esi@5 | |
1135 unsigned int *v7; // edi@5 | |
1136 char *v8; // ecx@6 | |
1137 int v9; // eax@6 | |
1138 IndoorCameraD3D *thisa; // [sp+0h] [bp-Ch]@1 | |
1139 signed int v12; // [sp+4h] [bp-8h]@5 | |
1140 unsigned int pVerticesa; // [sp+14h] [bp+8h]@6 | |
1141 unsigned int pOutNumVerticesa; // [sp+18h] [bp+Ch]@6 | |
1142 | |
1143 thisa = this; | |
1144 | |
1145 | |
1146 static RenderVertexSoft static_4371C3_array_50E5E0[64]; | |
1147 static bool __init_flag1 = false; | |
1148 if (!__init_flag1) | |
1149 { | |
1150 __init_flag1 = true; | |
1151 | |
1152 for (uint i = 0; i < 64; ++i) | |
1153 static_4371C3_array_50E5E0[i].flt_2C = 0.0f; | |
1154 } | |
1155 | |
1156 v12 = 0; | |
1157 v6 = pVertices; | |
1158 v7 = pOutNumVertices; | |
1159 if ( (signed int)*pOutNumVertices > 0 ) | |
1160 { | |
1161 pOutNumVerticesa = (char *)static_4371C3_array_50E5E0 - (char *)pVertices; | |
1162 pVerticesa = (char *)&static_4371C3_array_50E5E0[0].vWorldViewProjY - (char *)pVertices; | |
1163 v8 = (char *)&static_4371C3_array_50E5E0[0].vWorldPosition.y; | |
1164 v9 = (int)&v6->vWorldPosition.z; | |
1165 do | |
1166 { | |
1167 ++v12; | |
1168 *((int *)v8 - 1) = *(int *)(v9 - 8); | |
1169 *(int *)v8 = *(int *)(v9 - 4); | |
1170 v8 += 48; | |
1171 *(float *)(pOutNumVerticesa + v9) = *(float *)v9; | |
1172 *(float *)(pVerticesa + v9) = *(float *)(v9 + 28); | |
168 | 1173 *(float *)((char *)&static_4371C3_array_50E5E0[0]._rhw - (char *)v6 + v9) = *(float *)(v9 + 32); |
0 | 1174 v9 += 48; |
1175 } | |
1176 while ( v12 < (signed int)*v7 ); | |
1177 } | |
795 | 1178 return CalcPortalShape( |
0 | 1179 static_4371C3_array_50E5E0, |
1180 v7, | |
1181 v6, | |
1182 thisa->std__vector_000034_prolly_frustrum, | |
1183 4, | |
1184 0, | |
1185 _unused); | |
1186 } | |
1187 // 50F1E0: using guessed type char static_sub_4371C3_byte_50F1E0_init_flags; | |
1188 | |
1189 //----- (00437143) -------------------------------------------------------- | |
1190 int IndoorCameraD3D::_437143(unsigned int uNumInVertices, RenderVertexSoft *pOutVertices, RenderVertexSoft *pInVertices, unsigned int *pOutNumVertices) | |
1191 { | |
1192 unsigned int v5; // edi@1 | |
1193 char *pOutVertices_; // edx@2 | |
1194 char *v7; // eax@2 | |
1195 unsigned int v8; // ebx@2 | |
1196 double v9; // st7@3 | |
1197 double v10; // st6@3 | |
1198 int result; // eax@5 | |
1199 unsigned int a2a; // [sp+10h] [bp+Ch]@2 | |
1200 | |
1201 v5 = uNumInVertices; | |
1202 if ( (signed int)uNumInVertices > 0 ) | |
1203 { | |
1204 pOutVertices_ = (char *)&pOutVertices->vWorldViewProjY; | |
168 | 1205 v7 = (char *)&pInVertices->_rhw; |
0 | 1206 v8 = (char *)pOutVertices - (char *)pInVertices; |
1207 a2a = uNumInVertices; | |
1208 do | |
1209 { | |
1210 *(float *)v7 = 1.0 / (*((float *)v7 - 5) + 0.0000001); | |
1211 memcpy(pOutVertices_ - 28, v7 - 32, 0x30u); | |
1212 v9 = (double)pOutdoorCamera->int_fov_rad * *(float *)&v7[v8]; | |
1213 v10 = (double)pViewport->uScreenCenterX - v9 * *((float *)v7 - 4); | |
1214 v7 += 48; | |
1215 *((float *)pOutVertices_ - 1) = v10; | |
1216 *(float *)pOutVertices_ = (double)pViewport->uScreenCenterY - v9 * *((float *)v7 - 15); | |
1217 pOutVertices_ += 48; | |
1218 --a2a; | |
1219 } | |
1220 while ( a2a ); | |
1221 v5 = uNumInVertices; | |
1222 } | |
1223 result = (int)pOutNumVertices; | |
1224 *pOutNumVertices = v5; | |
1225 return result; | |
1226 } | |
781 | 1227 |
0 | 1228 //----- (00436F09) -------------------------------------------------------- |
1229 void IndoorCameraD3D::_436F09_mess_with_lightmap__clipflag_4(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices) | |
1230 { | |
1231 unsigned int *pOutNumVertices_; // ebx@1 | |
1232 double v6; // st7@2 | |
1233 signed int v7; // esi@2 | |
1234 char *v8; // edx@5 | |
1235 unsigned int v9; // eax@10 | |
1236 RenderVertexSoft *v10; // ecx@11 | |
1237 double v11; // st6@11 | |
1238 double v12; // st6@12 | |
1239 unsigned int v13; // edi@14 | |
1240 unsigned __int8 v14; // c2@16 | |
1241 unsigned __int8 v15; // c3@16 | |
1242 unsigned int v16; // edi@17 | |
1243 bool a1a; // [sp+Ch] [bp+8h]@7 | |
1244 int a4a; // [sp+18h] [bp+14h]@5 | |
1245 | |
1246 pOutNumVertices_ = pOutNumVertices; | |
1247 *pOutNumVertices = 0; | |
1248 if ( uNumInVertices ) | |
1249 { | |
1250 memcpy(&pInVertices[uNumInVertices], pInVertices, sizeof(pInVertices[uNumInVertices])); | |
1251 v6 = (double)pOutdoorCamera->shading_dist_mist; | |
1252 v7 = 0; | |
1253 if ( v6 >= pInVertices->vWorldViewPosition.x ) | |
1254 v7 = 1; | |
1255 if ( uNumInVertices + 1 > 1 ) | |
1256 { | |
1257 a4a = uNumInVertices; | |
1258 v8 = (char *)&pInVertices[1].u; | |
1259 do | |
1260 { | |
1261 a1a = v6 >= *((float *)v8 - 6); | |
1262 if ( v7 == a1a ) | |
1263 { | |
1264 v10 = pOutVertices; | |
1265 goto LABEL_23; | |
1266 } | |
1267 v9 = *pOutNumVertices_; | |
1268 if ( a1a ) | |
1269 { | |
1270 v10 = pOutVertices; | |
1271 v11 = (v6 - *((float *)v8 - 18)) / (*((float *)v8 - 6) - *((float *)v8 - 18)); | |
1272 pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 5) - *((float *)v8 - 17)) * v11 + *((float *)v8 - 17); | |
1273 pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 4) - *((float *)v8 - 16)) * v11 | |
1274 + *((float *)v8 - 16); | |
1275 pOutVertices[*pOutNumVertices_].u = (*(float *)v8 - *((float *)v8 - 12)) * v11 + *((float *)v8 - 12); | |
1276 pOutVertices[*pOutNumVertices_].v = (*((float *)v8 + 1) - *((float *)v8 - 11)) * v11 + *((float *)v8 - 11); | |
1277 } | |
1278 else | |
1279 { | |
1280 v12 = (v6 - *((float *)v8 - 6)) / (*((float *)v8 - 18) - *((float *)v8 - 6)); | |
1281 pOutVertices[v9].vWorldViewPosition.y = (*((float *)v8 - 17) - *((float *)v8 - 5)) * v12 + *((float *)v8 - 5); | |
1282 pOutVertices[*pOutNumVertices_].vWorldViewPosition.z = (*((float *)v8 - 16) - *((float *)v8 - 4)) * v12 | |
1283 + *((float *)v8 - 4); | |
1284 pOutVertices[*pOutNumVertices_].u = (*((float *)v8 - 12) - *(float *)v8) * v12 + *(float *)v8; | |
1285 pOutVertices[*pOutNumVertices_].v = (*((float *)v8 - 11) - *((float *)v8 + 1)) * v12 + *((float *)v8 + 1); | |
1286 v10 = pOutVertices; | |
1287 } | |
1288 v10[*pOutNumVertices_].vWorldViewPosition.x = v6; | |
168 | 1289 v10[*pOutNumVertices_]._rhw = 1.0 / v6; |
0 | 1290 if ( v7 ) |
1291 { | |
1292 v13 = (unsigned int)&v10[*pOutNumVertices_]; | |
1293 if ( *(float *)(v13 + 12) != *((float *)v8 - 18) || *(float *)(v13 + 16) != *((float *)v8 - 17) ) | |
1294 goto LABEL_21; | |
1295 v14 = 0; | |
1296 v15 = *(float *)(v13 + 20) == *((float *)v8 - 16); | |
1297 } | |
1298 else | |
1299 { | |
1300 v16 = (unsigned int)&v10[*pOutNumVertices_]; | |
1301 if ( *(float *)(v16 + 12) != *((float *)v8 - 6) || *(float *)(v16 + 16) != *((float *)v8 - 5) ) | |
1302 { | |
1303 LABEL_21: | |
1304 ++*pOutNumVertices_; | |
1305 goto LABEL_23; | |
1306 } | |
1307 v14 = 0; | |
1308 v15 = *(float *)(v16 + 20) == *((float *)v8 - 4); | |
1309 } | |
1310 if ( !(v15 | v14) ) | |
1311 goto LABEL_21; | |
1312 LABEL_23: | |
1313 if ( a1a ) | |
1314 { | |
1315 memcpy(&v10[*pOutNumVertices_], v8 - 36, sizeof(v10[*pOutNumVertices_])); | |
168 | 1316 pOutVertices[*pOutNumVertices_]._rhw = 1.0 / (*((float *)v8 - 6) + 0.0000001); |
0 | 1317 pOutVertices[(*pOutNumVertices_)++].flt_2C = *((float *)v8 + 2); |
1318 } | |
1319 v7 = a1a; | |
1320 v8 += 48; | |
1321 --a4a; | |
1322 } | |
1323 while ( a4a ); | |
1324 } | |
1325 if ( (signed int)*pOutNumVertices_ < 3 ) | |
1326 *pOutNumVertices_ = 0; | |
1327 } | |
1328 } | |
1329 | |
1330 //----- (00436CDC) -------------------------------------------------------- | |
1331 void IndoorCameraD3D::_436CDC_mess_with_lightmap__clipflag_2(RenderVertexSoft *pInVertices, int uNumInVertices, RenderVertexSoft *pOutVertices, unsigned int *pOutNumVertices) | |
1332 { | |
1333 signed int v5; // esi@2 | |
1334 char *v6; // edx@5 | |
1335 unsigned int v7; // eax@10 | |
1336 RenderVertexSoft *v8; // ecx@11 | |
1337 double v9; // st6@11 | |
1338 double v10; // st6@12 | |
1339 unsigned int v11; // edi@14 | |
1340 unsigned __int8 v12; // c2@16 | |
1341 unsigned __int8 v13; // c3@16 | |
1342 unsigned int v14; // edi@17 | |
1343 bool a1a; // [sp+Ch] [bp+8h]@7 | |
1344 | |
1345 if ( uNumInVertices ) | |
1346 { | |
1347 *pOutNumVertices = 0; | |
1348 memcpy(&pInVertices[uNumInVertices], pInVertices, sizeof(pInVertices[uNumInVertices])); | |
1349 v5 = 0; | |
1350 if ( pInVertices->vWorldViewPosition.x >= 8.0 ) | |
1351 v5 = 1; | |
1352 if ( uNumInVertices + 1 > 1 ) | |
1353 { | |
1354 v6 = (char *)&pInVertices[1].u; | |
1355 do | |
1356 { | |
1357 a1a = *((float *)v6 - 6) >= 8.0; | |
1358 if ( v5 == a1a ) | |
1359 { | |
1360 v8 = pOutVertices; | |
1361 goto LABEL_23; | |
1362 } | |
1363 v7 = *pOutNumVertices; | |
1364 if ( a1a ) | |
1365 { | |
1366 v8 = pOutVertices; | |
1367 v9 = (8.0 - *((float *)v6 - 18)) / (*((float *)v6 - 6) - *((float *)v6 - 18)); | |
1368 pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 5) - *((float *)v6 - 17)) * v9 + *((float *)v6 - 17); | |
1369 pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 4) - *((float *)v6 - 16)) * v9 | |
1370 + *((float *)v6 - 16); | |
1371 pOutVertices[*pOutNumVertices].u = (*(float *)v6 - *((float *)v6 - 12)) * v9 + *((float *)v6 - 12); | |
1372 pOutVertices[*pOutNumVertices].v = (*((float *)v6 + 1) - *((float *)v6 - 11)) * v9 + *((float *)v6 - 11); | |
1373 } | |
1374 else | |
1375 { | |
1376 v10 = (8.0 - *((float *)v6 - 6)) / (*((float *)v6 - 18) - *((float *)v6 - 6)); | |
1377 pOutVertices[v7].vWorldViewPosition.y = (*((float *)v6 - 17) - *((float *)v6 - 5)) * v10 + *((float *)v6 - 5); | |
1378 pOutVertices[*pOutNumVertices].vWorldViewPosition.z = (*((float *)v6 - 16) - *((float *)v6 - 4)) * v10 | |
1379 + *((float *)v6 - 4); | |
1380 pOutVertices[*pOutNumVertices].u = (*((float *)v6 - 12) - *(float *)v6) * v10 + *(float *)v6; | |
1381 pOutVertices[*pOutNumVertices].v = (*((float *)v6 - 11) - *((float *)v6 + 1)) * v10 + *((float *)v6 + 1); | |
1382 v8 = pOutVertices; | |
1383 } | |
1384 v8[*pOutNumVertices].vWorldViewPosition.x = 8.0; | |
168 | 1385 v8[*pOutNumVertices]._rhw = 0.125; |
0 | 1386 if ( v5 ) |
1387 { | |
1388 v11 = (unsigned int)&v8[*pOutNumVertices]; | |
1389 if ( *(float *)(v11 + 12) != *((float *)v6 - 18) || *(float *)(v11 + 16) != *((float *)v6 - 17) ) | |
1390 goto LABEL_21; | |
1391 v12 = 0; | |
1392 v13 = *(float *)(v11 + 20) == *((float *)v6 - 16); | |
1393 } | |
1394 else | |
1395 { | |
1396 v14 = (unsigned int)&v8[*pOutNumVertices]; | |
1397 if ( *(float *)(v14 + 12) != *((float *)v6 - 6) || *(float *)(v14 + 16) != *((float *)v6 - 5) ) | |
1398 { | |
1399 LABEL_21: | |
1400 ++*pOutNumVertices; | |
1401 goto LABEL_23; | |
1402 } | |
1403 v12 = 0; | |
1404 v13 = *(float *)(v14 + 20) == *((float *)v6 - 4); | |
1405 } | |
1406 if ( !(v13 | v12) ) | |
1407 goto LABEL_21; | |
1408 LABEL_23: | |
1409 if ( a1a ) | |
1410 { | |
1411 memcpy(&v8[*pOutNumVertices], v6 - 36, sizeof(v8[*pOutNumVertices])); | |
168 | 1412 pOutVertices[(*pOutNumVertices)++]._rhw = 1.0 / (*((float *)v6 - 6) + 0.0000001); |
0 | 1413 } |
1414 v5 = a1a; | |
1415 v6 += 48; | |
1416 --uNumInVertices; | |
1417 } | |
1418 while ( uNumInVertices ); | |
1419 } | |
1420 if ( (signed int)*pOutNumVertices < 3 ) | |
1421 *pOutNumVertices = 0; | |
1422 } | |
1423 } | |
1424 | |
1425 //----- (00436BB7) -------------------------------------------------------- | |
1426 void IndoorCameraD3D::Project(RenderVertexSoft *pVertices, unsigned int uNumVertices, char a4) | |
1427 { | |
1428 double v7; // st7@7 | |
1429 double v8; // st7@9 | |
1430 double v9; // st6@10 | |
1431 double v10; // st5@12 | |
1432 double v11; // st7@16 | |
1433 double v12; // st6@17 | |
1434 double v13; // st5@19 | |
1435 float uNumVerticesa; // [sp+14h] [bp+Ch]@13 | |
1436 float uNumVerticesb; // [sp+14h] [bp+Ch]@20 | |
1437 | |
1438 for (uint i = 0; i < uNumVertices; ++i) | |
1439 { | |
1440 if (byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor) | |
1441 { | |
1442 v7 = 1.0 / pVertices[i].vWorldViewPosition.x; | |
1443 | |
1444 pVertices[i].vWorldViewProjX = pVertices[i].vWorldViewPosition.y * fov * v7 + screenCenterX; | |
693 | 1445 pVertices[i].vWorldViewProjY = (signed int)pViewport->uViewportBR_Y - (pVertices[i].vWorldViewPosition.z * fov * v7 + screenCenterY); |
0 | 1446 } |
1447 else | |
1448 { | |
1449 extern void _outdoor_project(RenderVertexSoft *v); | |
1450 _outdoor_project(pVertices + i); | |
1451 } | |
1452 | |
1453 if ( a4 ) | |
1454 { | |
96 | 1455 // __debugbreak(); |
693 | 1456 v8 = (double)(signed int)pViewport->uViewportBR_X; |
0 | 1457 if ( v8 >= pVertices[i].vWorldViewProjX ) |
1458 v9 = pVertices[i].vWorldViewProjX; | |
1459 else | |
1460 v9 = v8; | |
693 | 1461 v10 = (double)(signed int)pViewport->uViewportTL_X; |
0 | 1462 if ( v10 <= v9 ) |
1463 { | |
1464 if ( v8 >= pVertices[i].vWorldViewProjX) | |
1465 v8 = pVertices[i].vWorldViewProjX; | |
1466 } | |
1467 else | |
1468 { | |
1469 uNumVerticesa = v10; | |
1470 v8 = uNumVerticesa; | |
1471 } | |
1472 pVertices[i].vWorldViewProjX = v8; | |
693 | 1473 v11 = (double)(signed int)pViewport->uViewportBR_Y; |
0 | 1474 if ( v11 >= pVertices[i].vWorldViewProjY) |
1475 v12 = pVertices[i].vWorldViewProjY; | |
1476 else | |
1477 v12 = v11; | |
693 | 1478 v13 = (double)(signed int)pViewport->uViewportTL_Y; |
0 | 1479 if ( v13 <= v12 ) |
1480 { | |
1481 if ( v11 >= pVertices[i].vWorldViewProjY) | |
1482 v11 = pVertices[i].vWorldViewProjY; | |
1483 } | |
1484 else | |
1485 { | |
1486 uNumVerticesb = v13; | |
1487 v11 = uNumVerticesb; | |
1488 } | |
1489 pVertices[i].vWorldViewProjY = v11; | |
1490 } | |
1491 } | |
1492 } | |
1493 | |
1494 //----- (00436A9A) -------------------------------------------------------- | |
1495 void IndoorCameraD3D::Project(signed int x, signed int y, signed int z, int *a5, int *a6) | |
1496 { | |
1497 double v6; // ST00_8@2 | |
1498 //double v7; // ST08_8@2 | |
1499 //double v8; // ST00_8@2 | |
1500 signed __int64 v9; // qtt@3 | |
1501 int v10; // ST04_4@3 | |
1502 float a2a; // [sp+18h] [bp+8h]@2 | |
1503 float a2b; // [sp+18h] [bp+8h]@2 | |
1504 | |
1505 if ( pRenderer->pRenderD3D ) | |
1506 { | |
1507 v6 = 1.0 / (double)x; | |
1508 a2a = (double)y * fov * v6 + screenCenterX; | |
1509 //v7 = a2a + 6.7553994e15; | |
1510 *a5 = floorf(a2a + 0.5f); | |
1511 a2b = (double)z * fov * v6 + screenCenterY; | |
1512 //v8 = a2b + 6.7553994e15; | |
693 | 1513 *a6 = pViewport->uViewportBR_Y - floorf(a2b + 0.5f); |
0 | 1514 } |
1515 else | |
1516 { | |
1517 LODWORD(v9) = pBLVRenderParams->field_40 << 16; | |
1518 HIDWORD(v9) = pBLVRenderParams->field_40 >> 16; | |
1519 v10 = v9 / x; | |
1520 LODWORD(v9) = pBLVRenderParams->field_40 << 16; | |
1521 HIDWORD(v9) = pBLVRenderParams->field_40 >> 16; | |
1522 *a5 = pBLVRenderParams->uViewportCenterX | |
1523 - ((signed int)(((unsigned __int64)(v10 * (signed __int64)y) >> 16) + 32768) >> 16); | |
1524 *a6 = pBLVRenderParams->uViewportCenterY - ((signed int)(((unsigned __int64)(v9 / x * z) >> 16) + 32768) >> 16); | |
1525 } | |
1526 } | |
1527 | |
1528 //----- (00436A6D) -------------------------------------------------------- | |
1529 double IndoorCameraD3D::GetPolygonMinZ(RenderVertexSoft *pVertices, unsigned int uStripType) | |
1530 { | |
1531 unsigned int v3; // edx@1 | |
1532 double result; // st7@1 | |
1533 float *v5; // ecx@2 | |
1534 | |
1535 v3 = uStripType; | |
86 | 1536 result = 3.402823466385289e38; |
0 | 1537 if ( (signed int)uStripType > 0 ) |
1538 { | |
1539 v5 = &pVertices->vWorldPosition.z; | |
1540 do | |
1541 { | |
1542 if ( *v5 < result ) | |
1543 result = *v5; | |
1544 v5 += 12; | |
1545 --v3; | |
1546 } | |
1547 while ( v3 ); | |
1548 } | |
1549 return result; | |
1550 } | |
1551 | |
1552 //----- (00436A24) -------------------------------------------------------- | |
1553 struct IDirect3DTexture2 *IndoorCameraD3D::LoadTextureAndGetHardwarePtr(char *Str1) | |
1554 { | |
1555 return pBitmaps_LOD->pHardwareTextures[pBitmaps_LOD->LoadTexture(Str1)]; | |
1556 } | |
1557 | |
1558 //----- (00436A40) -------------------------------------------------------- | |
1559 double IndoorCameraD3D::GetPolygonMaxZ(RenderVertexSoft *pVertex, unsigned int uStripType) | |
1560 { | |
1561 unsigned int v3; // edx@1 | |
1562 double result; // st7@1 | |
1563 float *v5; // ecx@2 | |
1564 | |
1565 v3 = uStripType; | |
1566 result = 1.1754944e-38; | |
1567 if ( (signed int)uStripType > 0 ) | |
1568 { | |
1569 v5 = &pVertex->vWorldPosition.z; | |
1570 do | |
1571 { | |
1572 if ( *v5 > result ) | |
1573 result = *v5; | |
1574 v5 += 12; | |
1575 --v3; | |
1576 } | |
1577 while ( v3 ); | |
1578 } | |
1579 return result; | |
1580 } |