1 / 12

Terrain

Terrain. Basic Terrain Rendering. 산이나 계곡등의 지형을 나타내는 방식 텍스쳐를 추가하면 해변이나 풀덮인 언덕 , 눈덮힌 산 등을 표현할 수도 있다 . 전체 지형을 다 그리는 것은 낭비이며 보이는 부분만 그리고 (View Frustum Culling), 멀리 있는 물체는 덜 세밀하게 그려야 (LOD:Level of Detail) 속도가 향상된다. Terrain Representation. Height Map

laurel
Download Presentation

Terrain

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Terrain

  2. Basic Terrain Rendering • 산이나 계곡등의 지형을 나타내는 방식 • 텍스쳐를 추가하면 해변이나 풀덮인 언덕, 눈덮힌 산 등을 표현할 수도 있다. • 전체 지형을 다 그리는 것은 낭비이며 보이는 부분만 그리고(View Frustum Culling), 멀리 있는 물체는 덜 세밀하게 그려야 (LOD:Level of Detail)속도가 향상된다.

  3. Terrain Representation • Height Map • 사각형의 지역내 각각의 점에 높이 값이 저장되어 있는 map (2차원 이미지와 비슷한 개념) • Height Map을 Geometry로 변환 (0,0) (1,0) • 높이 좌표는 height map 참조 (0,1) (1,1)

  4. Terrain LOD • Cracks, T-junctions • How do we solve this?

  5. Terrain LOD • Subdivide the terrain such that this is easier or done for free • Quadtrees , Bintrees

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

  7. Binary Triangle Tree (bintree) • Cracks and T-junctions are solved! • Any two triangles differ by no more than one resolution level • A little harder to implement • Forced Splitting

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

  9. 지형위를 걷기 • 현재 서있는 지점의 높이(y 좌표)에 따라 카메라의 높이를 조절한다. • 카메라 위치 즉 x와 z축 좌표를 이용하여 현재의 셀(삼각형)을 찾아내야 한다. • 그 후 x,z좌표값에서 해당되는 삼각형의 높이값을 계산한다. (0,0) (1,0) (0,1) (1,1)

  10. private: IDirect3DDevice9* _device; IDirect3DTexture9* _tex; IDirect3DVertexBuffer9* _vb; IDirect3DIndexBuffer9* _ib; int _numVertsPerRow; int _numVertsPerCol; int _cellSpacing; int _numCellsPerRow; int _numCellsPerCol; int _width; int _depth; int _numVertices; int _numTriangles; float _heightScale; std::vector<int> _heightmap; // helper methods bool readRawFile(std::string fileName); bool computeVertices(); bool computeIndices(); bool lightTerrain(D3DXVECTOR3* directionToLight); float computeShade(int cellRow, int cellCol, D3DXVECTOR3* directionToLight); struct TerrainVertex { TerrainVertex(){} TerrainVertex(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; }; }; class Terrain { public: Terrain( IDirect3DDevice9* device, std::string heightmapFileName, int numVertsPerRow, int numVertsPerCol, int cellSpacing, // space between cells float heightScale); ~Terrain(); int getHeightmapEntry(int row, int col); void setHeightmapEntry(int row, int col, int value); float getHeight(float x, float z); bool loadTexture(std::string fileName); bool genTexture(D3DXVECTOR3* directionToLight); bool draw(D3DXMATRIX* world, bool drawTris);

More Related