/***************************************************************************
 *                          Zanoza Modeler v2.x                            *
 *      This is unpublished propietary source code of Zanoza Software.     *
 *      The copyright notice does not evidence any actual or intended      *
 *                    publication of such source code.                     *
 *                                                                         *
 *                   Copyright (c) 2002 Zanoza Software.                   *
 *                                                                         *
 *                        All rights reserved.                             *
 ***************************************************************************
 *--------------------------------------------------------------------------
 * @author:   Oleg M.
 *--------------------------------------------------------------------------
 * @purpose:  ZModeler's vertex helpers
 *--------------------------------------------------------------------------
 * @histroy: 22.04.2003. Created
 */
#ifndef zverticeshelper_h_included
#define zverticeshelper_h_included

#include <zmodeler.h>

//------------------------------------------------------
//
//  ZVertexN - ZModeler's base Vertex.
//  Contains - position and normal
//  
//------------------------------------------------------
class DLL_LINKAGE ZVertexN : public ZVertex
{
public:
  //
  // constructors/destructors
  //
  ZVertexN();
  ZVertexN( const ZPoint3D pos, const ZVector norm);
  ZVertexN( const float _x, const float _y, const float _z,
            const float nx, const float ny, const float nz);
  ZVertexN(const ZVertexN& vtx);
  virtual ~ZVertexN();

public:
  //
  // the actual size:
  //
  virtual DWORD size() const;
  virtual DWORD format() const;

public:
  //
  // casting operators
  //
  virtual operator float* ();
  virtual operator const float* () const;

public:
  //
  // assignment operators
  //
  virtual ZVertex& operator =  ( const ZVertex& vtx);
  virtual ZVertex& operator += ( const ZVertex& vtx);
  virtual ZVertex& operator -= ( const ZVertex& vtx);
  virtual ZVertex& operator *= ( float v);
  virtual ZVertex& operator /= ( float v);

public:
  //
  // unary operators
  //
  virtual ZVertex& operator + () const;
  virtual ZVertex& operator - () const;

public:
  //
  // binary operators
  //
  virtual ZVertex& operator + ( const ZVertex& vtx) const;
  virtual ZVertex& operator - ( const ZVertex& vtx) const;
  virtual ZVertex& operator * ( const ZVertex& vtx) const; //cross product
  virtual ZVertex& operator * ( float v) const;
  virtual ZVertex& operator / ( float v) const;
  virtual float    operator ^ ( const ZVertex& vtx) const; //dot product

public:
  //
  // compare operators
  //
  virtual bool operator == ( const ZVertex& vtx) const;
  virtual bool operator != ( const ZVertex& vtx) const;
  virtual bool operator < ( const ZVertex& vtx) const;
  virtual bool operator <= ( const ZVertex& vtx) const;

public:
  //
  // accessors
  //
  virtual ZPoint3D&     position();
  virtual ZPoint3D&     position(const ZPoint3D& p);
  virtual ZVector&      normal(const int nWhich=0);
  virtual ZVector&      normal(const ZVector& n, const int nWhich=0);

private:
  //
  // data members:
  //
  ZPoint3D  m_position;
  ZVector   m_normal;
};


//------------------------------------------------------
//
//  ZVertexNUV - ZModeler's Vertex with multiple UV.
//  Contains   - position, normal, nUV uv coordinates
//  
//------------------------------------------------------
template <int nUV>
class DLL_LINKAGE ZVertexNUV : public ZVertexN
{
public:
  //
  // constructors/destructors
  //
  ZVertexNUV();

public:
  //
  // the actual size:
  //
  virtual DWORD size() const;
  virtual DWORD format() const;

public:
  //
  // assignment operators
  //
  virtual ZVertex& operator =  ( const ZVertex& vtx);

public:
  //
  // compare operators
  //
  virtual bool operator == ( const ZVertex& vtx) const;
  virtual bool operator != ( const ZVertex& vtx) const;

public:
  //
  // accessors
  //
  virtual ZPoint2D&     uv(const int i);
  virtual ZPoint2D&     uv(const int i, const ZPoint2D& uv);

private:
  //
  // data members:
  //
  ZPoint2D    m_uv[nUV];
};


//------------------------------------------------------
//
//  ZVertexColorNUV - ZModeler's Vertex with multiple UV.
//  Contains   - position, normal, nCLR colors and nUV uv coordinates
//  
//------------------------------------------------------
template <int nCLR, int nUV>
class DLL_LINKAGE ZVertexColorNUV : public ZVertexN
{
public:
  //
  // constructors/destructors
  //
  ZVertexColorNUV();

public:
  //
  // the actual size:
  //
  virtual DWORD size() const;
  virtual DWORD format() const;

public:
  //
  // assignment operators
  //
  virtual ZVertex& operator =  ( const ZVertex& vtx);

public:
  //
  // compare operators
  //
  virtual bool operator == ( const ZVertex& vtx) const;
  virtual bool operator != ( const ZVertex& vtx) const;

public:
  //
  // accessors
  //
  virtual ZPoint2D&     uv(const int i);
  virtual ZPoint2D&     uv(const int i, const ZPoint2D& uv);
  virtual ZColor&       color(const eVertexColor c);
  virtual ZColor&       color(const eVertexColor c, const ZColor& col);

private:
  //
  // data members:
  //
  ZPoint2D    m_uv[nUV];
  ZColor      m_colors[nCLR];
};



//------------------------------------------------------
//
//  ZBlendVertex  - ZModeler's Vertex with bones transform
//  Contains      - position, normal, nBW bones
//  
//------------------------------------------------------
template <int nWB>
class ZBlendVertex : public ZVertexN
{
public:
  //
  // constructors/destructors
  //
  ZBlendVertex();

public:
  //
  // the actual size:
  //
  virtual DWORD size() const;
  virtual DWORD format() const;

public:
  //
  // assignment operators
  //
  virtual ZVertex& operator =  ( const ZVertex& vtx);

public:
  //
  // compare operators
  //
  virtual bool operator == ( const ZVertex& vtx) const;
  virtual bool operator != ( const ZVertex& vtx) const;

public:
  //
  // accessors
  //
  virtual BYTE&         boneID(const int i);
  virtual BYTE&         boneID(const int i, const BYTE b);
  virtual float&        boneW(const int i);
  virtual float&        boneW(const int i, const float w);

private:
  //
  // data members:
  //

  BYTE        m_bones[4];//always 4 indexes
  float       m_weights[nWB];
};


//------------------------------------------------------
//
//  ZBlendUVVertex  - ZModeler's blend Vertex
//  Contains        - position, normal, bones and uv
//  
//------------------------------------------------------
template <int nUV, int nWB>
class ZBlendUVVertex : public ZVertexN
{
public:
  //
  // constructors/destructors
  //
  ZBlendUVVertex();

public:
  //
  // the actual size:
  //
  virtual DWORD size() const;
  virtual DWORD format() const;

public:
  //
  // assignment operators
  //
  virtual ZVertex& operator =  ( const ZVertex& vtx);

public:
  //
  // compare operators
  //
  virtual bool operator == ( const ZVertex& vtx) const;
  virtual bool operator != ( const ZVertex& vtx) const;

public:
  //
  // accessors
  //
  virtual ZPoint2D&     uv(const int i);
  virtual ZPoint2D&     uv(const int i, const ZPoint2D& uv);
  virtual BYTE&         boneID(const int i);
  virtual BYTE&         boneID(const int i, const BYTE b);
  virtual float&        boneW(const int i);
  virtual float&        boneW(const int i, const float w);

private:
  //
  // data members:
  //
  ZPoint2D    m_uv[nUV];
  BYTE        m_bones[4];//always 4 indexes
  float       m_weights[nWB];
};



//------------------------------------------------------
//
//  ZHeavyVertex  - ZModeler's Vertex with full data
//  Contains      - position, normal, at least one bone, color and uv
//  
//------------------------------------------------------
template <int nCLR, int nUV, int nWB>
class ZHeavyVertex : public ZVertexN
{
public:
  //
  // constructors/destructors
  //
  ZHeavyVertex();

public:
  //
  // the actual size:
  //
  virtual DWORD size() const;
  virtual DWORD format() const;

public:
  //
  // assignment operators
  //
  virtual ZVertex& operator =  ( const ZVertex& vtx);

public:
  //
  // compare operators
  //
  virtual bool operator == ( const ZVertex& vtx) const;
  virtual bool operator != ( const ZVertex& vtx) const;

public:
  //
  // accessors
  //
  virtual ZPoint2D&     uv(const int i);
  virtual ZPoint2D&     uv(const int i, const ZPoint2D& uv);
  virtual ZColor&       color(const eVertexColor c);
  virtual ZColor&       color(const eVertexColor c, const ZColor& col);
  virtual BYTE&         boneID(const int i);
  virtual BYTE&         boneID(const int i, const BYTE b);
  virtual float&        boneW(const int i);
  virtual float&        boneW(const int i, const float w);

private:
  //
  // data members:
  //
  ZColor      m_colors[nCLR];
  ZPoint2D    m_uv[nUV];
  BYTE        m_bones[4];//always 4 indexes
  float       m_weights[nWB];
};


#endif //zverticeshelper_h_included

