public DemoPartitionContext( GraphicsDevice graphicsDevice, ContentManager content, CDLODSettings settings, ICDLODVisibleRanges visibleRanges, SampleSourceDelegate noiseSource, float noiseMinX, float noiseMinY, float noiseWidth, float noiseHeight) { GraphicsDevice = graphicsDevice; Content = content; this.settings = settings; NoiseSource = noiseSource; NoiseMinX = noiseMinX; NoiseMinY = noiseMinY; NoiseWidth = noiseWidth; NoiseHeight = noiseHeight; TerrainRenderer = new DemoTerrainRenderer(GraphicsDevice, Content, settings); TerrainRenderer.InitializeMorphConsts(visibleRanges); var heightColors = new HeightColorCollection(); // default settings. heightColors.AddColor(-1.0000f, Color.Navy); heightColors.AddColor(-0.2500f, Color.Blue); heightColors.AddColor( 0.0000f, Color.LightSeaGreen); heightColors.AddColor( 0.0625f, Color.Khaki); heightColors.AddColor( 0.1250f, Color.DarkGreen); heightColors.AddColor( 0.3750f, Color.DarkGoldenrod); heightColors.AddColor( 0.7500f, Color.Gray); heightColors.AddColor( 1.0000f, Color.White); TerrainRenderer.InitializeHeightColors(heightColors); Selection = new CDLODSelection(settings, visibleRanges); }
public DemoPartitionContext( GraphicsDevice graphicsDevice, ContentManager content, CDLODSettings settings, ICDLODVisibleRanges visibleRanges) { GraphicsDevice = graphicsDevice; Content = content; this.settings = settings; TerrainRenderer = new DemoTerrainRenderer(GraphicsDevice, Content, settings); TerrainRenderer.InitializeMorphConsts(visibleRanges); var heightColors = new HeightColorCollection(); // default settings. heightColors.AddColor(-1.0000f, new Color( 0, 0, 128, 255)); heightColors.AddColor(-0.2500f, new Color( 0, 0, 255, 255)); heightColors.AddColor( 0.0000f, new Color( 0, 128, 255, 255)); heightColors.AddColor( 0.0625f, new Color(240, 240, 64, 255)); heightColors.AddColor( 0.1250f, new Color( 32, 160, 0, 255)); heightColors.AddColor( 0.3750f, new Color(224, 224, 0, 255)); heightColors.AddColor( 0.7500f, new Color(128, 128, 128, 255)); heightColors.AddColor( 1.0000f, new Color(255, 255, 255, 255)); TerrainRenderer.InitializeHeightColors(heightColors); Selection = new CDLODSelection(settings, visibleRanges); }
public CDLODSelection(CDLODSettings settings, ICDLODVisibleRanges visibleRanges) { Settings = settings; VisibleRanges = visibleRanges; Frustum = new BoundingFrustum(Matrix.Identity); selectedNodes = new CDLODSelectedNode[MaxSelectedNodeCount]; }
public static void Create(ICDLODVisibleRanges visibleRanges, out Vector2[] results) { results = new Vector2[visibleRanges.Count]; float lastStart = 0; for (int i = 0; i < visibleRanges.Count; i++) { // Calculate a morph start/end range. var end = visibleRanges[i]; var start = lastStart + (end - lastStart) * MorphStartRatio; end = MathHelper.Lerp(end, start, errorFudge); lastStart = start; // Calculate a morph constant. results[i] = new Vector2(end / (end - start), 1 / (end - start)); } }
// Invoke this method if the state of a IVisibleRanges instance is changed. public void InitializeMorphConsts(ICDLODVisibleRanges visibleRanges) { Vector2[] morphConsts; CDLODMorphConsts.Create(visibleRanges, out morphConsts); effect.MorphConsts = morphConsts; }