view IndoorCamera.cpp @ 564:8b77231088d8

Moon Temple doesn't crash
author Nomad
date Tue, 05 Mar 2013 01:45:15 +0200
parents d720a13e2273
children 2c71fa8913d2
line wrap: on
line source

#include "IndoorCamera.h"
#include "Render.h"
#include "Game.h"
#include "Indoor.h"
#include "Math.h"

#include "mm7_data.h"





IndoorCamera *pIndoorCamera; // idb





//----- (00481CCE) --------------------------------------------------------
float IndoorCamera::ViewTransform(RenderVertexSoft *a1)
{
  float result; // eax@1
  double vCamToVertexZ; // st7@1
  double v3; // st6@1
  double v4; // st5@1
  double v5; // st4@1
  float v6; // ST04_4@3
  float v7; // [sp+0h] [bp-14h]@1
  float v8; // [sp+8h] [bp-Ch]@1
  float vCamToVertexX; // [sp+Ch] [bp-8h]@1
  float vCamToVertexY; // [sp+10h] [bp-4h]@1

  v8 = fRotationXCosine;
  result = fRotationXSine;
  v7 = fRotationXSine;
  vCamToVertexX = a1->vWorldPosition.x - (double)pos.x;
  vCamToVertexY = a1->vWorldPosition.y - (double)pos.y;
  vCamToVertexZ = a1->vWorldPosition.z - (double)pos.z;
  v3 = fRotationYCosine;
  v4 = fRotationYSine;
  v5 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
  if ( sRotationX )
  {
    v6 = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
    a1->vWorldViewPosition.x = v5 * fRotationXCosine + fRotationXSine * vCamToVertexZ;
    a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
    a1->vWorldViewPosition.z = v8 * vCamToVertexZ - v6 * v7;
  }
  else
  {
    a1->vWorldViewPosition.x = vCamToVertexY * fRotationYSine + fRotationYCosine * vCamToVertexX;
    a1->vWorldViewPosition.y = v3 * vCamToVertexY - v4 * vCamToVertexX;
    a1->vWorldViewPosition.z = vCamToVertexZ;
  }
  return result;
}



//----- (0042394D) --------------------------------------------------------
void IndoorCamera::Initialize(int degFov, unsigned int uViewportWidth, unsigned int uViewportHeight)
{
  IndoorCamera *v4; // esi@1
  double v5; // st7@1

  v4 = this;
  v5 = (double)(signed int)(signed __int64)((double)(signed int)uViewportWidth
                                          * 0.5
                                          / tan((double)(degFov >> 1) * 0.01745329)
                                          + 0.5);
  v4->flt_1C_fov = v5;
  v4->flt_20_inv_1C = 65536.0 / v5;
}

//----- (004239A7) --------------------------------------------------------
void IndoorCamera::Initialize2()
{
  //IndoorCamera *v1; // esi@1
  double v2; // st7@4
  //double v3; // st7@6
  //int v4; // eax@6
  //int v5; // eax@6
  //int v6; // ST04_4@6
  //int v7; // eax@6
  //int v8; // ST04_4@6

  //v1 = this;
  fRotationYSine = sin((3.141592653589793 + 3.141592653589793) * (double)sRotationY * 0.00048828125);
  fRotationYCosine = cos((3.141592653589793 + 3.141592653589793) * (double)sRotationY * 0.00048828125);
  if ( byte_4D864C && pGame->uFlags & 0x80 || uCurrentlyLoadedLevelType == LEVEL_Indoor)
  {
    fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)-sRotationX * 0.00048828125);
    v2 = (3.141592653589793 + 3.141592653589793) * (double)-sRotationX;
  }
  else
  {
    fRotationXSine = sin((3.141592653589793 + 3.141592653589793) * (double)sRotationX * 0.00048828125);
    v2 = (3.141592653589793 + 3.141592653589793) * (double)sRotationX;
  }
  //v3 = cos(v2 * 0.00048828125);
  //v4 = sRotationY;
  fRotationXCosine = cos(v2 * 0.00048828125);
  //v5 = stru_5C6E00->SinCos(sRotationY - stru_5C6E00->uIntegerHalfPi);
  //v6 = sRotationY;
  _int_sine = stru_5C6E00->Sin(sRotationY);
  _int_cosine = stru_5C6E00->Cos(sRotationY);
  //v7 = stru_5C6E00->SinCos(sRotationX - stru_5C6E00->uIntegerHalfPi);
  //v8 = sRotationX;
  _int_sine_2 = stru_5C6E00->Sin(sRotationX);
  _int_cosine_2 = stru_5C6E00->Cos(sRotationX);
}
// 4D864C: using guessed type char byte_4D864C;