private void UserControlForm_Shown(object sender, EventArgs e)          // as launched, it may not be in front (as its launched from a control).. bring to front
        {
            //System.Diagnostics.Debug.WriteLine("UCF Shown+");
            this.BringToFront();

            if (IsTransparencySupported)
            {
                TransparentMode = (TransparencyMode)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(DBRefName + "Transparent", deftransparent ? (int)TransparencyMode.On : (int)TransparencyMode.Off);
            }

            bool wantedTopMost = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool(DBRefName + "TopMost", deftopmost);

            //kludge
            SetTopMost(wantedTopMost);
            SetTopMost(!wantedTopMost);
            SetTopMost(wantedTopMost); // this also establishes transparency

            var top = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt(DBRefName + "Top", -999);

            //System.Diagnostics.Debug.WriteLine("Position Top is {0} {1}", dbrefname, top);

            if (UserControl != null)
            {
                System.Diagnostics.Debug.WriteLine("UCCB Call set curosr, load layout, initial display");
                UserControl.SetCursor(UserControl.discoveryform.PrimaryCursor);
                UserControl.LoadLayout();
                UserControl.InitialDisplay();
            }

            IsLoaded = true;
            //System.Diagnostics.Debug.WriteLine("UCF Shown-");
        }
Esempio n. 2
0
        private void SetupTransparencyMode()
        {
            // Reset shader keywords
            material.DisableKeyword("_ALPHATEST_ON");        // Cut Out Transparency
            material.DisableKeyword("_ALPHABLEND_ON");       // Fade Transparency
            material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); // Transparent

            TransparencyMode transparencyMode = (TransparencyMode)model.transparencyMode;

            if (transparencyMode == TransparencyMode.AUTO)
            {
                if (!string.IsNullOrEmpty(model.alphaTexture) || model.albedoColor.a < 1f) //AlphaBlend
                {
                    transparencyMode = TransparencyMode.ALPHA_BLEND;
                }
                else // Opaque
                {
                    transparencyMode = TransparencyMode.OPAQUE;
                }
            }

            switch (transparencyMode)
            {
            case TransparencyMode.OPAQUE:
                material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Geometry;
                material.SetFloat(ShaderUtils.AlphaClip, 0);
                break;

            case TransparencyMode.ALPHA_TEST:     // ALPHATEST
                material.EnableKeyword("_ALPHATEST_ON");

                material.SetInt(ShaderUtils.SrcBlend, (int)UnityEngine.Rendering.BlendMode.One);
                material.SetInt(ShaderUtils.DstBlend, (int)UnityEngine.Rendering.BlendMode.Zero);
                material.SetInt(ShaderUtils.ZWrite, 1);
                material.SetFloat(ShaderUtils.AlphaClip, 1);
                material.SetFloat(ShaderUtils.Cutoff, model.alphaTest);
                material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.AlphaTest;
                break;

            case TransparencyMode.ALPHA_BLEND:     // ALPHABLEND
                material.EnableKeyword("_ALPHABLEND_ON");

                material.SetInt(ShaderUtils.SrcBlend, (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
                material.SetInt(ShaderUtils.DstBlend, (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                material.SetInt(ShaderUtils.ZWrite, 0);
                material.SetFloat(ShaderUtils.AlphaClip, 0);
                material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
                break;

            case TransparencyMode.ALPHA_TEST_AND_BLEND:
                material.EnableKeyword("_ALPHAPREMULTIPLY_ON");

                material.SetInt(ShaderUtils.SrcBlend, (int)UnityEngine.Rendering.BlendMode.One);
                material.SetInt(ShaderUtils.DstBlend, (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                material.SetInt(ShaderUtils.ZWrite, 0);
                material.SetFloat(ShaderUtils.AlphaClip, 1);
                material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
                break;
            }
        }
Esempio n. 3
0
        private void UserControlForm_Shown(object sender, EventArgs e)          // as launched, it may not be in front (as its launched from a control).. bring to front
        {
            this.BringToFront();

            if (IsTransparencySupported)
            {
                transparentmode = (TransparencyMode)SQLiteDBClass.GetSettingInt(dbrefname + "Transparent", deftransparent ? (int)TransparencyMode.On : (int)TransparencyMode.Off);
            }

            bool wantedTopMost = SQLiteDBClass.GetSettingBool(dbrefname + "TopMost", deftopmost);

            //kludge
            SetTopMost(wantedTopMost);
            SetTopMost(!wantedTopMost);
            SetTopMost(wantedTopMost); // this also establishes transparency

            var top = SQLiteDBClass.GetSettingInt(dbrefname + "Top", -999);

            //System.Diagnostics.Debug.WriteLine("Position Top is {0} {1}", dbrefname, top);

            if (UserControl != null)
            {
                UserControl.SetCursor(UserControl.discoveryform.PrimaryCursor);
                UserControl.LoadLayout();
                UserControl.InitialDisplay();
            }

            IsLoaded = true;
        }
 public void SetTransparency(TransparencyMode t)
 {
     if (IsTransparencySupported)
     {
         TransparentMode = t;
         UpdateTransparency();
         EliteDangerousCore.DB.UserDatabase.Instance.PutSettingInt(DBRefName + "Transparent", (int)TransparentMode);
     }
 }
Esempio n. 5
0
 public void SetTransparency(TransparencyMode t)
 {
     if (IsTransparencySupported)
     {
         transparentmode = t;
         UpdateTransparency();
         SQLiteDBClass.PutSettingInt(dbrefname + "Transparent", (int)transparentmode);
     }
 }
Esempio n. 6
0
        public static Bitmap Tilemap(ITilemap <TileInfo> tilemap, ITileset <Tile> tileset, Palette palette,
                                     TransparencyMode transparency)
        {
            CheckConsistentTileSizes(tilemap, tileset);
            var bitmap = new Bitmap(tilemap.Width * tilemap.TileWidth, tilemap.Height * tilemap.TileHeight,
                                    PixelFormat.Format32bppArgb);

            Tilemap(tilemap, tileset, palette, bitmap, 0, 0, new Rectangle(0, 0, bitmap.Width, bitmap.Height), transparency);
            return(bitmap);
        }
Esempio n. 7
0
        public static void Tile(Tile tile, Palette palette, int subPaletteIndex, bool flipX, bool flipY,
                                int x, int y, BitmapData canvas, TransparencyMode transparency)
        {
            if (canvas.PixelFormat != PixelFormat.Format32bppArgb)
            {
                throw new InvalidOperationException("PixelFormat");
            }

            uint *startPixel   = (uint *)(canvas.Scan0) + (y * canvas.Stride / sizeof(uint)) + x;
            uint *currentPixel = startPixel;

            var drawTransparentPixelAction = CreateDrawTransparentPixelAction(transparency);

            int startIndexX = flipX ? tile.Width - 1 : 0;
            int startIndexY = flipY ? tile.Height - 1 : 0;

            int indexIncrementX = flipX ? -1 : 1;
            int indexIncrementY = flipY ? -1 : 1;

            int currentIndexY = startIndexY;

            for (int pixelY = 0; (pixelY < tile.Height) && (y + pixelY < canvas.Height); pixelY++)
            {
                if (y + pixelY >= 0)
                {
                    currentPixel = startPixel;
                    int currentIndexX = startIndexX;

                    for (int pixelX = 0; (pixelX < tile.Width) && (x + pixelX < canvas.Width); pixelX++)
                    {
                        if (x + pixelX >= 0)
                        {
                            byte colorIndex = tile[currentIndexX, currentIndexY];
                            uint color      = palette[subPaletteIndex, colorIndex].Argb;

                            if (colorIndex == 0)
                            {
                                drawTransparentPixelAction(currentPixel, color);
                            }
                            else
                            {
                                *currentPixel = color;
                            }
                        }
                        currentIndexX += indexIncrementX;
                        currentPixel++;
                    }
                }
                currentIndexY += indexIncrementY;
                startPixel    += (canvas.Stride / sizeof(uint));
            }
        }
Esempio n. 8
0
        private void panel_transparency_Click(object sender, EventArgs e) // only works if transparency is supported
        {
            inpanelshow = true;                                           // in case we go transparent, we need to make sure its on.. since it won't be on if the timer is not running

            //nasty.. but nice
#if !__MonoCS__
            transparentmode = (TransparencyMode)(((int)transparentmode + 1) % Enum.GetValues(typeof(TransparencyMode)).Length);
#else
            transparentmode = (transparentmode == TransparencyMode.Off) ? TransparencyMode.On : TransparencyMode.Off;   // no idea what happens in Mono
#endif

            SetTransparency(transparentmode);
        }
        private void panel_transparency_Click(object sender, EventArgs e) // only works if transparency is supported
        {
            inpanelshow = true;                                           // in case we go transparent, we need to make sure its on.. since it won't be on if the timer is not running

            //nasty.. but nice
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                TransparentMode = (TransparencyMode)(((int)TransparentMode + 1) % Enum.GetValues(typeof(TransparencyMode)).Length);
            }
            else
            {
                TransparentMode = (TransparentMode == TransparencyMode.Off) ? TransparencyMode.On : TransparencyMode.Off;   // no idea what happens in Mono
            }

            SetTransparency(TransparentMode);
        }
Esempio n. 10
0
        private static DrawPixelAction CreateDrawTransparentPixelAction(TransparencyMode transparency)
        {
            switch (transparency)
            {
            case TransparencyMode.DontDraw:
                return((c, p) => { });

            case TransparencyMode.DrawSolid:
                return((c, p) => *c = p);

            case TransparencyMode.DrawTransparent:
                return((c, p) => *c = 0);

            default:
                throw new ArgumentException(nameof(transparency));
            }
        }
Esempio n. 11
0
        public BeForceField(TransparencyMode mode = TransparencyMode.Auto)
        {
            //========//========//========//========//========//========//========//========
            // HACK: the transparency key glitch is no more if the program is running on a version
            //       of Windows above 8 while claiming itself is compatible with that version
            //       fortunately with Windows 8 we can do the trick via WS_EX_NOREDIRECTIONBITMAP
            //========//========//========//========//========//========//========//========
            switch (mode)
            {
            case TransparencyMode.Auto:
                var ver = Environment.OSVersion.Version;
                // NT 6.1 = Windows 7, anything above this means Windows 8 & beyond
                mode = (ver.Major > 6 || (ver.Major == 6 && ver.Minor > 1)) ? TransparencyMode.NoRedirectionBitMap : TransparencyMode.LayeredHack;
                break;

            case TransparencyMode.Opaque:
            case TransparencyMode.LayeredHack:
            case TransparencyMode.NoRedirectionBitMap:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(mode));
            }

            TransparencyMode = mode;

            //========//========//========//========//========//========//========//========
            // HACK: there is a glitch in GDI so that having R & B bytes be different value will
            //       cause the window rendering transparent but actually not transparent for hit-testing
            //       so we are exploiting this glitch to do what we want
            //========//========//========//========//========//========//========//========
            if (TransparencyMode == TransparencyMode.LayeredHack)
            {
                var bytes = new byte[3];
                var rnd   = new Random();
                rnd.NextBytes(bytes);
                if (bytes[0] == bytes[2])
                {
                    bytes[0]++;
                }
                var color = Color.FromArgb(bytes[0], bytes[1], bytes[2]);
                BackColor = TransparencyKey = color;
            }
        }
Esempio n. 12
0
        public static unsafe Region Convert(Bitmap bitmap, Color transparencyKey, TransparencyMode mode, int orignX, int orignY)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException("Bitmap", "Bitmap cannot be null!");
            }
            bool         flag       = mode == TransparencyMode.ColorKeyOpaque;
            GraphicsUnit pixel      = GraphicsUnit.Pixel;
            RectangleF   bounds     = bitmap.GetBounds(ref pixel);
            Rectangle    rect       = new Rectangle((int)bounds.Left, (int)bounds.Top, (int)bounds.Width, (int)bounds.Height);
            uint         num        = (uint)((((transparencyKey.A << 0x18) | (transparencyKey.R << 0x10)) | (transparencyKey.G << 8)) | transparencyKey.B);
            BitmapData   bitmapdata = bitmap.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            uint *       numPtr     = (uint *)bitmapdata.Scan0.ToPointer();
            int          height     = (int)bounds.Height;
            int          width      = (int)bounds.Width;
            GraphicsPath path       = new GraphicsPath();

            for (int i = 0; i < height; i++)
            {
                byte *numPtr2 = (byte *)numPtr;
                int   num5    = 0;
                while (num5 < width)
                {
                    if (!(flag ^ (numPtr[0] == num)))
                    {
                        int num6 = num5;
                        while ((num5 < width) && !(flag ^ (numPtr[0] == num)))
                        {
                            num5++;
                            numPtr++;
                        }
                        path.AddRectangle(new Rectangle(num6 + orignX, i + orignY, num5 - num6, 1));
                    }
                    num5++;
                    numPtr++;
                }
                numPtr = (uint *)(numPtr2 + bitmapdata.Stride);
            }
            Region region = new Region(path);

            path.Dispose();
            bitmap.UnlockBits(bitmapdata);
            return(region);
        }
Esempio n. 13
0
        public Texture2D GenerateAtlas(Texture2D[] sprites, string name, out SpriteImportData[] spriteData, TransparencyMode transparencyMode,
                                       bool baseTwo = true)
        {
            var cols = sprites.Length;
            var rows = 1;

            float spriteCount = sprites.Length;

            var divider = 2;

            var width  = cols * spriteSize.x;
            var height = rows * spriteSize.y;


            while (width > height)
            {
                cols = (int)Math.Ceiling(spriteCount / divider);
                rows = (int)Math.Ceiling(spriteCount / cols);

                width  = cols * spriteSize.x;
                height = rows * spriteSize.y;

                if (cols <= 1)
                {
                    break;
                }

                divider++;
            }

            if (height > width)
            {
                divider -= 2;
            }
            else
            {
                divider -= 1;
            }

            if (divider < 1)
            {
                divider = 1;
            }

            cols = (int)Math.Ceiling(spriteCount / divider);
            rows = (int)Math.Ceiling(spriteCount / cols);

            if (transparencyMode == TransparencyMode.Mask)
            {
                return(GenerateAtlas(sprites, out spriteData, cols, rows, textureSettings.transparentColor, baseTwo));
            }

            return(GenerateAtlas(sprites, name, out spriteData, cols, rows, baseTwo));
        }
Esempio n. 14
0
        private void UserControlForm_Shown(object sender, EventArgs e)          // as launched, it may not be in front (as its launched from a control).. bring to front
        {
            this.BringToFront();

            if (IsTransparencySupported)
            {
                transparentmode = (TransparencyMode)SQLiteDBClass.GetSettingInt(dbrefname + "Transparent", deftransparent ? (int)TransparencyMode.On : (int)TransparencyMode.Off);
            }

            SetTopMost(SQLiteDBClass.GetSettingBool(dbrefname + "TopMost", deftopmost)); // this also establishes transparency

            var top = SQLiteDBClass.GetSettingInt(dbrefname + "Top", -999);

            //System.Diagnostics.Debug.WriteLine("Position Top is {0} {1}", dbrefname, top);

            if (top != -999 && norepositionwindow == false)
            {
                var left   = SQLiteDBClass.GetSettingInt(dbrefname + "Left", 0);
                var height = SQLiteDBClass.GetSettingInt(dbrefname + "Height", 800);
                var width  = SQLiteDBClass.GetSettingInt(dbrefname + "Width", 800);

                System.Diagnostics.Debug.WriteLine("Position {0} {1} {2} {3} {4}", dbrefname, top, left, width, height);
                // Adjust so window fits on screen; just in case user unplugged a monitor or something

                var screen = SystemInformation.VirtualScreen;
                if (height > screen.Height)
                {
                    height = screen.Height;
                }
                if (top + height > screen.Height + screen.Top)
                {
                    top = screen.Height + screen.Top - height;
                }
                if (width > screen.Width)
                {
                    width = screen.Width;
                }
                if (left + width > screen.Width + screen.Left)
                {
                    left = screen.Width + screen.Left - width;
                }
                if (top < screen.Top)
                {
                    top = screen.Top;
                }
                if (left < screen.Left)
                {
                    left = screen.Left;
                }

                this.Top    = top;
                this.Left   = left;
                this.Height = height;
                this.Width  = width;

                this.CreateParams.X = this.Left;
                this.CreateParams.Y = this.Top;
                this.StartPosition  = FormStartPosition.Manual;
            }

            if (UserControl != null)
            {
                UserControl.LoadLayout();
            }

            isloaded = true;
        }
Esempio n. 15
0
 public void SetTransparencyMode(TransparencyMode mode)
 {
     lastTransparencyMode = TransparencyMode = mode;
 }
Esempio n. 16
0
        public override void Deserialize(string key, string value)
        {
            switch (key)
            {
            case "lgpr":
                lightPrecision = (LightPrecision)int.Parse(value);
                break;

            case "limd":
                lightMode = (LightMode)int.Parse(value);
                break;

            case "uamb":
                useAmbient = bool.Parse(value);
                break;

            case "mssp":
                maskedSpec = bool.Parse(value);
                break;

            case "bkdf":
                bakedLight = bool.Parse(value);
                break;

            case "spmd":
                specularMode = (SpecularMode)int.Parse(value);
                break;

            case "trmd":
                transparencyMode = (TransparencyMode)int.Parse(value);
                break;

            case "grmd":
                glossRoughMode = (GlossRoughMode)int.Parse(value);
                break;

            /*case "shdc":
             *      shadowCast = bool.Parse( value );
             *      break;
             * case "shdr":
             *      shadowReceive = bool.Parse( value );
             *      break;*/
            case "lico":
                lightCount = (LightCount)int.Parse(value);
                break;

            case "lmpd":
                bakedLight |= bool.Parse(value);
                break;

            case "lprd":
                bakedLight |= bool.Parse(value);
                break;

            case "hqlp":
                highQualityLightProbes = bool.Parse(value);
                break;

            case "rprd":
                reflectprobed = bool.Parse(value);
                break;

            case "enco":
                energyConserving = bool.Parse(value);
                break;


            case "rmgx":
                remapGlossExponentially = bool.Parse(value);
                break;

            case "imps":
                includeMetaPass = bool.Parse(value);
                break;

            case "rpth":
                renderPath = (RenderPath)int.Parse(value);
                break;
            }
        }
Esempio n. 17
0
        public override float DrawInner(ref Rect r)
        {
            float prevYpos = r.y;

            r.y = 0;


            r.xMin += 20;
            r.y    += 20;

            renderPath = (RenderPath)UndoableContentScaledToolbar(r, "Render Path", (int)renderPath, strRenderPath, "render path");


            if (renderPath == RenderPath.Deferred)
            {
                if (lightMode != LightMode.PBL)
                {
                    lightMode = LightMode.PBL;
                }
                if (ps.catBlending.autoSort == false)
                {
                    ps.catBlending.autoSort = true;
                }
                if (ps.catBlending.blendModePreset != BlendModePreset.Opaque)
                {
                    ps.catBlending.blendModePreset = BlendModePreset.Opaque;
                    ps.catBlending.ConformBlendsToPreset();
                }
            }
            r.y += 20;
            if (renderPath == RenderPath.Deferred)
            {
                GUI.enabled = false;
                UndoableContentScaledToolbar(r, "Light Mode", (int)LightMode.PBL, strLightMode, "light mode");
                GUI.enabled = true;
            }
            else
            {
                lightMode = (LightMode)UndoableContentScaledToolbar(r, "Light Mode", (int)lightMode, strLightMode, "light mode");
            }
            r.y += 20;

            if (IsPBL())
            {
                specularMode = (SpecularMode)UndoableContentScaledToolbar(r, "Specular Mode", (int)specularMode, strSpecularMode, "specular mode");
                r.y         += 20;
            }

            GUI.enabled    = ps.HasSpecular();
            glossRoughMode = (GlossRoughMode)UndoableContentScaledToolbar(r, "Gloss Mode", (int)glossRoughMode, strGlossRoughMode, "gloss mode");
            r.y           += 20;
            GUI.enabled    = true;

            GUI.enabled      = ps.HasAlpha();        // Has Opacity connected
            transparencyMode = (TransparencyMode)UndoableContentScaledToolbar(r, "Transparency Mode", (int)transparencyMode, strTransparencyMode, "transparency mode");
            r.y        += 20;
            GUI.enabled = true;



            if (ps.catLighting.IsPBL() == false)
            {
                UndoableConditionalToggle(r, ref remapGlossExponentially,
                                          usableIf: ps.HasGloss() && renderPath != RenderPath.Deferred,
                                          disabledDisplayValue: renderPath == RenderPath.Deferred ? true : false,
                                          label: "Remap gloss from [0-1] to " + ((renderPath == RenderPath.Deferred) ? "[0-128]" : "[1-2048]"),
                                          undoSuffix: "gloss remap"
                                          );
                r.y += 20;
            }



            if (lightMode == LightMode.Unlit || lightMode == LightMode.PBL)
            {
                GUI.enabled = false;
            }
            {
                //bool b = energyConserving;
                if (lightMode == LightMode.PBL)
                {
                    GUI.Toggle(r, true, "Energy Conserving");                       // Dummy display of a checked energy conserve
                }
                else
                {
                    energyConserving = UndoableToggle(r, energyConserving, "Energy Conserving", "energy conservation", null);
                }
                //energyConserving = GUI.Toggle( r, energyConserving, "Energy Conserving" );

                r.y        += 20;
                GUI.enabled = true;
            }


            GUI.enabled = renderPath == RenderPath.Forward;
            lightCount  = (LightCount)UndoableContentScaledToolbar(r, "Light Count", (int)lightCount, strLightCount, "light count");
            GUI.enabled = true;
            r.y        += 20;


            //lightPrecision = (LightPrecision)ContentScaledToolbar(r, "Light Quality", (int)lightPrecision, strLightPrecision ); // TODO: Too unstable for release
            //r.y += 20;


            UndoableConditionalToggle(r, ref bakedLight,
                                      usableIf:                              ps.HasDiffuse() && lightMode != LightMode.Unlit,
                                      disabledDisplayValue:  false,
                                      label:                                 "Lightmap & light probes",
                                      undoSuffix:                    "lightmap & light probes"
                                      );
            r.y += 20;


            bool wantsMetaPass = ps.catLighting.bakedLight && (ps.HasDiffuse() || ps.HasEmissive());

            UndoableConditionalToggle(r, ref includeMetaPass,
                                      usableIf: wantsMetaPass,
                                      disabledDisplayValue: false,
                                      label: "Write meta pass (light bounce coloring)",
                                      undoSuffix: "write meta pass"
                                      );
            r.y += 20;

            //includeMetaPass = UndoableToggle( r, includeMetaPass, "Write meta pass (light bounce coloring)", "write meta pass", null );
            //r.y += 20;

            highQualityLightProbes = UndoableToggle(r, highQualityLightProbes, "Per-pixel light probe sampling", "per-pixel light probe sampling", null);
            r.y += 20;



            UndoableConditionalToggle(r, ref reflectprobed,
                                      usableIf: ps.HasSpecular() && lightMode != LightMode.Unlit,
                                      disabledDisplayValue: false,
                                      label: "Reflection probe support",
                                      undoSuffix: "reflection probe support"
                                      );
            r.y += 20;



            /*shadowCast = GUI.Toggle( r, shadowCast, "Cast shadows" );
             * r.y += 20;
             * shadowReceive = GUI.Toggle( r, shadowReceive, "Receive shadows" );
             * r.y += 20;*/



            //GUI.enabled = IsLit();

            /*
             * UndoableConditionalToggle( r, ref geometricAntiAliasing,
             *                                               usableIf: ps.HasSpecular() && ps.catLighting.IsPBL(),
             *                                               disabledDisplayValue: false,
             *                                               label: "Geometric specular anti-aliasing",
             *                                               undoSuffix: "geometric specular anti-aliasing"
             *                                               );
             * r.y += 20;
             */

            UndoableConditionalToggle(r, ref useAmbient,
                                      usableIf:                              !bakedLight && ps.catLighting.IsLit(),
                                      disabledDisplayValue:  bakedLight,
                                      label:                                 "Receive Ambient Light",
                                      undoSuffix:                    "receive ambient light"
                                      );
            r.y += 20;

            /*
             * if(lightprobed){
             *      GUI.enabled = false;
             *      GUI.Toggle( r, true, "Receive Ambient Light" );
             *      GUI.enabled = true;
             * }else{
             *      useAmbient = GUI.Toggle( r, useAmbient, "Receive Ambient Light" );
             * }*/


            //r.y += 20;

            /* DISABLED DUE TO CAUSING TOO MANY ARTIFACTS
             * if(ps.catLighting.HasSpecular() && renderPath == RenderPath.Forward){
             *      maskedSpec = UndoableToggle( r, maskedSpec, "Mask directional light specular by shadows", "directional light specular shadow masking", null );
             * } else {
             *      GUI.enabled = false;
             *      GUI.Toggle( r, false, "Mask directional light specular by shadows" );
             *      GUI.enabled = true;
             * }
             * r.y += 20;*/

            r.y += prevYpos;

            return((int)r.yMax);
        }
Esempio n. 18
0
        /// <summary>
        /// the meat of this class
        /// converts the bitmap to a region by scanning each line one by one
        /// this method will not affect the original bitmap in any way
        /// </summary>
        /// <param name="bitmap">The bitmap to convert</param>
        /// <param name="transparencyKey">The color which will indicate either transparency or opacity</param>
        /// <param name="mode">Whether the transparency key should indicate the transparent or the opaque region</param>
        public static unsafe Region Convert( Bitmap bitmap, Color transparencyKey,
            TransparencyMode mode)
        {
            //sanity check
            if ( bitmap == null )
                throw new ArgumentNullException( "Bitmap", "Bitmap cannot be null!" );

            //flag = true means the color key represents the opaque color
            bool modeFlag = ( mode == TransparencyMode.ColorKeyOpaque );

            GraphicsUnit unit = GraphicsUnit.Pixel;
            RectangleF boundsF = bitmap.GetBounds( ref unit );
            Rectangle bounds = new Rectangle( (int)boundsF.Left, (int)boundsF.Top,
                (int)boundsF.Width, (int)boundsF.Height );

            uint key = (uint)((transparencyKey.A << 24) | (transparencyKey.R << 16) |
                (transparencyKey.G << 8) | (transparencyKey.B << 0));

            //get access to the raw bits of the image
            BitmapData bitmapData = bitmap.LockBits( bounds, ImageLockMode.ReadOnly,
                PixelFormat.Format32bppArgb );
            uint* pixelPtr = (uint*)bitmapData.Scan0.ToPointer();

            //avoid property accessors in the for
            int yMax = (int)boundsF.Height;
            int xMax = (int)boundsF.Width;

            //to store all the little rectangles in
            GraphicsPath path = new GraphicsPath();

            for ( int y = 0; y < yMax; y++ )
            {
                //store the pointer so we can offset the stride directly from it later
                //to get to the next line
                byte* basePos = (byte*)pixelPtr;

                for ( int x = 0; x < xMax; x++, pixelPtr++  )
                {
                    //is this transparent? if yes, just go on with the loop
                    if ( modeFlag ^ ( *pixelPtr == key ) )
                        continue;

                    //store where the scan starts
                    int x0 = x;

                    //not transparent - scan until we find the next transparent byte
                    while( x < xMax && !( modeFlag ^ ( *pixelPtr == key ) ) )
                    {
                        ++x;
                        pixelPtr++;
                    }

                    //add the rectangle we have found to the path
                    path.AddRectangle( new Rectangle( x0, y, x-x0, 1 ) );
                }
                //jump to the next line
                pixelPtr = (uint*)(basePos + bitmapData.Stride);
            }

            //now create the region from all the rectangles
            Region region = new Region( path );

            //clean up
            path.Dispose();
            bitmap.UnlockBits( bitmapData );

            return region;
        }
Esempio n. 19
0
 public static void SetSeriesTransparencyModeAll(TransparencyMode mode)
 {
     for (int i = 0; i < DataSeries.AllDataSeries.Count; i++)
         DataSeries.AllDataSeries[i].SetTransparencyMode(mode);
 }
Esempio n. 20
0
 public static DataSeries SetSeriesTransparencyMode(DataSeries series, TransparencyMode mode)
 {
     series.SetTransparencyMode(mode);
     return series;
 }
Esempio n. 21
0
 public static DataSeries SetSeriesTransparencyMode(TransparencyMode mode)
 {
     return SetSeriesTransparencyMode(GetCurrentDataSeries(), mode);
 }
Esempio n. 22
0
        /// <summary>
        /// the meat of this class
        /// converts the bitmap to a region by scanning each line one by one
        /// this method will not affect the original bitmap in any way
        /// </summary>
        /// <param name="bitmap">The bitmap to convert</param>
        /// <param name="transparencyKey">The color which will indicate either transparency or opacity</param>
        /// <param name="mode">Whether the transparency key should indicate the transparent or the opaque region</param>
        public unsafe static Region Convert(Bitmap bitmap, Color transparencyKey,
                                            TransparencyMode mode)
        {
            //sanity check
            if (bitmap == null)
            {
                throw new ArgumentNullException("Bitmap", "Bitmap cannot be null!");
            }

            //flag = true means the color key represents the opaque color
            bool modeFlag = (mode == TransparencyMode.ColorKeyOpaque);

            GraphicsUnit unit    = GraphicsUnit.Pixel;
            RectangleF   boundsF = bitmap.GetBounds(ref unit);
            Rectangle    bounds  = new Rectangle((int)boundsF.Left, (int)boundsF.Top,
                                                 (int)boundsF.Width, (int)boundsF.Height);

            uint key = (uint)((transparencyKey.A << 24) | (transparencyKey.R << 16) |
                              (transparencyKey.G << 8) | (transparencyKey.B << 0));


            //get access to the raw bits of the image
            BitmapData bitmapData = bitmap.LockBits(bounds, ImageLockMode.ReadOnly,
                                                    PixelFormat.Format32bppArgb);
            uint *pixelPtr = (uint *)bitmapData.Scan0.ToPointer();

            //avoid property accessors in the for
            int yMax = (int)boundsF.Height;
            int xMax = (int)boundsF.Width;

            //to store all the little rectangles in
            GraphicsPath path = new GraphicsPath();

            for (int y = 0; y < yMax; y++)
            {
                //store the pointer so we can offset the stride directly from it later
                //to get to the next line
                byte *basePos = (byte *)pixelPtr;

                for (int x = 0; x < xMax; x++, pixelPtr++)
                {
                    //is this transparent? if yes, just go on with the loop
                    if (modeFlag ^ (*pixelPtr == key))
                    {
                        continue;
                    }

                    //store where the scan starts
                    int x0 = x;

                    //not transparent - scan until we find the next transparent byte
                    while (x < xMax && !(modeFlag ^ (*pixelPtr == key)))
                    {
                        ++x;
                        pixelPtr++;
                    }

                    //add the rectangle we have found to the path
                    path.AddRectangle(new Rectangle(x0, y, x - x0, 1));
                }
                //jump to the next line
                pixelPtr = (uint *)(basePos + bitmapData.Stride);
            }

            //now create the region from all the rectangles
            Region region = new Region(path);

            //clean up
            path.Dispose();
            bitmap.UnlockBits(bitmapData);

            return(region);
        }
Esempio n. 23
0
        /// <summary>
        /// Handles input, and moves the point lights around
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            const float LightRotSpeed = 0.3f;

            Matrix rotMatrix = Matrix.CreateRotationY(LightRotSpeed * 2 * MathHelper.Pi * dt);

            foreach (Light light in lights)
            {
                if (light is PointLight)
                {
                    PointLight pointLight = (PointLight)light;
                    pointLight.Position = Vector3.Transform(pointLight.Position, rotMatrix);
                }
            }

            const float CamMoveSpeed = 1000.0f;
            const float CamRotSpeed  = 0.3f;
            float       slowdown     = 1.0f;

            KeyboardState kbState = Keyboard.GetState();

            if (kbState.IsKeyDown(Keys.LeftShift))
            {
                slowdown = 0.1f;
            }

            if (kbState.IsKeyDown(Keys.W))
            {
                camera.Position += camera.WorldMatrix.Forward * CamMoveSpeed * slowdown * dt;
            }
            else if (kbState.IsKeyDown(Keys.S))
            {
                camera.Position += camera.WorldMatrix.Backward * CamMoveSpeed * slowdown * dt;
            }
            if (kbState.IsKeyDown(Keys.A))
            {
                camera.Position += camera.WorldMatrix.Left * CamMoveSpeed * slowdown * dt;
            }
            else if (kbState.IsKeyDown(Keys.D))
            {
                camera.Position += camera.WorldMatrix.Right * CamMoveSpeed * slowdown * dt;
            }
            if (kbState.IsKeyDown(Keys.Q))
            {
                camera.Position += camera.WorldMatrix.Up * CamMoveSpeed * slowdown * dt;
            }
            else if (kbState.IsKeyDown(Keys.E))
            {
                camera.Position += camera.WorldMatrix.Down * CamMoveSpeed * slowdown * dt;
            }

            if (kbState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (kbState.IsKeyDown(Keys.M) && !lastKBState.IsKeyDown(Keys.M))
            {
                enableMSAA = !enableMSAA;
                CreateRenderTargets();
            }

            if (kbState.IsKeyDown(Keys.V) && !lastKBState.IsKeyDown(Keys.V))
            {
                graphics.SynchronizeWithVerticalRetrace = !graphics.SynchronizeWithVerticalRetrace;
                graphics.ApplyChanges();
            }

            if (kbState.IsKeyDown(Keys.G) && !lastKBState.IsKeyDown(Keys.G))
            {
                int size = (int)gBufferSize;
                size++;
                size        = size % Enum.GetValues(typeof(GBufferSize)).Length;
                gBufferSize = (GBufferSize)size;
                CreateRenderTargets();
            }

            if (kbState.IsKeyDown(Keys.N) && !lastKBState.IsKeyDown(Keys.N))
            {
                enableNormalMaps = !enableNormalMaps;
            }

            if (kbState.IsKeyDown(Keys.P) && !lastKBState.IsKeyDown(Keys.P))
            {
                enablePointLights = !enablePointLights;
            }

            if (kbState.IsKeyDown(Keys.T) && !lastKBState.IsKeyDown(Keys.T))
            {
                int mode = (int)transparencyMode;
                mode++;
                mode             = mode % Enum.GetValues(typeof(TransparencyMode)).Length;
                transparencyMode = (TransparencyMode)mode;
            }

            if (kbState.IsKeyDown(Keys.L) && !lastKBState.IsKeyDown(Keys.L))
            {
                if (shadowMapSize == ShadowMapSize.Size1024)
                {
                    shadowMapSize = ShadowMapSize.Size2048;
                }
                else
                {
                    shadowMapSize = ShadowMapSize.Size1024;
                }
                CreateRenderTargets();
            }

            MouseState mouseState = Mouse.GetState();
            int        moveX      = mouseState.X - lastMouseState.X;
            int        moveY      = mouseState.Y - lastMouseState.Y;

            if (mouseState.RightButton == ButtonState.Pressed)
            {
                camera.XRotation -= moveY * CamRotSpeed * dt;
                camera.YRotation -= moveX * CamRotSpeed * dt;
            }

            lastKBState    = kbState;
            lastMouseState = mouseState;

            base.Update(gameTime);
        }
Esempio n. 24
0
        public static void Tilemap(ITilemap <TileInfo> tilemap, ITileset <Tile> tileset, Palette palette,
                                   Bitmap bitmap, int x, int y, Rectangle clippingRegion, TransparencyMode transparency)
        {
            var canvas = bitmap.LockBits();

            Tilemap(tilemap, tileset, palette, canvas, x, y, clippingRegion, transparency);
            bitmap.UnlockBits(canvas);
        }
Esempio n. 25
0
        public static void Tilemap(ITilemap <TileInfo> tilemap, ITileset <Tile> tileset, Palette palette,
                                   BitmapData canvas, int x, int y, Rectangle clippingRegion, TransparencyMode transparency)
        {
            CheckConsistentTileSizes(tilemap, tileset);

            for (int tileY = 0; tileY < tilemap.Height; tileY++)
            {
                for (int tileX = 0; tileX < tilemap.Width; tileX++)
                {
                    int pixelX = x + (tileX * tilemap.TileWidth);
                    int pixelY = y + (tileY * tilemap.TileHeight);

                    var tileRect = new Rectangle(pixelX, pixelY, tilemap.TileWidth, tilemap.TileHeight);

                    if (clippingRegion.IntersectsWith(tileRect))
                    {
                        var tileInfo = tilemap[tileX, tileY];
                        var tile     = tileset[tileInfo.TileIndex];

                        Tile(tile, palette, tileInfo.PaletteIndex, tileInfo.FlipX, tileInfo.FlipY,
                             pixelX, pixelY, canvas, transparency);
                    }
                }
            }
        }
Esempio n. 26
0
        private void SetTransparencyMode(TransparencyMode trans)
        {
            offToolStripMenuItem.Checked = helmetOnlyToolStripMenuItem.Checked = allToolStripMenuItem.Checked = false;
            GlobalSettings.Transparency = trans;

            switch (GlobalSettings.Transparency)
            {
                case TransparencyMode.Off:
                    offToolStripMenuItem.Checked = true;
                    break;
                case TransparencyMode.Helmet:
                    helmetOnlyToolStripMenuItem.Checked = true;
                    break;
                case TransparencyMode.All:
                    allToolStripMenuItem.Checked = true;
                    break;
            }

            Renderer.Invalidate();
        }
 public OutputFileFormatData(string extension, TransparencyMode transparencyMode, BitDepth bits)
 {
     Extension        = extension;
     TransparencyMode = transparencyMode;
     BitDepth         = bits;
 }