MyGame.Terrain.Terrain C# (CSharp) 메소드

Terrain() 공개 메소드

public Terrain ( Game game, Camera camera, Microsoft.Xna.Framework.Graphics.Texture2D HeightMap, float CellSize, float Height, Microsoft.Xna.Framework.Graphics.Texture2D BaseTexture, float TextureTiling, Vector3 LightDirection ) : System
game Game
camera Camera
HeightMap Microsoft.Xna.Framework.Graphics.Texture2D
CellSize float
Height float
BaseTexture Microsoft.Xna.Framework.Graphics.Texture2D
TextureTiling float
LightDirection Vector3
리턴 System
        public Terrain(Game game,Camera camera, Texture2D HeightMap, float CellSize, float Height,
            Texture2D BaseTexture, float TextureTiling, Vector3 LightDirection/*,Vector2 pos*/)
            : base(game)
        {
            this.baseTexture = BaseTexture;
            this.camera = camera;
            this.textureTiling = TextureTiling;
            this.lightDirection = LightDirection;
            this.heightMap = HeightMap;
            this.width = HeightMap.Width;
            this.length = HeightMap.Height;
            this.cellSize = CellSize;
            this.height = Height;
            //this.pos = pos;

            effect = Game.Content.Load<Effect>("TerrainEffect");

            // 1 vertex per pixel
            nVertices = width * length;

            // (Width-1) * (Length-1) cells, 2 triangles per cell, 3 indices per triangle
            nIndices = (width - 1) * (length - 1) * 6;

            vertexBuffer = new VertexBuffer(Game.GraphicsDevice, typeof(VertexPositionNormalTexture),
                nVertices, BufferUsage.WriteOnly);

            indexBuffer = new IndexBuffer(Game.GraphicsDevice, IndexElementSize.ThirtyTwoBits,
                nIndices, BufferUsage.WriteOnly);

            getHeights();
            createVertices();
            createIndices();
            genNormals();

            vertexBuffer.SetData<VertexPositionNormalTexture>(vertices);
            indexBuffer.SetData<int>(indices);
        }