14 this->ProjectionType = ProjectionType;
15 InvalidateProjection();
19 this->FieldOfView = FieldOfView;
20 InvalidateProjection();
24 this->ProjectionDistance = ProjectionDistance;
25 InvalidateProjection();
29 this->FarClip = FarClip;
30 InvalidateProjection();
34 this->ViewportWidth = ViewportWidth;
35 InvalidateProjection();
39 this->ViewportHeight = ViewportHeight;
40 InvalidateProjection();
44 this->UpDirection = UpDirection;
50 this->LookDirection = Direction;
56 this->Position = Position;
57 LookDirection = (Focus - Position).Normalized();
64 LookDirection = (Focus - Position).Normalized();
71 this->Position = Position;
72 this->UpDirection = UpDirection;
74 LookDirection = (Focus - Position).Normalized();
85 MainFrameBuffer->SetFrameBufferProps(current_props);
89void scl::camera::InvalidateViewProjection()
91 ViewProjection = View * Projection;
94void scl::camera::InvalidateProjection()
96 float ratio_x = FieldOfView / 2, ratio_y = FieldOfView / 2;
98 if (ViewportWidth >= ViewportHeight) ratio_x *= (float)ViewportWidth / ViewportHeight;
99 else ratio_y *= (float)ViewportHeight / ViewportWidth;
100 ViewportProjectionWidth = ratio_x * 2;
101 ViewportProjectionHeight = ratio_y * 2;
104 Projection =
matr4::Ortho(-ratio_x, ratio_x, -ratio_y, ratio_y, ProjectionDistance, FarClip);
106 Projection =
matr4::Frustum(-ratio_x, ratio_x, -ratio_y, ratio_y, ProjectionDistance, FarClip);
107 InvalidateViewProjection();
110void scl::camera::InvalidateView()
113 InvalidateViewProjection();
116void scl::camera::InvalidateBuffers()
118 ResizeMainFrameBuffer();
120 ResizeHDRFrameBuffer();
121 ResizeBlurFrameBuffers();
124void scl::camera::ResizeMainFrameBuffer()
126 frame_buffer_props current_props = MainFrameBuffer->GetFrameBufferProps();
127 if (current_props.Width != ViewportWidth || current_props.Height != ViewportHeight)
129 current_props.Width = (int)ViewportWidth;
130 current_props.Height = (int)ViewportHeight;
131 MainFrameBuffer->SetFrameBufferProps(current_props);
135void scl::camera::ResizeGBuffer()
137 frame_buffer_props current_props = GBuffer->GetFrameBufferProps();
138 if (current_props.Width != ViewportWidth || current_props.Height != ViewportHeight)
140 current_props.Width = (int)ViewportWidth;
141 current_props.Height = (int)ViewportHeight;
142 GBuffer->SetFrameBufferProps(current_props);
146void scl::camera::ResizeHDRFrameBuffer()
148 frame_buffer_props current_props = HDRFrameBuffer->GetFrameBufferProps();
149 if (current_props.Width != ViewportWidth || current_props.Height != ViewportHeight)
151 current_props.Width = (int)ViewportWidth;
152 current_props.Height = (int)ViewportHeight;
153 HDRFrameBuffer->SetFrameBufferProps(current_props);
157void scl::camera::ResizeBlurFrameBuffers()
159 for (
int i = 0; i < 2; i++)
161 frame_buffer_props current_props = BlurFrameBuffers[i]->GetFrameBufferProps();
162 if (current_props.Width != ViewportWidth || current_props.Height != ViewportHeight)
164 current_props.Width = (int)ViewportWidth;
165 current_props.Height = (int)ViewportHeight;
166 BlurFrameBuffers[i]->SetFrameBufferProps(current_props);
172 ProjectionType(ProjectionType), Effects(Effects)
185 this->ViewportWidth = ViewportWidth;
186 this->ViewportHeight = ViewportHeight;
188 InvalidateProjection();
203 LookDirection = (Focus - Position).Normalized();
212 Position += MoveVector;
Renderer virtual camer class definiton module.
camera & Move(const vec3 &MoveVector)
void SetProjectionDistance(float ProjectionDistance)
void SetView(const vec3 &Position, const vec3 &Focus, const vec3 &UpDirection)
void SetProjectionType(camera_projection_type ProjectionType)
camera & Resize(int ViewportWidth, int ViewportHeight)
void SetFieldOfView(float FieldOfView)
void SetDirection(const vec3 &Direction)
camera(camera_projection_type ProjectionType, camera_effects Effects={})
void SetFarClip(float FarClip)
void SetViewportHeight(int ViewportHeight)
camera & Rotate(const vec3 &Axis, degrees Angle)
void SetPosition(const vec3 &Position)
void SetUpDirection(const vec3 &UpDirection)
void SetRenderToSwapChain(bool IsSwapChainTarget)
void SetViewportWidth(int ViewportWidth)
void SetFocus(const vec3 &Focus)
static shared< frame_buffer > Create(const frame_buffer_props &Props)
static matr4 Rotate(vec3< float > Axis, degrees< float > Angle)
static matr4 Frustum(float Left, float Right, float Bottom, float Top, float Near, float Far)
static matr4 View(vec3< float > Location, vec3< float > At, vec3< float > Up)
static matr4 Ortho(float Left, float Right, float Bottom, float Top, float Near, float Far)
vec3< T > TransformVector(const vec3< T > &V) const
vec3< T > TransformPoint(const vec3< T > &V) const
static matr4 Translate(const vec3< float > &Transform)
vec3 Cross(const vec3 &Other) const
Frame buffer interface implementation module.
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.