Ignore:
Timestamp:
Feb 8, 2013, 12:28:51 AM (7 years ago)
Author:
touky
Message:

Added VertexDictionnary object to manage vertices with same coord && connected vertices.
Added UVs system with and UVs generation test (not very conclusive)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/easymesh/easymesh.h

    r2370 r2379  
    1515// ------------------
    1616//
     17
     18#define VU_BONES   2
     19#define VU_TEX_UV  1
     20#define VU_VANILLA 0
     21
     22#define VERTEX_USEAGE VU_VANILLA
    1723
    1824#if !defined __EASYMESH_EASYMESH_H__
     
    3945};
    4046
     47/* A safe enum for VertexDictionnary operations. */
     48struct VDictType
     49{
     50    enum Value
     51    {
     52        DoesNotExist=-3,
     53        Alone=-2,
     54        Master=-1
     55    }
     56    m_value;
     57
     58    inline VDictType(Value v) : m_value(v) {}
     59    inline operator Value() { return m_value; }
     60};
     61
     62//a class whose goal is to keep a list of the adjacent vertices for mesh operations purposes
     63class VertexDictionnary
     64{
     65public:
     66    int FindVertexMaster(const int search_idx);
     67    bool FindMatchingVertices(const int search_idx, Array<int> &matching_ids);
     68    bool FindConnectedVertices(const int search_idx, const Array<int> &tri_list, Array<int> &connected_vert, Array<int> const *ignored_tri = NULL);
     69    bool FindConnectedTriangles(const int search_idx, const Array<int> &tri_list, Array<int> &connected_tri, Array<int> const *ignored_tri = NULL);
     70    bool FindConnectedTriangles(const ivec2 &search_idx, const Array<int> &tri_list, Array<int> &connected_tri, Array<int> const *ignored_tri = NULL);
     71    bool FindConnectedTriangles(const ivec3 &search_idx, const Array<int> &tri_list, Array<int> &connected_tri, Array<int> const *ignored_tri = NULL);
     72    void AddVertex(int vert_id, vec3 vert_coord);
     73    void Clear() { vertex_list.Empty(); }
     74private:
     75    //<VertexId, VertexLocation, VertexMasterId>
     76    Array<int, vec3, int>   vertex_list;
     77    //List of the master_ vertices
     78    Array<int>              master_list;
     79};
    4180
    4281class EasyMesh
     
    82121    void AppendTriangleDuplicateVerts(int i1, int i2, int i3, int base);
    83122    void ComputeNormals(int start, int vcount);
     123public:
     124    void ComputeTexCoord(float uv_scale, int uv_offset);
    84125    void SetVertColor(vec4 const &color);
    85126
     
    142183    vec4 m_color, m_color2;
    143184    Array<uint16_t> m_indices;
    144     //TODO : <coord, norm, color, bone_id, bone_weight>
    145     //TODO : Array<vec3, vec3, vec4, ivec2, vec2> m_vert;
     185#if VERTEX_USEAGE == VU_BONES
     186    //TODO : -- BONE SUPPORT --
     187    //TODO : <COORD, NORM, COLOR, BONE_ID, BONE_WEIGHT>
     188    Array<vec3, vec3, vec4, ivec2, vec2> m_vert;
    146189    //TODO : More bone blend support than 2 ?
    147     //<coord, norm, color>
     190#elif VERTEX_USEAGE == VU_TEX_UV
     191    //TODO : -- UV SUPPORT --
     192    //TODO : <COORD, NORM, COLOR, UV>
     193    Array<vec3, vec3, vec4, vec2> m_vert;
     194#else
     195    //-- VANILLA --
     196    //<COORD, NORM, COLOR>
    148197    Array<vec3, vec3, vec4> m_vert;
     198#endif
     199
    149200    //<vert count, indices count>
    150201    Array<int, int> m_cursors;
     
    157208        /* FIXME: very naughty way of handling debug render modes */
    158209        Array<Shader *>shader;
     210#if VERTEX_USEAGE == VU_BONES
     211        //TODO : -- BONE SUPPORT --
     212        Array<ShaderAttrib> coord, norm, color, bone_id, bone_weight;
     213#elif VERTEX_USEAGE == VU_TEX_UV
     214        //-- UV SUPPORT --
     215        Array<ShaderAttrib> coord, norm, color, tex_coord;
     216#else
     217        //-- VANILLA --
    159218        Array<ShaderAttrib> coord, norm, color;
    160         Array<ShaderUniform> modelview, view, invview, proj, normalmat, damage, lights;
     219#endif
     220        Array<ShaderUniform> modelview, invmodelview, view, invview, proj, normalmat, damage, lights;
    161221
    162222        VertexDeclaration *vdecl;
Note: See TracChangeset for help on using the changeset viewer.