class mrpt::viz::CFrustum
Overview
A solid or wireframe frustum in 3D (a rectangular truncated pyramid), with arbitrary (possibly assymetric) field-of-view angles.
You can switch whether to show only the lines, the surface of the frustum, or both. By default only the lines are drawn.
The color of the object (via CVisualObject::setColor()) affects the color of lines. To set the color of planes use setPlaneColor()
As usual in MRPT, the +X axis is assumed to by the main direction, in this case of the pyramid axis.
The horizontal and vertical FOVs can be set directly with setHorzFOV() and setVertFOV() if they are symmetric, or with setHorzFOVAsymmetric() and setVertFOVAsymmetric() otherwise.
All FOV angles are positive numbers. FOVs must be below 90deg on each side (below 180deg in total). If you try to set FOVs to larger values they’ll truncated to 89.9deg.
See also:
mrpt::viz::Scene, mrpt::viz::CRenderizable
#include <mrpt/viz/CFrustum.h> class CFrustum: public mrpt::viz::CVisualObject, public mrpt::viz::VisualObjectParams_Triangles, public mrpt::viz::VisualObjectParams_Lines { public: // typedefs typedef std::shared_ptr<mrpt::viz ::CFrustum> Ptr; typedef std::shared_ptr<const mrpt::viz ::CFrustum> ConstPtr; typedef std::unique_ptr<mrpt::viz ::CFrustum> UniquePtr; typedef std::unique_ptr<const mrpt::viz ::CFrustum> ConstUniquePtr; // fields static constexpr const char* className = "mrpt::viz" "::" "CFrustum"; // construction CFrustum(); CFrustum( float near_distance, float far_distance, float horz_FOV_degrees, float vert_FOV_degrees, float lineWidth, bool draw_lines, bool draw_planes ); CFrustum(const mrpt::img::TCamera& intrinsics, double focalDistScale = 5e-3); // 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 setPlaneColor(const mrpt::img::TColor& c); const mrpt::img::TColor& getPlaneColor() const; void setNearFarPlanes(const float near_distance, const float far_distance); float getNearPlaneDistance() const; float getFarPlaneDistance() const; void setHorzFOV(const float fov_horz_degrees); void setVertFOV(const float fov_vert_degrees); void setHorzFOVAsymmetric(const float fov_horz_left_degrees, const float fov_horz_right_degrees); void setVertFOVAsymmetric(const float fov_vert_down_degrees, const float fov_vert_up_degrees); float getHorzFOV() const; float getVertFOV() const; float getHorzFOVLeft() const; float getHorzFOVRight() const; float getVertFOVDown() const; float getVertFOVUp() const; virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) 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::shared_ptr<CSerializable> Ptr; typedef std::shared_ptr<const CSerializable> ConstPtr; typedef std::shared_ptr<CVisualObject> Ptr; typedef std::shared_ptr<const CVisualObject> ConstPtr; typedef std::unique_ptr<CObject> UniquePtr; typedef std::unique_ptr<const CObject> ConstUniquePtr; // structs struct PoseAndScale; struct State; // methods static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; const auto& shaderTrianglesBuffer() const; auto& shaderTrianglesBufferMutex() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); PoseAndScale getPoseAndScale() const; virtual CVisualObject& setColor_u8(const mrpt::img::TColor& c); bool isLightEnabled() const; void enableLight(bool enable = true); TCullFace cullFaces() const; void notifyBBoxChange() const; auto getBoundingBoxLocalf() const; const auto& shaderLinesVertexPointBuffer() const; const auto& shaderLinesVertexColorBuffer() const; auto& shaderLinesBufferMutex() const; void setLineWidth(float w); float getLineWidth() const; void enableAntiAliasing(bool enable = true); bool isAntiAliasingEnabled() const;
Typedefs
typedef std::shared_ptr<mrpt::viz ::CFrustum> Ptr
A type for the associated smart pointer.
Construction
CFrustum()
Basic empty constructor.
Set all parameters to default.
CFrustum( float near_distance, float far_distance, float horz_FOV_degrees, float vert_FOV_degrees, float lineWidth, bool draw_lines, bool draw_planes )
Constructor with some parameters
CFrustum(const mrpt::img::TCamera& intrinsics, double focalDistScale = 5e-3)
Constructor from camera intrinsic parameters: creates a frustrum with the correct vertical and horizontal FOV angles for the given camera model, in wireframe.
(New in MRPT 2.1.8)
Parameters:
intrinsics |
Camera intrinsics. Distortion is ignored here. |
focalDistScale |
Scale for the far plane, in meters/pixels. |
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 setPlaneColor(const mrpt::img::TColor& c)
Changes the color of the planes; to change color of lines, use CRenderizable base methods.
void setNearFarPlanes(const float near_distance, const float far_distance)
Changes distance of near & far planes.
void setHorzFOV(const float fov_horz_degrees)
Changes horizontal FOV (symmetric)
void setVertFOV(const float fov_vert_degrees)
Changes vertical FOV (symmetric)
void setHorzFOVAsymmetric( const float fov_horz_left_degrees, const float fov_horz_right_degrees )
Changes horizontal FOV (asymmetric)
void setVertFOVAsymmetric( const float fov_vert_down_degrees, const float fov_vert_up_degrees )
Changes vertical FOV (asymmetric)
virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const
Simulation of ray-trace, given a pose.
Returns true if the ray effectively collisions with the object (returning the distance to the origin of the ray in “dist”), or false in other case. “dist” variable yields undefined behaviour when false is returned
virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const
Must be implemented by derived classes to provide the updated bounding box in the object local frame of coordinates.
This will be called only once after each time the derived class reports to notifyChange() that the object geometry changed.
See also:
getBoundingBox(), getBoundingBoxLocal(), getBoundingBoxLocalf()