www.pudn.com > roam.rar > Landscape.h
// Landscape.h: interface for the Landscape class.
//
//////////////////////////////////////////////////////////////////////
#ifndef LANDSCAPE_H
#define LANDSCAPE_H
#include "Patch.h"
// 定义地形图及其对应子块图大小:
#define MAP_1024
#ifdef MAP_2048
// ------- 2048x2048 MAP -------
#define MAP_SIZE (2048)
#define NUM_PATCHES_PER_SIDE (32)
#else
#ifdef MAP_1024
// ------- 1024x1024 MAP -------
#define MAP_SIZE (1024)
#define NUM_PATCHES_PER_SIDE (16)
#else
// ------- 512x512 MAP -------
#define MAP_SIZE (512)
#define NUM_PATCHES_PER_SIDE (8)
#endif
#endif
// How many TriTreeNodes should be allocated?
#define POOL_SIZE (85000)
// 每块子网格中含有的网格数
#define PATCH_SIZE (MAP_SIZE/NUM_PATCHES_PER_SIDE)
#define SQR(x) ((x) * (x))
#define MAX(a,b) ((a < b) ? (b) : (a))
#define DEG2RAD(a) (((a) * M_PI) / 180.0f)
#define M_PI (3.14159265358979323846f)
class Landscape
{
public:
virtual void Tessellate();
virtual void Render();
static TriTreeNode * AllocateTri();
virtual void Reset(int viewPosX,int viewPosY);
virtual void Init(double *hMap);
Landscape();
virtual ~Landscape();
static int GetNextTriNode() { return m_NextTriNode; }
static void SetNextTriNode( int nNextNode ) { m_NextTriNode = nNextNode; }
protected:
Patch m_Patches[NUM_PATCHES_PER_SIDE][NUM_PATCHES_PER_SIDE]; // 地形子块数组
static int m_NextTriNode; // Index to next free TriTreeNode
static TriTreeNode m_TriPool[POOL_SIZE]; // Pool of TriTree nodes for splitting
};
#endif