// Wild Magic Source Code
// David Eberly
// http://www.geometrictools.com
// Copyright (c) 1998-2007
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or (at
// your option) any later version.  The license is available for reading at
// either of the locations:
//     http://www.gnu.org/copyleft/lgpl.html
//     http://www.geometrictools.com/License/WildMagicLicense.pdf
//
// Version: 4.0.0 (2006/06/28)

#ifndef WUNIMATERIALMESH_H
#define WUNIMATERIALMESH_H

#include "Wm4Vector3.h"
#include "Wm4Vector2.h"
#include "Wm4ColorRGB.h"
#include "Wm4MaterialState.h"
#include "Wm4TextureEffect.h"
#include "Wm4TriMesh.h"

class WUnimaterialMesh
{
public:
    WUnimaterialMesh ();
    ~WUnimaterialMesh ();

    int& VQuantity ();
    Wm4::Vector3f*& Vertex ();
    Wm4::Vector3f*& Normal ();
    int& CQuantity ();
    Wm4::ColorRGB*& Color ();
    int& TQuantity ();
    Wm4::Vector2f*& Texture ();
    int& FQuantity ();
    int*& Face ();
    int*& CFace ();
    int*& TFace ();
    Wm4::MaterialStatePtr& MState();
    Wm4::TextureEffectPtr& TState();

    // A Max Vertex can have multiple UVW-coordinates.  Wild Magic supports
    // only one UV-coordinate (W is ignored), so any Max Vertex with N
    // UVW-coordinates must be duplicated into N Wild Magic vertices, each
    // having a single UV-coordinate.
    void DuplicateGeometry ();
    Wm4::TriMesh* ToTriMesh ();

    class VertexAttr
    {
    public:
        VertexAttr ();
        bool operator== (const VertexAttr& rkAttr) const;
        bool operator< (const VertexAttr& rkAttr) const;
        int V, C, T;
    };

private:
    int m_iVQuantity;
    Wm4::Vector3f* m_akVertex;
    Wm4::Vector3f* m_akNormal;

    int m_iCQuantity;
    Wm4::ColorRGB* m_akColor;

    int m_iTQuantity;
    Wm4::Vector2f* m_akTexture;

    int m_iFQuantity;
    int* m_aiFace;
    int* m_aiCFace;
    int* m_aiTFace;

    Wm4::MaterialStatePtr m_spkMState;
    Wm4::TextureEffectPtr m_spkTState;
};

#endif
