Terrain Terrain LOD l l Cracks Tjunctions How

  • Slides: 11
Download presentation
Terrain

Terrain

Terrain LOD l l Cracks, T-junctions How do we solve this?

Terrain LOD l l Cracks, T-junctions How do we solve this?

Terrain LOD § Subdivide the terrain such that this is easier or done for

Terrain LOD § Subdivide the terrain such that this is easier or done for free § Quadtrees

Quadtree § Each quad is actually two triangles § Still have cracks and T-junctions

Quadtree § Each quad is actually two triangles § Still have cracks and T-junctions § Easy to implement

Error Estimation/Control τ = 2 pixels τ = 4 pixels 79, 382 triangles 25,

Error Estimation/Control τ = 2 pixels τ = 4 pixels 79, 382 triangles 25, 100 triangles

class Terrain { public: Terrain( IDirect 3 DDevice 9* device, std: : string heightmap.

class Terrain { public: Terrain( IDirect 3 DDevice 9* device, std: : string heightmap. File. Name, int num. Verts. Per. Row, int num. Verts. Per. Col, int cell. Spacing, // space between cells float height. Scale); private: IDirect 3 DDevice 9* IDirect 3 DTexture 9* IDirect 3 DVertex. Buffer 9* IDirect 3 DIndex. Buffer 9* int _num. Verts. Per. Row; int _num. Verts. Per. Col; int _cell. Spacing; int int int ~Terrain(); int get. Heightmap. Entry(int row, int col); void set. Heightmap. Entry(int row, int col, int value); float get. Height(float x, float z); bool _device; _tex; _vb; _ib; _num. Cells. Per. Row; _num. Cells. Per. Col; _width; _depth; _num. Vertices; _num. Triangles; float _height. Scale; load. Texture(std: : string file. Name); gen. Texture(D 3 DXVECTOR 3* direction. To. Light); draw(D 3 DXMATRIX* world, bool draw. Tris); std: : vector<int> _heightmap; // helper methods bool read. Raw. File(std: : string file. Name); bool compute. Vertices(); bool compute. Indices(); bool light. Terrain(D 3 DXVECTOR 3* direction. To. Light); float compute. Shade(int cell. Row, int cell. Col, D 3 DXVECTOR 3* direction. To. Light); struct Terrain. Vertex { Terrain. Vertex(){} Terrain. Vertex(float x, float y, float z, float u, float v) { _x = x; _y = y; _z = z; _u = u; _v = v; } float _x, _y, _z; float _u, _v; static const DWORD FVF; }; };