sculpto
Public Member Functions | Public Attributes | List of all members
scl::camera Class Reference

#include <camera.h>

Public Member Functions

const matr4GetProjection () const
 
const matr4GetView () const
 
const matr4GetViewProjection () const
 
camera_projection_type GetProjectionType () const
 
float GetFieldOfView () const
 
float GetProjectionDistance () const
 
float GetFarClip () const
 
int GetViewportWidth () const
 
int GetViewportHeight () const
 
float GetViewportProjectionWidth () const
 
float GetViewportProjectionHeight () const
 
const vec3GetUpDirection () const
 
const vec3GetDirection () const
 
const vec3GetRightDirection () const
 
const vec3GetPosition () const
 
const vec3GetFocus () const
 
const shared< frame_buffer > & GetMainFrameBuffer () const
 
const shared< frame_buffer > & GetGBuffer () const
 
const shared< frame_buffer > & GetHDRFrameBuffer () const
 
const shared< frame_buffer > & GetBlurFrameBuffers (int Index=0) const
 
void SetProjectionType (camera_projection_type ProjectionType)
 
void SetFieldOfView (float FieldOfView)
 
void SetProjectionDistance (float ProjectionDistance)
 
void SetFarClip (float FarClip)
 
void SetViewportWidth (int ViewportWidth)
 
void SetViewportHeight (int ViewportHeight)
 
void SetUpDirection (const vec3 &UpDirection)
 
void SetDirection (const vec3 &Direction)
 
void SetPosition (const vec3 &Position)
 
void SetFocus (const vec3 &Focus)
 
void SetView (const vec3 &Position, const vec3 &Focus, const vec3 &UpDirection)
 
void SetRenderToSwapChain (bool IsSwapChainTarget)
 
 camera (camera_projection_type ProjectionType, camera_effects Effects={})
 
 ~camera ()
 
cameraResize (int ViewportWidth, int ViewportHeight)
 
cameraRotate (const vec3 &Axis, degrees Angle)
 
cameraMove (const vec3 &MoveVector)
 

Public Attributes

camera_effects Effects {}
 

Detailed Description

Renderer virtual camer class.

Definition at line 41 of file camera.h.

Constructor & Destructor Documentation

◆ camera()

scl::camera::camera ( camera_projection_type  ProjectionType,
camera_effects  Effects = {} 
)
  • Render camera controller default constructor.
Parameters
ProjectionType- render camera projection type.

Definition at line 171 of file camera.cpp.

171 :
172 ProjectionType(ProjectionType), Effects(Effects)
173{
174 MainFrameBuffer = frame_buffer::Create(frame_buffer_props { 16, 16, 1, false, 1, 0, true });
175 GBuffer = frame_buffer::Create(frame_buffer_props { 16, 16, 1, false, 6, 1, true });
176 HDRFrameBuffer = frame_buffer::Create(frame_buffer_props { 16, 16, 1, false, 2, 0, true });
177 for (int i = 0; i < 2; i++) BlurFrameBuffers[i] = frame_buffer::Create(frame_buffer_props { 16, 16, 1, false, 1, 0, true });
178
179 Resize(16, 16);
180 SetView({ 0, 3, 10 }, vec3 { 0 }, { 0, 1, 0 });
181}
void SetView(const vec3 &Position, const vec3 &Focus, const vec3 &UpDirection)
Definition: camera.cpp:69
camera & Resize(int ViewportWidth, int ViewportHeight)
Definition: camera.cpp:183
camera_effects Effects
Definition: camera.h:74
static shared< frame_buffer > Create(const frame_buffer_props &Props)
math::vec3< float > vec3
Definition: base.h:38

◆ ~camera()

scl::camera::~camera ( )
inline

Default camera destructor.

Definition at line 213 of file camera.h.

213{}

Member Function Documentation

◆ GetBlurFrameBuffers()

const shared< frame_buffer > & scl::camera::GetBlurFrameBuffers ( int  Index = 0) const
inline

Frame buffer for apllying gaussian blur effect getter function.

Definition at line 119 of file camera.h.

119{ return BlurFrameBuffers[Index]; }

◆ GetDirection()

const vec3 & scl::camera::GetDirection ( ) const
inline

Camera forward direction getter function.

Definition at line 104 of file camera.h.

104{ return LookDirection; }

◆ GetFarClip()

float scl::camera::GetFarClip ( ) const
inline

Distance to far clip plane getter function.

Definition at line 91 of file camera.h.

91{ return FarClip; };

◆ GetFieldOfView()

float scl::camera::GetFieldOfView ( ) const
inline

Field of view getter function.

Definition at line 87 of file camera.h.

87{ return FieldOfView; }

◆ GetFocus()

const vec3 & scl::camera::GetFocus ( ) const
inline

Camera focus point getter function.

Definition at line 110 of file camera.h.

110{ return Focus; }

◆ GetGBuffer()

const shared< frame_buffer > & scl::camera::GetGBuffer ( ) const
inline

Frame buffer for phong model geometry pass.

Definition at line 115 of file camera.h.

115{ return GBuffer; }

◆ GetHDRFrameBuffer()

const shared< frame_buffer > & scl::camera::GetHDRFrameBuffer ( ) const
inline

HDR Frame buffer, then tone mapped to destination frame buffer.

Definition at line 117 of file camera.h.

117{ return HDRFrameBuffer; }

◆ GetMainFrameBuffer()

const shared< frame_buffer > & scl::camera::GetMainFrameBuffer ( ) const
inline

Main renderer frame buffer.

Definition at line 113 of file camera.h.

113{ return MainFrameBuffer; }

◆ GetPosition()

const vec3 & scl::camera::GetPosition ( ) const
inline

Camera postion gertter function.

Definition at line 108 of file camera.h.

108{ return Position; }

◆ GetProjection()

const matr4 & scl::camera::GetProjection ( ) const
inline

Camer getter/setter functions.

Camera projection matrix getter function.

Definition at line 78 of file camera.h.

78{ return Projection; }

◆ GetProjectionDistance()

float scl::camera::GetProjectionDistance ( ) const
inline

Distance to near clip plane getter function.

Definition at line 89 of file camera.h.

89{ return ProjectionDistance; };

◆ GetProjectionType()

camera_projection_type scl::camera::GetProjectionType ( ) const
inline

Camera projection type getter function.

Definition at line 85 of file camera.h.

85{ return ProjectionType; }

◆ GetRightDirection()

const vec3 & scl::camera::GetRightDirection ( ) const
inline

Camera right direction getter function.

Definition at line 106 of file camera.h.

106{ return RightDirection; }

◆ GetUpDirection()

const vec3 & scl::camera::GetUpDirection ( ) const
inline

Camera up direction getter function.

Definition at line 102 of file camera.h.

102{ return UpDirection; }

◆ GetView()

const matr4 & scl::camera::GetView ( ) const
inline

Camera view matrix getter function.

Definition at line 80 of file camera.h.

80{ return View; }

◆ GetViewportHeight()

int scl::camera::GetViewportHeight ( ) const
inline

Projection plane height in pixels getter function.

Definition at line 95 of file camera.h.

95{ return ViewportHeight; };

◆ GetViewportProjectionHeight()

float scl::camera::GetViewportProjectionHeight ( ) const
inline

Viewport projection plane normalized height getter function.

Definition at line 99 of file camera.h.

99{ return ViewportProjectionHeight; }

◆ GetViewportProjectionWidth()

float scl::camera::GetViewportProjectionWidth ( ) const
inline

Viewport projection plane normalized width getter function.

Definition at line 97 of file camera.h.

97{ return ViewportProjectionWidth; }

◆ GetViewportWidth()

int scl::camera::GetViewportWidth ( ) const
inline

Projection plane width in pixels getter function.

Definition at line 93 of file camera.h.

93{ return ViewportWidth; };

◆ GetViewProjection()

const matr4 & scl::camera::GetViewProjection ( ) const
inline

Camera view projection matrix getter function.

Definition at line 82 of file camera.h.

82{ return ViewProjection; }

◆ Move()

scl::camera & scl::camera::Move ( const vec3 MoveVector)
  • Camera movement function.
Parameters
MoveVector- movement directions.
Returns
self reference.

Definition at line 210 of file camera.cpp.

211{
212 Position += MoveVector;
213 Focus += MoveVector;
214
215 InvalidateView();
216 return *this;
217}

◆ Resize()

scl::camera & scl::camera::Resize ( int  ViewportWidth,
int  ViewportHeight 
)
  • Set camera project pixel size function..
Parameters
ViewportWidth,ViewportHeight- new projection plane size in pixels.
Returns
- self reference.

Definition at line 183 of file camera.cpp.

184{
185 this->ViewportWidth = ViewportWidth;
186 this->ViewportHeight = ViewportHeight;
187
188 InvalidateProjection();
189 InvalidateBuffers();
190 return *this;
191}

◆ Rotate()

scl::camera & scl::camera::Rotate ( const vec3 Axis,
degrees  Angle 
)
  • Camera rotate function..
Parameters
Axis- rotation axis.
Angle- rotation angle (in degree).
Returns
self reference.

Definition at line 193 of file camera.cpp.

194{
195 matr4 transform =
196 matr4::Translate(-Position) *
197 matr4::Rotate(Axis, Angle) *
198 matr4::Translate(Position);
199
200 Focus = transform.TransformPoint(Focus);
201 Position = transform.TransformPoint(Position);
202 UpDirection = transform.TransformVector(UpDirection);
203 LookDirection = (Focus - Position).Normalized();
204 RightDirection = LookDirection.Cross(UpDirection).Normalized();
205
206 InvalidateView();
207 return *this;
208}
static matr4 Rotate(vec3< float > Axis, degrees< float > Angle)
Definition: matr4.h:288
static matr4 Translate(const vec3< float > &Transform)
Definition: matr4.h:257
vec3 Normalized() const
Definition: vec3.h:190
vec3 Cross(const vec3 &Other) const
Definition: vec3.h:224
math::matr4< float > matr4
Definition: base.h:48

◆ SetDirection()

void scl::camera::SetDirection ( const vec3 Direction)

Camera forward direction setter function.

Definition at line 49 of file camera.cpp.

49 {
50 this->LookDirection = Direction;
51 RightDirection = LookDirection.Cross(UpDirection).Normalized();
52 InvalidateView();
53}

◆ SetFarClip()

void scl::camera::SetFarClip ( float  FarClip)

Distance to far clip plane getter function.

Definition at line 28 of file camera.cpp.

28 {
29 this->FarClip = FarClip;
30 InvalidateProjection();
31}

◆ SetFieldOfView()

void scl::camera::SetFieldOfView ( float  FieldOfView)

Field of view getter function.

Definition at line 18 of file camera.cpp.

18 {
19 this->FieldOfView = FieldOfView;
20 InvalidateProjection();
21}

◆ SetFocus()

void scl::camera::SetFocus ( const vec3 Focus)

Camer focus point setter function.

Definition at line 62 of file camera.cpp.

62 {
63 this->Focus = Focus;
64 LookDirection = (Focus - Position).Normalized();
65 RightDirection = LookDirection.Cross(UpDirection).Normalized();
66 InvalidateView();
67}

◆ SetPosition()

void scl::camera::SetPosition ( const vec3 Position)

Camer position setter function.

Definition at line 55 of file camera.cpp.

55 {
56 this->Position = Position;
57 LookDirection = (Focus - Position).Normalized();
58 RightDirection = LookDirection.Cross(UpDirection).Normalized();
59 InvalidateView();
60}

◆ SetProjectionDistance()

void scl::camera::SetProjectionDistance ( float  ProjectionDistance)

Distance to near clip plane getter function.

Definition at line 23 of file camera.cpp.

23 {
24 this->ProjectionDistance = ProjectionDistance;
25 InvalidateProjection();
26}

◆ SetProjectionType()

void scl::camera::SetProjectionType ( camera_projection_type  ProjectionType)

Camera projection type setter function.

Definition at line 13 of file camera.cpp.

13 {
14 this->ProjectionType = ProjectionType;
15 InvalidateProjection();
16}

◆ SetRenderToSwapChain()

void scl::camera::SetRenderToSwapChain ( bool  IsSwapChainTarget)
  • Set flag, showing wheather camera main buffer is swap chain target or not.
Parameters
IsSwapChainTarget- flag, showing wheather camera main buffer is swap chain target or not
Returns
None.

Definition at line 79 of file camera.cpp.

80{
81 frame_buffer_props current_props = MainFrameBuffer->GetFrameBufferProps();
82 if (current_props.IsSwapChainTarget != IsSwapChainTarget)
83 {
84 current_props.IsSwapChainTarget = IsSwapChainTarget;
85 MainFrameBuffer->SetFrameBufferProps(current_props);
86 }
87}

◆ SetUpDirection()

void scl::camera::SetUpDirection ( const vec3 UpDirection)

Camera up direction setter function.

Definition at line 43 of file camera.cpp.

43 {
44 this->UpDirection = UpDirection;
45 RightDirection = LookDirection.Cross(UpDirection).Normalized();
46 InvalidateView();
47}

◆ SetView()

void scl::camera::SetView ( const vec3 Position,
const vec3 Focus,
const vec3 UpDirection 
)
  • Set view matrix by camera translation parametrs.
Parameters
Position- camera position.
Focus- camera focusing point.
UpDirection- camera up direction.

Definition at line 69 of file camera.cpp.

70{
71 this->Position = Position;
72 this->UpDirection = UpDirection;
73 this->Focus = Focus;
74 LookDirection = (Focus - Position).Normalized();
75 RightDirection = LookDirection.Cross(UpDirection).Normalized();
76 InvalidateView();
77}

◆ SetViewportHeight()

void scl::camera::SetViewportHeight ( int  ViewportHeight)

Projection plane height in pixels getter function.

Definition at line 38 of file camera.cpp.

38 {
39 this->ViewportHeight = ViewportHeight;
40 InvalidateProjection();
41}

◆ SetViewportWidth()

void scl::camera::SetViewportWidth ( int  ViewportWidth)

Projection plane width in pixels getter function.

Definition at line 33 of file camera.cpp.

33 {
34 this->ViewportWidth = ViewportWidth;
35 InvalidateProjection();
36}

Member Data Documentation

◆ Effects

camera_effects scl::camera::Effects {}

Frame buffer for apllying gaussian blur effect.

Camera rendering effects data.

Definition at line 74 of file camera.h.


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