public void Execute(TerrainGeometrySurface surface, TerrainNodeBounds bounds) { surface.Begin(); surface.Clear(); //device.VertexDeclaration = vertexPositionTexture; // disable depth buffer and alpha blending device.DepthStencilState = DepthStencilState.None; device.BlendState = BlendState.Opaque; generateTerrainEffect.Parameters["PermutationMap"].SetValue(permutationTexture); generateTerrainEffect.Parameters["GradientMap"].SetValue(gradientTexture); generateTerrainEffect.Parameters["PatchLeft"].SetValue((float)bounds.Left); generateTerrainEffect.Parameters["PatchTop"].SetValue((float)bounds.Top); generateTerrainEffect.Parameters["PatchWidth"].SetValue((float)bounds.Width); generateTerrainEffect.Parameters["PatchHeight"].SetValue((float)bounds.Height); generateTerrainEffect.Parameters["FaceMatrix"].SetValue(CubeFaces.GetFace(bounds.Face).FaceMatrix); for (int i = 0; i < generateTerrainEffect.CurrentTechnique.Passes.Count; i++) { EffectPass pass = generateTerrainEffect.CurrentTechnique.Passes[i]; pass.Apply(); device.DrawUserPrimitives(PrimitiveType.TriangleStrip, surface.Vertices, 0, 2); } surface.End(); }
public TerrainNodeSplitItem(TerrainNode parentNode, int childIndex, TerrainNodeBounds bounds, bool isSphere) { ParentNode = parentNode; ChildIndex = childIndex; Bounds = bounds; IsSphere = isSphere; }
/// <summary> /// Construct a terrain node instance from a pre-generated geometry map /// </summary> /// <param name="item"></param> /// <param name="level"></param> /// <param name="radius"></param> /// <param name="createTerrainNodeVertexBuffer"></param> public TerrainNode(TerrainNodeSplitItem item, int level, double radius, CreateTerrainNodeVertexBufferDelegate createTerrainNodeVertexBuffer, bool isSphere) { this.bounds = item.Bounds; this.level = level; this.radius = radius; this.createPosition = null; this.createTerrainNodeVertexBuffer = createTerrainNodeVertexBuffer; this.isSphere = isSphere; this.diffuseSurface = item.DiffuseSurface; this.normalSurface = item.NormalSurface; Initialize(item); }
/// <summary> /// Construct a terrain node instance /// </summary> /// <param name="bounds">Bounds for this node</param> /// <param name="level">Tree depth of this node</param> /// <param name="radius">Radius of the sphere this node belongs to</param> /// <param name="createPosition">Delegate for vertex position creation</param> public TerrainNode(TerrainNodeBounds bounds, int level, double radius, CreatePositionDelegate createPosition, CreateTerrainNodeVertexBufferDelegate createTerrainNodeVertexBuffer, bool isSphere) { this.bounds = bounds; this.level = level; this.radius = radius; this.createPosition = createPosition; this.createTerrainNodeVertexBuffer = createTerrainNodeVertexBuffer; this.isSphere = isSphere; Initialize(null); }
public void Execute(TerrainGeometrySurface surface, TerrainNodeBounds bounds) { surface.Begin(); surface.Clear(); // disable depth buffer and alpha blending device.DepthStencilState = DepthStencilState.None; device.BlendState = BlendState.Opaque; for (int i = 0; i < generateTerrainEffect.CurrentTechnique.Passes.Count; i++) { EffectPass pass = generateTerrainEffect.CurrentTechnique.Passes[i]; pass.Apply(); device.DrawUserPrimitives(PrimitiveType.TriangleStrip, surface.Vertices, 0, 2); } surface.End(); }
public static void QueueNodeSplit(TerrainNode parentNode, int childIndex, TerrainNodeBounds bounds, bool isSphere) { QueueNodeSplit(new TerrainNodeSplitItem(parentNode, childIndex, bounds, isSphere)); }