/// <summary>
 /// Default constructor
 /// </summary>
 public SpherePlanetAtmosphereRenderer( )
 {
     //	Load in atmosphere effect
     m_Effect = new EffectAssetHandle( "Effects/Planets/atmosphereShell.cgfx", true );
     m_Effect.OnReload += Effect_OnReload;
     m_Techniques = new TechniqueSelector( m_Effect, "DefaultTechnique" );
 }
        /// <summary>
        /// Default constructor
        /// </summary>
        public SpherePlanetCloudRenderer( )
        {
            EffectAssetHandle effect = new EffectAssetHandle( "Effects/Planets/cloudLayer.cgfx", true );
            effect.OnReload += Effect_OnReload;

            m_Technique = new TechniqueSelector( effect, "DefaultTechnique" );
        }
        /// <summary>
        /// Setup constructor
        /// </summary>
        public SpherePlanetSimpleCloudShellRenderer( string effectPath )
        {
            EffectAssetHandle effect = new EffectAssetHandle( effectPath, true );
            //	effect.OnReload += Effect_OnReload;
            m_Technique = new TechniqueSelector( effect, "DefaultTechnique" );

            m_TextureBuilder = new CloudCubeMapTextureBuilder( );
        }
        /// <summary>
        /// Setup constructor
        /// </summary>
        public PlanetSurface( float radius )
        {
            Graphics.Draw.StartCache( );
            Graphics.Draw.Sphere( Graphics.Draw.NewSurface( Color.OliveDrab ), Point3.Origin, radius, 100, 100 );
            m_Geometry = Graphics.Draw.StopCache( );

            m_Technique = new TechniqueSelector( "Shared/diffuseLit.cgfx", true, "DefaultTechnique" );
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="planet">Planet to render</param>
 /// <param name="effectPath">Path to the terrain effect</param>
 public PlanetPackTextureTechnique( IPlanet planet, string effectPath )
 {
     Arguments.CheckNotNull( planet, "planet" );
     Arguments.CheckNotNullOrEmpty( effectPath, "effectPath" );
     m_Planet = planet;
     m_NoiseTexture = ( ITexture2d )AssetManager.Instance.Load( "Terrain/TiledNoise.noise.jpg" );
     m_Effect = new EffectAssetHandle( effectPath, true );
     m_Effect.OnReload += Effect_OnReload;
     m_Technique = new TechniqueSelector( m_Effect, "DefaultTechnique" );
 }
        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( );
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public SpherePlanetReflectiveOceanRenderer( string effectPath, string waterAnimationPath )
        {
            Arguments.CheckNotNullOrEmpty( effectPath, "effectPath" );
            Arguments.CheckNotNull( waterAnimationPath, "waterAnimationPath" );

            m_Effect = new EffectAssetHandle( effectPath, true );
            m_Technique = new TechniqueSelector( m_Effect, "DefaultTechnique" );

            using ( WaveAnimation animation = ( WaveAnimation )AssetManager.Instance.Load( waterAnimationPath ) )
            {
                m_WaveAnimation = new AnimatedTexture2d( animation.ToTextures( true ), 5.0f );
            }
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public SpherePlanetOceanRenderer( )
        {
            m_Effect = new EffectAssetHandle( "Effects/Planets/sphereOcean.cgfx", true );
            m_Effect.OnReload += Effect_OnReload;

            m_Technique = new TechniqueSelector( m_Effect, "DefaultTechnique" );

            using ( WaveAnimation animation = ( WaveAnimation )AssetManager.Instance.Load( "Ocean/SimpleWater.waves.bin" ) )
            {
                m_WaveAnimation = new AnimatedTexture2d( animation.ToTextures( true ), 5.0f );
            }

            //	Generate cached sphere for rendering the planet
            Graphics.Draw.StartCache( );
            Graphics.Draw.Sphere( null, Point3.Origin, 10.0f, 80, 80 );
            m_OceanGeometry = Graphics.Draw.StopCache( );
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        public SpherePlanetOceanRenderer( string effectPath, string waterAnimationPath )
        {
            Arguments.CheckNotNull( effectPath, "effectPath" );
            Arguments.CheckNotNull( waterAnimationPath, "waterAnimationPath" );

            m_Effect = new EffectAssetHandle( effectPath, true );
            //	m_Effect.OnReload += Effect_OnReload;

            m_Technique = new TechniqueSelector( m_Effect, "DefaultTechnique" );

            using ( WaveAnimation animation = ( WaveAnimation )AssetManager.Instance.Load( waterAnimationPath ) )
            {
                m_WaveAnimation = new AnimatedTexture2d( animation.ToTextures( true ), 5.0f );
            }

            //	Generate cached sphere for rendering the planet
            Graphics.Draw.StartCache( );
            Graphics.Draw.Sphere( null, Point3.Origin, 10.0f, 80, 80 );
            m_OceanGeometry = Graphics.Draw.StopCache( );
        }
        public TerrainVisualiserControl( )
        {
            InitializeComponent( );
            m_Texture = RbGraphics.Factory.CreateTexture2d( );

            IEffect effect = ( IEffect )AssetManager.Instance.Load( @"Effects\Planets\TerrainVisualiser.cgfx" );
            m_Technique = new TechniqueSelector( effect, "ShowTerrainPropertiesTechnique" );

            terrainDisplay.OnRender += RenderTerrain;

            resolutionComboBox.Items.Add( "Fit to window" );
            resolutionComboBox.Items.Add( 2048 );
            resolutionComboBox.Items.Add( 1024 );
            resolutionComboBox.Items.Add( 512 );
            resolutionComboBox.Items.Add( 256 );
            resolutionComboBox.Items.Add( 128 );
            resolutionComboBox.Items.Add( 64 );
            resolutionComboBox.Items.Add( 32 );
            resolutionComboBox.Items.Add( 16 );
            resolutionComboBox.Items.Add( 8 );
            resolutionComboBox.Items.Add( 4 );
            resolutionComboBox.SelectedIndex = 0;
        }
 /// <summary>
 /// Called when the terrain effect is reloaded
 /// </summary>
 private void Effect_OnReload( ISource source )
 {
     m_Technique = new TechniqueSelector( m_Effect.Asset, m_Technique.Name );
 }
 /// <summary>
 /// Called when the atmosphere effect is reloaded
 /// </summary>
 private void Effect_OnReload( Rb.Assets.Interfaces.ISource obj )
 {
     m_Techniques = new TechniqueSelector( m_Effect.Asset, m_Techniques.Name );
 }
 /// <summary>
 /// Default constructor
 /// </summary>
 public SpherePlanetAtmosphereScatteringRenderer( )
 {
     //	Load in atmosphere effect
     m_Techniques = new TechniqueSelector( "Effects/Planets/atmosphereShell.cgfx", true, "DefaultTechnique" );
 }
 /// <summary>
 /// Setup constructor
 /// </summary>
 public SpherePlanetHomogenousProceduralMarbleRenderer( )
 {
     m_TextureBuilder = new SpherePlanetMarbleTextureBuilder( );
     IEffect effect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/marbleSpherePlanet.cgfx" );
     m_Technique = new TechniqueSelector( effect, "DefaultTechnique" );
 }
        public PlanetTerrainRenderer( )
        {
            IEffect effect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/terrestrialPlanetTerrain.cgfx" );
            TechniqueSelector selector = new TechniqueSelector( effect, "DefaultTechnique" );

            m_PlanetTerrainTechnique = selector;

            float hDim = 1;
            Point3[] cubePoints = new Point3[]
                {
                    new Point3( -hDim, -hDim, -hDim ),
                    new Point3( +hDim, -hDim, -hDim ),
                    new Point3( +hDim, +hDim, -hDim ),
                    new Point3( -hDim, +hDim, -hDim ),

                    new Point3( -hDim, -hDim, +hDim ),
                    new Point3( +hDim, -hDim, +hDim ),
                    new Point3( +hDim, +hDim, +hDim ),
                    new Point3( -hDim, +hDim, +hDim ),
                };
            int res = 3;
            int defaultLodLevel = 0;
            CubeSide[] sides = new CubeSide[ ]
                {
                    new CubeSide( res, cubePoints[ 0 ], cubePoints[ 1 ], cubePoints[ 3 ], defaultLodLevel, true ),	//	-z
                    new CubeSide( res, cubePoints[ 7 ], cubePoints[ 6 ], cubePoints[ 4 ], defaultLodLevel, true ),	//	+z
                    new CubeSide( res, cubePoints[ 4 ], cubePoints[ 5 ], cubePoints[ 0 ], defaultLodLevel, true ),	//	+y
                    new CubeSide( res, cubePoints[ 6 ], cubePoints[ 7 ], cubePoints[ 2 ], defaultLodLevel, true ),	//	-y
                    new CubeSide( res, cubePoints[ 0 ], cubePoints[ 3 ], cubePoints[ 4 ], defaultLodLevel, true ),	//	-x
                    new CubeSide( res, cubePoints[ 5 ], cubePoints[ 6 ], cubePoints[ 1 ], defaultLodLevel, true )		//	+x
                };

            foreach ( CubeSide side in sides )
            {
                side.PreBuild( m_Builder );
                foreach ( TerrainPatch patch in side.TerrainPatches )
                {
                    m_Patches.Add( patch );
                }
            }

            //	Arrange patches in a spiral, with the centre patch on side -y at position 0
            //int ringSize = 1;
            //CubeSide bottomSide = sides[ 3 ];
            //for ( int offsetFromCentre = 0; offsetFromCentre < res; ++offsetFromCentre )
            //{
            //    if ( offsetFromCentre == 0 )
            //    {
            //        continue;
            //    }
            //    int start = ( res / 2 ) - offsetFromCentre;

            //    ringSize += 2;
            //}

            //int[] cubeSides = new int[]
            //    {
            //        0, 1, 3,	//	-z
            //        7, 6, 4,	//	+z
            //        4, 5, 0,	//	+y
            //        6, 7, 2,	//	-y
            //        0, 3, 4,	//	-x
            //        5, 6, 1		//	+x
            //    };
            //int[] sideConnections = new int[]
            //    {
            //    //	Left	Top		Right	Bottom
            //        4,		2,		5,		3,		//	Side 0 (-z)
            //    //	0,		0,		0,		0,		//	Side 1 (+z)
            //    //	0,		0,		0,		0,		//	Side 2 (+y)
            //    //	0,		0,		0,		0,		//	Side 3 (-y)
            //    //	0,		0,		0,		0,		//	Side 4 (-x)
            //    //	0,		0,		0,		0,		//	Side 5 (+x)
            //    };

            //	for ( int side = 0; side < cubeSides.Length / 3; ++side )
            //for ( int side = 0; side < 1; ++side )
            //{
            //    CubeSide leftSide	= sides[ sideConnections[ side * 4 ] ];
            //    CubeSide topSide	= sides[ sideConnections[ side * 4 + 1 ] ];
            //    CubeSide rightSide	= sides[ sideConnections[ side * 4 + 2 ] ];
            //    CubeSide bottomSide	= sides[ sideConnections[ side * 4 + 3 ] ];

            //    sides[ side ].Link( leftSide, topSide, rightSide, bottomSide );
            //}

            foreach ( CubeSide side in sides )
            {
                side.Build( m_Builder );
            }

            m_PatchRenderState = Graphics.Factory.CreateRenderState( );
            m_PatchRenderState.DepthTest = true;
            m_PatchRenderState.DepthWrite = true;
            m_PatchRenderState.CullBackFaces = true;
            m_PatchRenderState.FaceRenderMode = PolygonRenderMode.Lines;
        }
 /// <summary>
 /// Setup constructor
 /// </summary>
 public SpherePlanetMarbleRenderer( ISpherePlanetMarbleTextureBuilder textureBuilder )
 {
     m_TextureBuilder = textureBuilder;
     IEffect effect = ( IEffect )AssetManager.Instance.Load( "Effects/Planets/marbleSpherePlanet.cgfx" );
     m_Technique = new TechniqueSelector( effect, "DefaultTechnique" );
 }