예제 #1
0
            public void DrawIntoTexture(Helpers.ZBufferedTexture Texture, CellStruct StartXY, PAL tmpPalette, int zIndex = 0)
            {
                var fw = (int)Width;
                var fh = (int)Height;

                if (fw * fh != ProcessedBytes.Length)
                {
                    throw new InvalidDataException("Frame does not decompress to the right amount of bytes");
                }

                for (var y = 0; y < fh; ++y)
                {
                    for (var x = 0; x < fw; ++x)
                    {
                        var ixPix = y * fw + x;
                        var ixClr = ProcessedBytes[ixPix];
                        var clr   = PAL.TranslucentColor;
                        if (ixClr != 0)
                        {
                            clr = tmpPalette.Colors[ixClr];
                        }
                        Texture.PutPixel(clr, StartXY.X + x, StartXY.Y + y, zIndex);
                    }
                }
            }
예제 #2
0
파일: TMP.cs 프로젝트: johnson2heng/cncpp
 internal void Highlight(Helpers.ZBufferedTexture tex, CellStruct TopLeft)
 {
     for (var y = 0; y < TileHeight; ++y)
     {
         var l = FirstPixelInRow(y);
         var r = TileWidth - l;
         tex.PutPixel(Color.Red, TopLeft.X + l, TopLeft.Y + y, Int32.MaxValue);
         tex.PutPixel(Color.Red, TopLeft.X + r, TopLeft.Y + y, Int32.MaxValue);
     }
 }
예제 #3
0
파일: TMP.cs 프로젝트: johnson2heng/cncpp
 public Helpers.ZBufferedTexture PrepareTexture(PAL Palette)
 {
     _Texture = new Helpers.ZBufferedTexture(Bounds.Width, Bounds.Height);
     GetBaseTextureStandalone(Palette);
     if (HasExtraData)
     {
         GetExtrasTextureStandalone(Palette);
     }
     return(_Texture);
 }
예제 #4
0
        public void DrawIntoTextureTL(Helpers.ZBufferedTexture Texture, CellStruct topLeft, uint FrameIndex, PAL tmpPalette, int zIndex = 0)
        {
            if (FrameIndex > FrameHeaders.Count)
            {
                throw new InvalidOperationException(String.Format("Frame {0} is not present in this file.", FrameIndex));
            }

            var frame = FrameHeaders[(int)FrameIndex];

            frame.DrawIntoTexture(Texture, topLeft, tmpPalette, zIndex);
        }
예제 #5
0
        public override void Draw(Helpers.ZBufferedTexture Texture)
        {
            var Type = GetObjectType() as OverlayTypeClass;

            if (Type.Voxel)
            {
            }
            else
            {
                var image = Type.SHPImage.Value;
                if (image != null)
                {
                    var adjust = OverlayTypeClass.PositionAdjustment(Type.ArrayIndex);

                    var cell = GetCell();

                    var h = 2 + TacticalClass.Adjust2DYTo3DZ(Location.Z);

                    var TL = TacticalClass.Instance.Position2DOnScreen(Location);// +new CellStruct(0, 30 - TacticalClass.From3DZTo2DY(Location.Z));// +adjust;

//                    Debug.WriteLine("Drawing overlay @ {0}, {1}", TL.X, TL.Y);
                    if (Type.Tiberium)
                    {
                        var ix = OverlayToTiberium(Type.ArrayIndex);
                        if (ix != -1)
                        {
                            var OTypes = CCFactory <OverlayTypeClass, OverlayClass> .Get().FactoryItems;

                            var tib = TiberiumClass.All[ix];
                            OverlayTypeClass tOverlay;
                            if (cell.Slope != 0)
                            {
                                tOverlay = OTypes[tib.NumImages + tib.NumExtraImages / 4 * (cell.Slope - 1) + tib.Overlay.ArrayIndex];
                            }
                            else
                            {
                                tOverlay = OTypes[tib.Overlay.ArrayIndex + cell.X * cell.Y % tib.NumImages];
                            }
                            tOverlay.SHPImage.Value.DrawIntoTextureBL(Texture, TL, (uint)cell.OverlayState, MapTheater.TemperatePAL, h);
                        }
                    }
                    else if (Type.Wall)
                    {
                        var tp = cell.TacticalPosition;
//                        Debug.WriteLine("Drawing overlay @ {0},{1}", tp.X, tp.Y);
                        image.DrawIntoTextureBL(Texture, TL, (uint)cell.OverlayState, MapTheater.unitPAL, h);
                    }
                    else
                    {
                        image.DrawIntoTextureBL(Texture, TL, 0, MapTheater.isoPAL, h);
                    }
                }
            }
        }
예제 #6
0
        public void GetTexture(uint FrameIndex, ref Helpers.ZBufferedTexture resultTexture)
        {
            if (Palette == null)
            {
                throw new InvalidOperationException("Cannot create texture without a palette.");
            }
            if (FrameIndex > FrameHeaders.Count)
            {
                throw new InvalidOperationException(String.Format("Frame {0} is not present in this file.", FrameIndex));
            }

            var frame = FrameHeaders[(int)FrameIndex];
            var fw    = (int)frame.Width;
            var fh    = (int)frame.Height;

            int hw = fw * fh;

            if (hw != frame.ProcessedBytes.Length)
            {
                throw new InvalidDataException("Frame does not decompress to the right amount of bytes");
            }

            if (resultTexture == null)
            {
                resultTexture = new Helpers.ZBufferedTexture((int)frame.X + fw, (int)frame.Y + fh);
            }
            else
            {
                resultTexture.Clear();
            }

            for (var y = 0; y < fh; ++y)
            {
                for (var x = 0; x < fw; ++x)
                {
                    var   ix = frame.ProcessedBytes[y * fw + x];
                    Color c;
                    if (ix == 0)
                    {
                        c = PAL.TranslucentColor;
                    }
                    else
                    {
                        c = Palette.Colors[ix];
                    }
                    resultTexture.PutPixel(c, (int)frame.X + x, (int)frame.Y + y, 0);
                }
            }
        }
예제 #7
0
        public void DrawIntoTextureBL(Helpers.ZBufferedTexture Texture, CellStruct BottomLeft, uint FrameIndex, PAL tmpPalette, int zIndex = 0)
        {
            if (FrameIndex > FrameHeaders.Count)
            {
                throw new InvalidOperationException(String.Format("Frame {0} is not present in this file.", FrameIndex));
            }

            var frame = FrameHeaders[(int)FrameIndex];

            var fh = (int)frame.Height;

            var startX = (int)(BottomLeft.X);
            var startY = (int)(BottomLeft.Y - fh);

            frame.DrawIntoTexture(Texture, new CellStruct(startX, startY), tmpPalette, zIndex);
        }
예제 #8
0
        public virtual void Draw(Helpers.ZBufferedTexture Texture)
        {
            var Type = GetObjectType();

            if (Type.Voxel)
            {
            }
            else
            {
                var image = Type.SHPImage.Value;
                if (image != null)
                {
                    var center = GetCell().TacticalPosition;
                    image.DrawIntoTexture(Texture, center, 0, MapTheater.unitPAL);
                }
            }
        }
예제 #9
0
파일: TMP.cs 프로젝트: DCoderLT/cncpp
 public Helpers.ZBufferedTexture PrepareTexture(PAL Palette)
 {
     _Texture = new Helpers.ZBufferedTexture(Bounds.Width, Bounds.Height);
     GetBaseTextureStandalone(Palette);
     if (HasExtraData) {
         GetExtrasTextureStandalone(Palette);
     }
     return _Texture;
 }
예제 #10
0
파일: SHP.cs 프로젝트: DCoderLT/cncpp
        public void GetTexture(uint FrameIndex, ref Helpers.ZBufferedTexture resultTexture)
        {
            if (Palette == null) {
                throw new InvalidOperationException("Cannot create texture without a palette.");
            }
            if (FrameIndex > FrameHeaders.Count) {
                throw new InvalidOperationException(String.Format("Frame {0} is not present in this file.", FrameIndex));
            }

            var frame = FrameHeaders[(int)FrameIndex];
            var fw = (int)frame.Width;
            var fh = (int)frame.Height;

            int hw = fw * fh;

            if (hw != frame.ProcessedBytes.Length) {
                throw new InvalidDataException("Frame does not decompress to the right amount of bytes");
            }

            if (resultTexture == null) {
                resultTexture = new Helpers.ZBufferedTexture((int)frame.X + fw, (int)frame.Y + fh);
            } else {
                resultTexture.Clear();
            }

            for (var y = 0; y < fh; ++y) {
                for (var x = 0; x < fw; ++x) {
                    var ix = frame.ProcessedBytes[y * fw + x];
                    Color c;
                    if (ix == 0) {
                        c = PAL.TranslucentColor;
                    } else {
                        c = Palette.Colors[ix];
                    }
                    resultTexture.PutPixel(c, (int)frame.X + x, (int)frame.Y + y, 0);
                }
            }
        }