Mercurial > mm7
comparison Outdoor.cpp @ 1637:2c71fa8913d2
class OutdoorCamera -> ODMRenderParams
author | Nomad |
---|---|
date | Tue, 17 Sep 2013 14:10:41 +0200 |
parents | 61ea994a1812 |
children | ccde94f02b75 |
comparison
equal
deleted
inserted
replaced
1633:384a6b9d1333 | 1637:2c71fa8913d2 |
---|---|
31 #include "MM7.h" | 31 #include "MM7.h" |
32 #include "Lights.h" | 32 #include "Lights.h" |
33 | 33 |
34 | 34 |
35 #include "MapInfo.h" | 35 #include "MapInfo.h" |
36 #include "OutdoorCamera.h" | |
37 #include "Outdoor_stuff.h" | 36 #include "Outdoor_stuff.h" |
38 #include "BSPModel.h" | 37 #include "BSPModel.h" |
39 #include "GUIWindow.h" | 38 #include "GUIWindow.h" |
40 | 39 |
41 MapStartPoint uLevel_StartingPointType; // weak | 40 MapStartPoint uLevel_StartingPointType; // weak |
42 | 41 |
43 OutdoorLocation *pOutdoor = new OutdoorLocation; | 42 OutdoorLocation *pOutdoor = new OutdoorLocation; |
44 OutdoorCamera *pOutdoorCamera; | 43 ODMRenderParams *pODMRenderParams; |
45 | 44 |
46 | 45 |
47 stru149 stru_8019C8; | 46 stru149 stru_8019C8; |
48 std::array<struct Polygon, 2000 + 18000> array_77EC08; | 47 std::array<struct Polygon, 2000 + 18000> array_77EC08; |
49 Surf stru_80C980; | |
50 Edge defaultEdge; // weak | |
51 Edge stru_80C9A4; | |
52 Edge stru_80C9D8; | |
53 | 48 |
54 | 49 |
55 struct FogProbabilityTableEntry | 50 struct FogProbabilityTableEntry |
56 { | 51 { |
57 unsigned char small_fog_chance; | 52 unsigned char small_fog_chance; |
103 pIndoorCamera->pos.x = pParty->vPosition.x - fixpoint_sub0(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); | 98 pIndoorCamera->pos.x = pParty->vPosition.x - fixpoint_sub0(stru_5C6E00->Cos(pParty->sRotationY), pParty->y_rotation_granularity); |
104 pIndoorCamera->pos.y = pParty->vPosition.y - fixpoint_sub0(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); | 99 pIndoorCamera->pos.y = pParty->vPosition.y - fixpoint_sub0(stru_5C6E00->Sin(pParty->sRotationY), pParty->y_rotation_granularity); |
105 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel; | 100 pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel; |
106 if (bRedraw || pRenderer->pRenderD3D) | 101 if (bRedraw || pRenderer->pRenderD3D) |
107 { | 102 { |
108 pOutdoorCamera->RotationToInts(); | 103 pODMRenderParams->RotationToInts(); |
109 sub_481ED9_MessWithOutdoorCamera(); | 104 sub_481ED9_MessWithODMRenderParams(); |
110 } | 105 } |
111 | 106 |
112 pIndoorCamera->uMapGridCellX = WorldPosToGridCellX(pParty->vPosition.x); | 107 pIndoorCamera->uMapGridCellX = WorldPosToGridCellX(pParty->vPosition.x); |
113 pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.y); | 108 pIndoorCamera->uMapGridCellZ = WorldPosToGridCellZ(pParty->vPosition.y); |
114 assert(pIndoorCamera->uMapGridCellX <= 127 && pIndoorCamera->uMapGridCellZ <= 127); | 109 assert(pIndoorCamera->uMapGridCellX <= 127 && pIndoorCamera->uMapGridCellZ <= 127); |
136 else | 131 else |
137 { | 132 { |
138 pRenderer->DrawBuildingsSW(); | 133 pRenderer->DrawBuildingsSW(); |
139 pRenderer->DrawBezierTerrain(); | 134 pRenderer->DrawBezierTerrain(); |
140 sr_sub_486F92_MessWithEdgesAndSpans(); | 135 sr_sub_486F92_MessWithEdgesAndSpans(); |
141 pOutdoorCamera->_487355(); | 136 pODMRenderParams->ApplyLightmapsSW(); |
142 }*/ | 137 }*/ |
143 } | 138 } |
144 | 139 |
145 | 140 |
146 pMobileLightsStack->uNumLightsActive = 0; | 141 pMobileLightsStack->uNumLightsActive = 0; |
168 _unused000 = 0; | 163 _unused000 = 0; |
169 uNumSpritesDrawnThisFrame = 0; | 164 uNumSpritesDrawnThisFrame = 0; |
170 uNumBillboardsToDraw = 0; | 165 uNumBillboardsToDraw = 0; |
171 | 166 |
172 PrepareActorsDrawList(); | 167 PrepareActorsDrawList(); |
173 if (!pOutdoorCamera->bDoNotRenderDecorations) | 168 if (!pODMRenderParams->bDoNotRenderDecorations) |
174 pRenderer->PrepareDecorationsRenderList_ODM(); | 169 pRenderer->PrepareDecorationsRenderList_ODM(); |
175 | 170 |
176 pRenderer->DrawSpriteObjects_ODM(); | 171 pRenderer->DrawSpriteObjects_ODM(); |
177 pRenderer->TransformBillboardsAndSetPalettesODM(); | 172 pRenderer->TransformBillboardsAndSetPalettesODM(); |
178 //sr_485F53((Vec2_int_ *)sr_6BE060.data()); | 173 //sr_485F53((Vec2_int_ *)sr_6BE060.data()); |
3016 } | 3011 } |
3017 v17 = (x - pIndoorCamera->pos.x) << 16; | 3012 v17 = (x - pIndoorCamera->pos.x) << 16; |
3018 if ( pIndoorCamera->sRotationX ) | 3013 if ( pIndoorCamera->sRotationX ) |
3019 { | 3014 { |
3020 v18 = (y - pIndoorCamera->pos.y) << 16; | 3015 v18 = (y - pIndoorCamera->pos.y) << 16; |
3021 v47 = ((unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) | 3016 v47 = ((unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) |
3022 + ((unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16); | 3017 + ((unsigned __int64)(v18 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16); |
3023 v50 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | 3018 v50 = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; |
3024 v53 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | 3019 v53 = (unsigned __int64)(v18 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; |
3025 v44 = (z - pIndoorCamera->pos.z) << 16; | 3020 v44 = (z - pIndoorCamera->pos.z) << 16; |
3026 v19 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) | 3021 v19 = ((unsigned __int64)(v44 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16) |
3027 + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); | 3022 + ((unsigned __int64)(v47 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16); |
3028 X = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16) | 3023 X = ((unsigned __int64)(v44 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16) |
3029 + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16); | 3024 + ((unsigned __int64)(v47 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16); |
3030 if ( v19 < 262144 || v19 > pOutdoorCamera->shading_dist_mist << 16 ) | 3025 if ( v19 < 262144 || v19 > pODMRenderParams->shading_dist_mist << 16 ) |
3031 continue; | 3026 continue; |
3032 v20 = v53 - v50; | 3027 v20 = v53 - v50; |
3033 v42 = v53 - v50; | 3028 v42 = v53 - v50; |
3034 v21 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16) | 3029 v21 = ((unsigned __int64)(v44 * (signed __int64)pODMRenderParams->camera_rotation_x_int_cosine) >> 16) |
3035 - ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16); | 3030 - ((unsigned __int64)(v47 * (signed __int64)pODMRenderParams->camera_rotation_x_int_sine) >> 16); |
3036 } | 3031 } |
3037 else | 3032 else |
3038 { | 3033 { |
3039 v48 = (y - pIndoorCamera->pos.y) << 16; | 3034 v48 = (y - pIndoorCamera->pos.y) << 16; |
3040 v51 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16; | 3035 v51 = (unsigned __int64)(v17 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16; |
3041 v22 = (unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | 3036 v22 = (unsigned __int64)(v48 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; |
3042 X = v22 + v51; | 3037 X = v22 + v51; |
3043 if ( v22 + v51 < 262144 || v22 + v51 > pOutdoorCamera->shading_dist_mist << 16 ) | 3038 if ( v22 + v51 < 262144 || v22 + v51 > pODMRenderParams->shading_dist_mist << 16 ) |
3044 continue; | 3039 continue; |
3045 v23 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) | 3040 v23 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16) |
3046 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16; | 3041 * (signed __int64)pODMRenderParams->camera_rotation_y_int_sine) >> 16; |
3047 v20 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; | 3042 v20 = ((unsigned __int64)(v48 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v23; |
3048 v42 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23; | 3043 v42 = ((unsigned __int64)(v48 * (signed __int64)pODMRenderParams->camera_rotation_y_int_cosine) >> 16) - v23; |
3049 v21 = (z - pIndoorCamera->pos.z) << 16; | 3044 v21 = (z - pIndoorCamera->pos.z) << 16; |
3050 } | 3045 } |
3051 v45 = v21; | 3046 v45 = v21; |
3052 v24 = abs(v20); | 3047 v24 = abs(v20); |
3053 if ( abs(X) >= v24 ) | 3048 if ( abs(X) >= v24 ) |
3054 { | 3049 { |
3055 LODWORD(v25) = 0; | 3050 LODWORD(v25) = 0; |
3056 HIDWORD(v25) = SLOWORD(pOutdoorCamera->int_fov_rad); | 3051 HIDWORD(v25) = SLOWORD(pODMRenderParams->int_fov_rad); |
3057 v58 = v25 / X; | 3052 v58 = v25 / X; |
3058 v26 = v25 / X; | 3053 v26 = v25 / X; |
3059 LODWORD(v25) = 0; | 3054 LODWORD(v25) = 0; |
3060 HIDWORD(v25) = SLOWORD(pOutdoorCamera->int_fov_rad); | 3055 HIDWORD(v25) = SLOWORD(pODMRenderParams->int_fov_rad); |
3061 v57 = v25 / X; | 3056 v57 = v25 / X; |
3062 v27 = pViewport->uScreenCenterX | 3057 v27 = pViewport->uScreenCenterX |
3063 - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); | 3058 - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); |
3064 v43 = pViewport->uScreenCenterX | 3059 v43 = pViewport->uScreenCenterX |
3065 - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); | 3060 - ((signed int)(((unsigned __int64)(v26 * (signed __int64)v42) >> 16) + 32768) >> 16); |
3603 pCmap = 0; | 3598 pCmap = 0; |
3604 pFaceIDLIST = 0; | 3599 pFaceIDLIST = 0; |
3605 pOMAP = 0; | 3600 pOMAP = 0; |
3606 } | 3601 } |
3607 | 3602 |
3603 | |
3604 | |
3605 | |
3606 //----- (00481E55) -------------------------------------------------------- | |
3607 void ODM_Project(unsigned int uNumVertices) | |
3608 { | |
3609 double v1; // st7@2 | |
3610 double v2; // st6@2 | |
3611 double v3; // st5@2 | |
3612 int v4; // eax@2 | |
3613 unsigned int v5; // edx@2 | |
3614 double v6; // st4@3 | |
3615 double v7; // st3@3 | |
3616 | |
3617 if ( (signed int)uNumVertices > 0 ) | |
3618 { | |
3619 v1 = (double)pODMRenderParams->int_fov_rad; | |
3620 v2 = (double)pViewport->uScreenCenterX; | |
3621 v3 = (double)pViewport->uScreenCenterY; | |
3622 v4 = 0; | |
3623 v5 = uNumVertices; | |
3624 do | |
3625 { | |
3626 v6 = v1 * array_507D30[v4]._rhw; | |
3627 v7 = v6 * array_507D30[v4].vWorldViewPosition.y; | |
3628 memcpy(&array_50AC10[v4], &array_507D30[v4], sizeof(array_50AC10[v4])); | |
3629 array_50AC10[v4].vWorldViewProjX = v2 - v7; | |
3630 array_50AC10[v4].vWorldViewProjY = v3 - v6 * array_507D30[v4].vWorldViewPosition.z; | |
3631 ++v4; | |
3632 --v5; | |
3633 } | |
3634 while ( v5 ); | |
3635 } | |
3636 } | |
3637 //----- (00485F64) -------------------------------------------------------- | |
3638 void ODMRenderParams::Initialize() | |
3639 { | |
3640 int v1; // eax@1 | |
3641 int v2; // eax@2 | |
3642 signed __int64 v3; // qtt@4 | |
3643 int v4; // eax@4 | |
3644 | |
3645 this->uCameraFovInDegrees = 75; | |
3646 v1 = stru_5C6E00->uPiMask & 0xD5; | |
3647 if ( v1 >= (signed int)stru_5C6E00->uIntegerHalfPi ) | |
3648 v2 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v1]; | |
3649 else | |
3650 v2 = stru_5C6E00->pTanTable[v1]; | |
3651 LODWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 31; | |
3652 HIDWORD(v3) = (viewparams->uSomeZ - viewparams->uSomeX) << 15 >> 16; | |
3653 v4 = (signed int)(v3 / v2) >> 16; | |
3654 this->int_fov_rad = v4; | |
3655 this->field_4C = 360000; | |
3656 this->int_fov_rad_inv = 65536 / v4; | |
3657 this->field_50 = 115; | |
3658 //sr_6BE060[1] = 1; | |
3659 RotationToInts(); | |
3660 } | |
3661 | |
3662 //----- (0048600E) -------------------------------------------------------- | |
3663 void ODMRenderParams::RotationToInts() | |
3664 { | |
3665 camera_rotation_y_int_sine = stru_5C6E00->Sin(rotation_y); | |
3666 camera_rotation_y_int_cosine = stru_5C6E00->Cos(rotation_y); | |
3667 camera_rotation_x_int_sine = stru_5C6E00->Sin(rotation_x); | |
3668 camera_rotation_x_int_cosine = stru_5C6E00->Cos(rotation_x); | |
3669 } |