Cogs.Core
|
Component that calculates position and orientation of the entity TransformComponent. More...
#include <OrbitingCameraController.h>
Public Member Functions | |
void | initialize (Context *context) |
void | update () |
void | attachToView (ViewContext *viewContext) |
Attach to view - required for ray-picking. | |
void | setTarget (const glm::vec3 &target) |
Set target position - deprecated. Update "cameraTarget" field instead. | |
![]() | |
class Entity * | getContainer () 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 Component * | getComponent (const Reflection::Name &name) const |
COGSFOUNDATION_API Component * | getComponent (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::Type & | getType () 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 () |
![]() | |
static COGSCORE_DLL_API void | registerType () |
Register the type in the type system. | |
template<typename T > | |
static Reflection::Type & | registerDerivedType () |
Convenience method for registering the type of a derived 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 | |
glm::dvec3 | cameraTarget = glm::dvec3(0, 0, 0) |
Camera target. Define centre of camera rotation. | |
glm::vec3 | cameraLook = glm::vec3(0, 0, -1) |
camera looking direction. Updated when navigating the camers. | |
float | verticalAngle = glm::pi<float>() * 0.25f |
Current camera angle in vertical direction [-PI,+PI] (glm::pitch(transformComponent->rotation)) | |
float | horizontalAngle = 0 |
Current camera angle in horizontal direction [-TwoPI,+TwoPI] (glm::roll(transformComponent->rotation)) | |
float | distance = 20 |
Distance from camera target to camera. | |
float | minVerticalAngle = 0.0f |
Minimum camera angle in vertical direction [-PI,+PI]. | |
float | maxVerticalAngle = glm::pi<float>() |
Maximum camera angle in vertical direction [-PI,+PI]. | |
float | minDistance = 0.01f |
Minimal distance from camera position to camera target (zoom). | |
float | maxDistance = 50000.0f |
Maximal distance from camera position to camera target (zoom). | |
float | minFOV = glm::radians(1.f) |
Minimal field of view. | |
float | maxFOV = glm::radians(140.f) |
Maximal field of view. | |
bool | enabled = true |
Navigation is only active when this flag is set. | |
bool | seek = false |
Deprecated Seeking flag - not used. | |
bool | moveCamera = true |
Set to false to disable controller moving the camera and only apply rotate and zoom. Useful for viewing 360 images. | |
float | defaultPickingRadius = 4.0f |
Default distance an object can be from a ray to be considered hit. | |
![]() | |
void * | messageCallback = nullptr |
void * | userData = nullptr |
size_t | dynamicTypeInfoIndex = static_cast<size_t>(-1) |
Private Member Functions | |
void | handleSeek (int32_t x, int32_t y) |
void | handleRotate (int32_t x0, int32_t y0, int32_t x1, int32_t y1, bool first) |
void | handleTranslate (int32_t x0, int32_t y0, int32_t x1, int32_t y1, bool first) |
void | handleDolly (float delta, bool first) |
void | handleZoom (float delta, bool first) |
Private Attributes | |
Context * | context = nullptr |
ViewContext * | view = nullptr |
float | horizontalAngleStart = 0.f |
float | verticalAngleStart = 0.f |
float | distanceStart = 0.f |
float | fovStart = 0.f |
glm::dvec3 | cameraTargetStart |
bool | prevDragWithShift = false |
int32_t | dragStartCoordY = 0 |
Component that calculates position and orientation of the entity TransformComponent.
Normally added to a Camera entity to handle camera rotate and zoom. Will handle input events moving the (camera) transformation based on the input events (mouse & touch).
When using this controller, avoid changing TransformComponent fields as changed values will be replaced next time this component is modified. Insted calculate new rotations, distance and target field values of this component.
Definition at line 22 of file OrbitingCameraController.h.
Cogs::Core::OrbitingCameraController::OrbitingCameraController | ( | ) |
Definition at line 41 of file OrbitingCameraController.cpp.
|
inline |
Attach to view - required for ray-picking.
Definition at line 32 of file OrbitingCameraController.h.
|
private |
Definition at line 152 of file OrbitingCameraController.cpp.
|
private |
Definition at line 110 of file OrbitingCameraController.cpp.
|
private |
Definition at line 94 of file OrbitingCameraController.cpp.
|
private |
Definition at line 120 of file OrbitingCameraController.cpp.
|
private |
Definition at line 158 of file OrbitingCameraController.cpp.
void Cogs::Core::OrbitingCameraController::initialize | ( | Context * | context | ) |
Definition at line 78 of file OrbitingCameraController.cpp.
|
static |
Definition at line 46 of file OrbitingCameraController.cpp.
|
inline |
Set target position - deprecated. Update "cameraTarget" field instead.
Definition at line 35 of file OrbitingCameraController.h.
References cameraTarget, and Cogs::ComponentModel::Component::setChanged().
void Cogs::Core::OrbitingCameraController::update | ( | ) |
Definition at line 166 of file OrbitingCameraController.cpp.
glm::vec3 Cogs::Core::OrbitingCameraController::cameraLook = glm::vec3(0, 0, -1) |
camera looking direction. Updated when navigating the camers.
Definition at line 43 of file OrbitingCameraController.h.
glm::dvec3 Cogs::Core::OrbitingCameraController::cameraTarget = glm::dvec3(0, 0, 0) |
Camera target. Define centre of camera rotation.
Definition at line 40 of file OrbitingCameraController.h.
Referenced by setTarget().
|
private |
Definition at line 91 of file OrbitingCameraController.h.
|
private |
Definition at line 85 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::defaultPickingRadius = 4.0f |
Default distance an object can be from a ray to be considered hit.
Definition at line 82 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::distance = 20 |
Distance from camera target to camera.
Definition at line 52 of file OrbitingCameraController.h.
|
private |
Definition at line 89 of file OrbitingCameraController.h.
|
private |
Definition at line 94 of file OrbitingCameraController.h.
bool Cogs::Core::OrbitingCameraController::enabled = true |
Navigation is only active when this flag is set.
Definition at line 73 of file OrbitingCameraController.h.
|
private |
Definition at line 90 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::horizontalAngle = 0 |
Current camera angle in horizontal direction [-TwoPI,+TwoPI] (glm::roll(transformComponent->rotation))
Definition at line 49 of file OrbitingCameraController.h.
|
private |
Definition at line 87 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::maxDistance = 50000.0f |
Maximal distance from camera position to camera target (zoom).
Definition at line 64 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::maxFOV = glm::radians(140.f) |
Maximal field of view.
Definition at line 70 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::maxVerticalAngle = glm::pi<float>() |
Maximum camera angle in vertical direction [-PI,+PI].
Definition at line 58 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::minDistance = 0.01f |
Minimal distance from camera position to camera target (zoom).
Definition at line 61 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::minFOV = glm::radians(1.f) |
Minimal field of view.
Definition at line 67 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::minVerticalAngle = 0.0f |
Minimum camera angle in vertical direction [-PI,+PI].
Definition at line 55 of file OrbitingCameraController.h.
bool Cogs::Core::OrbitingCameraController::moveCamera = true |
Set to false to disable controller moving the camera and only apply rotate and zoom. Useful for viewing 360 images.
Definition at line 79 of file OrbitingCameraController.h.
|
private |
Definition at line 93 of file OrbitingCameraController.h.
bool Cogs::Core::OrbitingCameraController::seek = false |
Deprecated Seeking flag - not used.
Definition at line 76 of file OrbitingCameraController.h.
float Cogs::Core::OrbitingCameraController::verticalAngle = glm::pi<float>() * 0.25f |
Current camera angle in vertical direction [-PI,+PI] (glm::pitch(transformComponent->rotation))
Definition at line 46 of file OrbitingCameraController.h.
|
private |
Definition at line 88 of file OrbitingCameraController.h.
|
private |
Definition at line 86 of file OrbitingCameraController.h.