class hiro::draw::VisualCamera — HIRO 0.7.0 documentation

# class hiro::draw::VisualCamera

## Overview

A wrapper over view matrix, providing intuitive control. More…

    #include <VisualCamera.h>

    class VisualCamera {
    public:
        // typedefs

        typedef std::function<void(void)> CallbackOnChange;

        // construction

        VisualCamera();

        // methods

        void CopyView(const hiro::draw::VisualCamera& source_camera);
        const glm_ext::TransMat4& GetViewMatrix() const;
        glm::vec3 GetForward() const;
        glm::vec3 GetRight() const;
        glm::vec3 GetUp() const;
        void SetPosition(const glm::vec3& camera_position);
        void AlignUpVector(const glm::vec3& vector);
        void LookInDirection(const glm::vec3& new_forward);
        void LookAt(const glm::vec3& point_of_interest, const glm::vec3& up);
        void SetPositionAndLookAt(const glm::vec3& camera_position, const glm::vec3& point_of_interest, const glm::vec3& up);
        glm::vec3 GetPosition() const;
        void Rotate(const glm::quat& rot);
        void Dolly(const float distance);
        void Crab(const float distance);
        void Boom(const float distance);
        void Pan(const float angle);
        void Tilt(const float angle);
        void Roll(const float angle);
        void Move(const glm::vec3& move_vector);
        void ReadFromStream(std::istream& str);
        void WriteToStream(std::ostream& str);
        void SubscribeChange(const hiro::draw::VisualCamera::CallbackOnChange& listener);
        void Reset();

    protected:
        // fields

        glm::vec3 position_ = glm::vec3(0.0f);
        glm::vec3 basis_z_ = glm::vec3(0.0f, 0.0f, -1.0f);
        glm::vec3 basis_y_ = glm::vec3(0.0f, 1.0f, 0.0f);
        glm_ext::TransMat4 view_matrix_;
        std::vector<hiro::draw::VisualCamera::CallbackOnChange> listeners_;

        // methods

        void UpdateCameraSpace();
    };

## Detailed Documentation

A wrapper over view matrix, providing intuitive control.

Position - defines position of camera on CameraMode::MOVE_FREE and target point on other modes. Displacement - distance to camera position, non zero only when mode is not CameraMode::MOVE_FREE.

### Construction

    VisualCamera()

Creates orbiting camera looking from position (0,0,10), up vector directing positive Y axis.

### Methods

    void CopyView(const hiro::draw::VisualCamera& source_camera)

Sets up view to exactly match the one of specified camera.

    const glm_ext::TransMat4& GetViewMatrix() const

Returns current view matrix.

    glm::vec3 GetForward() const

Returns forward vector of camera orientation.

    glm::vec3 GetRight() const

Returns right vector of camera orientation.

    glm::vec3 GetUp() const

Returns up vector of camera orientation.

    void SetPosition(const glm::vec3& camera_position)

Set position of camera.

    void AlignUpVector(const glm::vec3& vector)

Sets up up vector to match specified.

    void LookInDirection(const glm::vec3& new_forward)

Sets up forward vector to match specified.

    void LookAt(const glm::vec3& point_of_interest, const glm::vec3& up)

Sets look direction of camera so that it looks from the actual position at defined point of interest.

    void SetPositionAndLookAt(const glm::vec3& camera_position, const glm::vec3& point_of_interest, const glm::vec3& up)

Set position of camera and sets look direction of camera so that it looks from the actual position at defined point of interest.

    glm::vec3 GetPosition() const

Returns actual position of camera.

    void Rotate(const glm::quat& rot)

Rotates camera by a specified quaternion.

    void Dolly(const float distance)

Moves forward.

    void Crab(const float distance)

Moves right.

    void Boom(const float distance)

Moves up.

    void Pan(const float angle)

Rotates towards left side.

    void Tilt(const float angle)

Rotates towards top side.

    void Roll(const float angle)

Rotates around its view direction, counter-clockwise.

    void Move(const glm::vec3& move_vector)

Moves camera position by a specified 3D vector.

    void ReadFromStream(std::istream& str)

Loads all state values from stream.

    void WriteToStream(std::ostream& str)

Saves all state values to stream.

    void SubscribeChange(const hiro::draw::VisualCamera::CallbackOnChange& listener)

Subscribes specified function to be called whenever camera changes.

    void Reset()

Resets all camera values to default.