OpenBarnyard
 
Loading...
Searching...
No Matches
TCameraObject Class Reference

#include <TCameraObject.h>

Public Member Functions

 TCameraObject ()
 
 ~TCameraObject ()
 
void Render ()
 
TFLOAT SetNear (TFLOAT fNear)
 
TFLOAT SetFar (TFLOAT fFar)
 
TFLOAT SetFOV (TFLOAT fFOV)
 
TFLOAT SetProjectionCentreX (TFLOAT fCentreX)
 
TFLOAT SetProjectionCentreY (TFLOAT fCentreY)
 
TFLOAT GetNear () const
 
TFLOAT GetFar () const
 
TFLOAT GetFOV () const
 
TRenderContext::CameraMode GetMode () const
 
void SetMode (TRenderContext::CameraMode a_eMode)
 
TBOOL IsEnabled () const
 
TTransformObjectGetTransformObject ()
 

Static Public Attributes

static constexpr TFLOAT s_kMinFOV = ( 1.0f / 180.0f ) * TMath::PI
 
static constexpr TFLOAT s_kMaxFOV = TMath::PI
 

Detailed Description

Definition at line 7 of file TCameraObject.h.

Constructor & Destructor Documentation

◆ TCameraObject()

TCameraObject::TCameraObject ( )

Definition at line 13 of file TCameraObject.cpp.

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}
#define TTRUE
Definition Typedefs.h:25
TFORCEINLINE constexpr TFLOAT DegToRad(TFLOAT fDeg)
Definition TMathInline.h:64

◆ ~TCameraObject()

TCameraObject::~TCameraObject ( )

Definition at line 25 of file TCameraObject.cpp.

26{
27}

Member Function Documentation

◆ GetFar()

TFLOAT TCameraObject::GetFar ( ) const
inline

Definition at line 57 of file TCameraObject.h.

58 {
59 return m_fFar;
60 }

◆ GetFOV()

TFLOAT TCameraObject::GetFOV ( ) const
inline

Definition at line 62 of file TCameraObject.h.

63 {
64 return m_fFOV;
65 }

◆ GetMode()

TRenderContext::CameraMode TCameraObject::GetMode ( ) const
inline

Definition at line 67 of file TCameraObject.h.

68 {
69 return m_eMode;
70 }

◆ GetNear()

TFLOAT TCameraObject::GetNear ( ) const
inline

Definition at line 52 of file TCameraObject.h.

53 {
54 return m_fNear;
55 }

◆ GetTransformObject()

TTransformObject & TCameraObject::GetTransformObject ( )
inline

Definition at line 82 of file TCameraObject.h.

83 {
84 return m_TransformObject;
85 }

◆ IsEnabled()

TBOOL TCameraObject::IsEnabled ( ) const
inline

Definition at line 77 of file TCameraObject.h.

78 {
79 return m_bEnabled;
80 }

◆ Render()

void TCameraObject::Render ( )

Definition at line 30 of file TCameraObject.cpp.

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}
void InvertOrthogonal()
TFLOAT y
Definition TVector2.h:139
TFLOAT x
Definition TVector2.h:139
static TFORCEINLINE TRenderInterface * GetSingleton()
Definition TSingleton.h:49

◆ SetFar()

TFLOAT TCameraObject::SetFar ( TFLOAT fFar)
inline

Definition at line 26 of file TCameraObject.h.

27 {
28 return std::exchange( m_fFar, fFar );
29 }

◆ SetFOV()

TFLOAT TCameraObject::SetFOV ( TFLOAT fFOV)
inline

Definition at line 32 of file TCameraObject.h.

33 {
35 return std::exchange( m_fFOV, fFOV );
36 }
TFORCEINLINE void Clip(T &rVal, const T &Min, const T &Max)
static constexpr TFLOAT s_kMinFOV
static constexpr TFLOAT s_kMaxFOV

◆ SetMode()

void TCameraObject::SetMode ( TRenderContext::CameraMode a_eMode)
inline

Definition at line 72 of file TCameraObject.h.

73 {
74 m_eMode = a_eMode;
75 }

◆ SetNear()

TFLOAT TCameraObject::SetNear ( TFLOAT fNear)
inline

Definition at line 20 of file TCameraObject.h.

21 {
22 return std::exchange( m_fNear, fNear );
23 }

◆ SetProjectionCentreX()

TFLOAT TCameraObject::SetProjectionCentreX ( TFLOAT fCentreX)
inline

Definition at line 39 of file TCameraObject.h.

40 {
41 TMath::Clip( fCentreX, 0.0f, 1.0f );
42 return std::exchange( m_fCentreX, fCentreX );
43 }

◆ SetProjectionCentreY()

TFLOAT TCameraObject::SetProjectionCentreY ( TFLOAT fCentreY)
inline

Definition at line 46 of file TCameraObject.h.

47 {
48 TMath::Clip( fCentreY, 0.0f, 1.0f );
49 return std::exchange( m_fCentreY, fCentreY );
50 }

Member Data Documentation

◆ s_kMaxFOV

TFLOAT TCameraObject::s_kMaxFOV = TMath::PI
inlinestaticconstexpr

Definition at line 11 of file TCameraObject.h.

◆ s_kMinFOV

TFLOAT TCameraObject::s_kMinFOV = ( 1.0f / 180.0f ) * TMath::PI
inlinestaticconstexpr

Definition at line 10 of file TCameraObject.h.


The documentation for this class was generated from the following files: