comparison Engine/Graphics/IndoorCameraD3D.cpp @ 2543:b6140dfeac27

GameOver h/cpp
author a.parshin
date Sun, 10 May 2015 03:21:14 +0200
parents a902abdfc7f2
children b8a56afc6ba1
comparison
equal deleted inserted replaced
2542:bacf9809126a 2543:b6140dfeac27
17 float _calc_fov(int viewport_width, int angle_degree) 17 float _calc_fov(int viewport_width, int angle_degree)
18 { 18 {
19 return viewport_width * 0.5 / tan(angle_degree / 2 * 0.01745329) + 0.5; 19 return viewport_width * 0.5 / tan(angle_degree / 2 * 0.01745329) + 0.5;
20 } 20 }
21 21
22 IndoorCameraD3D *pIndoorCameraD3D = new IndoorCameraD3D;
22 23
23 24
24 //----- (004361EF) -------------------------------------------------------- 25 //----- (004361EF) --------------------------------------------------------
25 IndoorCameraD3D::IndoorCameraD3D() 26 IndoorCameraD3D::IndoorCameraD3D()
26 { 27 {
107 int to_x; // [sp+14h] [bp+8h]@1 108 int to_x; // [sp+14h] [bp+8h]@1
108 int to_y; // [sp+18h] [bp+Ch]@1 109 int to_y; // [sp+18h] [bp+Ch]@1
109 // int a2b; // [sp+18h] [bp+Ch]@5 110 // int a2b; // [sp+18h] [bp+Ch]@5
110 int a3a; // [sp+1Ch] [bp+10h]@5 111 int a3a; // [sp+1Ch] [bp+10h]@5
111 112
112 to_x = x - pEngine->pIndoorCameraD3D->vPartyPos.x; 113 to_x = x - pIndoorCameraD3D->vPartyPos.x;
113 to_y = y - pEngine->pIndoorCameraD3D->vPartyPos.y; 114 to_y = y - pIndoorCameraD3D->vPartyPos.y;
114 if (pEngine->pIndoorCameraD3D->sRotationX) 115 if (pIndoorCameraD3D->sRotationX)
115 { 116 {
116 to_z = (z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16; 117 to_z = (z - pIndoorCameraD3D->vPartyPos.z) << 16;
117 //if ( pRenderer->pRenderD3D ) 118 //if ( pRenderer->pRenderD3D )
118 //{ 119 //{
119 v14 = (unsigned __int64)(to_x * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) 120 v14 = (unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_cosine_y)
120 + (unsigned __int64)(to_y * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y); 121 + (unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_sine_y);
121 v9 = (unsigned __int64)(to_x * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) 122 v9 = (unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_sine_y)
122 - (unsigned __int64)(to_y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y); 123 - (unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_cosine_y);
123 //} 124 //}
124 a3a = (z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16; 125 a3a = (z - pIndoorCameraD3D->vPartyPos.z) << 16;
125 *pOutX = fixpoint_mul(v14, pEngine->pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(to_z, pEngine->pIndoorCameraD3D->int_sine_x); 126 *pOutX = fixpoint_mul(v14, pIndoorCameraD3D->int_cosine_x) - fixpoint_mul(to_z, pIndoorCameraD3D->int_sine_x);
126 *pOutZ = v9; 127 *pOutZ = v9;
127 *pOutY = fixpoint_mul(v14, pEngine->pIndoorCameraD3D->int_sine_x) + fixpoint_mul(a3a, pEngine->pIndoorCameraD3D->int_cosine_x); 128 *pOutY = fixpoint_mul(v14, pIndoorCameraD3D->int_sine_x) + fixpoint_mul(a3a, pIndoorCameraD3D->int_cosine_x);
128 } 129 }
129 else 130 else
130 { 131 {
131 *pOutY = (z - pEngine->pIndoorCameraD3D->vPartyPos.z) << 16; 132 *pOutY = (z - pIndoorCameraD3D->vPartyPos.z) << 16;
132 //if ( pRenderer->pRenderD3D ) 133 //if ( pRenderer->pRenderD3D )
133 //{ 134 //{
134 //v10 = pOutX; 135 //v10 = pOutX;
135 *pOutX = (unsigned __int64)(to_x * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y) 136 *pOutX = (unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_cosine_y)
136 + (unsigned __int64)(to_y * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y); 137 + (unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_sine_y);
137 *pOutZ = (unsigned __int64)(to_x * (signed __int64)pEngine->pIndoorCameraD3D->int_sine_y) 138 *pOutZ = (unsigned __int64)(to_x * (signed __int64)pIndoorCameraD3D->int_sine_y)
138 - (unsigned __int64)(to_y * (signed __int64)pEngine->pIndoorCameraD3D->int_cosine_y); 139 - (unsigned __int64)(to_y * (signed __int64)pIndoorCameraD3D->int_cosine_y);
139 //} 140 //}
140 } 141 }
141 if (!bDoNotShow) 142 if (!bDoNotShow)
142 return false; 143 return false;
143 144
177 float sin_y = fRotationYSine, 178 float sin_y = fRotationYSine,
178 cos_y = fRotationYCosine; 179 cos_y = fRotationYCosine;
179 180
180 //v4 = uNumVertices; 181 //v4 = uNumVertices;
181 //v7 = pIndoorCamera->fRotationXSine; 182 //v7 = pIndoorCamera->fRotationXSine;
182 if (pEngine->pIndoorCameraD3D->sRotationX) 183 if (pIndoorCameraD3D->sRotationX)
183 { 184 {
184 185
185 //_EAX = a1a; 186 //_EAX = a1a;
186 for (uint i = 0; i < uNumVertices; ++i) 187 for (uint i = 0; i < uNumVertices; ++i)
187 { 188 {
224 // 2[(a1a[i].z - pIndoorCamera->pos.z)] 225 // 2[(a1a[i].z - pIndoorCamera->pos.z)]
225 // 3[pIndoorCamera->fRotationXCosine] 226 // 3[pIndoorCamera->fRotationXCosine]
226 // 4[pIndoorCamera->fRotationYSine] 227 // 4[pIndoorCamera->fRotationYSine]
227 // 5[pIndoorCamera->fRotationYCosine] 228 // 5[pIndoorCamera->fRotationYCosine]
228 }*/ 229 }*/
229 st0 = sin_y * (a1a[i].vWorldPosition.x - pEngine->pIndoorCameraD3D->vPartyPos.x) - cos_y * (a1a[i].vWorldPosition.y - pEngine->pIndoorCameraD3D->vPartyPos.y); 230 st0 = sin_y * (a1a[i].vWorldPosition.x - pIndoorCameraD3D->vPartyPos.x) - cos_y * (a1a[i].vWorldPosition.y - 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 st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCameraD3D->vPartyPos.x) + sin_y * (a1a[i].vWorldPosition.y - pIndoorCameraD3D->vPartyPos.y);
231 st2 = (a1a[i].vWorldPosition.z - pEngine->pIndoorCameraD3D->vPartyPos.z); 232 st2 = (a1a[i].vWorldPosition.z - pIndoorCameraD3D->vPartyPos.z);
232 } 233 }
233 if (false)//else 234 if (false)//else
234 { 235 {
235 /*__asm 236 /*__asm
236 { 237 {
292 // 2[(a1a[i].z - pIndoorCamera->pos.z)] 293 // 2[(a1a[i].z - pIndoorCamera->pos.z)]
293 // 3[pIndoorCamera->fRotationXCosine] 294 // 3[pIndoorCamera->fRotationXCosine]
294 // 4[pIndoorCamera->fRotationYSine] 295 // 4[pIndoorCamera->fRotationYSine]
295 // 5[pIndoorCamera->fRotationYCosine] 296 // 5[pIndoorCamera->fRotationYCosine]
296 }*/ 297 }*/
297 st0 = cos_y * (a1a[i].vWorldPosition.y - pEngine->pIndoorCameraD3D->vPartyPos.y) + sin_y * (a1a[i].vWorldPosition.x - pEngine->pIndoorCameraD3D->vPartyPos.x); 298 st0 = cos_y * (a1a[i].vWorldPosition.y - pIndoorCameraD3D->vPartyPos.y) + sin_y * (a1a[i].vWorldPosition.x - 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 st1 = cos_y * (a1a[i].vWorldPosition.x - pIndoorCameraD3D->vPartyPos.x) - sin_y * (a1a[i].vWorldPosition.y - pIndoorCameraD3D->vPartyPos.y);
299 st2 = (a1a[i].vWorldPosition.z - pEngine->pIndoorCameraD3D->vPartyPos.z); 300 st2 = (a1a[i].vWorldPosition.z - pIndoorCameraD3D->vPartyPos.z);
300 } 301 }
301 302
302 a1a[i].vWorldViewPosition.x = st1*cos_x - st2*sin_x; 303 a1a[i].vWorldViewPosition.x = st1*cos_x - st2*sin_x;
303 a1a[i].vWorldViewPosition.y = st0; 304 a1a[i].vWorldViewPosition.y = st0;
304 a1a[i].vWorldViewPosition.z = st2*cos_x + st1*sin_x; 305 a1a[i].vWorldViewPosition.z = st2*cos_x + st1*sin_x;
358 // 2[sin_y] 359 // 2[sin_y]
359 // 3[cos_y] 360 // 3[cos_y]
360 fstp dword ptr [eax+10h] 361 fstp dword ptr [eax+10h]
361 fstp dword ptr [eax+14h] 362 fstp dword ptr [eax+14h]
362 }*/ 363 }*/
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.x = cos_y * (a1a[i].vWorldPosition.x - pIndoorCameraD3D->vPartyPos.x) + sin_y * (a1a[i].vWorldPosition.y - 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.y = sin_y * (a1a[i].vWorldPosition.x - pIndoorCameraD3D->vPartyPos.x) - cos_y * (a1a[i].vWorldPosition.y - pIndoorCameraD3D->vPartyPos.y);
365 a1a[i].vWorldViewPosition.z = (a1a[i].vWorldPosition.z - pEngine->pIndoorCameraD3D->vPartyPos.z); 366 a1a[i].vWorldViewPosition.z = (a1a[i].vWorldPosition.z - pIndoorCameraD3D->vPartyPos.z);
366 } 367 }
367 if (false)//else 368 if (false)//else
368 { 369 {
369 __debugbreak(); 370 __debugbreak();
370 /*__asm 371 /*__asm
409 float vCamToVertexY; // [sp+10h] [bp-4h]@1 410 float vCamToVertexY; // [sp+10h] [bp-4h]@1
410 411
411 v8 = fRotationXCosine; 412 v8 = fRotationXCosine;
412 result = fRotationXSine; 413 result = fRotationXSine;
413 v7 = fRotationXSine; 414 v7 = fRotationXSine;
414 vCamToVertexX = a1->vWorldPosition.x - (double)pEngine->pIndoorCameraD3D->vPartyPos.x; 415 vCamToVertexX = a1->vWorldPosition.x - (double)pIndoorCameraD3D->vPartyPos.x;
415 vCamToVertexY = a1->vWorldPosition.y - (double)pEngine->pIndoorCameraD3D->vPartyPos.y; 416 vCamToVertexY = a1->vWorldPosition.y - (double)pIndoorCameraD3D->vPartyPos.y;
416 vCamToVertexZ = a1->vWorldPosition.z - (double)pEngine->pIndoorCameraD3D->vPartyPos.z; 417 vCamToVertexZ = a1->vWorldPosition.z - (double)pIndoorCameraD3D->vPartyPos.z;
417 v3 = fRotationYCosine; 418 v3 = fRotationYCosine;
418 v4 = fRotationYSine; 419 v4 = fRotationYSine;
419 v5 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX; 420 v5 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
420 if (pEngine->pIndoorCameraD3D->sRotationX) 421 if (pIndoorCameraD3D->sRotationX)
421 { 422 {
422 v6 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX; 423 v6 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
423 a1->vWorldViewPosition.x = v5 * fRotationXCosine + fRotationXSine * vCamToVertexZ; 424 a1->vWorldViewPosition.x = v5 * fRotationXCosine + fRotationXSine * vCamToVertexZ;
424 a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX; 425 a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
425 a1->vWorldViewPosition.z = v8 * vCamToVertexZ - v6 * v7; 426 a1->vWorldViewPosition.z = v8 * vCamToVertexZ - v6 * v7;
502 { 503 {
503 if (pFace->Portal()) 504 if (pFace->Portal())
504 return false; 505 return false;
505 506
506 //really strange cull; dot(to_cam, normal) < 0 means we see the BACK face, not font %_% 507 //really strange cull; dot(to_cam, normal) < 0 means we see the BACK face, not font %_%
507 if ( (a2->vWorldPosition.z - (double)pEngine->pIndoorCameraD3D->vPartyPos.z) * (double)pFace->pFacePlane_old.vNormal.z 508 if ( (a2->vWorldPosition.z - (double)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.y - (double)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) 510 + (a2->vWorldPosition.x - (double)pIndoorCameraD3D->vPartyPos.x) * (double)pFace->pFacePlane_old.vNormal.x < 0.0)
510 return false; 511 return false;
511 512
512 return true; 513 return true;
513 } 514 }
514 515
766 void IndoorCameraD3D::_437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2) 767 void IndoorCameraD3D::_437607(IndoorCameraD3D_Vec3 *a1, IndoorCameraD3D_Vec4 *a2)
767 { 768 {
768 double v4; // st7@1 769 double v4; // st7@1
769 IndoorCameraD3D_Vec3 v8; // [sp+8h] [bp-1Ch]@1 770 IndoorCameraD3D_Vec3 v8; // [sp+8h] [bp-1Ch]@1
770 771
771 v8.x = (double)pEngine->pIndoorCameraD3D->vPartyPos.x; 772 v8.x = (double)pIndoorCameraD3D->vPartyPos.x;
772 v8.y = (double)pEngine->pIndoorCameraD3D->vPartyPos.y; 773 v8.y = (double)pIndoorCameraD3D->vPartyPos.y;
773 v8.z = (double)pEngine->pIndoorCameraD3D->vPartyPos.z; 774 v8.z = (double)pIndoorCameraD3D->vPartyPos.z;
774 Vec3Transform(a1, a2); 775 Vec3Transform(a1, a2);
775 776
776 v4 = v8.x * a2->x + v8.y * a2->y + v8.z * a2->z; 777 v4 = v8.x * a2->x + v8.y * a2->y + v8.z * a2->z;
777 a2->dot = v4 + 0.000099999997; 778 a2->dot = v4 + 0.000099999997;
778 } 779 }
839 result = false; 840 result = false;
840 memcpy(&a2[*pOutNumVertices], a2, sizeof(a2[*pOutNumVertices])); 841 memcpy(&a2[*pOutNumVertices], a2, sizeof(a2[*pOutNumVertices]));
841 memcpy(&a2[*pOutNumVertices + 1], &a2[1], sizeof(a2[*pOutNumVertices + 1])); 842 memcpy(&a2[*pOutNumVertices + 1], &a2[1], sizeof(a2[*pOutNumVertices + 1]));
842 843
843 if ( (signed int)*pOutNumVertices <= 3 844 if ( (signed int)*pOutNumVertices <= 3
844 || (((v18.vWorldPosition.z - (double)pEngine->pIndoorCameraD3D->vPartyPos.z) * thisa->face_plane.vNormal.z 845 || (((v18.vWorldPosition.z - (double)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.y - (double)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), 847 + (v18.vWorldPosition.x - (double)pIndoorCameraD3D->vPartyPos.x) * thisa->face_plane.vNormal.x < 0.0) ? (v6 = 1.0) : (v6 = -1.0),
847 (signed int)*pOutNumVertices <= 0) ) 848 (signed int)*pOutNumVertices <= 0) )
848 return 0; 849 return 0;
849 850
850 for ( int i = 1; i - 1 < (signed int)*pOutNumVertices; i++ ) 851 for ( int i = 1; i - 1 < (signed int)*pOutNumVertices; i++ )
851 { 852 {
1358 if (byte_4D864C && pEngine->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor) 1359 if (byte_4D864C && pEngine->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
1359 { 1360 {
1360 fRotationXSine = sin((pi_double + pi_double) * (double)-sRotationX / 2048.0); 1361 fRotationXSine = sin((pi_double + pi_double) * (double)-sRotationX / 2048.0);
1361 fRotationXCosine = cos((pi_double + pi_double) * (double)-sRotationX / 2048.0); 1362 fRotationXCosine = cos((pi_double + pi_double) * (double)-sRotationX / 2048.0);
1362 1363
1363 int_sine_y = stru_5C6E00->Sin( pEngine->pIndoorCameraD3D->sRotationY); 1364 int_sine_y = stru_5C6E00->Sin( pIndoorCameraD3D->sRotationY);
1364 int_cosine_y = stru_5C6E00->Cos( pEngine->pIndoorCameraD3D->sRotationY); 1365 int_cosine_y = stru_5C6E00->Cos( pIndoorCameraD3D->sRotationY);
1365 int_sine_x = stru_5C6E00->Sin(-pEngine->pIndoorCameraD3D->sRotationX); 1366 int_sine_x = stru_5C6E00->Sin(-pIndoorCameraD3D->sRotationX);
1366 int_cosine_x = stru_5C6E00->Cos(-pEngine->pIndoorCameraD3D->sRotationX); 1367 int_cosine_x = stru_5C6E00->Cos(-pIndoorCameraD3D->sRotationX);
1367 } 1368 }
1368 else 1369 else
1369 { 1370 {
1370 fRotationXSine = sin((pi_double + pi_double) * (double)sRotationX / 2048.0); 1371 fRotationXSine = sin((pi_double + pi_double) * (double)sRotationX / 2048.0);
1371 fRotationXCosine = cos((pi_double + pi_double) * (double)sRotationX / 2048.0); 1372 fRotationXCosine = cos((pi_double + pi_double) * (double)sRotationX / 2048.0);
1372 1373
1373 int_sine_y = stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationY); 1374 int_sine_y = stru_5C6E00->Sin(pIndoorCameraD3D->sRotationY);
1374 int_cosine_y = stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationY); 1375 int_cosine_y = stru_5C6E00->Cos(pIndoorCameraD3D->sRotationY);
1375 int_sine_x = stru_5C6E00->Sin(pEngine->pIndoorCameraD3D->sRotationX); 1376 int_sine_x = stru_5C6E00->Sin(pIndoorCameraD3D->sRotationX);
1376 int_cosine_x = stru_5C6E00->Cos(pEngine->pIndoorCameraD3D->sRotationX); 1377 int_cosine_x = stru_5C6E00->Cos(pIndoorCameraD3D->sRotationX);
1377 } 1378 }
1378 } 1379 }