// TerrainEngine.h
// Header file containing definition of CTerrainEngine class
#ifndef _TERRAINENGINE_H
#define _TERRAINENGINE_H
#include <d3d8.h>
#include <d3dx8.h>
typedef struct _tagTerrainVertex
{
float x, y, z;
D3DCOLOR dwColour;
float tu1, tv1;
} TERRAINVERTEX;
#define D3DFVF_TERRAIN (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 )
class CTerrainEngine
{
public:
LPDIRECT3DTEXTURE8 m_pTextureHeightmap; // heightmap texture
LPDIRECT3DTEXTURE8 m_pTextureGround; // texture for ground level
LPDIRECT3DVERTEXBUFFER8 m_pVertexBuffer; // VB for terrain mesh
LPDIRECT3DINDEXBUFFER8 m_pIndexBuffer; // Index buffer for terrain
int m_nHeightArray[256][256]; // 0-255*0-255 array for Y vals of each heightmap pixel
TERRAINVERTEX m_vTerrain[128*128]; // 6 verts per quad, one quad per pixel
short m_sIndices[(6*(128*128))]; // Index buffer indices
CTerrainEngine();
~CTerrainEngine();
HRESULT Initialise(LPDIRECT3DDEVICE8& pDevice, char* pszHeightmap);
HRESULT Render(LPDIRECT3DDEVICE8& pDevice, LPDIRECT3DSURFACE8& pBackBuffer);
};
#endif // _TERRAINENGINE_H