internal PlanarTerrainBlock(PlanarTerrain terrain, Vector2i blockIndex) { this.terrain = terrain; this.blockIndex = blockIndex; int size = terrain.BlockSize; //heightTexture = new Texture2D(device, size, size, true, Format.Single, DepthFormat.None, 0, RenderTargetUsage.PlatformContents); //heightBackBuffer = new Texture2D(device, size, size, true, Format.Single, DepthFormat.None, 0, RenderTargetUsage.PlatformContents); treeRoot = new TerrainTreeNode(this, new Vector2i(0, 0), size, terrain.DeepestLod); DirtyTreeArea = new Box2i(0, 0, size, size); }
public TerrainComponent(PlanarTerrain terrain) { if (terrain == null) { throw new ArgumentNullException("terrain"); } Terrain = terrain; terrain.ComponentsMutable.Add(this); if (SupportsNodeLodBlend) { terrain.ComponentsNodeLodBlend.Add(this); } if (SupportsNodeClip) { terrain.ComponentsNodeClip.Add(this); } }
/// <summary>Detach the <see cref="TerrainComponent"/> from the <see cref="Terrain"/>.</summary> public void Detach() { if (Terrain != null) { throw new InvalidOperationException("The module has already been detached from the terrain."); } Terrain.ComponentsMutable.Remove(this); OnDetach(); if (Detached != null) { Detached(this, EventArgs.Empty); } if (SupportsNodeLodBlend) { Terrain.ComponentsNodeLodBlend.Remove(this); } if (SupportsNodeClip) { Terrain.ComponentsNodeClip.Remove(this); } Terrain = null; }