1295
|
1 #include "OutdoorCamera.h"
|
|
2 #include "IndoorCamera.h"
|
|
3 #include "Outdoor_stuff.h"
|
|
4 #include "Game.h"
|
|
5 #include "LightmapBuilder.h"
|
|
6 #include "Viewport.h"
|
|
7 #include "Math.h"
|
|
8 #include "mm7_data.h"
|
|
9 #include "Allocator.h"
|
|
10
|
|
11 //----- (00487355) --------------------------------------------------------
|
|
12 bool OutdoorCamera::_487355()
|
|
13 {
|
|
14 int v0; // esi@1
|
|
15 stru148 *v1; // edi@2
|
|
16 bool result; // eax@3
|
|
17
|
|
18 v0 = 0;
|
|
19 if ( pOutdoorCamera->numStru148s > 0 )
|
|
20 {
|
|
21 v1 = array_77EC08.data();
|
|
22 do
|
|
23 {
|
|
24 result = pGame->pLightmapBuilder->_45D3C7(v1);
|
|
25 ++v0;
|
|
26 ++v1;
|
|
27 }
|
|
28 while ( v0 < pOutdoorCamera->numStru148s );
|
|
29 }
|
|
30 return result;
|
|
31 }
|
|
32 //----- (00481E55) --------------------------------------------------------
|
|
33 void OutdoorCamera::Project(unsigned int uNumVertices)
|
|
34 {
|
|
35 double v1; // st7@2
|
|
36 double v2; // st6@2
|
|
37 double v3; // st5@2
|
|
38 int v4; // eax@2
|
|
39 unsigned int v5; // edx@2
|
|
40 double v6; // st4@3
|
|
41 double v7; // st3@3
|
|
42
|
|
43 if ( (signed int)uNumVertices > 0 )
|
|
44 {
|
|
45 v1 = (double)pOutdoorCamera->int_fov_rad;
|
|
46 v2 = (double)pViewport->uScreenCenterX;
|
|
47 v3 = (double)pViewport->uScreenCenterY;
|
|
48 v4 = 0;
|
|
49 v5 = uNumVertices;
|
|
50 do
|
|
51 {
|
|
52 v6 = v1 * array_507D30[v4]._rhw;
|
|
53 v7 = v6 * array_507D30[v4].vWorldViewPosition.y;
|
|
54 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4]));
|
|
55 array_50AC10[v4].vWorldViewProjX = v2 - v7;
|
|
56 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z;
|
|
57 ++v4;
|
|
58 --v5;
|
|
59 }
|
|
60 while ( v5 );
|
|
61 }
|
|
62 }
|
|
63 //----- (00485F64) --------------------------------------------------------
|
|
64 void OutdoorCamera::_485F64()
|
|
65 {
|
|
66 int v1; // eax@1
|
|
67 int v2; // eax@2
|
|
68 signed __int64 v3; // qtt@4
|
|
69 int v4; // eax@4
|
|
70
|
|
71 this->uCameraFovInDegrees = 75;
|
|
72 v1 = stru_5C6E00->uPiMask & 0xD5;
|
|
73 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi )
|
|
74 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1];
|
|
75 else
|
|
76 v2 = stru_5C6E00->pTanTable[v1];
|
|
77 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31;
|
|
78 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16;
|
|
79 v4 = (signed int)(v3 / v2) >> 16;
|
|
80 this->int_fov_rad = v4;
|
|
81 this->field_4C = 360000;
|
|
82 this->int_fov_rad_inv = 65536 / v4;
|
|
83 this->field_50 = 115;
|
|
84 unnamed_6BE060[1] = 1;
|
|
85 RotationToInts();
|
|
86 }
|
|
87
|
|
88 //----- (0048600E) --------------------------------------------------------
|
|
89 void OutdoorCamera::RotationToInts()
|
|
90 {
|
|
91 camera_rotation_y_int_sine = stru_5C6E00->Sin(pIndoorCamera->sRotationY);
|
|
92 camera_rotation_y_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationY);
|
|
93 camera_rotation_x_int_sine = stru_5C6E00->Sin(pIndoorCamera->sRotationX);
|
|
94 camera_rotation_x_int_cosine = stru_5C6E00->Cos(pIndoorCamera->sRotationX);
|
|
95 }
|
|
96 //----- (00486A28) --------------------------------------------------------
|
|
97 void OutdoorCamera::AllocSoftwareDrawBuffers()
|
|
98 {
|
|
99 if ( !this || !pSpans )
|
|
100 {
|
|
101 ReleaseSoftwareDrawBuffers();
|
|
102 pSpans = (Span *)pAllocator->AllocNamedChunk(pSpans, 0x493E0u, "SPANS");
|
|
103 pEdges = (Edge *)pAllocator->AllocNamedChunk(pEdges, 0x4C2C0u, "EDGES");
|
|
104 pSurfs = (Surf *)pAllocator->AllocNamedChunk(pSurfs, 0x11940u, "SURFS");
|
|
105 pNewEdges = (Edge *)pAllocator->AllocNamedChunk(pNewEdges, 0x6180u, "NEWEDGES");
|
|
106 memset(pSpans, 0, 0x493E0u);
|
|
107 memset(pEdges, 0, 0x4C2C0u);
|
|
108 memset(pSurfs, 0, 0x11940u);
|
|
109 memset(pNewEdges, 0, 0x6180u);
|
|
110 }
|
|
111 }
|
|
112
|
|
113 //----- (00486AFC) --------------------------------------------------------
|
|
114 void OutdoorCamera::ReleaseSoftwareDrawBuffers()
|
|
115 {
|
|
116 pAllocator->FreeChunk(pSpans);
|
|
117 pAllocator->FreeChunk(pEdges);
|
|
118 pAllocator->FreeChunk(pSurfs);
|
|
119 pAllocator->FreeChunk(pNewEdges);
|
|
120 pSpans = 0;
|
|
121 pEdges = 0;
|
|
122 pSurfs = 0;
|
|
123 pNewEdges = 0;
|
|
124 } |