annotate IndoorCamera.cpp @ 0:8b8875f5b359

Initial commit
author Nomad
date Fri, 05 Oct 2012 16:07:14 +0200
parents
children 5159d2e6f559
rev   line source
0
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
1 #include "IndoorCamera.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
2 #include "Render.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
3 #include "Game.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
4 #include "Indoor.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
5 #include "Math.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
7 #include "mm7_data.h"
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
8
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
9
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
10
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
11
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
12
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
13 IndoorCamera *pIndoorCamera; // idb
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
14
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
15
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
16
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
17
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
18
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
19 //----- (00481CCE) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
20 float IndoorCamera::ViewTransform(RenderVertexSoft *a1)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
21 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
22 float result; // eax@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
23 double vCamToVertexZ; // st7@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
24 double v3; // st6@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
25 double v4; // st5@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
26 double v5; // st4@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
27 float v6; // ST04_4@3
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
28 float v7; // [sp+0h] [bp-14h]@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
29 float v8; // [sp+8h] [bp-Ch]@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
30 float vCamToVertexX; // [sp+Ch] [bp-8h]@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
31 float vCamToVertexY; // [sp+10h] [bp-4h]@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
32
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
33 v8 = fRotationXCosine;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
34 result = fRotationXSine;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
35 v7 = fRotationXSine;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
36 vCamToVertexX = a1->vWorldPosition.x - (double)pos.x;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
37 vCamToVertexY = a1->vWorldPosition.y - (double)pos.y;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
38 vCamToVertexZ = a1->vWorldPosition.z - (double)pos.z;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
39 v3 = fRotationYCosine;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
40 v4 = fRotationYSine;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
41 v5 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
42 if ( sRotationX )
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
43 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
44 v6 = v5;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
45 a1->vWorldViewPosition.x = v5 * fRotationXCosine + fRotationXSine * vCamToVertexZ;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
46 a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
47 a1->vWorldViewPosition.z = v8 * vCamToVertexZ - v6 * v7;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
48 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
49 else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
50 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
51 a1->vWorldViewPosition.x = v5;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
52 a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
53 a1->vWorldViewPosition.z = vCamToVertexZ;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
54 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
55 return result;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
56 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
57
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
58
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
59
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
60 //----- (0042394D) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
61 void IndoorCamera::Initialize(int degFov, unsigned int uViewportWidth, unsigned int uViewportHeight)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
62 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
63 IndoorCamera *v4; // esi@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
64 double v5; // st7@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
65
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
66 v4 = this;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
67 v5 = (double)(signed int)(signed __int64)((double)(signed int)uViewportWidth
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
68 * 0.5
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
69 / tan((double)(degFov >> 1) * 0.01745329)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
70 + 0.5);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
71 v4->flt_1C_fov = v5;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
72 v4->flt_20_inv_1C = 65536.0 / v5;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
73 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
74
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
75 //----- (004239A7) --------------------------------------------------------
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
76 void IndoorCamera::Initialize2()
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
77 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
78 IndoorCamera *v1; // esi@1
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
79 double v2; // st7@4
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
80 double v3; // st7@6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
81 int v4; // eax@6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
82 int v5; // eax@6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
83 int v6; // ST04_4@6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
84 int v7; // eax@6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
85 int v8; // ST04_4@6
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
86
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
87 v1 = this;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
88 this->fRotationYSine = sin((3.141592653589793 + 3.141592653589793) * (double)this->sRotationY * 0.00048828125);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
89 v1->fRotationYCosine = cos((3.141592653589793 + 3.141592653589793) * (double)v1->sRotationY * 0.00048828125);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
90 if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
91 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
92 v1->fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)-v1->sRotationX * 0.00048828125);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
93 v2 = (3.141592653589793 + 3.141592653589793) * (double)-v1->sRotationX;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
94 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
95 else
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
96 {
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
97 v1->fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)v1->sRotationX * 0.00048828125);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
98 v2 = (3.141592653589793 + 3.141592653589793) * (double)v1->sRotationX;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
99 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
100 v3 = cos(v2 * 0.00048828125);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
101 v4 = v1->sRotationY;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
102 v1->fRotationXCosine = v3;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
103 v5 = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
104 v6 = v1->sRotationY;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
105 v1->_int_sine = v5;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
106 v1->_int_cosine = stru_5C6E00->SinCos(v6);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
107 v7 = stru_5C6E00->SinCos(v1->sRotationX - stru_5C6E00->uIntegerHalfPi);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
108 v8 = v1->sRotationX;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
109 v1->_int_sine_2 = v7;
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
110 v1->_int_cosine_2 = stru_5C6E00->SinCos(v8);
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
111 }
8b8875f5b359 Initial commit
Nomad
parents:
diff changeset
112 // 4D864C: using guessed type char byte_4D864C;