Пример #1
0
 private void GlControl1_Paint(object sender, PaintEventArgs e)
 {
     GL.ClearColor(Color.Black);
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
     GL.Begin(PrimitiveType.Points);
     for (int i = 0; i < SelectedTexture.RawData.Length; i++)
     {
         GL.Color4(SelectedTexture.RawData[i]);
         GL.Vertex2(i % (SelectedTexture.Width), i / (SelectedTexture.Width));
     }
     GL.End();
     if (SelectedTexture.MipLevels > 0)
     {
         var widthOffset = SelectedTexture.Width;
         for (var i = 0; i < SelectedTexture.MipLevels; ++i)
         {
             var mip      = SelectedTexture.GetMips(i);
             var mipWidth = (SelectedTexture.Width / (1 << (i + 1)));
             GL.Begin(PrimitiveType.Points);
             for (int j = 0; j < mip.Length; ++j)
             {
                 GL.Color4(mip[j]);
                 GL.Vertex2(widthOffset + j % mipWidth, j / mipWidth);
             }
             GL.End();
             widthOffset += mipWidth;
         }
     }
     GlControl1.SwapBuffers();
     Application.DoEvents();
 }
Пример #2
0
 private void UpdateTexture()
 {
     if (Mat)
     {
         Twinsanity.Material Material = (Twinsanity.Material)Materials._Item[CurTex];
         uint TexId = Material.Texture;
         for (int i = 0; i <= Textures._Item.Length - 1; i++)
         {
             if (Textures._Item[i].ID == TexId)
             {
                 Texture = (Twinsanity.Texture)Textures._Item[i];
                 break;
             }
         }
         Label1.Text = (CurTex + 1).ToString() + @"\" + Materials._Item.Length.ToString();
         this.Text   = Material.Name + " Texture: " + Texture.ID.ToString();
     }
     else
     {
         Texture     = (Twinsanity.Texture)Textures._Item[CurTex];
         Label1.Text = (CurTex + 1).ToString() + @"\" + Textures._Item.Length.ToString();
         this.Text   = "ID: " + Texture.ID.ToString();
     }
     GlControl1.Invalidate();
 }
Пример #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (OpenFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         Index = 0;
         Array.Resize(ref PSM_Surface, OpenFileDialog1.FileNames.Length);
         for (int i = 0; i <= OpenFileDialog1.FileNames.Length - 1; i++)
         {
             PSM_Surface[i] = new PSM();
             if (OpenFileDialog1.FilterIndex == 1)
             {
                 PSM_Surface[i].LoadPSM(OpenFileDialog1.FileNames[i], CheckBox1.Checked);
             }
             else if (OpenFileDialog1.FilterIndex == 2)
             {
                 PSM_Surface[i].LoadPTC(OpenFileDialog1.FileNames[i], CheckBox1.Checked);
             }
             else if (OpenFileDialog1.FilterIndex == 3)
             {
                 PSM_Surface[i].LoadPSF(OpenFileDialog1.FileNames[i], CheckBox1.Checked);
             }
         }
         Label1.Text = (Index + 1).ToString() + @"\" + PSM_Surface.Length.ToString();
         GlControl1.Invalidate();
     }
 }
Пример #4
0
 private void Button6_Click(object sender, EventArgs e)
 {
     if (!(PSM_Surface[Index].PSM_Segments.Length == 8))
     {
         Interaction.MsgBox("Inappropriate PSM");
     }
     if (OpenFileDialog2.ShowDialog() == DialogResult.OK)
     {
         System.Drawing.Bitmap BMP = new System.Drawing.Bitmap(OpenFileDialog2.FileName);
         if (!(BMP.Width == 512) | !(BMP.Height == 512))
         {
             Interaction.MsgBox("Inappropriate image.");
         }
         for (int r = 0; r <= 1; r++)
         {
             for (int c = 0; c <= 3; c++)
             {
                 System.Drawing.Bitmap SEG = new System.Drawing.Bitmap(128, 256);
                 for (int x = 0; x <= 127; x++)
                 {
                     for (int y = 0; y <= 255; y++)
                     {
                         SEG.SetPixel(x, y, BMP.GetPixel(x + c * 128, y + r * 256));
                     }
                 }
                 PSM_Surface[Index].ReplacePSMSegment(SEG, c + r * 4);
                 string   path = OpenFileDialog2.FileName.Split('.')[0];
                 string[] name = path.Split('\\');
                 PSM_Surface[Index].PSM_Segments[c + r * 4].Name = name[name.Length - 1] + "_" + (r + c * 4 + 1).ToString();
             }
         }
         GlControl1.Invalidate();
     }
 }
Пример #5
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case Keys.Right:
                Controller.CameraProp.Move(10, 0, 0);
                GlControl1.Invalidate();
                return(true);

            case Keys.Left:
                Controller.CameraProp.Move(-10, 0, 0);
                GlControl1.Invalidate();
                return(true);

            case Keys.Up:
                Controller.CameraProp.Move(0, -10, 0);
                GlControl1.Invalidate();
                return(true);

            case Keys.Down:
                Controller.CameraProp.Move(0, 10, 0);
                GlControl1.Invalidate();
                return(true);

            case Keys.W:
                Controller.CameraProp.AddRotation(1);
                GlControl1.Invalidate();
                return(true);

            case Keys.S:
                Controller.CameraProp.AddRotation(-1);
                GlControl1.Invalidate();
                return(true);

            case Keys.A:
                Controller.CameraProp.AddRotation(0, 1);
                GlControl1.Invalidate();
                return(true);

            case Keys.D:
                Controller.CameraProp.AddRotation(0, -1);
                GlControl1.Invalidate();
                return(true);

            case Keys.Z:
                Controller.CameraProp.Move(0, 0, -10);
                GlControl1.Invalidate();
                return(true);

            case Keys.X:
                Controller.CameraProp.Move(0, 0, 10);
                GlControl1.Invalidate();
                return(true);
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Пример #6
0
 void GlControl1_Paint(object sender, PaintEventArgs e)
 {
     if (!Loaded)
     {
         return;
     }
     Controller.Paint();
     GlControl1.SwapBuffers();
 }
Пример #7
0
        void Form1_MouseWheel(object sender, MouseEventArgs e)
        {
            if (!Loaded || Controller.File == null)
            {
                return;
            }

            Controller.CameraProp.Move(0, 0, -e.Delta * 0.5f);
            GlControl1.Invalidate();
        }
Пример #8
0
 private void Button3_Click(object sender, EventArgs e)
 {
     if (Index < PSM_Surface.Length - 1)
     {
         Index += 1;
     }
     else
     {
         Index = 0;
     }
     Label1.Text = (Index + 1).ToString() + @"\" + PSM_Surface.Length.ToString();
     GlControl1.Invalidate();
 }
Пример #9
0
 private void GlControl1_Paint(object sender, PaintEventArgs e)
 {
     GL.ClearColor(Color.Black);
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
     GL.Begin(PrimitiveType.Points);
     for (int i = 0; i < Texture.RawData.Length; i++)
     {
         GL.Color4(Texture.RawData[i]);
         GL.Vertex2(i % (Texture.Width), i / (Texture.Width));
     }
     GL.End();
     GlControl1.SwapBuffers();
     Application.DoEvents();
 }
Пример #10
0
 private void Button5_Click(object sender, EventArgs e)
 {
     if (OpenFileDialog2.ShowDialog() == DialogResult.OK)
     {
         System.Drawing.Bitmap BMP = new System.Drawing.Bitmap(OpenFileDialog2.FileName);
         if (PSM_Surface[Index].ReplacePSMSegment(BMP, ComboBox1.SelectedIndex) != 0)
         {
             Interaction.MsgBox("Inappropriate image.");
         }
         string[] name = OpenFileDialog2.FileName.Split('.');
         PSM_Surface[Index].PSM_Segments[ComboBox1.SelectedIndex + 1].Name = name[name.Length - 2] + (ComboBox1.SelectedIndex + 1).ToString();
         GlControl1.Invalidate();
     }
 }
Пример #11
0
 private void GlControl1_Paint(object sender, PaintEventArgs e)
 {
     GL.ClearColor(Color.Black);
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
     GL.Begin(BeginMode.Points);
     if (!(PSM_Surface == null))
     {
         {
             var withBlock = PSM_Surface[Index];
             ComboBox1.Items.Clear();
             for (int i = 0; i <= withBlock.PSM_Segments.Length - 1; i++)
             {
                 ComboBox1.Items.Add(withBlock.PSM_Segments[i].Name);
             }
             ComboBox1.SelectedIndex = 0;
             uint shift_x = 0;
             uint shift_y = 0;
             for (int i = 0; i <= withBlock.PSM_Segments.Length - 1; i++)
             {
                 if (shift_x + withBlock.PSM_Segments[i].Texture.Width > 512)
                 {
                     shift_x  = 0;
                     shift_y += withBlock.PSM_Segments[i].Texture.Height;
                 }
                 for (int j = 0; j <= withBlock.PSM_Segments[i].Texture.RawData.Length - 1; j++)
                 {
                     if (CheckBox2.Checked)
                     {
                         GL.Color4((byte)255, withBlock.PSM_Segments[i].Texture.Index[j], withBlock.PSM_Segments[i].Texture.Index[j], withBlock.PSM_Segments[i].Texture.Index[j]);
                     }
                     else
                     {
                         GL.Color4(withBlock.PSM_Segments[i].Texture.RawData[j]);
                     }
                     GL.Vertex2(shift_x + j % withBlock.PSM_Segments[i].Texture.Width, shift_y + j / withBlock.PSM_Segments[i].Texture.Width);
                 }
                 shift_x += withBlock.PSM_Segments[i].Texture.Width;
             }
         }
     }
     GL.End();
     GlControl1.SwapBuffers();
     Application.DoEvents();
 }
Пример #12
0
 void GlControl1_MouseMove(object sender, MouseEventArgs e)
 {
     if (!Loaded || Controller.File == null)
     {
         return;
     }
     if (e.Button == MouseButtons.Left && LeftButtonMouse)
     {
         Controller.CameraProp.Move(-(e.X - LeftMouseDownLocation.X) * Controller.CameraProp.Zoom,
                                    -(e.Y - LeftMouseDownLocation.Y) * Controller.CameraProp.Zoom, 0);
         GlControl1.Invalidate();
         LeftMouseDownLocation = e.Location;
     }
     else if (e.Button == MouseButtons.Right && RightButtonMouse)
     {
         Controller.CameraProp.AddRotation(y: -(e.X - RightMouseDownLocation.X) * 0.25f,
                                           x: -(e.Y - RightMouseDownLocation.Y) * 0.25f);
         GlControl1.Invalidate();
         RightMouseDownLocation = e.Location;
     }
 }
Пример #13
0
 private void GlControl1_Paint(object sender, PaintEventArgs e)
 {
     GL.ClearColor(Color.Black);
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
     GL.Begin(PrimitiveType.Points);
     for (int i = 0; i <= Texture.RawData.Length - 1; i++)
     {
         if (CheckBox1.Checked == true)
         {
             GL.Color4(Color.FromArgb(255, Texture.Index[i], Texture.Index[i], Texture.Index[i]));
         }
         else
         {
             GL.Color4(Texture.RawData[i]);
         }
         GL.Vertex2(i % (Texture.Width), i / (Texture.Width));
     }
     GL.End();
     GlControl1.SwapBuffers();
     Application.DoEvents();
 }
Пример #14
0
 private void GlControl1_Paint(object sender, PaintEventArgs e)
 {
     GL.ClearColor(Color.Black);
     GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
     GL.Begin(PrimitiveType.Points);
     if (cbViewFullPSM.Enabled && cbViewFullPSM.Checked)
     {
         var widthOffset = 0;
         var heighOffset = 0;
         var maxWidth    = PTCs.Max(p => p.Texture.Width);
         var maxHeight   = PTCs.Max(p => p.Texture.Height);
         for (int i = 0; i < PTCs.Count; ++i)
         {
             for (int j = 0; j < PTCs[i].Texture.RawData.Length; ++j)
             {
                 GL.Color4(PTCs[i].Texture.RawData[j]);
                 GL.Vertex2(widthOffset + (j % (PTCs[i].Texture.Width)), heighOffset + (j / (PTCs[i].Texture.Width)));
             }
             widthOffset += maxWidth;
             if ((i + 1) % 4 == 0)
             {
                 heighOffset += maxHeight;
                 widthOffset  = 0;
             }
         }
     }
     else
     {
         for (int i = 0; i < SelectedPTC.Texture.RawData.Length; i++)
         {
             GL.Color4(SelectedPTC.Texture.RawData[i]);
             GL.Vertex2(i % (SelectedPTC.Texture.Width), i / (SelectedPTC.Texture.Width));
         }
     }
     GL.End();
     GlControl1.SwapBuffers();
     Application.DoEvents();
 }
Пример #15
0
 private void CheckBox1_CheckedChanged(object sender, EventArgs e)
 {
     GlControl1.Invalidate();
 }