Ejemplo n.º 1
0
 public GNDDebug(VectorTU vecStart, VectorTU vecEnd, int coordX, int coordY, int CubeNum)
 {
     StartVector = vecStart;
     EndVector   = vecEnd;
     X           = coordX;
     Y           = coordY;
     Cubes       = CubeNum;
 }
Ejemplo n.º 2
0
        private void ModTexture(Bitmap Texture, ref Graphics g, VectorTU StartMod, VectorTU EndMod)
        {
            int startX = (int)(Texture.Width * StartMod.P1);
            int startY = (int)(Texture.Height * StartMod.P2);
            int endX   = (int)(Texture.Width * EndMod.P1);
            int endY   = (int)(Texture.Height * EndMod.P2);

            g.DrawImage(Texture, new Rectangle(startX, startY, endX, endY));
        }
Ejemplo n.º 3
0
        private unsafe VectorTU ReadVector4(BinaryReader bin)
        {
            if ((bin.BaseStream.Length - bin.BaseStream.Position) < 12)
            {
                return(VectorTU.Zero);
            }

            VectorTU vec = new VectorTU(
                bin.ReadSingle(),
                bin.ReadSingle(),
                bin.ReadSingle(),
                bin.ReadSingle()
                );

            return(vec);
        }
Ejemplo n.º 4
0
		public GNDDebug( VectorTU vecStart, VectorTU vecEnd, int coordX, int coordY, int CubeNum ) {
			StartVector = vecStart;
			EndVector = vecEnd;
			X = coordX;
			Y = coordY;
			Cubes = CubeNum;
		}
Ejemplo n.º 5
0
		private void ModTexture( Bitmap Texture, ref Graphics g, VectorTU StartMod, VectorTU EndMod ) {
			int startX = (int)( Texture.Width * StartMod.P1 );
			int startY = (int)( Texture.Height * StartMod.P2 );
			int endX = (int)( Texture.Width * EndMod.P1 );
			int endY = (int)( Texture.Height * EndMod.P2 );

			g.DrawImage( Texture, new Rectangle( startX, startY, endX, endY ) );
		}
Ejemplo n.º 6
0
		private unsafe VectorTU ReadVector4( BinaryReader bin ) {
			if( ( bin.BaseStream.Length - bin.BaseStream.Position ) < 12 )
				return VectorTU.Zero;

			VectorTU vec = new VectorTU(
				bin.ReadSingle(),
				bin.ReadSingle(),
				bin.ReadSingle(),
				bin.ReadSingle()
			);

			return vec;
		}
Ejemplo n.º 7
0
        private void DrawGND(int ScaleX, int ScaleY, bool FixxSize, bool DrawPosition)
        {
            Font   font = new Font("Aial", 6);
            Bitmap bmp  = null;

            if (FixxSize == true)
            {
                bmp = new Bitmap(Math.Min(this.Width + 10, (int)mHeader.Width * ScaleX + 2), Math.Min(this.Height + 10, (int)mHeader.Height * ScaleY + 2));
            }
            else
            {
                bmp = new Bitmap((int)mHeader.Width * ScaleX + 2, (int)mHeader.Height * ScaleY + 2);
            }
            string Root = textBox2.Text;
            int    x = -1, y = (int)mHeader.Height - 1, yPos = 0, cubeNum = 0, tileNum = 0;

            //pictureBox1.Width = bmp.Width;
            //pictureBox1.Height = bmp.Height;
            //pictureBox1.Image = bmp;

            lblData.Text = "Image W/H: [" + bmp.Width + "/" + bmp.Height + "]; ";

            Stopwatch watch = Stopwatch.StartNew();

            using (Graphics g = Graphics.FromImage(bmp)) {
                g.DrawRectangle(new Pen(Color.Red), 0, 0, bmp.Width - 1, bmp.Height - 1);
                g.Save();

                for (int i = 0; i < mCubes.Length; i++)
                {
                    Application.DoEvents();

                    if (++x >= mHeader.Width)
                    {
                        x = 0;
                        y--;
                        yPos++;
                    }

                    cubeNum = (x + (y * (int)mHeader.Width));
                    tileNum = mCubes[cubeNum].tile_up;
                    Debug.WriteLine("Cube: " + cubeNum + " (Up " + mCubes[cubeNum].tile_up + ", Side " + mCubes[cubeNum].tile_side + ", aSide " + mCubes[cubeNum].tile_aside + "), X/Y: " + x + "/" + y + (FixxSize == true ? ((x * ScaleX + 1) > this.Width ? " [skipping - zu breit]" : (yPos * ScaleY + 1) > this.Height ? " [skipping - zu hoch]" : "") : ""));

                    if (tileNum == -1)
                    {
                        if (mCubes[cubeNum].tile_side != -1)
                        {
                            tileNum = mCubes[cubeNum].tile_side;
                        }
                        else if (mCubes[cubeNum].tile_aside != -1)
                        {
                            tileNum = mCubes[cubeNum].tile_aside;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (FixxSize == true)
                    {
                        if ((x * ScaleX + 1) > this.Width && (yPos * ScaleY + 1) > this.Height)
                        {
                            break;
                        }
                        if ((x * ScaleX + 1) > this.Width || (yPos * ScaleY + 1) > this.Height)
                        {
                            continue;
                        }
                    }

                    Bitmap   tex     = GetTextureImage(tileNum, false);
                    VectorTU vWidth  = mTiles[tileNum].VectorWidth;
                    VectorTU vHeight = mTiles[tileNum].VectorHeight;


                    int startX = (int)(vWidth.P1 * (float)tex.Width);
                    int startY = (int)(vHeight.P1 * (float)tex.Height);
                    int endX   = (int)(vWidth.P2 * (float)tex.Width);
                    int endY   = (int)(vHeight.P3 * (float)tex.Height);

                    // Image Spiegeln
                    if (startX > endX)
                    {
                        startX.Swap(ref startX, ref endX);
                        tex = tex.MirrorVertical();
                    }

                    if (startY > endY)
                    {
                        startY.Swap(ref startY, ref endY);
                        tex = tex.MirrorHorizontal();
                    }

                    int       sizeX   = endX - startX;
                    int       sizeY   = endY - startY;
                    Rectangle srcRect = new Rectangle(startX, startY, (sizeX < 0 ? -sizeX : sizeX), (sizeY < 0 ? -sizeY : sizeY));


                    g.DrawImage(tex, new Rectangle(x * ScaleX + 1, yPos * ScaleY + 1, ScaleX, ScaleY), srcRect, GraphicsUnit.Pixel);
                    //g.DrawImage( tex, new Rectangle( x * ScaleX + 1, yPos * ScaleY + 1, ScaleX, ScaleY ) );

                    /*
                     * if( DrawPosition == true ) {
                     *      g.DrawString( vWidth.ToString(), font, Brushes.White, new PointF( x * ScaleX + 2, yPos * ScaleY + 2 ) );
                     *      g.DrawString( vHeight.ToString(), font, Brushes.White, new PointF( x * ScaleX + 2, yPos * ScaleY + 17 ) );
                     *      g.DrawString( "X/Y [" + x + "/" + y + "] Cube [" + cubeNum + "]", font, Brushes.White, new PointF( x * ScaleX + 2, yPos * ScaleY + 32 ) );
                     *      g.DrawString( "Start [" + startX + "/" + startY + "] End [" + endX + "/" + endY + "]", font, Brushes.White, new PointF( x * ScaleX + 2, yPos * ScaleY + 47 ) );
                     * }
                     */
                    //pictureBox1.Image = bmp;
                }
            }


            CreateGrid(bmp, ScaleX, ScaleY, bmp.Width, bmp.Height);

            //pictureBox1.Image = bmp;

            string testImage = AppDomain.CurrentDomain.BaseDirectory + Path.GetFileNameWithoutExtension(textBox1.Text) + @".png";

            try {
                bmp.Save(testImage, System.Drawing.Imaging.ImageFormat.Jpeg);
            } catch (Exception e) {
                Debug.WriteLine(e);
            }

            string end = "finished in " + watch.ElapsedMilliseconds + " ms...";

            Debug.WriteLine(end);
            MessageBox.Show(end);
            watch = null;
        }