Esempio n. 1
0
        private void SetupGorgon()
        {
            Gorgon.Initialize(true, false);
            Gorgon.SetMode(this);
            //Gorgon.AllowBackgroundRendering = true;
            //Gorgon.Screen.BackgroundColor = Color.FromArgb(50, 50, 50);

            //Gorgon.CurrentClippingViewport = new Viewport(0, 20, Gorgon.Screen.Width, Gorgon.Screen.Height - 20);
            //PreciseTimer preciseTimer = new PreciseTimer();
            //Gorgon.MinimumFrameTime = PreciseTimer.FpsToMilliseconds(66);
            Gorgon.Idle += new FrameEventHandler(Gorgon_Idle);
            Gorgon.FrameStatsVisible = true;

            bouncesprite = new Sprite("bouncey", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Items.png"), new Vector2D(0, 0), new Vector2D(22, 20));
            bouncesprite.SetScale(3, 3);
            decalsprite = new Sprite("decal", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Decals.png"), new Vector2D(56, 0), new Vector2D(103, 29));
            decalsprite.SetScale(1, 1);
            decalShader = FXShader.FromFile(mediadir + @"\shaders\decalshader.fx", ShaderCompileOptions.Debug);
            decalShader.Parameters["tex1"].SetValue(decalsprite.Image);

            baseTarget       = new RenderImage("baseTarget", 32, 32, ImageBufferFormats.BufferRGB888A8);
            baseTargetSprite = new Sprite("baseTargetSprite", baseTarget);

            bounceysprites = new BounceySprite[10];
            for (int i = 0; i < 10; i++)
            {
                bounceysprites[i] = new BounceySprite(bouncesprite, new Vector2D(random.Next(0, Gorgon.Screen.Width), random.Next(0, Gorgon.Screen.Height)),
                                                      new Vector2D((float)random.Next(-100000, 100000) / 100000, (float)random.Next(-100000, 100000) / 100000),
                                                      decalsprite, new Vector2D(random.Next(-10, 15), random.Next(-10, 15)), decalShader, this);
            }


            //Calculate decal texcoord offsets

            /*Vector2D decalBToffset = new Vector2D(10,5);
             * float BTXDTL_x = decalBToffset.X / bouncesprite.Image.Width;
             * float BTXDTL_y = decalBToffset.Y / bouncesprite.Image.Height;
             * float BTXDBR_x = (decalBToffset.X + decalsprite.Width)/bouncesprite.Image.Width;
             * float BTXDBR_y = (decalBToffset.Y + decalsprite.Height)/bouncesprite.Image.Height;
             * float CFx = (float)decalsprite.Image.Width/(float)bouncesprite.Image.Width;
             * float CFy = (float)decalsprite.Image.Height / (float)bouncesprite.Image.Height;
             * float DOtc_xtl = (float)decalsprite.ImageOffset.X / (float)decalsprite.Image.Width;
             * float DOtc_ytl = (float)decalsprite.ImageOffset.Y / (float)decalsprite.Image.Height;
             *
             * Vector4D decalParms1 = new Vector4D(BTXDTL_x, BTXDTL_y, BTXDBR_x, BTXDBR_y);
             * Vector4D decalParms2 = new Vector4D(CFx, CFy, DOtc_xtl, DOtc_ytl);*/
        }
Esempio n. 2
0
        private void SetupGorgon()
        {
            Gorgon.Initialize(true, false);
            Gorgon.SetMode(this);
            //Gorgon.AllowBackgroundRendering = true;
            //Gorgon.Screen.BackgroundColor = Color.FromArgb(50, 50, 50);

            //Gorgon.CurrentClippingViewport = new Viewport(0, 20, Gorgon.Screen.Width, Gorgon.Screen.Height - 20);
            //PreciseTimer preciseTimer = new PreciseTimer();
            //Gorgon.MinimumFrameTime = PreciseTimer.FpsToMilliseconds(66);
            Gorgon.Idle += new FrameEventHandler(Gorgon_Idle);
            Gorgon.FrameStatsVisible = true;

            bouncesprite = new Sprite("bouncey", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Items.png"), new Vector2D(0,0), new Vector2D(22,20));
            bouncesprite.SetScale(3, 3);
            decalsprite = new Sprite("decal", GorgonLibrary.Graphics.Image.FromFile(mediadir + @"\textures\0_Decals.png"), new Vector2D(56,0), new Vector2D(103,29));
            decalsprite.SetScale(1, 1);
            decalShader = FXShader.FromFile(mediadir + @"\shaders\decalshader.fx", ShaderCompileOptions.Debug);
            decalShader.Parameters["tex1"].SetValue(decalsprite.Image);

            baseTarget = new RenderImage("baseTarget", 32, 32, ImageBufferFormats.BufferRGB888A8);
            baseTargetSprite = new Sprite("baseTargetSprite", baseTarget);

            bounceysprites = new BounceySprite[10];
            for (int i = 0; i < 10; i++)
            {
                bounceysprites[i] = new BounceySprite(bouncesprite, new Vector2D(random.Next(0, Gorgon.Screen.Width), random.Next(0, Gorgon.Screen.Height)), 
                                        new Vector2D((float)random.Next(-100000,100000) / 100000, (float)random.Next(-100000,100000) / 100000),
                                        decalsprite, new Vector2D(random.Next(-10,15), random.Next(-10,15)), decalShader, this);
            }


            //Calculate decal texcoord offsets
            /*Vector2D decalBToffset = new Vector2D(10,5);
            float BTXDTL_x = decalBToffset.X / bouncesprite.Image.Width;
            float BTXDTL_y = decalBToffset.Y / bouncesprite.Image.Height;
            float BTXDBR_x = (decalBToffset.X + decalsprite.Width)/bouncesprite.Image.Width;
            float BTXDBR_y = (decalBToffset.Y + decalsprite.Height)/bouncesprite.Image.Height;
            float CFx = (float)decalsprite.Image.Width/(float)bouncesprite.Image.Width;
            float CFy = (float)decalsprite.Image.Height / (float)bouncesprite.Image.Height;
            float DOtc_xtl = (float)decalsprite.ImageOffset.X / (float)decalsprite.Image.Width;
            float DOtc_ytl = (float)decalsprite.ImageOffset.Y / (float)decalsprite.Image.Height;

            Vector4D decalParms1 = new Vector4D(BTXDTL_x, BTXDTL_y, BTXDBR_x, BTXDBR_y);
            Vector4D decalParms2 = new Vector4D(CFx, CFy, DOtc_xtl, DOtc_ytl);*/
        }