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(); }
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(); } }
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(); } }
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)); }
void Form1_MouseWheel(object sender, MouseEventArgs e) { if (!Loaded || Controller.File == null) { return; } Controller.CameraProp.Move(0, 0, -e.Delta * 0.5f); GlControl1.Invalidate(); }
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(); }
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(); } }
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; } }
private void CheckBox1_CheckedChanged(object sender, EventArgs e) { GlControl1.Invalidate(); }