/// <summary> /// Sets up the terrain functions /// </summary> /// <param name="heightFunction">The terrain height function</param> /// <param name="groundFunction">The terrain ground offset function</param> public void SetupTerrain( TerrainFunction heightFunction, TerrainFunction groundFunction ) { if ( PlanetModel == null ) { throw new InvalidOperationException( "Terrain model does not have an associated planet. Cannot setup terrain" ); } float height = MaximumHeight.ToRenderUnits; m_Gen = new TerrainGenerator( TerrainGeometry.Plane, heightFunction, groundFunction ); m_Gen.Setup( 1024, 0, height ); m_Gen.SetSmallestStepSize( 0.001f, 0.001f ); OnModelChanged( ); }
/// <summary> /// Sets up the terrain functions /// </summary> /// <param name="heightFunction">The terrain height function</param> /// <param name="groundFunction">The terrain ground offset function</param> public void SetupTerrain( TerrainFunction heightFunction, TerrainFunction groundFunction ) { if ( Planet == null ) { throw new InvalidOperationException( "Terrain model does not have an associated planet. Cannot setup terrain" ); } float radius = SpherePlanet.PlanetModel.Radius.ToRenderUnits; float height = MaximumHeight.ToRenderUnits; // NOTE: AP: Patch scale is irrelevant, because vertices are projected onto the function sphere anyway m_Gen = new TerrainGenerator( TerrainGeometry.Sphere, heightFunction, groundFunction ); m_Gen.Setup( 1024, radius, radius + height ); m_Gen.SetSmallestStepSize( MinimumStepSize, MinimumStepSize ); OnModelChanged( false, true ); }
/// <summary> /// Creates a terrain generator from a model definition /// </summary> private static TerrainGenerator CreateTerrainGenerator( ISpherePlanet planet, IPlanetHomogenousProceduralTerrainModel model ) { float radius = planet.Model.Radius.ToRenderUnits; float height = model.MaximumHeight.ToRenderUnits; TerrainGenerator generator = new TerrainGenerator( TerrainGeometry.Sphere, model.HeightFunction, model.GroundOffsetFunction ); generator.Setup( 1024, radius, radius + height ); generator.SetSmallestStepSize( MinimumStepSize, MinimumStepSize ); return generator; }