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