class mrpt::viz::CCamera

Python API: mrpt.viz.CCamera

Overview

Defines the intrinsic and extrinsic camera coordinates from which to render a 3D scene.

By default, each viewport has its own camera, accessible via Viewport::getCamera(), but if a CCamera object is added as an object to be rendered, it will override the internal viewport camera.

Available projection models:

Defining the position and orientation of a camera is possible by:

  • Using an “orbit” model: defined by a “pointing to” point, a distance to object, and azimuth + elevation angles; or

  • Directly giving the SE(3) camera pose, setting the set6DOFMode() to true and storing the desired pose with CVisualObject::setPose(). Pose axis convention is +Z pointing forwards, +X right, +Y down.

See also:

opengl::Scene

#include <mrpt/viz/CCamera.h>

class CCamera: public mrpt::viz::CVisualObject
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::viz ::CCamera> Ptr;
    typedef std::shared_ptr<const mrpt::viz ::CCamera> ConstPtr;
    typedef std::unique_ptr<mrpt::viz ::CCamera> UniquePtr;
    typedef std::unique_ptr<const mrpt::viz ::CCamera> ConstUniquePtr;

    // fields

    static constexpr const char* className = "mrpt::viz" "::" "CCamera";

    // construction

    CCamera();

    // methods

    static constexpr auto getClassName();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    static std::shared_ptr<CObject> CreateObject();

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename Alloc, typename... Args>
    static Ptr CreateAlloc(
        const Alloc& alloc,
        Args&&... args
        );

    template <typename... Args>
    static UniquePtr CreateUnique(Args&&... args);

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual mrpt::rtti::CObject* clone() const;
    void setProjectiveModel(bool v = true);
    void setOrthogonal(bool v = true);
    void setProjectiveFromPinhole(const mrpt::img::TCamera& camIntrinsics);
    void setNoProjection();
    void setProjectiveFOVdeg(float ang);
    float getProjectiveFOVdeg() const;
    bool hasPinholeModel() const;
    const std::optional<mrpt::img::TCamera>& getPinholeModel() const;
    bool isProjective() const;
    bool isOrthogonal() const;
    bool isNoProjection() const;

    void setPointingAt(
        float x,
        float y,
        float z
        );

    template <class POSEORPOINT>
    void setPointingAt(const POSEORPOINT& p);

    void setPointingAt(const mrpt::math::TPoint3D& p);
    float getPointingAtX() const;
    float getPointingAtY() const;
    float getPointingAtZ() const;
    mrpt::math::TPoint3Df getPointingAt() const;
    float getZoomDistance() const;
    float getAzimuthDegrees() const;
    float getElevationDegrees() const;
    float getRollDegrees() const;
    void setZoomDistance(float z);
    void setAzimuthDegrees(float ang);
    void setElevationDegrees(float ang);
    void setRollDegrees(float ang);
    void set6DOFMode(bool v);
    bool is6DOFMode() const;
    virtual void toYAMLMap(mrpt::containers::yaml& propertiesMap) const;
    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::unique_ptr<CObject> UniquePtr;
    typedef std::unique_ptr<const CObject> ConstUniquePtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;
    typedef std::shared_ptr<CVisualObject> Ptr;
    typedef std::shared_ptr<const CVisualObject> ConstPtr;

    // structs

    struct BuffersVersion;
    struct ChangeCounter;
    struct PoseAndScale;
    struct State;

    // methods

    mrpt::rtti::CObject::Ptr duplicateGetSmartPtr() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual CObject* clone() const = 0;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    void setName(const std::string& n);
    std::string getName() const;
    bool isVisible() const;
    void setVisibility(bool visible = true);
    bool castShadows() const;
    void castShadows(bool doCast);
    void enableShowName(bool showName = true);
    bool isShowNameEnabled() const;
    CVisualObject& setPose(const mrpt::poses::CPose3D& o);
    CVisualObject& setPose(const mrpt::poses::CPose2D& o);
    CVisualObject& setPose(const mrpt::math::TPose3D& o);
    CVisualObject& setPose(const mrpt::math::TPose2D& o);
    CVisualObject& setPose(const mrpt::poses::CPoint3D& o);
    CVisualObject& setPose(const mrpt::poses::CPoint2D& o);
    mrpt::math::TPose3D getPose() const;
    PoseAndScale getPoseAndScale() const;
    mrpt::poses::CPose3D getCPose() const;
    CVisualObject& setLocation(double x, double y, double z);
    CVisualObject& setLocation(const mrpt::math::TPoint3D& p);
    mrpt::img::TColorf getColor() const;
    mrpt::img::TColor getColor_u8() const;
    CVisualObject& setColorA(const float a);
    virtual CVisualObject& setColorA_u8(const uint8_t a);
    float materialShininess() const;
    void materialShininess(float shininess);
    float materialSpecularExponent() const;
    void materialSpecularExponent(float exponent);
    mrpt::img::TColorf materialEmissive() const;
    void materialEmissive(const mrpt::img::TColorf& color);
    CVisualObject& setScale(float s);
    CVisualObject& setScale(float sx, float sy, float sz);
    float getScaleX() const;
    float getScaleY() const;
    float getScaleZ() const;
    CVisualObject& setColor(const mrpt::img::TColorf& c);
    CVisualObject& setColor(float R, float G, float B, float A = 1);
    virtual CVisualObject& setColor_u8(const mrpt::img::TColor& c);
    CVisualObject& setColor_u8(uint8_t R, uint8_t G, uint8_t B, uint8_t A = 255);
    virtual bool cullElegible() const;
    virtual void toYAMLMap(mrpt::containers::yaml& propertiesMap) const;
    virtual bool isCompositeObject() const;
    virtual const std::deque<std::shared_ptr<CVisualObject>>& getInternalChildren() const;
    void notifyChange() const;
    void notifyTransformChange() const;
    void clearChangedFlag() const;
    void notifyBBoxChange() const;
    bool hasToUpdateBuffers() const;
    uint64_t dataVersion() const;
    uint64_t transformVersion() const;
    bool hasToUpdateBuffersSince(uint64_t sinceVersion) const;
    void updateBuffersIfNeeded() const;
    virtual void updateBuffers() const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    auto getBoundingBox() const;
    auto getBoundingBoxLocal() const;
    auto getBoundingBoxLocalf() const;
    virtual mrpt::math::TPoint3Df getLocalRepresentativePoint() const;
    void setLocalRepresentativePoint(const mrpt::math::TPoint3Df& p);
    mrpt::viz::CText& labelObject() const;
    std::shared_ptr<mrpt::viz::CText> labelObjectPtr() const;

Typedefs

typedef std::shared_ptr<mrpt::viz ::CCamera> Ptr

A type for the associated smart pointer.

Methods

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.

virtual mrpt::rtti::CObject* clone() const

Returns a deep copy (clone) of the object, indepently of its class.

void setProjectiveModel(bool v = true)

Enable/Disable projective mode (vs.

orthogonal).

void setOrthogonal(bool v = true)

Enable/Disable orthogonal mode (vs.

projective)

void setNoProjection()

Disable all coordinate transformations and allow direct use of pixel coordinates, that is, the projection matrix is the identity.

In this mode, (-1,-1) is the bottom-left corner and (+1,+1) the top-right corner, per OpenGL defaults. This mode can be disabled calling setProjectiveModel() or setOrthogonal()

void setProjectiveFOVdeg(float ang)

Vertical field-of-View in degs, only when projectiveModel=true (default=30 deg).

float getProjectiveFOVdeg() const

Field-of-View in degs, only when projectiveModel=true (default=30 deg).

void set6DOFMode(bool v)

Set 6DOFMode, if enabled camera is set according to its pose, set via CVisualObject::setPose().

(default=false). Conventionally, eye is set looking towards +Z axis, “down” is the +Y axis, right is “+X” axis. In this mode azimuth/elevation are ignored.

virtual void toYAMLMap(mrpt::containers::yaml& propertiesMap) const

Used from Scene::asYAML().

(New in MRPT 2.4.2)

virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const

In this class, returns a fixed box (max,max,max), (-max,-max,-max).