Cogs.Core
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Cogs::Core::CameraComponent Class Reference

Defines a camera. More...

#include <CameraComponent.h>

Inheritance diagram for Cogs::Core::CameraComponent:
Cogs::ComponentModel::Component

Public Member Functions

bool supportsPicking () const
 Check if the camera supports use for ray picking.
 
 CameraComponent ()=default
 Constructs a camera with defaults set.
 
- Public Member Functions inherited from Cogs::ComponentModel::Component
class EntitygetContainer () const
 Get the container currently owning this component instance.
 
void setContainer (class Entity *container)
 Set the container owning this component instance.
 
template<typename ComponentType >
ComponentType * getComponent () const
 
COGSFOUNDATION_API ComponentgetComponent (const Reflection::Name &name) const
 
COGSFOUNDATION_API ComponentgetComponent (const Reflection::TypeId &id) const
 
template<typename ComponentType >
ComponentHandle getComponentHandle () const
 
COGSFOUNDATION_API ComponentHandle getComponentHandle (const Reflection::Name &name) const
 
COGSFOUNDATION_API ComponentHandle getComponentHandle (const Reflection::TypeId &id) const
 
void setActive ()
 Sets the component to the ComponentFlags::Active state.
 
bool isActive () const
 Gets if the component is currently set to the ComponentFlags::Active state.
 
void setChanged ()
 Sets the component to the ComponentFlags::Changed state with carry.
 
void setChangedTransient ()
 Sets the component to the ComponentFlags::Changed state without carry.
 
void setFieldChanged (const Reflection::FieldId fieldId)
 Sets the component to the ComponentFlags::Changed state without carry.
 
template<typename ClassType , typename FieldType >
void setFieldChanged (FieldType ClassType::*field)
 Sets a flag indicating that the given field has changed.
 
void setFieldChangedTransient (const Reflection::FieldId fieldId)
 Sets the component to the ComponentFlags::Changed state without carry.
 
bool hasChanged () const
 
bool hasAnyfieldChanged () const
 Gets if any fields have been changed.
 
bool hasFieldChanged (const Reflection::FieldId fieldId) const
 Gets if the field with the given id on this component instance has changed.
 
template<typename ClassType , typename FieldType >
bool hasFieldChanged (FieldType ClassType::*field) const
 Gets if the given field has changed.
 
void resetCarryChanged ()
 Reset the CarryChanged flag. Called at start of redraw. See ComponentFlags::CarryChanged.
 
void resetChanged ()
 Resets the changed state of the component, respecting any carry state set.
 
template<typename ClassType , typename FieldType >
Reflection::FieldId getFieldId (FieldType ClassType::*field) const
 Gets field ID of the given field.
 
void resetFieldsChanged ()
 Resets the state of all changed field flags.
 
void resetFieldChanged (const Reflection::FieldId fieldId)
 Resets the changed state of the given fieldId.
 
template<typename ClassType , typename FieldType >
void resetFieldChanged (FieldType ClassType::*field)
 Resets the changed state of the given field.
 
constexpr void setFlags (const uint32_t flags)
 Override all flags of the Component, setting the given flags.
 
constexpr void setFlag (const uint32_t flag)
 Set the given flags. Does not override the currently set flags.
 
constexpr void unsetFlag (const uint32_t flag)
 Unset the given flag. Does not remove the status of other than the given flags.
 
constexpr bool isSet (const uint32_t flag) const
 Checks if the given flag is set. Requires exact bit match if test of several bits.
 
constexpr void setTypeId (const Reflection::TypeId typeId)
 Set the Reflection::TypeId of the component.
 
constexpr Reflection::TypeId getTypeId () const
 Get the Reflection::TypeId of the component.
 
COGSFOUNDATION_API const Reflection::TypegetType () const
 Get the full Reflection::Type of the component.
 
constexpr void setIndex (const ComponentIndex index)
 Set the components pool index. For internal use only.
 
constexpr ComponentIndex getIndex () const
 Get the components pool index. For internal use only.
 
constexpr void setGeneration (uint16_t generation)
 Sets the component generation.
 
constexpr uint16_t getGeneration () const
 Gets the component generation.
 
size_t hash (size_t hashValue=Cogs::hash()) const
 Calculates a hash of this component's members.
 

Static Public Member Functions

static void registerType ()
 Register the type in the type system.
 
- Static Public Member Functions inherited from Cogs::ComponentModel::Component
static COGSFOUNDATION_API void registerType ()
 Register the Component type in the global type database.
 
static COGSFOUNDATION_API Reflection::TypeId getComponentTypeId (const StringView &name)
 Get the type id of the component type with the given name.
 

Public Attributes

RenderLayers layerMask = RenderLayers::AllStandard
 Layer mask used to determine which RenderComponent instances should be visible in this cameras viewport.
 
LightingLayers lightingMask = LightingLayers::All
 Lighting mask used to determine which lights are active for the current viewport.
 
int32_t stackOrder = 0
 Specifies the ordering of cameras when rendering to the same render target, lower numbers render before higher numberrs.
 
float focalDistance = 1.0f
 Focal distance of the camera, given in scene units.
 
float fieldOfView = glm::pi<float>() / 4.0f
 Vertical field of view, given in radians.
 
float orthoHeight = 100.0f
 Height of the viewport in scene units when using orthographic projection.
 
float discardThreshold = 0.f
 Discard objects occupying less pixels than threshold.
 
float keepThreshold = 1.0f
 
glm::vec2 viewportOrigin = glm::vec2(0, 0)
 Origin of the viewport covered by this instance, given in screen units from the lower left.
 
glm::vec2 viewportSize = glm::vec2(100, 100)
 Size of the viewport covered by this instance, given in pixels.
 
glm::vec2 subsetMin = glm::vec2(0.f, 0.f)
 Subset of the frustum to view (for only rendering a subset of the view covered by the viewport), range [0,1].
 
glm::vec2 subsetMax = glm::vec2(1.f, 1.f)
 Subset of the frustum to view (for only rendering a subset of the view covered by the viewport), range [0,1].
 
glm::vec4 clearColor = glm::vec4(0.0f)
 Use the following colour to clear the render target before rendering.
 
float nearDistance = 1.0f
 
float farDistance = 1000.0f
 
float nearPlaneLimit = 1.0f
 Smallest value allowed to adjust near plane to.
 
float farPlaneLimit = 10000000.0f
 Largest value allowed to adjust far plane to.
 
float exposure = 1.f
 Exposure factor for HDR rendering.
 
bool enableClippingPlaneAdjustment = true
 If automatic adjustment of the clipping planes should be performed to fit as much of the scene as possible.
 
ProjectionMode projectionMode = ProjectionMode::Perspective
 The projection mode to use for the camera.
 
TextureHandle renderTexture = TextureHandle::NoHandle
 The render texture to output the rendered scene from the camera to.
 
TextureHandle resolveTarget = TextureHandle::NoHandle
 The texture to which the rendered output will be resolved. (Needs an offscreen renderTexture for this to function.)
 
std::string renderPipeline
 Render pipeline to apply when rendering to texture. Defaults to the built-in forward rendering pipeline.
 
std::vector< std::string > renderPipelineOptions
 Extra options passed when creating the render pipeline,.
 
EntityPtr environment
 Environment to use for rendering.
 
CameraFlags flags = CameraFlags::EnableRender | CameraFlags::EnablePicking
 Camera behavior flags.
 
uint32_t clientFlags = 0
 Application defined, camera specific flags passed to shaders.
 

Detailed Description

Defines a camera.

Cameras are used by the renderer to perform culling and rendering of the scene.

Definition at line 42 of file CameraComponent.h.

Member Function Documentation

◆ registerType()

void Cogs::Core::CameraComponent::registerType ( )
static

◆ supportsPicking()

bool Cogs::Core::CameraComponent::supportsPicking ( ) const
inline

Check if the camera supports use for ray picking.

Definition at line 49 of file CameraComponent.h.

References Cogs::Core::EnablePicking, and flags.

Member Data Documentation

◆ clearColor

glm::vec4 Cogs::Core::CameraComponent::clearColor = glm::vec4(0.0f)

Use the following colour to clear the render target before rendering.

Set CameraFlags::OverrideClearColor to use.

Definition at line 121 of file CameraComponent.h.

◆ clientFlags

uint32_t Cogs::Core::CameraComponent::clientFlags = 0

Application defined, camera specific flags passed to shaders.

Definition at line 165 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateProjection().

◆ discardThreshold

float Cogs::Core::CameraComponent::discardThreshold = 0.f

Discard objects occupying less pixels than threshold.

Set to zero to disable.

Definition at line 97 of file CameraComponent.h.

Referenced by registerType().

◆ enableClippingPlaneAdjustment

bool Cogs::Core::CameraComponent::enableClippingPlaneAdjustment = true

If automatic adjustment of the clipping planes should be performed to fit as much of the scene as possible.

Definition at line 141 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateClippingPlanes().

◆ environment

EntityPtr Cogs::Core::CameraComponent::environment

Environment to use for rendering.

Definition at line 159 of file CameraComponent.h.

Referenced by registerType().

◆ exposure

float Cogs::Core::CameraComponent::exposure = 1.f

Exposure factor for HDR rendering.

Definition at line 138 of file CameraComponent.h.

Referenced by registerType().

◆ farDistance

float Cogs::Core::CameraComponent::farDistance = 1000.0f

Distance to the far plane, given in scene units. Only used if enableClippingPlaneAdjustment is false.

Definition at line 129 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateClippingPlanes().

◆ farPlaneLimit

float Cogs::Core::CameraComponent::farPlaneLimit = 10000000.0f

Largest value allowed to adjust far plane to.

Definition at line 135 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateClippingPlanes().

◆ fieldOfView

float Cogs::Core::CameraComponent::fieldOfView = glm::pi<float>() / 4.0f

Vertical field of view, given in radians.

Definition at line 86 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateProjection().

◆ flags

CameraFlags Cogs::Core::CameraComponent::flags = CameraFlags::EnableRender | CameraFlags::EnablePicking

◆ focalDistance

float Cogs::Core::CameraComponent::focalDistance = 1.0f

Focal distance of the camera, given in scene units.

Definition at line 81 of file CameraComponent.h.

Referenced by registerType().

◆ keepThreshold

float Cogs::Core::CameraComponent::keepThreshold = 1.0f

Definition at line 102 of file CameraComponent.h.

◆ layerMask

RenderLayers Cogs::Core::CameraComponent::layerMask = RenderLayers::AllStandard

Layer mask used to determine which RenderComponent instances should be visible in this cameras viewport.

The layer mask is combined with the layer of the component, and combined with the component visibility to determine if any rendering should take place.

Definition at line 63 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateClippingPlanes().

◆ lightingMask

LightingLayers Cogs::Core::CameraComponent::lightingMask = LightingLayers::All

Lighting mask used to determine which lights are active for the current viewport.

The layer mask is combined with the lighting layer of any light components, and of any rendering tasks lighting layer mask.

Definition at line 71 of file CameraComponent.h.

Referenced by registerType().

◆ nearDistance

float Cogs::Core::CameraComponent::nearDistance = 1.0f

Distance to the near plane, given in scene units. Only used if enableClippingPlaneAdjustment is false.

Definition at line 125 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateClippingPlanes().

◆ nearPlaneLimit

float Cogs::Core::CameraComponent::nearPlaneLimit = 1.0f

Smallest value allowed to adjust near plane to.

Definition at line 132 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateClippingPlanes().

◆ orthoHeight

float Cogs::Core::CameraComponent::orthoHeight = 100.0f

Height of the viewport in scene units when using orthographic projection.

The width of the projection is determined by the aspect ratio given by viewportSize.

Definition at line 92 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateProjection().

◆ projectionMode

ProjectionMode Cogs::Core::CameraComponent::projectionMode = ProjectionMode::Perspective

The projection mode to use for the camera.

Definition at line 144 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateProjection().

◆ renderPipeline

std::string Cogs::Core::CameraComponent::renderPipeline

Render pipeline to apply when rendering to texture. Defaults to the built-in forward rendering pipeline.

Definition at line 153 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraArraySystem::update().

◆ renderPipelineOptions

std::vector<std::string> Cogs::Core::CameraComponent::renderPipelineOptions

Extra options passed when creating the render pipeline,.

See also
Cogs::Core::PipelineOptions.

Definition at line 156 of file CameraComponent.h.

Referenced by registerType().

◆ renderTexture

TextureHandle Cogs::Core::CameraComponent::renderTexture = TextureHandle::NoHandle

The render texture to output the rendered scene from the camera to.

Definition at line 147 of file CameraComponent.h.

Referenced by Cogs::Core::VideoCaptureSystem::preUpdate(), registerType(), and Cogs::Core::ViewContext::setCamera().

◆ resolveTarget

TextureHandle Cogs::Core::CameraComponent::resolveTarget = TextureHandle::NoHandle

The texture to which the rendered output will be resolved. (Needs an offscreen renderTexture for this to function.)

Definition at line 150 of file CameraComponent.h.

Referenced by Cogs::Core::VideoCaptureSystem::preUpdate().

◆ stackOrder

int32_t Cogs::Core::CameraComponent::stackOrder = 0

Specifies the ordering of cameras when rendering to the same render target, lower numbers render before higher numberrs.

Definition at line 76 of file CameraComponent.h.

Referenced by registerType().

◆ subsetMax

glm::vec2 Cogs::Core::CameraComponent::subsetMax = glm::vec2(1.f, 1.f)

Subset of the frustum to view (for only rendering a subset of the view covered by the viewport), range [0,1].

Definition at line 118 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateProjection().

◆ subsetMin

glm::vec2 Cogs::Core::CameraComponent::subsetMin = glm::vec2(0.f, 0.f)

Subset of the frustum to view (for only rendering a subset of the view covered by the viewport), range [0,1].

Definition at line 115 of file CameraComponent.h.

Referenced by registerType(), and Cogs::Core::CameraSystem::updateProjection().

◆ viewportOrigin

glm::vec2 Cogs::Core::CameraComponent::viewportOrigin = glm::vec2(0, 0)

Origin of the viewport covered by this instance, given in screen units from the lower left.

Definition at line 107 of file CameraComponent.h.

Referenced by registerType().

◆ viewportSize

glm::vec2 Cogs::Core::CameraComponent::viewportSize = glm::vec2(100, 100)

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