/// <summary>
        /// Creates bitmaps for the texture
        /// </summary>
        private static Bitmap[] CreateTextureBitmaps( IProgressMonitor progressMonitor, ISpherePlanet planet )
        {
            Bitmap[] faceBitmaps = new Bitmap[ 6 ];
            int width = 256;
            int height = 256;
            progressMonitor.UpdateProgress( 0 );

            ISpherePlanetTerrainRenderer renderer = planet.Renderer.GetRenderer<ISpherePlanetTerrainRenderer>( );
            if ( renderer == null )
            {
                throw new InvalidOperationException( "Expected a valid ISpherePlanetTerrainRenderer to be available" );
            }

            faceBitmaps[ ( int )CubeMapFace.PositiveX ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveX, width, height ); progressMonitor.UpdateProgress( 1 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.NegativeX ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeX, width, height ); progressMonitor.UpdateProgress( 2 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.PositiveY ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveY, width, height ); progressMonitor.UpdateProgress( 3 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.NegativeY ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeY, width, height ); progressMonitor.UpdateProgress( 4 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.PositiveZ ] = renderer.CreateMarbleTextureFace( CubeMapFace.PositiveZ, width, height ); progressMonitor.UpdateProgress( 5 / 6.0f );
            faceBitmaps[ ( int )CubeMapFace.NegativeZ ] = renderer.CreateMarbleTextureFace( CubeMapFace.NegativeZ, width, height );
            progressMonitor.UpdateProgress( 1 );

            foreach ( object cubeMapFace in Enum.GetValues( typeof( CubeMapFace ) ) )
            {
                faceBitmaps[ ( int )cubeMapFace ].Save( "PlanetCubeMap" + cubeMapFace + ".png" );
            }

            return faceBitmaps;
        }
        /// <summary>
        /// Adds the request to build a texture for the specified planet onto a build queue
        /// </summary>
        public void QueueBuild( IWorkItemQueue queue, ISpherePlanet planet, Action<ITexture> onComplete )
        {
            SourceSinkWorkItem.Builder<Bitmap[]> sourceSink = new SourceSinkWorkItem.Builder<Bitmap[]>( );
            sourceSink.SetSource( CreateTextureBitmaps, planet );
            sourceSink.SetSink( FinishBuild, onComplete );

            queue.Enqueue( sourceSink.Build( "Build Marble Texture" ), null );
        }
 /// <summary>
 /// Returns true if the marble texture needs to be rebuilt
 /// </summary>
 public bool RequiresRebuild( ISpherePlanet planet )
 {
     return false;
 }
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="spherePlanet">Spherical planet</param>
 public SpherePlanetModel( ISpherePlanet spherePlanet )
     : base(spherePlanet)
 {
 }
 /// <summary>
 /// Builds a texture. Blocking call.
 /// </summary>
 public ITexture Build( ISpherePlanet planet, IProgressMonitor progressMonitor )
 {
     return CreateTexture( CreateTextureBitmaps( progressMonitor, planet ) );
 }
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="view">Camera view</param>
 /// <param name="planet">Planet instance to view</param>
 /// <exception cref="System.ArgumentNullException">Thrown if view or planet are null</exception>
 public SpherePlanetViewController( IUniCameraView view, ISpherePlanet planet )
     : base(view, planet)
 {
     m_Planet = planet;
 }
 /// <summary>
 /// Setup constructor
 /// </summary>
 public SpherePlanetPackTextureTechnique( ISpherePlanet planet )
     : base(planet, "Effects/Planets/terrestrialPlanetTerrain.cgfx")
 {
 }
        /// <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;
        }
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="planet">Spherical planet that this renderer is attached to</param>
 /// <param name="nearSorter">Render order sorter used to determine the order that near objects are rendered in</param>
 /// <param name="farSorter">Render order sorter used to determine the order that far objects are rendered in</param>
 public SpherePlanetRenderer( ISpherePlanet planet, IRenderOrderSorter nearSorter, IRenderOrderSorter farSorter )
     : base(planet, nearSorter, farSorter)
 {
 }
 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="planet">Spherical planet that this renderer is attached to</param>
 public SpherePlanetRenderer( ISpherePlanet planet )
     : base(planet)
 {
 }