class mrpt::viz::VisualObjectParams_TexturedTriangles

Overview

#include <mrpt/viz/CVisualObject.h>

class VisualObjectParams_TexturedTriangles: public mrpt::viz::CVisualObject
{
public:
    // construction

    VisualObjectParams_TexturedTriangles();

    // methods

    void assignDetailMap(const mrpt::img::CImage& img, const mrpt::math::TPoint2Df& uvScale);
    void assignDetailMap(mrpt::img::CImage&& img, const mrpt::math::TPoint2Df& uvScale);
    void assignDetailNormalMap(const mrpt::img::CImage& img);
    void assignDetailNormalMap(mrpt::img::CImage&& img);
    void setDetailMapUVScale(const mrpt::math::TPoint2Df& uvScale);
    mrpt::math::TPoint2Df detailMapUVScale() const;
    void clearDetailMaps();
    bool detailMapHasBeenAssigned() const;
    bool detailNormalMapHasBeenAssigned() const;
    const mrpt::img::CImage& getDetailMapImage() const;
    const mrpt::img::CImage& getDetailNormalMapImage() const;
    const auto& shaderTexturedTrianglesBuffer() const;
    auto& shaderTexturedTrianglesBufferMutex() const;
    void assignImage(const mrpt::img::CImage& img, const mrpt::img::CImage& imgAlpha);
    void assignImage(const mrpt::img::CImage& img);
    void assignImage(mrpt::img::CImage&& img, mrpt::img::CImage&& imgAlpha);
    void assignImage(mrpt::img::CImage&& img);
    bool isLightEnabled() const;
    void enableLight(bool enable = true);
    void cullFaces(const TCullFace& cf);
    TCullFace cullFaces() const;
    const mrpt::img::CImage& getTextureImage() const;
    const mrpt::img::CImage& getTextureAlphaImage() const;
    bool textureImageHasBeenAssigned() const;
    void setAlphaMode(TAlphaMode mode);
    TAlphaMode alphaMode() const;
    TAlphaMode effectiveAlphaMode() const;
    void setAlphaCutoff(float cutoff);
    float alphaCutoff() const;
    float effectiveAlphaCutoff() const;
    void assignNormalMap(const mrpt::img::CImage& img);
    void assignNormalMap(mrpt::img::CImage&& img);
    const mrpt::img::CImage& getNormalMapImage() const;
    bool normalMapHasBeenAssigned() const;
    void assignEmissiveMap(const mrpt::img::CImage& img);
    void assignEmissiveMap(mrpt::img::CImage&& img);
    const mrpt::img::CImage& getEmissiveMapImage() const;
    bool emissiveMapHasBeenAssigned() const;
    void enableTextureLinearInterpolation(bool enable);
    bool textureLinearInterpolation() const;
    void enableTextureMipMap(bool enable);
    bool textureMipMap() const;
};

// direct descendants

class CMesh;
class CSetOfTexturedTriangles;
class CTexturedPlane;

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;

Methods

void assignDetailMap(const mrpt::img::CImage& img, const mrpt::math::TPoint2Df& uvScale)

Assigns a detail color map and its tiling scale (see setDetailMapUVScale()).

The textured color is multiplied by twice the detail value:

color = texture(uv) * vertexColor * 2 * detail(uv * uvScale)

Detail pixel values are used as linear factors in [0,1] (they are not decoded as sRGB), so mid-gray is practically neutral (exactly 127.5; 128 brightens by 0.4%), and a detail map that averages 50% gray keeps the average brightness of the surface. Since the product is done in linear space, a given image adds less visible contrast than gamma-space “detail x2” shaders (e.g. Unity legacy ones): increase its contrast if needed. Detail maps are usually grayscale. They do not change alpha. Mipmaps and linear interpolation are always used for detail maps.

See also:

assignDetailNormalMap(), clearDetailMaps()

void assignDetailMap(mrpt::img::CImage&& img, const mrpt::math::TPoint2Df& uvScale)

Similar to assignDetailMap(), but with move semantics.

void assignDetailNormalMap(const mrpt::img::CImage& img)

Assigns a tangent-space detail normal map, in the same convention as assignNormalMap(), tiled with detailMapUVScale().

It can be used with or without a detail color map. It is combined with the main normal map, or with the geometric normal if there is none, by Reoriented Normal Mapping (RNM, Barre-Brisebois and Hill, 2012): the detail normal is rotated by the rotation that takes the unperturbed normal (0,0,1) to the main normal. Hence, a flat detail normal (128,128,255) keeps the main normal.

void assignDetailNormalMap(mrpt::img::CImage&& img)

Similar to assignDetailNormalMap(), but with move semantics.

void setDetailMapUVScale(const mrpt::math::TPoint2Df& uvScale)

Sets the tiling scale of the detail color and normal maps: they are sampled at the main texture coordinates times uvScale, so they repeat uvScale.x times per unit of the main texture coordinate u, and uvScale.y times per unit of v (both must be positive and finite).

For example, a terrain whose texture spans the whole mesh (as in CMesh by default) gets one detail tile every size / uvScale meters. Default: (1,1).

mrpt::math::TPoint2Df detailMapUVScale() const

The tiling scale of the detail maps.

See also:

setDetailMapUVScale()

void clearDetailMaps()

Removes the detail color and normal maps, and resets the detail scale to (1,1).

Objects without detail maps render exactly as if this feature did not exist.

void assignImage(const mrpt::img::CImage& img, const mrpt::img::CImage& imgAlpha)

Assigns a texture and a transparency image, and enables transparency (If the images are not 2^N x 2^M, they will be internally filled to its dimensions to be powers of two)

Images are copied, the original ones can be deleted.

It detects the alpha mode for TAlphaMode::Auto : after changing the alpha of the image in place, call it again (notifyChange() is not enough).

void assignImage(const mrpt::img::CImage& img)

Assigns a texture image, and disable transparency.

Images are copied, the original ones can be deleted.

void assignImage(mrpt::img::CImage&& img, mrpt::img::CImage&& imgAlpha)

Similar to assignImage, but the passed images are moved in (move semantic).

void assignImage(mrpt::img::CImage&& img)

Similar to assignImage, but with move semantics.

void cullFaces(const TCullFace& cf)

Control whether to render the FRONT, BACK, or BOTH (default) set of faces.

Refer to docs for glCullFace(). Example: If set to cullFaces(TCullFace::BACK);, back faces will not be drawn (“culled”)

void setAlphaMode(TAlphaMode mode)

Sets how the texture alpha channel is used (default: Auto).

See also:

setAlphaCutoff(), effectiveAlphaCutoff()

TAlphaMode effectiveAlphaMode() const

The texture alpha mode in use: alphaMode(), or the one detected from the texture for TAlphaMode::Auto (never Auto).

Translucent vertex colors may still make the object blended.

void setAlphaCutoff(float cutoff)

Alpha threshold for TAlphaMode::Mask (default: 0.5)

float effectiveAlphaCutoff() const

The alpha cutoff for the shaders: alphaCutoff() if the effective alpha mode is Mask (set explicitly, or detected by Auto), a negative value if Opaque was set explicitly (alpha is ignored), or 0 otherwise (blending).

Renderers also draw textures detected as Opaque by Auto (or no texture) as opaque objects if their vertex colors are opaque too, ignoring the texture alpha (see effectiveAlphaMode()).

void assignNormalMap(const mrpt::img::CImage& img)

Assigns a normal map image for tangent-space normal mapping.

The image should encode normals in tangent space as RGB where (128,128,255) represents the unperturbed surface normal. Normals follow the OpenGL convention (green points to the image top, as in Blender or glTF). For DirectX-style normal maps, invert the green channel first. Images are copied, the original ones can be deleted.

void assignNormalMap(mrpt::img::CImage&& img)

Similar to assignNormalMap, but with move semantics.

void assignEmissiveMap(const mrpt::img::CImage& img)

Assigns an emissive map: the light emitted by each surface point is materialEmissive() times this image (sRGB, like the diffuse texture), so only parts of the surface glow (e.g.

the bulb of a lamp). Images are copied, the original ones can be deleted.

void assignEmissiveMap(mrpt::img::CImage&& img)

Similar to assignEmissiveMap, but with move semantics.

void enableTextureLinearInterpolation(bool enable)

Enable linear interpolation of textures (default=false, use nearest pixel)