#include "CFTTShaderBuiltInConstants.h"
#include "CFTTMatrix32.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Matrix.h"
#include "FTTGraphics.h"

//003489AC
bool CFTTShaderBuiltInConstants::ms_bRecalcWorldMatrix3x3 = true;    //002014E6 = 1, 00201720 = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcWorldView = true;         //002014FC = 1, 002015A6 = 1, 00201808 = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcWorldViewProj = true;     //002014FE = 1, 002015A0 = 1, 00201614 = 1, 002017C4 = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcPosWorldViewProj = true;  //00201500 = 1, 002015A2 = 1, 00201616 = 1, 002016B0 = 1, 0020177C = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcPosWorld = true;          //00201502 = 1, 002016B2 = 1, 00201890 = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcWorldViewMatrixZ = true;  //00201506 = 1, 002015AA = 1, 00201A72 = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcWorldInvTrans = true;     //00201508 = 1, 002018DA = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcOrthoProj = true;         //0020150A = 1, 002015B2 = 1, 0020161A = 1, 002019F4 = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcViewProj = true;          //002015A4 = 1, 00201618 = 1, 0020184C = 0
bool CFTTShaderBuiltInConstants::ms_bRecalcInvView = true;           //002015AE = 1, 0020197C = 0

float CFTTShaderBuiltInConstants::ms_fFragCoordToUVMatrix[9];  //005A9E08

CFTTVector32 CFTTShaderBuiltInConstants::ms_vCamDir;              //005A9D50
CFTTVector32x4 CFTTShaderBuiltInConstants::ms_vViewport;          //005A9D5C
CFTTVector32x4 CFTTShaderBuiltInConstants::ms_vOrthoProjX;        //005A9D6C
CFTTVector32x4 CFTTShaderBuiltInConstants::ms_vOrthoProjY;        //005A9D7C
CFTTVector32x4 CFTTShaderBuiltInConstants::ms_vWorldViewMatrixZ;  //005A9D8C

CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matWorld;                      //005A9AC4
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matView;                       //005A9B04
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matProj;                       //005A9B44
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matPos = {1.0, 0.0, 0.0, 0.0,  //0034896C
                                                      0.0, 1.0, 0.0, 0.0,
                                                      0.0, 0.0, 1.0, 0.0,
                                                      0.0, 0.0, 0.0, 1.0};

const CFTTVector32x4 *CFTTShaderBuiltInConstants::ms_pBoneMats;   //005A9E2C
CFTTMatrix3x3 CFTTShaderBuiltInConstants::ms_fUVMatrix3x3[2];     //005A9DC0
CFTTMatrix3x3 CFTTShaderBuiltInConstants::ms_fWorldMatrix3x3;     //005A9D9C
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matPosWorldViewProj;  //005A9BC4
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matWorldViewProj;     //005A9B84
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matWorldView;         //005A9C44
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matViewProj;          //005A9C04
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matPosWorld;          //005A9C84
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matWorldInvTrans;     //005A9CC4
CFTTMatrix32 CFTTShaderBuiltInConstants::ms_matInvView;           //005A9D04
//-------------------------------------------------------------------------------------------------
//002014A8 经过单元测试，功能正常
void CFTTShaderBuiltInConstants::SetWorldMatrix(CFTTMatrix32 const &worldmatrix) {
  // LOGI("CFTTShaderBuiltInConstants::SetWorldMatrix entry");
}
//-------------------------------------------------------------------------------------------------
//00201540 经过单元测试，功能正常
void CFTTShaderBuiltInConstants::SetViewMatrix(CFTTMatrix32 const &viewmatrix) {
}
//-------------------------------------------------------------------------------------------------
//002015DC 经过单元测试，功能正常
void CFTTShaderBuiltInConstants::SetProjMatrix(CFTTMatrix32 const &projmatrix) {
}
//-------------------------------------------------------------------------------------------------
//00201634
void CFTTShaderBuiltInConstants::SetViewport(int width, int height) {
}
//-------------------------------------------------------------------------------------------------
//0020166C
void CFTTShaderBuiltInConstants::SetBoneMatrices(CFTTVector32x4 const *bonematrices) {
}
//-------------------------------------------------------------------------------------------------
//0020167C
void CFTTShaderBuiltInConstants::SetPosTransform(float const *postransform) {
}
//-------------------------------------------------------------------------------------------------
//002016C4
void CFTTShaderBuiltInConstants::SetUVTransform1(CFTTVector32x4 transform) {
}
//-------------------------------------------------------------------------------------------------
void CFTTShaderBuiltInConstants::SetUVTransform2(CFTTVector32x4 transform) {
}
//-------------------------------------------------------------------------------------------------
//002016FC
CFTTMatrix3x3 *CFTTShaderBuiltInConstants::GetWorldMatrix3x3() {
  return &CFTTShaderBuiltInConstants::ms_fWorldMatrix3x3;
}
//-------------------------------------------------------------------------------------------------
//00201754
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetPosWorldViewProjMatrix() {
  return &CFTTShaderBuiltInConstants::ms_matPosWorldViewProj;
}
//-------------------------------------------------------------------------------------------------
//0020179C
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetWorldViewProjMatrix() {
  return &CFTTShaderBuiltInConstants::ms_matWorldViewProj;
}
//-------------------------------------------------------------------------------------------------
//002017E4 经过单元测试，功能正常
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetWorldViewMatrix() {
  return &CFTTShaderBuiltInConstants::ms_matWorldView;
}
//-------------------------------------------------------------------------------------------------
//00201828
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetViewProjMatrix() {
  return &CFTTShaderBuiltInConstants::ms_matViewProj;
}
//-------------------------------------------------------------------------------------------------
//0020186C
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetPosWorldMatrix() {
  return &CFTTShaderBuiltInConstants::ms_matPosWorld;
}
//-------------------------------------------------------------------------------------------------
//002018B0
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetInvTransposeWorldMatrix() {
  return &CFTTShaderBuiltInConstants::ms_matWorldInvTrans;
}
//-------------------------------------------------------------------------------------------------
//00201950
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetInvViewMatrix() {
  return &CFTTShaderBuiltInConstants::ms_matInvView;
}
//-------------------------------------------------------------------------------------------------
float *CFTTShaderBuiltInConstants::GetCamPos() {
  CFTTMatrix32 *matInvView = GetInvViewMatrix();
  return (float *)(&(matInvView->d[3]));
}
//-------------------------------------------------------------------------------------------------
//002019AC
CFTTVector32x4 *CFTTShaderBuiltInConstants::GetOrthoProjectionX() {
  return &CFTTShaderBuiltInConstants::ms_vOrthoProjX;
}
//-------------------------------------------------------------------------------------------------
//002019D0
void CFTTShaderBuiltInConstants::RecalcOrthoProj() {
}
//-------------------------------------------------------------------------------------------------
//00201A24
CFTTVector32x4 *CFTTShaderBuiltInConstants::GetOrthoProjectionY() {
  return &CFTTShaderBuiltInConstants::ms_vOrthoProjY;
}
//-------------------------------------------------------------------------------------------------
//00201A48
CFTTVector32x4 *CFTTShaderBuiltInConstants::GetWorldViewMatrixZ() {
  return &CFTTShaderBuiltInConstants::ms_vWorldViewMatrixZ;
}
//-------------------------------------------------------------------------------------------------
//00201A90
float *CFTTShaderBuiltInConstants::GetFragCoordToUVMatrix() {
  return &CFTTShaderBuiltInConstants::ms_fFragCoordToUVMatrix[0];
}
//-------------------------------------------------------------------------------------------------
//00201B98
const CFTTVector32x4 *CFTTShaderBuiltInConstants::GetBoneMatrices() {
  return CFTTShaderBuiltInConstants::ms_pBoneMats;
}
//-------------------------------------------------------------------------------------------------
//00201BA8
CFTTMatrix32 *CFTTShaderBuiltInConstants::GetPosTransform() {
  return &CFTTShaderBuiltInConstants::ms_matPos;
}
//-------------------------------------------------------------------------------------------------
//00201BB4
CFTTMatrix3x3 *CFTTShaderBuiltInConstants::GetUVTransform1() {
  return &CFTTShaderBuiltInConstants::ms_fUVMatrix3x3[0];
}
//-------------------------------------------------------------------------------------------------
//00201BC0
CFTTMatrix3x3 *CFTTShaderBuiltInConstants::GetUVTransform2() {
  return &CFTTShaderBuiltInConstants::ms_fUVMatrix3x3[1];
}
//-------------------------------------------------------------------------------------------------