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);
}