/// <summary>
        /// Creates a project
        /// </summary>
        public override Project CreateProject( string name )
        {
            ISpherePlanetModelTemplate template = new SpherePlanetModelTemplate( );
            //	template.Add( new PlanetHomogenousProceduralTerrainTemplate( ) );
            template.Add( new PlanetAtmosphereScatteringTemplate( ) );

            ISpherePlanet planet = new SpherePlanet( );

            return new SpherePlanetProject( this, name, template, planet );
        }
        public OpenGlSpherePlanetRenderer( SpherePlanet planet )
            : base(planet)
        {
            IEffect effect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/terrestrialPlanet.cgfx" );
            TechniqueSelector selector = new TechniqueSelector( effect, "DefaultTechnique" );

            int res = 128;
            //	IPlanetTerrainGenerator terrainGenerator = new TestStPlanetTerrainGenerator( );
            //	IPlanetTerrainGenerator terrainGenerator = new TestFacePlanetTerrainGenerator( );
            //	IPlanetTerrainGenerator terrainGenerator = new TestCloudGenerator( );
            IPlanetTerrainGenerator terrainGenerator = new TestNoisePlanetTerrainGenerator( );
            ICubeMapTexture planetTexture = Graphics.Factory.CreateCubeMapTexture( );
            planetTexture.Build
                (
                    GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.PosX, res ),
                    GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.NegX, res ),
                    GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.PosY, res ),
                    GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.NegY, res ),
                    GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.PosZ, res ),
                    GeneratePlanetTextureFace( terrainGenerator, PlanetMapFace.NegZ, res ),
                    true
                );

            int cloudRes = 128;
            ICubeMapTexture cloudTexture = Graphics.Factory.CreateCubeMapTexture( );
            IPlanetTerrainGenerator cloudGenerator = new TestCloudGenerator( );
            cloudTexture.Build
            (
                GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.PosX, cloudRes ),
                GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.NegX, cloudRes ),
                GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.PosY, cloudRes ),
                GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.NegY, cloudRes ),
                GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.PosZ, cloudRes ),
                GeneratePlanetCloudTextureFace( cloudGenerator, PlanetMapFace.NegZ, cloudRes ),
                true
            );

            int bmpIndex = 0;
            foreach ( Bitmap bitmap in planetTexture.ToBitmaps( ) )
            {
                bitmap.Save( planet.Name + " Planet Texture " + bmpIndex++ + ".jpg", ImageFormat.Jpeg );
            }
            m_PlanetTexture = planetTexture;
            m_CloudTexture = cloudTexture;

            m_PlanetTechnique = selector;

            IEffect cloudEffect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/cloudLayer.cgfx" );
            m_CloudTechnique = new TechniqueSelector( cloudEffect, "DefaultTechnique" );

            Graphics.Draw.StartCache( );
            RenderSphere( 8 );
            m_PlanetGeometry = Graphics.Draw.StopCache( );
        }
        public void Render( IRenderContext context, SpherePlanet planet, ITexture planetTerrainTexture )
        {
            Graphics.Renderer.PushTransform( TransformType.LocalToWorld );
            {
                IUniCamera curCam = UniCamera.Current;
                UniTransform transform = planet.Transform;
                double scale = 1.0 / 100000.0;
                float x = ( float )( UniUnits.Metres.FromUniUnits( transform.Position.X - curCam.Position.X ) * scale );
                float y = ( float )( UniUnits.Metres.FromUniUnits( transform.Position.Y - curCam.Position.Y ) * scale );
                float z = ( float )( UniUnits.Metres.FromUniUnits( transform.Position.Z - curCam.Position.Z ) * scale );

                Graphics.Renderer.SetTransform( TransformType.LocalToWorld, new Point3( x, y, z ), transform.XAxis, transform.YAxis, transform.ZAxis );

                float radius = ( float )( ( UniUnits.Metres.FromUniUnits( planet.Radius ) * scale ) / TerrainPatch.PlanetRadius );
                Graphics.Renderer.Scale( TransformType.LocalToWorld, radius, radius, radius );
            }

            m_PlanetTerrainTechnique.Effect.Parameters[ "TerrainSampler" ].Set( planetTerrainTexture );

            m_Builder.BeginPatchRendering( );
            context.ApplyTechnique( m_PlanetTerrainTechnique, RenderPatches );
            m_Builder.EndPatchRendering( );

            //	Graphics.Renderer.PushRenderState( m_PatchRenderState );
            //	Graphics.Renderer.PopRenderState( );
            Graphics.Renderer.PopTransform( TransformType.LocalToWorld );
        }
        private static SolarSystem CreateSolarSystem( UniPoint3 initialViewPos )
        {
            SolarSystem system = new SolarSystem( );

            SpherePlanet planet = new SpherePlanet( null, "TEST0", 80000.0 );
            initialViewPos.Z = planet.Radius + UniUnits.Metres.ToUniUnits( 10000 );
            //SpherePlanet moon = new SpherePlanet( new CircularOrbit( planet, 1600000.0, TimeSpan.FromSeconds( 60 ) ), "TEST1", 30000.0f );
            //SpherePlanet moon1 = new SpherePlanet( new CircularOrbit( moon, 500000.0, TimeSpan.FromSeconds( 60 ) ), "TEST2", 100000.0f );
            //moon.Moons.Add( moon1 );
            //planet.Moons.Add( moon );

            system.Planets.Add( planet );
            //system.Planets.Add( moon );
            //system.Planets.Add( moon1 );

            return system;
        }