Click here to Skip to main content
15,886,199 members
Articles / Multimedia / OpenGL

Modified version of lib3ds reader of .3ds format

Rate me:
Please Sign up or sign in to vote.
4.78/5 (15 votes)
4 Oct 2012CPOL3 min read 42.6K   2.9K   23  
In this article I present version of lib3ds reader for C++ language
#ifndef LIB3DS_MESH_TYPE_H
#define LIB3DS_MESH_TYPE_H

#include <QString>
#include <QVector3D>
#include <QVector2D>
#include <QVector>


/* Texture map projection */
typedef enum {
  LIB3DS_MAP_NONE           = -1,
  LIB3DS_MAP_PLANAR         = 0,
  LIB3DS_MAP_CYLINDRICAL    = 1,
  LIB3DS_MAP_SPHERICAL      = 2
} Lib3dsMapType;

/** Object flags for cameras, lights and meshes */
typedef enum Lib3dsObjectFlags {
    LIB3DS_OBJECT_HIDDEN          = 0x01,
    LIB3DS_OBJECT_VIS_LOFTER      = 0x02,
    LIB3DS_OBJECT_DOESNT_CAST     = 0x04,
    LIB3DS_OBJECT_MATTE           = 0x08,
    LIB3DS_OBJECT_DONT_RCVSHADOW  = 0x10,
    LIB3DS_OBJECT_FAST            = 0x20,
    LIB3DS_OBJECT_FROZEN          = 0x40
} Lib3dsObjectFlags;

typedef struct Lib3dsFace
{
    unsigned short  index[3];
    unsigned short  flags;
    QString         material;
    unsigned        smoothing_group;
    float           normal[3];
} Lib3dsFace;

/* Triangular mesh object */
typedef struct Lib3dsMesh_setting {
    unsigned        user_id;
    void*           user_ptr;
    unsigned        object_flags;        /**< @see Lib3dsObjectFlags */
    int             color;               /**< Index to editor palette [0..255] */
    float           matrix[4][4];        /**< Transformation matrix for mesh data */


    int             map_type;
    float           map_pos[3];
    float           map_matrix[4][4];
    float           map_scale;
    float           map_tile[2];
    float           map_planar_size[2];
    float           map_cylinder_height;
} Lib3dsMesh_setting;



/* Triangular mesh object */
typedef struct Lib3dsMesh
{
    QString                 name;            /**< Mesh name. Don't use more than 8 characters  */
    QVector<Lib3dsFace>     faces;
    Lib3dsMesh_setting      setting;
    QVector<QVector3D>      vertices;
    QVector<QVector2D>      texcos;
    QVector<unsigned short> vflags;
    QString                 box_front;
    QString                 box_back;
    QString                 box_left;
    QString                 box_right;
    QString                 box_top;
    QString                 box_bottom;
} Lib3dsMesh;

#endif // LIB3DS_MESH_TYPE_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions