D:/Zythum/DinoKod/Landscape/SubTileDraw.h

00001 //---------------------------------------------------------------------------------------------
00002 //      This file is a part of "DinoKod".
00003 //      Copyright © 2003 Dino Productions. All Rights Reserved.
00004 //      
00005 //      File                    : SubTileDraw.h
00006 //      Author                  : Sebastien LEIX        sebastien.leix@wanadoo.fr
00007 //      Date                    : 12/02/2003
00008 //      Modification    :
00009 //
00010 //---------------------------------------------------------------------------------------------
00011 #ifndef __SUBTILEDRAW_H__
00012 #define __SUBTILEDRAW_H__
00013 
00014 #include "Landscape/LandscapeDll.h"
00015 #include "Common/Vertex.h"
00016 #include "Render/VertexBuffer.h"
00017 #include "Landscape/SubTile.h"
00018 #include "Landscape/Tile.h"
00019 
00020 class KTileDraw;
00021 class KShader;
00022 
00023 //---------------------------------------------------------------------------------------------
00024 enum KSUBTILEDRAWMIPINDICES
00025 {
00026         KSTMI_CENTER,
00027         KSTMI_UP,
00028         KSTMI_DOWN,
00029         KSTMI_LEFT,
00030         KSTMI_RIGHT,
00031         KSTMI_MIP_UP,
00032         KSTMI_MIP_DOWN,
00033         KSTMI_MIP_LEFT,
00034         KSTMI_MIP_RIGHT,
00035         KSTMI_COUNT
00036 };
00037 
00038 //---------------------------------------------------------------------------------------------
00039 class LANDSCAPE_API KSubTileDrawMipMesh
00040 {
00041 public:
00042         KVertex2*                       m_pVertex;
00043         u32                                     m_nVertex;
00044         KINDEX*                         m_pIndex[KSTMI_COUNT];
00045         u32                                     m_nIndex[KSTMI_COUNT];
00046 
00047         KSubTileDrawMipMesh()
00048         {
00049                 m_pVertex       = NULL;
00050                 m_nVertex       = 0;
00051                 for( u32 i = 0; i < KSTMI_COUNT; i ++ )
00052                 {
00053                         m_pIndex[i]     = NULL;
00054                         m_nIndex[i]     = 0;
00055                 }
00056         }
00057 
00058         void                            ComputeNormal();
00059 };
00060 
00061 //---------------------------------------------------------------------------------------------
00062 class LANDSCAPE_API KSubTileDraw : public KSubTile
00063 {
00064 protected:
00065         KShader*                                m_pShader;
00066         KSHADER                                 m_hShader;
00067         KSubTileDrawMipMesh*    m_pMipMesh;
00068         u32                                             m_nMipMesh;
00069         u32                                             m_CurrentMipLevel;
00070         bool                                    m_bDraw;
00071         KINDEX*                                 m_pIndexList;
00072         u32                                             m_nIndexList;
00073         u32                                             m_nIndexListPos;
00074         KVector                                 m_pBBox[8];
00075 
00076         void                                    FlushIndexList();
00077         void                                    AddIndexList( u32 MipIndices );
00078         bool                                    GetHeight( s32 CellX, s32 CellY, KTILEHEIGHT* pHeight );
00079         KVector                                 GetNormal( s32 CellX, s32 CellY );
00080 
00081 public:
00082         KSubTileDraw( KTile* pTile, float PosX, float PosY );
00083         virtual                                 ~KSubTileDraw();
00084 
00085         void                                    ToDraw( bool bDraw )                            { m_bDraw = bDraw;                              }
00086         bool                                    IsToDraw()                                                      { return m_bDraw;                               }
00087 
00088         bool                                    Init( KRender* pRender );
00089         void                                    Draw();
00090         
00091         void                                    SetCurrentMipLevel( u32 MipLevel )      { m_CurrentMipLevel = MipLevel; }
00092         u32                                             GetCurrentMipLevel()                            { return m_CurrentMipLevel;             }
00093 
00094         KVector*                                GetpBBox()                                                      { return m_pBBox;                               }
00095         void                                    ComputeBBox();
00096 
00097         bool                                    GetRayIntersection( KVector& Orig, KVector& Dir, KVector* pPoint );
00098 
00099         void                                    BuildVertex();
00100 
00101         KTileDraw*                              GetpTileDraw()                                          { return (KTileDraw*)m_pTile;   }
00102         void                                    ReloadShader();
00103 };
00104 
00105 #endif  __SUBTILEDRAW_H__

Generated on Sun Mar 25 20:02:12 2007 for Zythum Project by  doxygen 1.5.1-p1