/***************************************************************************
 *                          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 Melashenko
 *--------------------------------------------------------------------------
 * @purpose:
   *--------------------------------------------------------------------------
 * @created: Thursday, 29 May, 2003 11:44:06
 */

#if !defined(renderTypes_h_included)
#define renderTypes_h_included

#include <zmodeler.h>

namespace rend
{
  //
  // type of get/setSolor in IMaterial
  //
  enum eColorType
  {
    AMBIENT,
    DIFFUSE,
    SPECULAR,
    EMISSIVE,
    ALL
  };

  //------------------------------------------------
  //            Texture groups
  //------------------------------------------------
  enum eTextureGroup
  {
    TG_GENERIC              = 0, //generic texture
    TG_AMBIENT              = 1, //base texture for terrains etc. ambient color.
    TG_ENVIRONMENT          = 2, //environment textures
    TG_CHROMIC              = 3, //chromic effect.
    TG_BACKGROUND           = 4,
    TG_SCHEMATIC            = 5,
    TG_EFFECTS              = 6,
    TG_PARICLES             = 7,
    TG_BUMPMAP              = 8,
    TG_LIGHTMAP             = 9,
    TG_SHADOWMAP            = 10,
    TG_FORCE_DWORD          = 0x7FFFFFFF
  };
  typedef ZSequence<eTextureGroup>  tTextureGroupSeq;
};//rend

#include <rend/IRenderExtension.h>
#include <rend/ITexture.h>

namespace rend
{
  //
  // type of data in render-block
  //
  enum eRenderBlockType
  {
    DOTS          = 0,//1px
    MINPOINTS     = 1,//2px
    MIDPOINTS     = 2,//4px
    BIGPOINTS     = 3,//6px
    LINES         = 4,//set of lines
    LINESTRIP     = 5,//single linestrip
    TRIANGLES     = 6,//triangle list
    TRIANGLEFAN   = 7,//triangle fan
    TRIANGLESTRIP = 8,//triangle strip
    /*patches*/
  };

// specific bits for tRenderBlock::m_dwFlags field:
#define RENDERBLOCK_WIREFRAME         0x00000001
#define RENDERBLOCK_USESTENCIL        0x00000002
#define RENDERBLOCK_ZTEST             0x00000004
#define RENDERBLOCK_ZWRITE            0x00000008
#define RENDERBLOCK_DOUBLESIDED       0x00000010
// color and blend
#define RENDERBLOCK_USECOLOR          0x00001000
#define RENDERBLOCK_MIXCOLOR         (0x00002000 | RENDERBLOCK_USECOLOR)
#define RENDERBLOCK_ADDCOLOR         (0x00004000 | RENDERBLOCK_USECOLOR)
#define RENDERBLOCK_USEBLEND          0x00010000
#define RENDERBLOCK_MIXBLEND         (0x00020000 | RENDERBLOCK_USEBLEND)
#define RENDERBLOCK_ADDBLEND         (0x00040000 | RENDERBLOCK_USEBLEND)
// z-correction:
#define RENDERBLOCK_ZCORRECTION       0x00100000
#define RENDERBLOCK_ZCORRECTION1      RENDERBLOCK_ZCORRECTION
#define RENDERBLOCK_ZCORRECTION2      0x00200000
#define RENDERBLOCK_ZCORRECTION3      0x00300000
#define RENDERBLOCK_ZCORRECTION4      0x00400000
#define RENDERBLOCK_GET_ZCORRECTION(dw)    (((dw) & 0x00F00000) >> 20)
#define RENDERBLOCK_SET_ZCORRECTION(n)     ((n) << 20)

  //------------------------------------------------
  //   The struct is passed into IRenderManager and
  // contains raw data to be rendered. You can pass
  // these blocks to render manager in any order.
  //   This is low-level API data type: use only if
  // there is no walkarounds.
  //------------------------------------------------
  struct tRenderBlock
  {
    eRenderBlockType    m_type;
    long                m_nMaterial;
    ZPtr<IIndexBuffer>  m_pIndexes;
    ZPtr<IVertexBuffer> m_pVertices;
    ZBufPtr<BYTE>       m_pRawVertexData;
    long                m_nFirstIndex;
    long                m_nPrimitiveCount;
    long                m_nVertices;      //amount of vertices in vertex buffer
    DWORD               m_dwFVF;          //FVF of supplied vertices
    DWORD               m_dwVertexStride; //stride of vertices in supplied buffer
    DWORD               m_dwStencilRef;
    DWORD               m_dwStencilMask;
    DWORD               m_dwStencilFunc;
    DWORD               m_dwStencilPass;
    DWORD               m_dwStencilFail;
    DWORD               m_dwFlags;        //see #defines above
    ZColor              m_color;          //used only if (m_bForceColor || (-1==m_nMaterial))
    DWORD               m_dwSrcBlend;
    DWORD               m_dwDestBlend;
    ZPtr<CRenderExtensionCol> m_pExtentions;
    DWORD               m_dwExtention;
    //constructor
    DLL_LINKAGE         tRenderBlock();   
  };
  //sequence type
  typedef ZSequence<tRenderBlock> tRenderBlockSeq;

  //
  // UVMapping source for texture layer
  //
  enum eUVSource
  {
    UV_MANUAL1            = 0,
    UV_MANUAL2            = 1,
    UV_MANUAL3            = 2,
    UV_MANUAL4            = 3,
    UV_AUTO_SPHERE_ENV    = 4,
    UV_CAMERA_NORMAL      = 5,
    UV_CAMERA_POSITION    = 6,
    UV_CAMERA_REFLECTION  = 7,
    UV_SPHERE_MAP         = 8,
  };

  //------------------------------------------------
  //   The struct contains information about single
  // texture layer.
  //------------------------------------------------
  struct tTextureLayerInfo
  {
    bool                    m_bEnabled;
    core::ePriority         m_priority;
    eUVSource               m_source;
    ZPtr<rend::ITexture>    m_pTexture;
    DWORD                   m_dwColorArg0;
    DWORD                   m_dwColorArg1;
    DWORD                   m_dwColorArg2;
    DWORD                   m_dwColorOp;
    DWORD                   m_dwAlphaArg0;
    DWORD                   m_dwAlphaArg1;
    DWORD                   m_dwAlphaArg2;
    DWORD                   m_dwAlphaOp;
    bool                    m_bResultToTemp;
    DWORD                   m_dwAddressModeU;
    DWORD                   m_dwAddressModeV;
    DWORD                   m_dwAddressModeW;
    DWORD                   m_dwMagFilter;
    DWORD                   m_dwMinFilter;
    DWORD                   m_dwMipFilter;
    ZColor                  m_colorConstant;
    // :FIXME: consider uv-transform
    DLL_LINKAGE             tTextureLayerInfo();
  };
  //sequence type
  typedef ZSequence<tTextureLayerInfo> tTextureLayerInfoSeq;

#define Z3D_RENDEREXTENSION_RESOLVER    _T("ZModeler::RenderExtension")

};//rend

#endif