Beispiel #1
0
        protected override void InitializeGame()
        {
            System.Windows.Forms.Cursor.Hide();

            renderer.ProjectionMode = ProjectionMode.Orthogonal;
            renderer.ViewMatrix = Matrix.LookAtLH( new Vector3( 0, 0, -5.0f ), new Vector3(), new Vector3( 0, 1, 0 ) );
            renderer.Device.RenderState.Lighting = false;

            showFPS = config.GetSetting<bool>( "ShowFPS" );

            fpsFont = renderer.CreateFont( "Arial", 16 );
            fpsFont.ShadowColor = Color.Gray;

            cursor = new Cursor( renderer, "cursor", new Size( 10, 10 ) );

            useBloom = config.GetSetting<bool>( "UseBloom" );

            sceneTex = new Gas.Graphics.Texture( renderer, renderer.FullscreenSize.Width, renderer.FullscreenSize.Height,
                true );
            bloomProcessor = new BloomPostProcessor( renderer );
            bloomProcessor.Blur = config.GetSetting<float>( "BloomBlur" );
            bloomProcessor.BloomScale = config.GetSetting<float>( "BloomScale" );
            bloomProcessor.BrightPassThreshold = config.GetSetting<float>( "BloomBrightPassThreshold" );

            cursorInfluenceMagnitude = config.GetSetting<int>( "CursorInfluenceMagnitude" );

            InitializeGrid();

            this.KeyDown += new KeyEventHandler( OnKeyDown );
        }
Beispiel #2
0
        protected override void InitializeGame()
        {
            this.Icon = new Icon(Application.StartupPath + @"\GasIcon.ico");
            Cursor.Hide();

            useBloom = config.GetSetting<bool>("UseBloom");

            renderer.ProjectionMode = ProjectionMode.Orthogonal;
            renderer.ViewMatrix = Matrix.LookAtLH(new Vector3(0, 0, 5.0f), new Vector3(),
                new Vector3(0, 1, 0));

            font = new Gas.Graphics.Font(renderer, "Arial", 16);
            font.ShadowColor = Color.Red;

            sceneImage = new Texture(renderer, renderer.FullscreenSize.Width, renderer.FullscreenSize.Height,
                true);
            bloomProcessor = new BloomPostProcessor(renderer);
            bloomProcessor.BloomScale = config.GetSetting<float>("BloomScale");
            bloomProcessor.Blur = config.GetSetting<float>("Blur");
            bloomProcessor.BrightPassThreshold = config.GetSetting<float>("BrightPassThreshold");

            sceneGraph = new SceneGraph(renderer);

            string lightColorName = config.GetSetting<string>("LightColor");
            Color lightColor = Color.FromName(lightColorName);
            light = new LightNode(renderer, sceneGraph, Matrix.Identity, 250.0f, 1.0f, lightColor);

            backgroundQuad = new GeometryNode(renderer, sceneGraph, Matrix.Translation(0.0f, 0.0f, -1.0f),
                Mesh.Rectangle(renderer, Color.Black, renderer.FullscreenSize.Width,
                renderer.FullscreenSize.Height, 2.0f), "roughWall");

            waterMesh = new GeometryNode(renderer, sceneGraph, Matrix.Translation(0.0f, 0.0f, 0.0f),
                Mesh.Circle(renderer, Color.Black, 500, 64, 1.0f), "water");

            object1 = new GeometryNode(renderer, sceneGraph, Matrix.Translation(0.0f, 0.0f, 1.0f),
                Mesh.Circle(renderer, Color.Blue, 85, 12), "stones");
            object2 = new GeometryNode(renderer, sceneGraph, Matrix.Identity,
                Mesh.Circle(renderer, Color.Blue, 65, 8), "stones");
            object3 = new GeometryNode(renderer, sceneGraph, Matrix.Identity,
                Mesh.Circle(renderer, Color.Blue, 25, 6), "stones");

            sceneGraph.Root.AddChild(backgroundQuad);
            sceneGraph.Root.AddChild(waterMesh);
            sceneGraph.Root.AddChild(object1);
            object1.AddChild(object2);
            object1.AddChild(light);
            object2.AddChild(object3);

            this.KeyDown += new KeyEventHandler(OnKeyDown);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the BloomPostProcessor.
        /// </summary>
        public BloomPostProcessor( Renderer renderer )
        {
            if ( renderer == null )
                throw new ArgumentNullException( "renderer", "Can't create the BloomPostProcessor with a "
                    + "null Renderer reference." );

            this.renderer = renderer;

            brightPassTex = new Texture( renderer, renderer.FullscreenSize.Width / 2,
                renderer.FullscreenSize.Height / 2, true );
            blurHorizontalTex = new Texture( renderer, renderer.FullscreenSize.Width / 2,
                renderer.FullscreenSize.Height / 2, true );
            blurVerticalTex = new Texture( renderer, renderer.FullscreenSize.Width / 2,
                renderer.FullscreenSize.Height / 2, true );
            finalBloomImage = new Texture( renderer, renderer.FullscreenSize.Width,
                renderer.FullscreenSize.Height, true );

            fullscreenQuad = Mesh.Rectangle( renderer, Color.Black, renderer.FullscreenSize.Width,
                renderer.FullscreenSize.Height );

            bloomEffect = GlobalResourceCache.CreateEffectFromFile( renderer,
                @".\\FXFiles\\Bloom.fx" );
        }
Beispiel #4
0
 public void SetValue( string name, Texture val )
 {
     effect.SetValue( GetHandle( name ), val.D3DTexture );
 }
Beispiel #5
0
            private void CreateTextSurface( string text )
            {
                Material textMat = new Material( renderer );
                textMat.VisualEffectName = "lighting";

                Texture textTex = new Texture( renderer, pressedSurf.Size.Width, pressedSurf.Size.Height,
                    true );

                renderer.SaveRenderTarget();
                textTex.SetAsRenderTarget();
                renderer.Clear( Microsoft.DirectX.Direct3D.ClearFlags.Target, Color.FromArgb( 0, 0, 0, 0 ),
                    1.0f, 0 );

                renderer.Begin( null );
                font.RenderTextCentered( new Vector2( pressedSurf.Size.Width / 2, pressedSurf.Size.Height / 2 ),
                    text, Color.White, false );
                renderer.End();

                renderer.RestoreRenderTarget();

                textMat.Textures[ 0 ] = textTex;
                renderer.AddMaterial( textMat, typeof( Button ).ToString() + ". Text: " + text );

                textSurf = new Surface( renderer, typeof( Button ).ToString() + ". Text: " + text,
                    pressedSurf.Size );
            }
Beispiel #6
0
        public static void Initialize( Renderer renderer )
        {
            ShadowManager.renderer = renderer;

            blur = config.GetSetting<float>( "ShadowBlur" );

            shadowTex = new Texture( renderer, renderer.FullscreenSize.Width / 2,
                renderer.FullscreenSize.Height / 2, true );
            blurHorizontalTex = new Texture( renderer, renderer.FullscreenSize.Width / 2,
                renderer.FullscreenSize.Height / 2, true );
            blurVerticalTex = new Texture( renderer, renderer.FullscreenSize.Width / 2,
                renderer.FullscreenSize.Height / 2, true );
            finalTex = new Texture( renderer, renderer.FullscreenSize.Width,
                renderer.FullscreenSize.Height, true );

            fullscreenQuad = Mesh.Rectangle( renderer, Color.Black, renderer.FullscreenSize.Width,
                renderer.FullscreenSize.Height );

            shadowEffect = GlobalResourceCache.CreateEffectFromFile( renderer,
                @".\\FXFiles\\Shadow.fx" );

            initialized = true;
        }
Beispiel #7
0
 /// <summary>
 /// Binds a texture to an Effect parameter.
 /// </summary>
 public void BindTexture( string effectParameterName, Texture texture )
 {
     if ( currentEffect != null )
         currentEffect.SetValue( effectParameterName, texture );
 }
Beispiel #8
0
        /// <summary>
        /// Create a texture from a file. If the texture has already been created, the cached
        /// version is returned.
        /// </summary>
        public static Texture CreateTextureFromFile( Renderer renderer, string filename )
        {
            // Search cache first
            foreach ( string cachedFilename in textureCache.Keys )
            {
                if ( StringHelper.CaseInsensitiveCompare( cachedFilename, filename ) )
                    return textureCache[ cachedFilename ] as Texture;
            }

            Texture newTex = new Texture( renderer, filename );

            textureCache.Add( filename, newTex );

            return newTex;
        }