OpenBarnyard
 
Loading...
Searching...
No Matches
TCameraObject.cpp
Go to the documentation of this file.
1#include "ToshiPCH.h"
2#include "TCameraObject.h"
3
4//-----------------------------------------------------------------------------
5// Enables memory debugging.
6// Note: Should be the last include!
7//-----------------------------------------------------------------------------
9
11
12// $Barnyard: FUNCTION 006cd030
14{
15 m_Unk1 = 0;
17 m_fNear = 1.0f;
18 m_fFar = 100.0f;
19 m_fFOV = TMath::DegToRad( 90.0f );
20 m_fCentreX = 0.5f;
21 m_fCentreY = 0.5f;
22 m_bEnabled = TTRUE;
23}
24
28
29// $Barnyard: FUNCTION 006cd0d0
31{
32 if ( m_bEnabled )
33 {
34 auto pRender = TRenderInterface::GetSingleton();
35 auto pRenderContext = pRender->GetCurrentContext();
36
37 TRenderContext::PROJECTIONPARAMS projParams = pRenderContext->GetProjectionParams();
38 projParams.m_Centre = { m_fCentreX * pRenderContext->GetWidth(), m_fCentreY * pRenderContext->GetHeight() };
39
40 auto render = TRenderInterface::GetSingleton();
41
42 if ( m_Unk1 == 0 )
43 {
44 projParams.m_Proj.x = ( pRenderContext->GetWidth() * 0.5f ) / tan( m_fFOV * 0.5f );
45 projParams.m_Proj.y = projParams.m_Proj.x;
46
48 {
49 projParams.m_Proj.y *= render->GetPixelAspectRatio();
50 }
51 }
52 else
53 {
54 projParams.m_Proj.y = ( pRenderContext->GetHeight() * 0.5f ) / tan( m_fFOV * 0.5f );
55 projParams.m_Proj.x = projParams.m_Proj.y;
56
58 {
59 projParams.m_Proj.x /= render->GetPixelAspectRatio();
60 }
61 }
62
63 projParams.m_fNearClip = m_fNear;
64 projParams.m_fFarClip = m_fFar;
65
66 pRenderContext->SetProjectionParams( projParams );
67
69 pRenderContext->SetCameraMode( m_eMode );
70
71 TMatrix44 matrix;
72 m_TransformObject.GetLocalMatrixImp( matrix );
73 matrix.InvertOrthogonal();
74
75 pRenderContext->SetWorldViewMatrix( matrix );
76 pRenderContext->SetModelViewMatrix( matrix );
77 pRenderContext->Update();
78 }
79}
80
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
#define TTRUE
Definition Typedefs.h:25
TFORCEINLINE constexpr TFLOAT DegToRad(TFLOAT fDeg)
Definition TMathInline.h:64
void InvertOrthogonal()
TFLOAT y
Definition TVector2.h:139
TFLOAT x
Definition TVector2.h:139
static TFORCEINLINE TRenderInterface * GetSingleton()
Definition TSingleton.h:49