T3DObject


This template class has been removed in release 10.0.0. Use Vertex Array instead.

This template class represents generic 3D object. This template is different from the TMesh. Although the TMesh template is also represents a 3D object the differentce between them is significant. This template stores vertex positions, normals, and texture coordinates into separate arrays which means some of them may belong to several vertices and thus to several polygons. It is more efficient way of representing 3D geometry for editing purposes. If you are planning to create 3D editor application you would better use this template class instead of TMesh.

You can find more information in comments below.

template<class TYPE>
    class T3DObject
    {
    public:
        using Vec2 = math::TVec2<TYPE>; // 2D vector type 
        using Vec3 = math::TVec3<TYPE>; // 3D vector type 
        using Polygon = T3DPolygon<TYPE>; // Polygon type 
    public:
        T3DObject(); // Create empty object 
        T3DObject(const T3DObject &other); // Create copy of another 3D object 
        T3DObject(T3DObject &&other); // Create copy of another 3D object by moving its data 
        T3DObject(const size_t position_count, const size_t normal_count, const size_t coord_count, const size_t polygon_count); // Create object with specified count of positions, normals, texture coordinates, and polygons allocated 
        ~T3DObject(); // Destroy the object 
    
        T3DObject &operator=(const T3DObject &other);
        T3DObject &operator=(T3DObject &&other);
        const Polygon &operator[](const size_t index) const;
    
        size_t position_count() const; // Return position count 
        const Vec3 &position(const size_t index) const; // Return constant reference to specified position 
        Vec3 &position(const size_t index); // Return reference to specified position 
        void position(const size_t index, const Vec3 &value); // Update specified position value 
        Vec3 *positions(); // Return pointer to positions array 
        size_t normal_count() const; // Return normal count 
        const Vec3 &normal(const size_t index) const; // Return constant reference to specified normal 
        Vec3 &normal(const size_t index); // Return reference to specified normal 
        void normal(const size_t index, const Vec3 &value); // Update specified normal value 
        Vec3 *normals(); // Return pointer to normals array 
        size_t coord_count() const; // Return texture coordinate count 
        const Vec2 &coord(const size_t index) const; // Return constant reference to specified texture coordinate 
        Vec2 &coord(const size_t index); // Return reference to specified texture coordinate 
        void coord(const size_t index, const Vec2 &value); // Update value of specified texture coordinate 
        Vec2 *coords(); // Return pointer to texture coordinate array 
        size_t polygon_count() const; // Return polygon count 
        const Polygon &polygon(const size_t index) const; // Return constant reference to specified polygon 
        Polygon &polygon(const size_t index); // Return reference to specified polygon 
        void polygon(const size_t index, const Polygon &value); // Update specified polygon value 
        Polygon *polygons(); // Return pointer to polygon array 
        bool resize(const size_t position_count, const size_t normal_count, const size_t coord_count, const size_t polygon_count); // Set new count of positions, normals, texture coordinates, and polygons 
        void update_planes(); // Calculate main planes of all polygons 
        void relax_normals(); // Calculate average normals of all vertices 
    };
Namespace: nitisa::graphics3d
Include: Nitisa/Modules/Graphics3D/Core/3DObject.h