All pastes #1463117 Raw Edit

Anonymous

public text v1 · immutable
#1463117 ·published 2009-06-17 08:22 UTC
rendered paste body
Imports Tao.OpenGl
Imports Tao.Platform.Windows
Imports Tao.DevIl
Imports System.Math
Imports System.IO
Imports Tao.FreeGlut
Imports System.Runtime.InteropServices
Structure TempLimbPos
    Dim LimbNo As Integer
    Dim NextLimbNo As Integer
    Dim x As Single
    Dim y As Single
    Dim z As Single
    Dim xr As Single
    Dim yr As Single
    Dim zr As Single
End Structure
Structure Light
    Dim r As Double
    Dim g As Double
    Dim b As Double
End Structure
Structure Vertex3D
    Dim x() As Int16
    Dim y() As Int16
    Dim z() As Int16
    Dim u() As Int16
    Dim v() As Int16
    Dim r() As Single
    Dim g() As Single
    Dim b() As Single
    Dim a() As Single
End Structure
Structure CTriSelect
    Dim g As Short
    Dim b As Short
End Structure
Structure Polygon3D
    Dim A As ArrayList
    Dim B As ArrayList
    Dim C As ArrayList
End Structure
Structure VertexCollision
    Dim x As ArrayList
    Dim y As ArrayList
    Dim z As ArrayList
    Dim ox As ArrayList
    Dim oy As ArrayList
    Dim oz As ArrayList
    Dim tr3 As ArrayList
    Dim tg3 As ArrayList
    Dim tb3 As ArrayList
End Structure
Structure color4c
    Dim r As ArrayList
    Dim g As ArrayList
    Dim b As ArrayList
    Dim a As ArrayList
End Structure
Structure PolygonCollision
    Dim A As ArrayList
    Dim B As ArrayList
    Dim C As ArrayList
    Dim tr5 As ArrayList
    Dim tg5 As ArrayList
    Dim tb5 As ArrayList
End Structure
Structure DisplayList
    Dim startpos As Integer
    Dim endpos As Integer
    Dim skip As Boolean
    Dim x As Int16
    Dim y As Int16
    Dim z As Int16
    Dim xrot As Int16
    Dim yrot As Int16
    Dim zrot As Int16
    Dim CommandCount As Integer
    Dim SkipDL As ArrayList
    Dim Commands() As DLCommandArray
End Structure
Structure ROMData
    Dim Levels() As Sc
    Dim Objects() As Obj
    Dim Others() As OtherData
End Structure
Structure Map
    Dim startoff As Integer
    Dim endoff As Integer
    Dim filename As String
End Structure
Structure Sc
    Dim startoff As Integer
    Dim endoff As Integer
    Dim filename As String
    Dim Maps() As Map
End Structure
Structure Obj
    Dim startoff As Integer
    Dim endoff As Integer
    Dim filename As String
End Structure
Structure OtherData
    Dim startoff As Integer
    Dim endoff As Integer
    Dim filename As String
End Structure
Structure DLCommandArray
    Dim CMDDword() As Byte
    Dim SkipCommand As Boolean
End Structure
Structure FileBuffers
    Dim Level() As Byte
    Dim Map() As Byte
    Dim ActorModel() As Byte
End Structure
Public Class MainWin
#Region "GPL License"
    'Utility of Time, N64 Zeldas Model/Map Editor and Viewer
    'Copyright (C) 2006-2007 cooliscool

    'This program is free software: you can redistribute it and/or modify
    'it under the terms of the GNU General Public License as published by
    'the Free Software Foundation, either version 3 of the License, or
    '(at your option) any later version.

    'This program is distributed in the hope that it will be useful,
    'but WITHOUT ANY WARRANTY; without even the implied warranty of
    'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    'GNU General Public License for more details.

    'You should have received a copy of the GNU General Public License
    'along with this program.  If not, see <http://www.gnu.org/licenses/>.
#End Region
#Region "Necessary for OpenGL Initialization"

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()
        'SimpleOpenGlControl1.Multisampling = 4
        'Add any initialization after the InitializeComponent() call
        SimpleOpenGlControl1.InitializeContexts()
    End Sub
    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        If Disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(Disposing)
        SimpleOpenGlControl1.DestroyContexts()
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
    Friend WithEvents LoadROM As System.Windows.Forms.OpenFileDialog

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainWin))
        Me.LoadROM = New System.Windows.Forms.OpenFileDialog
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
        Me.StatusStrip1 = New System.Windows.Forms.StatusStrip
        Me.ToolStripStatusLabel5 = New System.Windows.Forms.ToolStripStatusLabel
        Me.ToolStripStatusLabel4 = New System.Windows.Forms.ToolStripStatusLabel
        Me.ToolStripSeparator4 = New System.Windows.Forms.ToolStripSeparator
        Me.ToolStripButton4 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripButton5 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripButton13 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripButton3 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripSeparator2 = New System.Windows.Forms.ToolStripSeparator
        Me.ToolStripButton18 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripButton12 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripSeparator1 = New System.Windows.Forms.ToolStripSeparator
        Me.ToolStripButton17 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripSeparator6 = New System.Windows.Forms.ToolStripSeparator
        Me.ToolStripSeparator5 = New System.Windows.Forms.ToolStripSeparator
        Me.ToolStripButton1 = New System.Windows.Forms.ToolStripButton
        Me.ToolStripSeparator3 = New System.Windows.Forms.ToolStripSeparator
        Me.ContextMenuStrip4 = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.VertexWelderToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ActorSelectorToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.VertexSelectorToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SinglePointToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.PerMeshToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.AllSharedToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.WeldModesingleAndAllSharedOnlyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.TriangleEditorToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.AxesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripMenuItem7 = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripMenuItem8 = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripMenuItem6 = New System.Windows.Forms.ToolStripMenuItem
        Me.ColorDialog1 = New System.Windows.Forms.ColorDialog
        Me.ColorDialog2 = New System.Windows.Forms.ColorDialog
        Me.ContextMenuStrip5 = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.ClearSkyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.CloudySkyToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.Timer2 = New System.Windows.Forms.Timer(Me.components)
        Me.Label12 = New System.Windows.Forms.Label
        Me.TrackBar4 = New System.Windows.Forms.TrackBar
        Me.SaveFileDialog2 = New System.Windows.Forms.SaveFileDialog
        Me.MenuStrip1 = New System.Windows.Forms.MenuStrip
        Me.FileToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
        Me.OpenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.toolStripSeparator = New System.Windows.Forms.ToolStripSeparator
        Me.SaveToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.toolStripSeparator12 = New System.Windows.Forms.ToolStripSeparator
        Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.EditToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
        Me.UndoToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.OptionsToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
        Me.HelpToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
        Me.ContentsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.OpenModelToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SaveChangesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ReloadCurrentFileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ImportCSVToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripSeparator10 = New System.Windows.Forms.ToolStripSeparator
        Me.QuitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.EditToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ResetSelectedVerticesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ResetAllGraphicsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ResetAllCollisionToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripSeparator11 = New System.Windows.Forms.ToolStripSeparator
        Me.ResetSelectedActorToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ResetAllActorsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ResetAllSceneActorsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripSeparator9 = New System.Windows.Forms.ToolStripSeparator
        Me.SelectAllRoomActorsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SelectAllSceneActorsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SelectAllGraphicsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SelectAllCollisionToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.OptionsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.LaunchROMInPJ64ToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ZeldaResourceExtractorToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.FeaturesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.RenderModeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ViewingMeshToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
        Me.CollisionMeshToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.PrimitiveTypeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.FilledToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.WireframeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripSeparator8 = New System.Windows.Forms.ToolStripSeparator
        Me.MouseToolToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SetupToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.HelpToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ControlsInfoToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripSeparator7 = New System.Windows.Forms.ToolStripSeparator
        Me.AboutToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SearchForUpdatesToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.SaveFileDialog3 = New System.Windows.Forms.SaveFileDialog
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.ComboBox3 = New System.Windows.Forms.ComboBox
        Me.Label11 = New System.Windows.Forms.Label
        Me.OpenFileDialog3 = New System.Windows.Forms.OpenFileDialog
        Me.OpenFileDialog4 = New System.Windows.Forms.OpenFileDialog
        Me.FolderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog
        Me.Timer3 = New System.Windows.Forms.Timer(Me.components)
        Me.ContextMenuStrip7 = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.FlagsToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.AddPresetToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem
        Me.Timer4 = New System.Windows.Forms.Timer(Me.components)
        Me.OpenFileDialog5 = New System.Windows.Forms.OpenFileDialog
        Me.TabPage5 = New System.Windows.Forms.TabPage
        Me.GroupBox7 = New System.Windows.Forms.GroupBox
        Me.Label36 = New System.Windows.Forms.Label
        Me.TextBox20 = New System.Windows.Forms.TextBox
        Me.Label38 = New System.Windows.Forms.Label
        Me.Label37 = New System.Windows.Forms.Label
        Me.Label35 = New System.Windows.Forms.Label
        Me.Label33 = New System.Windows.Forms.Label
        Me.Label32 = New System.Windows.Forms.Label
        Me.Label23 = New System.Windows.Forms.Label
        Me.Label13 = New System.Windows.Forms.Label
        Me.Label1 = New System.Windows.Forms.Label
        Me.TextBox19 = New System.Windows.Forms.TextBox
        Me.Button22 = New System.Windows.Forms.Button
        Me.TextBox18 = New System.Windows.Forms.TextBox
        Me.TextBox17 = New System.Windows.Forms.TextBox
        Me.TextBox15 = New System.Windows.Forms.TextBox
        Me.Button21 = New System.Windows.Forms.Button
        Me.Label34 = New System.Windows.Forms.Label
        Me.TextBox14 = New System.Windows.Forms.TextBox
        Me.ComboBox1 = New System.Windows.Forms.ComboBox
        Me.Label31 = New System.Windows.Forms.Label
        Me.TextBox16 = New System.Windows.Forms.TextBox
        Me.ComboBox8 = New System.Windows.Forms.ComboBox
        Me.Label10 = New System.Windows.Forms.Label
        Me.GroupBox9 = New System.Windows.Forms.GroupBox
        Me.ProgressBar1 = New System.Windows.Forms.ProgressBar
        Me.Label28 = New System.Windows.Forms.Label
        Me.Button16 = New System.Windows.Forms.Button
        Me.Button15 = New System.Windows.Forms.Button
        Me.TabPage4 = New System.Windows.Forms.TabPage
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.Label30 = New System.Windows.Forms.Label
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Button7 = New System.Windows.Forms.Button
        Me.Button6 = New System.Windows.Forms.Button
        Me.Label29 = New System.Windows.Forms.Label
        Me.RadioButton3 = New System.Windows.Forms.RadioButton
        Me.RadioButton1 = New System.Windows.Forms.RadioButton
        Me.RadioButton2 = New System.Windows.Forms.RadioButton
        Me.GroupBox10 = New System.Windows.Forms.GroupBox
        Me.CheckBox5 = New System.Windows.Forms.CheckBox
        Me.CheckBox15 = New System.Windows.Forms.CheckBox
        Me.CheckBox14 = New System.Windows.Forms.CheckBox
        Me.CheckBox13 = New System.Windows.Forms.CheckBox
        Me.TabPage3 = New System.Windows.Forms.TabPage
        Me.GroupBox3 = New System.Windows.Forms.GroupBox
        Me.Button3 = New System.Windows.Forms.Button
        Me.CheckBox7 = New System.Windows.Forms.CheckBox
        Me.CheckBox4 = New System.Windows.Forms.CheckBox
        Me.CheckBox3 = New System.Windows.Forms.CheckBox
        Me.CheckBox2 = New System.Windows.Forms.CheckBox
        Me.CheckBox1 = New System.Windows.Forms.CheckBox
        Me.GroupBox6 = New System.Windows.Forms.GroupBox
        Me.ComboBox6 = New System.Windows.Forms.ComboBox
        Me.Label2 = New System.Windows.Forms.Label
        Me.Button11 = New System.Windows.Forms.Button
        Me.TextBox13 = New System.Windows.Forms.TextBox
        Me.Label21 = New System.Windows.Forms.Label
        Me.TabPage2 = New System.Windows.Forms.TabPage
        Me.ComboBox5 = New System.Windows.Forms.ComboBox
        Me.Button2 = New System.Windows.Forms.Button
        Me.ComboBox4 = New System.Windows.Forms.ComboBox
        Me.TextBox6 = New System.Windows.Forms.TextBox
        Me.GroupBox4 = New System.Windows.Forms.GroupBox
        Me.Button40 = New System.Windows.Forms.Button
        Me.Button39 = New System.Windows.Forms.Button
        Me.Button38 = New System.Windows.Forms.Button
        Me.Label14 = New System.Windows.Forms.Label
        Me.Label17 = New System.Windows.Forms.Label
        Me.TextBox9 = New System.Windows.Forms.TextBox
        Me.Label18 = New System.Windows.Forms.Label
        Me.TextBox8 = New System.Windows.Forms.TextBox
        Me.Label19 = New System.Windows.Forms.Label
        Me.TextBox7 = New System.Windows.Forms.TextBox
        Me.TextBox10 = New System.Windows.Forms.TextBox
        Me.Label16 = New System.Windows.Forms.Label
        Me.TextBox11 = New System.Windows.Forms.TextBox
        Me.Label15 = New System.Windows.Forms.Label
        Me.TextBox12 = New System.Windows.Forms.TextBox
        Me.GroupBox5 = New System.Windows.Forms.GroupBox
        Me.Label45 = New System.Windows.Forms.Label
        Me.Button23 = New System.Windows.Forms.Button
        Me.Label7 = New System.Windows.Forms.Label
        Me.TextBox4 = New System.Windows.Forms.TextBox
        Me.Label8 = New System.Windows.Forms.Label
        Me.Label6 = New System.Windows.Forms.Label
        Me.TextBox5 = New System.Windows.Forms.TextBox
        Me.Label22 = New System.Windows.Forms.Label
        Me.Button5 = New System.Windows.Forms.Button
        Me.ComboBox7 = New System.Windows.Forms.ComboBox
        Me.Label24 = New System.Windows.Forms.Label
        Me.TabPage1 = New System.Windows.Forms.TabPage
        Me.Button12 = New System.Windows.Forms.Button
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label5 = New System.Windows.Forms.Label
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.CheckBox18 = New System.Windows.Forms.CheckBox
        Me.CheckBox17 = New System.Windows.Forms.CheckBox
        Me.CheckBox16 = New System.Windows.Forms.CheckBox
        Me.Button30 = New System.Windows.Forms.Button
        Me.Button31 = New System.Windows.Forms.Button
        Me.Button32 = New System.Windows.Forms.Button
        Me.GroupBox11 = New System.Windows.Forms.GroupBox
        Me.CheckBox19 = New System.Windows.Forms.CheckBox
        Me.Label44 = New System.Windows.Forms.Label
        Me.Button37 = New System.Windows.Forms.Button
        Me.Button33 = New System.Windows.Forms.Button
        Me.Button34 = New System.Windows.Forms.Button
        Me.Button28 = New System.Windows.Forms.Button
        Me.Button10 = New System.Windows.Forms.Button
        Me.Label41 = New System.Windows.Forms.Label
        Me.Button29 = New System.Windows.Forms.Button
        Me.Label42 = New System.Windows.Forms.Label
        Me.TextBox21 = New System.Windows.Forms.TextBox
        Me.TextBox22 = New System.Windows.Forms.TextBox
        Me.Label27 = New System.Windows.Forms.Label
        Me.Label20 = New System.Windows.Forms.Label
        Me.Button20 = New System.Windows.Forms.Button
        Me.Label26 = New System.Windows.Forms.Label
        Me.Button19 = New System.Windows.Forms.Button
        Me.Button17 = New System.Windows.Forms.Button
        Me.Label25 = New System.Windows.Forms.Label
        Me.Label9 = New System.Windows.Forms.Label
        Me.Button18 = New System.Windows.Forms.Button
        Me.Button14 = New System.Windows.Forms.Button
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.Button13 = New System.Windows.Forms.Button
        Me.TextBox3 = New System.Windows.Forms.TextBox
        Me.Movement = New System.Windows.Forms.GroupBox
        Me.Button24 = New System.Windows.Forms.Button
        Me.Label39 = New System.Windows.Forms.Label
        Me.Label40 = New System.Windows.Forms.Label
        Me.Button25 = New System.Windows.Forms.Button
        Me.Button26 = New System.Windows.Forms.Button
        Me.Button27 = New System.Windows.Forms.Button
        Me.Button8 = New System.Windows.Forms.Button
        Me.TabControl1 = New System.Windows.Forms.TabControl
        Me.TabPage6 = New System.Windows.Forms.TabPage
        Me.Button41 = New System.Windows.Forms.Button
        Me.DebugTree = New System.Windows.Forms.TreeView
        Me.ContextMenuStrip2 = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.ToolStripMenuItem3 = New System.Windows.Forms.ToolStripMenuItem
        Me.TabPage7 = New System.Windows.Forms.TabPage
        Me.FileTree = New System.Windows.Forms.TreeView
        Me.Label43 = New System.Windows.Forms.Label
        Me.TrackBar1 = New System.Windows.Forms.TrackBar
        Me.SimpleOpenGlControl1 = New Tao.Platform.Windows.SimpleOpenGlControl
        Me.ContextMenuStrip1 = New System.Windows.Forms.ContextMenuStrip(Me.components)
        Me.ToolStripMenuItem1 = New System.Windows.Forms.ToolStripMenuItem
        Me.ToolStripMenuItem2 = New System.Windows.Forms.ToolStripMenuItem
        Me.Button9 = New System.Windows.Forms.Button
        Me.ContextMenuStrip4.SuspendLayout()
        Me.ContextMenuStrip5.SuspendLayout()
        CType(Me.TrackBar4, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.MenuStrip1.SuspendLayout()
        Me.ContextMenuStrip7.SuspendLayout()
        Me.TabPage5.SuspendLayout()
        Me.GroupBox7.SuspendLayout()
        Me.GroupBox9.SuspendLayout()
        Me.TabPage4.SuspendLayout()
        Me.GroupBox1.SuspendLayout()
        CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox10.SuspendLayout()
        Me.TabPage3.SuspendLayout()
        Me.GroupBox3.SuspendLayout()
        Me.GroupBox6.SuspendLayout()
        Me.TabPage2.SuspendLayout()
        Me.GroupBox4.SuspendLayout()
        Me.GroupBox5.SuspendLayout()
        Me.TabPage1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.GroupBox11.SuspendLayout()
        Me.Movement.SuspendLayout()
        Me.TabControl1.SuspendLayout()
        Me.TabPage6.SuspendLayout()
        Me.ContextMenuStrip2.SuspendLayout()
        Me.TabPage7.SuspendLayout()
        CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.ContextMenuStrip1.SuspendLayout()
        Me.SuspendLayout()
        '
        'LoadROM
        '
        Me.LoadROM.Filter = "ROMs|*.z64;*.v64;*.n64"
        Me.LoadROM.Title = "Load N64 Zelda Compliant Data"
        '
        'SaveFileDialog1
        '
        Me.SaveFileDialog1.DefaultExt = "wrl"
        Me.SaveFileDialog1.Filter = "VRML Worlds|*.wrl"
        '
        'StatusStrip1
        '
        Me.StatusStrip1.Location = New System.Drawing.Point(0, 551)
        Me.StatusStrip1.Name = "StatusStrip1"
        Me.StatusStrip1.Size = New System.Drawing.Size(792, 22)
        Me.StatusStrip1.TabIndex = 1
        Me.StatusStrip1.Text = "StatusStrip1"
        '
        'ToolStripStatusLabel5
        '
        Me.ToolStripStatusLabel5.BorderSides = CType((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom), System.Windows.Forms.ToolStripStatusLabelBorderSides)
        Me.ToolStripStatusLabel5.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenOuter
        Me.ToolStripStatusLabel5.Name = "ToolStripStatusLabel5"
        Me.ToolStripStatusLabel5.Size = New System.Drawing.Size(29, 22)
        Me.ToolStripStatusLabel5.Text = "FPS"
        '
        'ToolStripStatusLabel4
        '
        Me.ToolStripStatusLabel4.BorderSides = CType((((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Top) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Right) _
                    Or System.Windows.Forms.ToolStripStatusLabelBorderSides.Bottom), System.Windows.Forms.ToolStripStatusLabelBorderSides)
        Me.ToolStripStatusLabel4.BorderStyle = System.Windows.Forms.Border3DStyle.SunkenOuter
        Me.ToolStripStatusLabel4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
        Me.ToolStripStatusLabel4.Font = New System.Drawing.Font("Trebuchet MS", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ToolStripStatusLabel4.Name = "ToolStripStatusLabel4"
        Me.ToolStripStatusLabel4.Size = New System.Drawing.Size(111, 22)
        Me.ToolStripStatusLabel4.Text = "Tool: Camera only"
        '
        'ToolStripSeparator4
        '
        Me.ToolStripSeparator4.Name = "ToolStripSeparator4"
        Me.ToolStripSeparator4.Size = New System.Drawing.Size(6, 41)
        '
        'ToolStripButton4
        '
        Me.ToolStripButton4.Image = CType(resources.GetObject("ToolStripButton4.Image"), System.Drawing.Image)
        Me.ToolStripButton4.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.ToolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton4.Name = "ToolStripButton4"
        Me.ToolStripButton4.Size = New System.Drawing.Size(38, 38)
        Me.ToolStripButton4.Text = "Open"
        Me.ToolStripButton4.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton4.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        '
        'ToolStripButton5
        '
        Me.ToolStripButton5.Image = CType(resources.GetObject("ToolStripButton5.Image"), System.Drawing.Image)
        Me.ToolStripButton5.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.ToolStripButton5.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton5.Name = "ToolStripButton5"
        Me.ToolStripButton5.Size = New System.Drawing.Size(34, 38)
        Me.ToolStripButton5.Text = "Quit"
        Me.ToolStripButton5.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton5.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        '
        'ToolStripButton13
        '
        Me.ToolStripButton13.Image = CType(resources.GetObject("ToolStripButton13.Image"), System.Drawing.Image)
        Me.ToolStripButton13.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.ToolStripButton13.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton13.Name = "ToolStripButton13"
        Me.ToolStripButton13.Size = New System.Drawing.Size(35, 38)
        Me.ToolStripButton13.Text = "Save"
        Me.ToolStripButton13.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton13.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        '
        'ToolStripButton3
        '
        Me.ToolStripButton3.Enabled = False
        Me.ToolStripButton3.Image = Global.UoT.My.Resources.Resources.BombosMedallion
        Me.ToolStripButton3.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None
        Me.ToolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton3.Name = "ToolStripButton3"
        Me.ToolStripButton3.Size = New System.Drawing.Size(44, 38)
        Me.ToolStripButton3.Text = "Reload"
        Me.ToolStripButton3.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText
        '
        'ToolStripSeparator2
        '
        Me.ToolStripSeparator2.Name = "ToolStripSeparator2"
        Me.ToolStripSeparator2.Size = New System.Drawing.Size(6, 41)
        '
        'ToolStripButton18
        '
        Me.ToolStripButton18.Image = CType(resources.GetObject("ToolStripButton18.Image"), System.Drawing.Image)
        Me.ToolStripButton18.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.ToolStripButton18.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton18.Name = "ToolStripButton18"
        Me.ToolStripButton18.Size = New System.Drawing.Size(66, 38)
        Me.ToolStripButton18.Text = "Mouse Tool"
        Me.ToolStripButton18.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton18.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        '
        'ToolStripButton12
        '
        Me.ToolStripButton12.Image = CType(resources.GetObject("ToolStripButton12.Image"), System.Drawing.Image)
        Me.ToolStripButton12.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.ToolStripButton12.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton12.Name = "ToolStripButton12"
        Me.ToolStripButton12.Size = New System.Drawing.Size(37, 38)
        Me.ToolStripButton12.Text = "Filled"
        Me.ToolStripButton12.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton12.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        '
        'ToolStripSeparator1
        '
        Me.ToolStripSeparator1.Name = "ToolStripSeparator1"
        Me.ToolStripSeparator1.Size = New System.Drawing.Size(6, 41)
        '
        'ToolStripButton17
        '
        Me.ToolStripButton17.Image = CType(resources.GetObject("ToolStripButton17.Image"), System.Drawing.Image)
        Me.ToolStripButton17.ImageAlign = System.Drawing.ContentAlignment.TopCenter
        Me.ToolStripButton17.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None
        Me.ToolStripButton17.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton17.Name = "ToolStripButton17"
        Me.ToolStripButton17.Size = New System.Drawing.Size(35, 38)
        Me.ToolStripButton17.Text = "PJ64"
        Me.ToolStripButton17.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton17.TextImageRelation = System.Windows.Forms.TextImageRelation.Overlay
        '
        'ToolStripSeparator6
        '
        Me.ToolStripSeparator6.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right
        Me.ToolStripSeparator6.Name = "ToolStripSeparator6"
        Me.ToolStripSeparator6.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.ToolStripSeparator6.Size = New System.Drawing.Size(6, 41)
        '
        'ToolStripSeparator5
        '
        Me.ToolStripSeparator5.Name = "ToolStripSeparator5"
        Me.ToolStripSeparator5.Size = New System.Drawing.Size(6, 41)
        '
        'ToolStripButton1
        '
        Me.ToolStripButton1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right
        Me.ToolStripButton1.Image = CType(resources.GetObject("ToolStripButton1.Image"), System.Drawing.Image)
        Me.ToolStripButton1.ImageAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.ToolStripButton1.Name = "ToolStripButton1"
        Me.ToolStripButton1.Size = New System.Drawing.Size(63, 38)
        Me.ToolStripButton1.Text = "Show Tabs"
        Me.ToolStripButton1.TextAlign = System.Drawing.ContentAlignment.BottomCenter
        Me.ToolStripButton1.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText
        '
        'ToolStripSeparator3
        '
        Me.ToolStripSeparator3.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right
        Me.ToolStripSeparator3.Name = "ToolStripSeparator3"
        Me.ToolStripSeparator3.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.ToolStripSeparator3.Size = New System.Drawing.Size(6, 41)
        '
        'ContextMenuStrip4
        '
        Me.ContextMenuStrip4.BackColor = System.Drawing.SystemColors.ControlLight
        Me.ContextMenuStrip4.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.VertexWelderToolStripMenuItem, Me.ActorSelectorToolStripMenuItem, Me.VertexSelectorToolStripMenuItem, Me.TriangleEditorToolStripMenuItem, Me.AxesToolStripMenuItem})
        Me.ContextMenuStrip4.Name = "ContextMenuStrip4"
        Me.ContextMenuStrip4.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional
        Me.ContextMenuStrip4.Size = New System.Drawing.Size(198, 114)
        '
        'VertexWelderToolStripMenuItem
        '
        Me.VertexWelderToolStripMenuItem.BackColor = System.Drawing.SystemColors.ControlLight
        Me.VertexWelderToolStripMenuItem.Checked = True
        Me.VertexWelderToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked
        Me.VertexWelderToolStripMenuItem.Name = "VertexWelderToolStripMenuItem"
        Me.VertexWelderToolStripMenuItem.ShortcutKeyDisplayString = "1"
        Me.VertexWelderToolStripMenuItem.Size = New System.Drawing.Size(197, 22)
        Me.VertexWelderToolStripMenuItem.Text = "Camera Only"
        '
        'ActorSelectorToolStripMenuItem
        '
        Me.ActorSelectorToolStripMenuItem.BackColor = System.Drawing.SystemColors.ControlLight
        Me.ActorSelectorToolStripMenuItem.Name = "ActorSelectorToolStripMenuItem"
        Me.ActorSelectorToolStripMenuItem.ShortcutKeyDisplayString = "2"
        Me.ActorSelectorToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D2), System.Windows.Forms.Keys)
        Me.ActorSelectorToolStripMenuItem.Size = New System.Drawing.Size(197, 22)
        Me.ActorSelectorToolStripMenuItem.Text = "Actor Mover"
        '
        'VertexSelectorToolStripMenuItem
        '
        Me.VertexSelectorToolStripMenuItem.BackColor = System.Drawing.SystemColors.ControlLight
        Me.VertexSelectorToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.SinglePointToolStripMenuItem, Me.PerMeshToolStripMenuItem, Me.AllSharedToolStripMenuItem, Me.WeldModesingleAndAllSharedOnlyToolStripMenuItem})
        Me.VertexSelectorToolStripMenuItem.Name = "VertexSelectorToolStripMenuItem"
        Me.VertexSelectorToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.VertexSelectorToolStripMenuItem.Size = New System.Drawing.Size(197, 22)
        Me.VertexSelectorToolStripMenuItem.Text = "Vertex Editor"
        '
        'SinglePointToolStripMenuItem
        '
        Me.SinglePointToolStripMenuItem.Name = "SinglePointToolStripMenuItem"
        Me.SinglePointToolStripMenuItem.ShortcutKeyDisplayString = "3"
        Me.SinglePointToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D3), System.Windows.Forms.Keys)
        Me.SinglePointToolStripMenuItem.Size = New System.Drawing.Size(227, 22)
        Me.SinglePointToolStripMenuItem.Text = "Single point"
        '
        'PerMeshToolStripMenuItem
        '
        Me.PerMeshToolStripMenuItem.Name = "PerMeshToolStripMenuItem"
        Me.PerMeshToolStripMenuItem.ShortcutKeyDisplayString = "4"
        Me.PerMeshToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D4), System.Windows.Forms.Keys)
        Me.PerMeshToolStripMenuItem.Size = New System.Drawing.Size(227, 22)
        Me.PerMeshToolStripMenuItem.Text = "Per-Mesh"
        '
        'AllSharedToolStripMenuItem
        '
        Me.AllSharedToolStripMenuItem.Name = "AllSharedToolStripMenuItem"
        Me.AllSharedToolStripMenuItem.ShortcutKeyDisplayString = "5"
        Me.AllSharedToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D5), System.Windows.Forms.Keys)
        Me.AllSharedToolStripMenuItem.Size = New System.Drawing.Size(227, 22)
        Me.AllSharedToolStripMenuItem.Text = "All shared"
        '
        'WeldModesingleAndAllSharedOnlyToolStripMenuItem
        '
        Me.WeldModesingleAndAllSharedOnlyToolStripMenuItem.Name = "WeldModesingleAndAllSharedOnlyToolStripMenuItem"
        Me.WeldModesingleAndAllSharedOnlyToolStripMenuItem.ShortcutKeyDisplayString = "Num +"
        Me.WeldModesingleAndAllSharedOnlyToolStripMenuItem.Size = New System.Drawing.Size(227, 22)
        Me.WeldModesingleAndAllSharedOnlyToolStripMenuItem.Text = "Weld mode (single only)"
        '
        'TriangleEditorToolStripMenuItem
        '
        Me.TriangleEditorToolStripMenuItem.BackColor = System.Drawing.SystemColors.ControlLight
        Me.TriangleEditorToolStripMenuItem.Name = "TriangleEditorToolStripMenuItem"
        Me.TriangleEditorToolStripMenuItem.ShortcutKeyDisplayString = "6"
        Me.TriangleEditorToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D6), System.Windows.Forms.Keys)
        Me.TriangleEditorToolStripMenuItem.Size = New System.Drawing.Size(197, 22)
        Me.TriangleEditorToolStripMenuItem.Text = "Collision Triangle Editor"
        '
        'AxesToolStripMenuItem
        '
        Me.AxesToolStripMenuItem.BackColor = System.Drawing.SystemColors.ControlLight
        Me.AxesToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem7, Me.ToolStripMenuItem8, Me.ToolStripMenuItem6})
        Me.AxesToolStripMenuItem.Name = "AxesToolStripMenuItem"
        Me.AxesToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.AxesToolStripMenuItem.ShowShortcutKeys = False
        Me.AxesToolStripMenuItem.Size = New System.Drawing.Size(197, 22)
        Me.AxesToolStripMenuItem.Text = "Move on axes"
        '
        'ToolStripMenuItem7
        '
        Me.ToolStripMenuItem7.BackColor = System.Drawing.SystemColors.Control
        Me.ToolStripMenuItem7.Checked = True
        Me.ToolStripMenuItem7.CheckState = System.Windows.Forms.CheckState.Checked
        Me.ToolStripMenuItem7.Name = "ToolStripMenuItem7"
        Me.ToolStripMenuItem7.ShortcutKeyDisplayString = "8"
        Me.ToolStripMenuItem7.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D8), System.Windows.Forms.Keys)
        Me.ToolStripMenuItem7.Size = New System.Drawing.Size(123, 22)
        Me.ToolStripMenuItem7.Text = "X and Y"
        '
        'ToolStripMenuItem8
        '
        Me.ToolStripMenuItem8.BackColor = System.Drawing.SystemColors.Control
        Me.ToolStripMenuItem8.Name = "ToolStripMenuItem8"
        Me.ToolStripMenuItem8.ShortcutKeyDisplayString = "9"
        Me.ToolStripMenuItem8.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D9), System.Windows.Forms.Keys)
        Me.ToolStripMenuItem8.Size = New System.Drawing.Size(123, 22)
        Me.ToolStripMenuItem8.Text = "X"
        '
        'ToolStripMenuItem6
        '
        Me.ToolStripMenuItem6.BackColor = System.Drawing.SystemColors.Control
        Me.ToolStripMenuItem6.Name = "ToolStripMenuItem6"
        Me.ToolStripMenuItem6.ShortcutKeyDisplayString = "0"
        Me.ToolStripMenuItem6.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.D0), System.Windows.Forms.Keys)
        Me.ToolStripMenuItem6.Size = New System.Drawing.Size(123, 22)
        Me.ToolStripMenuItem6.Text = "Y"
        '
        'ColorDialog2
        '
        Me.ColorDialog2.AnyColor = True
        Me.ColorDialog2.SolidColorOnly = True
        '
        'ContextMenuStrip5
        '
        Me.ContextMenuStrip5.BackColor = System.Drawing.SystemColors.ControlLight
        Me.ContextMenuStrip5.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ClearSkyToolStripMenuItem, Me.CloudySkyToolStripMenuItem})
        Me.ContextMenuStrip5.Name = "ContextMenuStrip1"
        Me.ContextMenuStrip5.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional
        Me.ContextMenuStrip5.Size = New System.Drawing.Size(128, 48)
        '
        'ClearSkyToolStripMenuItem
        '
        Me.ClearSkyToolStripMenuItem.BackColor = System.Drawing.SystemColors.ControlLight
        Me.ClearSkyToolStripMenuItem.Name = "ClearSkyToolStripMenuItem"
        Me.ClearSkyToolStripMenuItem.Size = New System.Drawing.Size(127, 22)
        Me.ClearSkyToolStripMenuItem.Text = "Clear Sky"
        '
        'CloudySkyToolStripMenuItem
        '
        Me.CloudySkyToolStripMenuItem.BackColor = System.Drawing.SystemColors.ControlLight
        Me.CloudySkyToolStripMenuItem.Name = "CloudySkyToolStripMenuItem"
        Me.CloudySkyToolStripMenuItem.Size = New System.Drawing.Size(127, 22)
        Me.CloudySkyToolStripMenuItem.Text = "Cloudy Sky"
        '
        'Timer2
        '
        Me.Timer2.Enabled = True
        Me.Timer2.Interval = 1000
        '
        'Label12
        '
        Me.Label12.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label12.AutoSize = True
        Me.Label12.BackColor = System.Drawing.SystemColors.Control
        Me.Label12.Font = New System.Drawing.Font("Trebuchet MS", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label12.Location = New System.Drawing.Point(586, 553)
        Me.Label12.Name = "Label12"
        Me.Label12.Size = New System.Drawing.Size(95, 18)
        Me.Label12.TabIndex = 39
        Me.Label12.Text = "Tool Sensitivity:"
        '
        'TrackBar4
        '
        Me.TrackBar4.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TrackBar4.AutoSize = False
        Me.TrackBar4.Cursor = System.Windows.Forms.Cursors.Hand
        Me.TrackBar4.LargeChange = 1
        Me.TrackBar4.Location = New System.Drawing.Point(680, 554)
        Me.TrackBar4.Maximum = 15
        Me.TrackBar4.Minimum = 1
        Me.TrackBar4.Name = "TrackBar4"
        Me.TrackBar4.Size = New System.Drawing.Size(90, 15)
        Me.TrackBar4.TabIndex = 99
        Me.TrackBar4.Value = 2
        '
        'SaveFileDialog2
        '
        Me.SaveFileDialog2.Filter = "Text Documents|*.txt"
        '
        'MenuStrip1
        '
        Me.MenuStrip1.AllowMerge = False
        Me.MenuStrip1.AutoSize = False
        Me.MenuStrip1.BackColor = System.Drawing.SystemColors.ControlLight
        Me.MenuStrip1.Font = New System.Drawing.Font("Trebuchet MS", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.MenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem1, Me.EditToolStripMenuItem1, Me.ToolsToolStripMenuItem, Me.HelpToolStripMenuItem1})
        Me.MenuStrip1.Location = New System.Drawing.Point(0, 0)
        Me.MenuStrip1.Name = "MenuStrip1"
        Me.MenuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional
        Me.MenuStrip1.Size = New System.Drawing.Size(792, 21)
        Me.MenuStrip1.Stretch = False
        Me.MenuStrip1.TabIndex = 40
        Me.MenuStrip1.Text = "MenuStrip1"
        '
        'FileToolStripMenuItem1
        '
        Me.FileToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OpenToolStripMenuItem, Me.toolStripSeparator, Me.SaveToolStripMenuItem, Me.toolStripSeparator12, Me.ExitToolStripMenuItem})
        Me.FileToolStripMenuItem1.Name = "FileToolStripMenuItem1"
        Me.FileToolStripMenuItem1.Size = New System.Drawing.Size(37, 17)
        Me.FileToolStripMenuItem1.Text = "&File"
        '
        'OpenToolStripMenuItem
        '
        Me.OpenToolStripMenuItem.Image = CType(resources.GetObject("OpenToolStripMenuItem.Image"), System.Drawing.Image)
        Me.OpenToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.OpenToolStripMenuItem.Name = "OpenToolStripMenuItem"
        Me.OpenToolStripMenuItem.Size = New System.Drawing.Size(137, 22)
        Me.OpenToolStripMenuItem.Text = "&Open ROM"
        '
        'toolStripSeparator
        '
        Me.toolStripSeparator.Name = "toolStripSeparator"
        Me.toolStripSeparator.Size = New System.Drawing.Size(134, 6)
        '
        'SaveToolStripMenuItem
        '
        Me.SaveToolStripMenuItem.Image = CType(resources.GetObject("SaveToolStripMenuItem.Image"), System.Drawing.Image)
        Me.SaveToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta
        Me.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"
        Me.SaveToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.S), System.Windows.Forms.Keys)
        Me.SaveToolStripMenuItem.Size = New System.Drawing.Size(137, 22)
        Me.SaveToolStripMenuItem.Text = "&Save"
        '
        'toolStripSeparator12
        '
        Me.toolStripSeparator12.Name = "toolStripSeparator12"
        Me.toolStripSeparator12.Size = New System.Drawing.Size(134, 6)
        '
        'ExitToolStripMenuItem
        '
        Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem"
        Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(137, 22)
        Me.ExitToolStripMenuItem.Text = "E&xit"
        '
        'EditToolStripMenuItem1
        '
        Me.EditToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.UndoToolStripMenuItem})
        Me.EditToolStripMenuItem1.Name = "EditToolStripMenuItem1"
        Me.EditToolStripMenuItem1.Size = New System.Drawing.Size(44, 17)
        Me.EditToolStripMenuItem1.Text = "&View"
        '
        'UndoToolStripMenuItem
        '
        Me.UndoToolStripMenuItem.Name = "UndoToolStripMenuItem"
        Me.UndoToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F1
        Me.UndoToolStripMenuItem.Size = New System.Drawing.Size(153, 22)
        Me.UndoToolStripMenuItem.Text = "Toggle tabs"
        '
        'ToolsToolStripMenuItem
        '
        Me.ToolsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OptionsToolStripMenuItem1})
        Me.ToolsToolStripMenuItem.Name = "ToolsToolStripMenuItem"
        Me.ToolsToolStripMenuItem.Size = New System.Drawing.Size(81, 17)
        Me.ToolsToolStripMenuItem.Text = "&Preferences"
        '
        'OptionsToolStripMenuItem1
        '
        Me.OptionsToolStripMenuItem1.Name = "OptionsToolStripMenuItem1"
        Me.OptionsToolStripMenuItem1.Size = New System.Drawing.Size(104, 22)
        Me.OptionsToolStripMenuItem1.Text = "&Setup"
        '
        'HelpToolStripMenuItem1
        '
        Me.HelpToolStripMenuItem1.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContentsToolStripMenuItem})
        Me.HelpToolStripMenuItem1.Name = "HelpToolStripMenuItem1"
        Me.HelpToolStripMenuItem1.Size = New System.Drawing.Size(41, 17)
        Me.HelpToolStripMenuItem1.Text = "&Help"
        '
        'ContentsToolStripMenuItem
        '
        Me.ContentsToolStripMenuItem.Name = "ContentsToolStripMenuItem"
        Me.ContentsToolStripMenuItem.Size = New System.Drawing.Size(118, 22)
        Me.ContentsToolStripMenuItem.Text = "&Controls"
        '
        'FileToolStripMenuItem
        '
        Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.OpenModelToolStripMenuItem, Me.SaveChangesToolStripMenuItem, Me.ReloadCurrentFileToolStripMenuItem, Me.ImportCSVToolStripMenuItem, Me.ToolStripSeparator10, Me.QuitToolStripMenuItem})
        Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem"
        Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 17)
        Me.FileToolStripMenuItem.Text = "File"
        '
        'OpenModelToolStripMenuItem
        '
        Me.OpenModelToolStripMenuItem.Name = "OpenModelToolStripMenuItem"
        Me.OpenModelToolStripMenuItem.ShortcutKeyDisplayString = "Alt+O"
        Me.OpenModelToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.O), System.Windows.Forms.Keys)
        Me.OpenModelToolStripMenuItem.Size = New System.Drawing.Size(202, 22)
        Me.OpenModelToolStripMenuItem.Text = "&Open ROM..."
        '
        'SaveChangesToolStripMenuItem
        '
        Me.SaveChangesToolStripMenuItem.Name = "SaveChangesToolStripMenuItem"
        Me.SaveChangesToolStripMenuItem.ShortcutKeyDisplayString = "Alt+S"
        Me.SaveChangesToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.S), System.Windows.Forms.Keys)
        Me.SaveChangesToolStripMenuItem.Size = New System.Drawing.Size(202, 22)
        Me.SaveChangesToolStripMenuItem.Text = "&Save"
        '
        'ReloadCurrentFileToolStripMenuItem
        '
        Me.ReloadCurrentFileToolStripMenuItem.Name = "ReloadCurrentFileToolStripMenuItem"
        Me.ReloadCurrentFileToolStripMenuItem.Size = New System.Drawing.Size(202, 22)
        Me.ReloadCurrentFileToolStripMenuItem.Text = "&Reload current file"
        '
        'ImportCSVToolStripMenuItem
        '
        Me.ImportCSVToolStripMenuItem.Name = "ImportCSVToolStripMenuItem"
        Me.ImportCSVToolStripMenuItem.Size = New System.Drawing.Size(202, 22)
        Me.ImportCSVToolStripMenuItem.Text = "Convert Wavefront OBJ..."
        '
        'ToolStripSeparator10
        '
        Me.ToolStripSeparator10.Name = "ToolStripSeparator10"
        Me.ToolStripSeparator10.Size = New System.Drawing.Size(199, 6)
        '
        'QuitToolStripMenuItem
        '
        Me.QuitToolStripMenuItem.Name = "QuitToolStripMenuItem"
        Me.QuitToolStripMenuItem.Size = New System.Drawing.Size(202, 22)
        Me.QuitToolStripMenuItem.Text = "E&xit"
        '
        'EditToolStripMenuItem
        '
        Me.EditToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ResetSelectedVerticesToolStripMenuItem, Me.ResetAllGraphicsToolStripMenuItem, Me.ResetAllCollisionToolStripMenuItem, Me.ToolStripSeparator11, Me.ResetSelectedActorToolStripMenuItem, Me.ResetAllActorsToolStripMenuItem, Me.ResetAllSceneActorsToolStripMenuItem, Me.ToolStripSeparator9, Me.SelectAllRoomActorsToolStripMenuItem, Me.SelectAllSceneActorsToolStripMenuItem, Me.SelectAllGraphicsToolStripMenuItem, Me.SelectAllCollisionToolStripMenuItem})
        Me.EditToolStripMenuItem.Name = "EditToolStripMenuItem"
        Me.EditToolStripMenuItem.Size = New System.Drawing.Size(40, 17)
        Me.EditToolStripMenuItem.Text = "Edit"
        '
        'ResetSelectedVerticesToolStripMenuItem
        '
        Me.ResetSelectedVerticesToolStripMenuItem.Name = "ResetSelectedVerticesToolStripMenuItem"
        Me.ResetSelectedVerticesToolStripMenuItem.ShortcutKeyDisplayString = "V"
        Me.ResetSelectedVerticesToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.ResetSelectedVerticesToolStripMenuItem.Text = "Reset selected vertices"
        '
        'ResetAllGraphicsToolStripMenuItem
        '
        Me.ResetAllGraphicsToolStripMenuItem.Name = "ResetAllGraphicsToolStripMenuItem"
        Me.ResetAllGraphicsToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.ResetAllGraphicsToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.V), System.Windows.Forms.Keys)
        Me.ResetAllGraphicsToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.ResetAllGraphicsToolStripMenuItem.Text = "Reset all graphics"
        '
        'ResetAllCollisionToolStripMenuItem
        '
        Me.ResetAllCollisionToolStripMenuItem.Name = "ResetAllCollisionToolStripMenuItem"
        Me.ResetAllCollisionToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.ResetAllCollisionToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.C), System.Windows.Forms.Keys)
        Me.ResetAllCollisionToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.ResetAllCollisionToolStripMenuItem.Text = "Reset all collision"
        '
        'ToolStripSeparator11
        '
        Me.ToolStripSeparator11.Name = "ToolStripSeparator11"
        Me.ToolStripSeparator11.Size = New System.Drawing.Size(215, 6)
        '
        'ResetSelectedActorToolStripMenuItem
        '
        Me.ResetSelectedActorToolStripMenuItem.Name = "ResetSelectedActorToolStripMenuItem"
        Me.ResetSelectedActorToolStripMenuItem.ShortcutKeyDisplayString = "B"
        Me.ResetSelectedActorToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.ResetSelectedActorToolStripMenuItem.Text = "Reset selected actors"
        '
        'ResetAllActorsToolStripMenuItem
        '
        Me.ResetAllActorsToolStripMenuItem.Name = "ResetAllActorsToolStripMenuItem"
        Me.ResetAllActorsToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.B), System.Windows.Forms.Keys)
        Me.ResetAllActorsToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.ResetAllActorsToolStripMenuItem.Text = "Reset all room actors"
        '
        'ResetAllSceneActorsToolStripMenuItem
        '
        Me.ResetAllSceneActorsToolStripMenuItem.Name = "ResetAllSceneActorsToolStripMenuItem"
        Me.ResetAllSceneActorsToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.N), System.Windows.Forms.Keys)
        Me.ResetAllSceneActorsToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.ResetAllSceneActorsToolStripMenuItem.Text = "Reset all scene actors"
        '
        'ToolStripSeparator9
        '
        Me.ToolStripSeparator9.Name = "ToolStripSeparator9"
        Me.ToolStripSeparator9.Size = New System.Drawing.Size(215, 6)
        '
        'SelectAllRoomActorsToolStripMenuItem
        '
        Me.SelectAllRoomActorsToolStripMenuItem.Name = "SelectAllRoomActorsToolStripMenuItem"
        Me.SelectAllRoomActorsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F11
        Me.SelectAllRoomActorsToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.SelectAllRoomActorsToolStripMenuItem.Text = "Select all room actors"
        '
        'SelectAllSceneActorsToolStripMenuItem
        '
        Me.SelectAllSceneActorsToolStripMenuItem.Name = "SelectAllSceneActorsToolStripMenuItem"
        Me.SelectAllSceneActorsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F12
        Me.SelectAllSceneActorsToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.SelectAllSceneActorsToolStripMenuItem.Text = "Select all scene actors"
        '
        'SelectAllGraphicsToolStripMenuItem
        '
        Me.SelectAllGraphicsToolStripMenuItem.Name = "SelectAllGraphicsToolStripMenuItem"
        Me.SelectAllGraphicsToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.SelectAllGraphicsToolStripMenuItem.Text = "Select all graphics"
        '
        'SelectAllCollisionToolStripMenuItem
        '
        Me.SelectAllCollisionToolStripMenuItem.Name = "SelectAllCollisionToolStripMenuItem"
        Me.SelectAllCollisionToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
        Me.SelectAllCollisionToolStripMenuItem.Text = "Select all collision"
        '
        'OptionsToolStripMenuItem
        '
        Me.OptionsToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.LaunchROMInPJ64ToolStripMenuItem, Me.ZeldaResourceExtractorToolStripMenuItem})
        Me.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem"
        Me.OptionsToolStripMenuItem.Size = New System.Drawing.Size(59, 17)
        Me.OptionsToolStripMenuItem.Text = "Options"
        '
        'LaunchROMInPJ64ToolStripMenuItem
        '
        Me.LaunchROMInPJ64ToolStripMenuItem.Name = "LaunchROMInPJ64ToolStripMenuItem"
        Me.LaunchROMInPJ64ToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.LaunchROMInPJ64ToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.P), System.Windows.Forms.Keys)
        Me.LaunchROMInPJ64ToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
        Me.LaunchROMInPJ64ToolStripMenuItem.Text = "&Launch ROM in &PJ64..."
        '
        'ZeldaResourceExtractorToolStripMenuItem
        '
        Me.ZeldaResourceExtractorToolStripMenuItem.Name = "ZeldaResourceExtractorToolStripMenuItem"
        Me.ZeldaResourceExtractorToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.R), System.Windows.Forms.Keys)
        Me.ZeldaResourceExtractorToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
        Me.ZeldaResourceExtractorToolStripMenuItem.Text = "Extract &ROM..."
        '
        'FeaturesToolStripMenuItem
        '
        Me.FeaturesToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.RenderModeToolStripMenuItem, Me.PrimitiveTypeToolStripMenuItem, Me.ToolStripSeparator8, Me.MouseToolToolStripMenuItem, Me.SetupToolStripMenuItem})
        Me.FeaturesToolStripMenuItem.Name = "FeaturesToolStripMenuItem"
        Me.FeaturesToolStripMenuItem.Size = New System.Drawing.Size(81, 17)
        Me.FeaturesToolStripMenuItem.Text = "Preferences"
        '
        'RenderModeToolStripMenuItem
        '
        Me.RenderModeToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ViewingMeshToolStripMenuItem1, Me.CollisionMeshToolStripMenuItem})
        Me.RenderModeToolStripMenuItem.Name = "RenderModeToolStripMenuItem"
        Me.RenderModeToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.R), System.Windows.Forms.Keys)
        Me.RenderModeToolStripMenuItem.Size = New System.Drawing.Size(162, 22)
        Me.RenderModeToolStripMenuItem.Text = "&Render"
        '
        'ViewingMeshToolStripMenuItem1
        '
        Me.ViewingMeshToolStripMenuItem1.Checked = True
        Me.ViewingMeshToolStripMenuItem1.CheckState = System.Windows.Forms.CheckState.Checked
        Me.ViewingMeshToolStripMenuItem1.Name = "ViewingMeshToolStripMenuItem1"
        Me.ViewingMeshToolStripMenuItem1.Size = New System.Drawing.Size(143, 22)
        Me.ViewingMeshToolStripMenuItem1.Text = "Graphics Mesh"
        '
        'CollisionMeshToolStripMenuItem
        '
        Me.CollisionMeshToolStripMenuItem.Name = "CollisionMeshToolStripMenuItem"
        Me.CollisionMeshToolStripMenuItem.Size = New System.Drawing.Size(143, 22)
        Me.CollisionMeshToolStripMenuItem.Text = "Collision Mesh"
        '
        'PrimitiveTypeToolStripMenuItem
        '
        Me.PrimitiveTypeToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FilledToolStripMenuItem, Me.WireframeToolStripMenuItem})
        Me.PrimitiveTypeToolStripMenuItem.Name = "PrimitiveTypeToolStripMenuItem"
        Me.PrimitiveTypeToolStripMenuItem.ShortcutKeyDisplayString = "F1"
        Me.PrimitiveTypeToolStripMenuItem.Size = New System.Drawing.Size(162, 22)
        Me.PrimitiveTypeToolStripMenuItem.Text = "&Primitive Mode"
        '
        'FilledToolStripMenuItem
        '
        Me.FilledToolStripMenuItem.AutoSize = False
        Me.FilledToolStripMenuItem.Image = CType(resources.GetObject("FilledToolStripMenuItem.Image"), System.Drawing.Image)
        Me.FilledToolStripMenuItem.Name = "FilledToolStripMenuItem"
        Me.FilledToolStripMenuItem.Size = New System.Drawing.Size(152, 20)
        Me.FilledToolStripMenuItem.Text = "&Filled"
        '
        'WireframeToolStripMenuItem
        '
        Me.WireframeToolStripMenuItem.AutoSize = False
        Me.WireframeToolStripMenuItem.Image = CType(resources.GetObject("WireframeToolStripMenuItem.Image"), System.Drawing.Image)
        Me.WireframeToolStripMenuItem.Name = "WireframeToolStripMenuItem"
        Me.WireframeToolStripMenuItem.Size = New System.Drawing.Size(152, 20)
        Me.WireframeToolStripMenuItem.Text = "&Wireframe"
        '
        'ToolStripSeparator8
        '
        Me.ToolStripSeparator8.Name = "ToolStripSeparator8"
        Me.ToolStripSeparator8.Size = New System.Drawing.Size(159, 6)
        '
        'MouseToolToolStripMenuItem
        '
        Me.MouseToolToolStripMenuItem.Name = "MouseToolToolStripMenuItem"
        Me.MouseToolToolStripMenuItem.Size = New System.Drawing.Size(162, 22)
        Me.MouseToolToolStripMenuItem.Text = "&Mouse Tool..."
        '
        'SetupToolStripMenuItem
        '
        Me.SetupToolStripMenuItem.Name = "SetupToolStripMenuItem"
        Me.SetupToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.SetupToolStripMenuItem.Size = New System.Drawing.Size(162, 22)
        Me.SetupToolStripMenuItem.Text = "&Setup..."
        '
        'HelpToolStripMenuItem
        '
        Me.HelpToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ControlsInfoToolStripMenuItem, Me.ToolStripSeparator7, Me.AboutToolStripMenuItem, Me.SearchForUpdatesToolStripMenuItem})
        Me.HelpToolStripMenuItem.Name = "HelpToolStripMenuItem"
        Me.HelpToolStripMenuItem.Size = New System.Drawing.Size(41, 17)
        Me.HelpToolStripMenuItem.Text = "Help"
        '
        'ControlsInfoToolStripMenuItem
        '
        Me.ControlsInfoToolStripMenuItem.Name = "ControlsInfoToolStripMenuItem"
        Me.ControlsInfoToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.ControlsInfoToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.H), System.Windows.Forms.Keys)
        Me.ControlsInfoToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
        Me.ControlsInfoToolStripMenuItem.Text = "&Controls"
        '
        'ToolStripSeparator7
        '
        Me.ToolStripSeparator7.Name = "ToolStripSeparator7"
        Me.ToolStripSeparator7.Size = New System.Drawing.Size(214, 6)
        '
        'AboutToolStripMenuItem
        '
        Me.AboutToolStripMenuItem.Name = "AboutToolStripMenuItem"
        Me.AboutToolStripMenuItem.ShortcutKeyDisplayString = ""
        Me.AboutToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Q), System.Windows.Forms.Keys)
        Me.AboutToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
        Me.AboutToolStripMenuItem.Text = "A&bout Utility of Time"
        '
        'SearchForUpdatesToolStripMenuItem
        '
        Me.SearchForUpdatesToolStripMenuItem.Name = "SearchForUpdatesToolStripMenuItem"
        Me.SearchForUpdatesToolStripMenuItem.ShortcutKeys = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.U), System.Windows.Forms.Keys)
        Me.SearchForUpdatesToolStripMenuItem.Size = New System.Drawing.Size(217, 22)
        Me.SearchForUpdatesToolStripMenuItem.Text = "Search for updates..."
        '
        'Timer1
        '
        Me.Timer1.Interval = 1
        '
        'ComboBox3
        '
        Me.ComboBox3.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.ComboBox3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.ComboBox3.FormattingEnabled = True
        Me.ComboBox3.Location = New System.Drawing.Point(244, 1)
        Me.ComboBox3.Name = "ComboBox3"
        Me.ComboBox3.Size = New System.Drawing.Size(86, 21)
        Me.ComboBox3.TabIndex = 41
        '
        'Label11
        '
        Me.Label11.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        Me.Label11.AutoSize = True
        Me.Label11.Font = New System.Drawing.Font("Trebuchet MS", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label11.Location = New System.Drawing.Point(172, 4)
        Me.Label11.Name = "Label11"
        Me.Label11.Size = New System.Drawing.Size(70, 16)
        Me.Label11.TabIndex = 42
        Me.Label11.Text = "Display lists:"
        '
        'OpenFileDialog3
        '
        Me.OpenFileDialog3.Filter = "Wavefront OBJ Models (*.obj)|*.obj"
        '
        'OpenFileDialog4
        '
        Me.OpenFileDialog4.Filter = "Text files (*.txt)|*.txt"
        '
        'Timer3
        '
        Me.Timer3.Interval = 1000
        '
        'ContextMenuStrip7
        '
        Me.ContextMenuStrip7.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FlagsToolStripMenuItem, Me.AddPresetToolStripMenuItem})
        Me.ContextMenuStrip7.Name = "ContextMenuStrip7"
        Me.ContextMenuStrip7.Size = New System.Drawing.Size(166, 48)
        '
        'FlagsToolStripMenuItem
        '
        Me.FlagsToolStripMenuItem.Name = "FlagsToolStripMenuItem"
        Me.FlagsToolStripMenuItem.Size = New System.Drawing.Size(165, 22)
        Me.FlagsToolStripMenuItem.Text = "Flags"
        '
        'AddPresetToolStripMenuItem
        '
        Me.AddPresetToolStripMenuItem.Name = "AddPresetToolStripMenuItem"
        Me.AddPresetToolStripMenuItem.Size = New System.Drawing.Size(165, 22)
        Me.AddPresetToolStripMenuItem.Text = "Add flags preset..."
        '
        'OpenFileDialog5
        '
        Me.OpenFileDialog5.Filter = "Misc. Data|*.zdata|Actor Data|*.zactor"
        Me.OpenFileDialog5.Title = "Unknown texture bank found. Choose file to attempt to get data from."
        '
        'TabPage5
        '
        Me.TabPage5.Controls.Add(Me.GroupBox7)
        Me.TabPage5.Controls.Add(Me.GroupBox9)
        Me.TabPage5.Location = New System.Drawing.Point(4, 40)
        Me.TabPage5.Name = "TabPage5"
        Me.TabPage5.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage5.Size = New System.Drawing.Size(234, 507)
        Me.TabPage5.TabIndex = 4
        Me.TabPage5.Text = "Collision"
        Me.TabPage5.UseVisualStyleBackColor = True
        '
        'GroupBox7
        '
        Me.GroupBox7.Controls.Add(Me.Label36)
        Me.GroupBox7.Controls.Add(Me.TextBox20)
        Me.GroupBox7.Controls.Add(Me.Label38)
        Me.GroupBox7.Controls.Add(Me.Label37)
        Me.GroupBox7.Controls.Add(Me.Label35)
        Me.GroupBox7.Controls.Add(Me.Label33)
        Me.GroupBox7.Controls.Add(Me.Label32)
        Me.GroupBox7.Controls.Add(Me.Label23)
        Me.GroupBox7.Controls.Add(Me.Label13)
        Me.GroupBox7.Controls.Add(Me.Label1)
        Me.GroupBox7.Controls.Add(Me.TextBox19)
        Me.GroupBox7.Controls.Add(Me.Button22)
        Me.GroupBox7.Controls.Add(Me.TextBox18)
        Me.GroupBox7.Controls.Add(Me.TextBox17)
        Me.GroupBox7.Controls.Add(Me.TextBox15)
        Me.GroupBox7.Controls.Add(Me.Button21)
        Me.GroupBox7.Controls.Add(Me.Label34)
        Me.GroupBox7.Controls.Add(Me.TextBox14)
        Me.GroupBox7.Controls.Add(Me.ComboBox1)
        Me.GroupBox7.Controls.Add(Me.Label31)
        Me.GroupBox7.Controls.Add(Me.TextBox16)
        Me.GroupBox7.Controls.Add(Me.ComboBox8)
        Me.GroupBox7.Controls.Add(Me.Label10)
        Me.GroupBox7.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.GroupBox7.Location = New System.Drawing.Point(15, 9)
        Me.GroupBox7.Name = "GroupBox7"
        Me.GroupBox7.Size = New System.Drawing.Size(202, 288)
        Me.GroupBox7.TabIndex = 86
        Me.GroupBox7.TabStop = False
        Me.GroupBox7.Text = "Collision Types"
        '
        'Label36
        '
        Me.Label36.AutoSize = True
        Me.Label36.Location = New System.Drawing.Point(91, 135)
        Me.Label36.Name = "Label36"
        Me.Label36.Size = New System.Drawing.Size(18, 13)
        Me.Label36.TabIndex = 107
        Me.Label36.Text = "0x"
        '
        'TextBox20
        '
        Me.TextBox20.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox20.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox20.Location = New System.Drawing.Point(111, 128)
        Me.TextBox20.MaxLength = 1
        Me.TextBox20.Name = "TextBox20"
        Me.TextBox20.Size = New System.Drawing.Size(55, 20)
        Me.TextBox20.TabIndex = 105
        '
        'Label38
        '
        Me.Label38.AutoSize = True
        Me.Label38.Location = New System.Drawing.Point(108, 112)
        Me.Label38.Name = "Label38"
        Me.Label38.Size = New System.Drawing.Size(91, 13)
        Me.Label38.TabIndex = 106
        Me.Label38.Text = "Walked on sound"
        '
        'Label37
        '
        Me.Label37.AutoSize = True
        Me.Label37.Location = New System.Drawing.Point(10, 263)
        Me.Label37.Name = "Label37"
        Me.Label37.Size = New System.Drawing.Size(18, 13)
        Me.Label37.TabIndex = 104
        Me.Label37.Text = "0x"
        '
        'Label35
        '
        Me.Label35.AutoSize = True
        Me.Label35.Location = New System.Drawing.Point(10, 221)
        Me.Label35.Name = "Label35"
        Me.Label35.Size = New System.Drawing.Size(18, 13)
        Me.Label35.TabIndex = 103
        Me.Label35.Text = "0x"
        '
        'Label33
        '
        Me.Label33.AutoSize = True
        Me.Label33.Location = New System.Drawing.Point(10, 179)
        Me.Label33.Name = "Label33"
        Me.Label33.Size = New System.Drawing.Size(18, 13)
        Me.Label33.TabIndex = 102
        Me.Label33.Text = "0x"
        '
        'Label32
        '
        Me.Label32.AutoSize = True
        Me.Label32.Location = New System.Drawing.Point(10, 135)
        Me.Label32.Name = "Label32"
        Me.Label32.Size = New System.Drawing.Size(18, 13)
        Me.Label32.TabIndex = 101
        Me.Label32.Text = "0x"
        '
        'Label23
        '
        Me.Label23.AutoSize = True
        Me.Label23.Location = New System.Drawing.Point(27, 198)
        Me.Label23.Name = "Label23"
        Me.Label23.Size = New System.Drawing.Size(41, 13)
        Me.Label23.TabIndex = 100
        Me.Label23.Text = "Flags 3"
        '
        'Label13
        '
        Me.Label13.AutoSize = True
        Me.Label13.Location = New System.Drawing.Point(27, 240)
        Me.Label13.Name = "Label13"
        Me.Label13.Size = New System.Drawing.Size(41, 13)
        Me.Label13.TabIndex = 99
        Me.Label13.Text = "Flags 4"
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(26, 156)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(41, 13)
        Me.Label1.TabIndex = 98
        Me.Label1.Text = "Flags 2"
        '
        'TextBox19
        '
        Me.TextBox19.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox19.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox19.Location = New System.Drawing.Point(30, 256)
        Me.TextBox19.MaxLength = 4
        Me.TextBox19.Name = "TextBox19"
        Me.TextBox19.Size = New System.Drawing.Size(55, 20)
        Me.TextBox19.TabIndex = 17
        '
        'Button22
        '
        Me.Button22.BackColor = System.Drawing.SystemColors.Control
        Me.Button22.Location = New System.Drawing.Point(129, 254)
        Me.Button22.Name = "Button22"
        Me.Button22.Size = New System.Drawing.Size(50, 23)
        Me.Button22.TabIndex = 18
        Me.Button22.Text = "Apply"
        Me.Button22.UseVisualStyleBackColor = True
        '
        'TextBox18
        '
        Me.TextBox18.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox18.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox18.Location = New System.Drawing.Point(29, 172)
        Me.TextBox18.MaxLength = 4
        Me.TextBox18.Name = "TextBox18"
        Me.TextBox18.Size = New System.Drawing.Size(56, 20)
        Me.TextBox18.TabIndex = 16
        '
        'TextBox17
        '
        Me.TextBox17.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox17.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox17.Location = New System.Drawing.Point(30, 214)
        Me.TextBox17.MaxLength = 4
        Me.TextBox17.Name = "TextBox17"
        Me.TextBox17.Size = New System.Drawing.Size(55, 20)
        Me.TextBox17.TabIndex = 15
        '
        'TextBox15
        '
        Me.TextBox15.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox15.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox15.Location = New System.Drawing.Point(30, 128)
        Me.TextBox15.MaxLength = 4
        Me.TextBox15.Name = "TextBox15"
        Me.TextBox15.Size = New System.Drawing.Size(55, 20)
        Me.TextBox15.TabIndex = 14
        '
        'Button21
        '
        Me.Button21.BackColor = System.Drawing.SystemColors.Control
        Me.Button21.Location = New System.Drawing.Point(146, 0)
        Me.Button21.Name = "Button21"
        Me.Button21.Size = New System.Drawing.Size(50, 23)
        Me.Button21.TabIndex = 13
        Me.Button21.Text = "Presets"
        Me.Button21.UseVisualStyleBackColor = False
        '
        'Label34
        '
        Me.Label34.AutoSize = True
        Me.Label34.Location = New System.Drawing.Point(27, 112)
        Me.Label34.Name = "Label34"
        Me.Label34.Size = New System.Drawing.Size(41, 13)
        Me.Label34.TabIndex = 97
        Me.Label34.Text = "Flags 1"
        '
        'TextBox14
        '
        Me.TextBox14.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox14.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox14.Location = New System.Drawing.Point(124, 79)
        Me.TextBox14.MaxLength = 4
        Me.TextBox14.Name = "TextBox14"
        Me.TextBox14.ReadOnly = True
        Me.TextBox14.Size = New System.Drawing.Size(55, 20)
        Me.TextBox14.TabIndex = 91
        '
        'ComboBox1
        '
        Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.ComboBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.ComboBox1.FormattingEnabled = True
        Me.ComboBox1.Location = New System.Drawing.Point(11, 78)
        Me.ComboBox1.Name = "ComboBox1"
        Me.ComboBox1.Size = New System.Drawing.Size(102, 21)
        Me.ComboBox1.TabIndex = 12
        '
        'Label31
        '
        Me.Label31.AutoSize = True
        Me.Label31.Location = New System.Drawing.Point(8, 62)
        Me.Label31.Name = "Label31"
        Me.Label31.Size = New System.Drawing.Size(50, 13)
        Me.Label31.TabIndex = 87
        Me.Label31.Text = "Variables"
        '
        'TextBox16
        '
        Me.TextBox16.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox16.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox16.Location = New System.Drawing.Point(124, 39)
        Me.TextBox16.MaxLength = 4
        Me.TextBox16.Name = "TextBox16"
        Me.TextBox16.Size = New System.Drawing.Size(55, 20)
        Me.TextBox16.TabIndex = 11
        '
        'ComboBox8
        '
        Me.ComboBox8.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.ComboBox8.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.ComboBox8.FormattingEnabled = True
        Me.ComboBox8.Location = New System.Drawing.Point(11, 38)
        Me.ComboBox8.Name = "ComboBox8"
        Me.ComboBox8.Size = New System.Drawing.Size(102, 21)
        Me.ComboBox8.TabIndex = 10
        '
        'Label10
        '
        Me.Label10.AutoSize = True
        Me.Label10.Location = New System.Drawing.Point(8, 20)
        Me.Label10.Name = "Label10"
        Me.Label10.Size = New System.Drawing.Size(29, 13)
        Me.Label10.TabIndex = 83
        Me.Label10.Text = "Exits"
        '
        'GroupBox9
        '
        Me.GroupBox9.Controls.Add(Me.ProgressBar1)
        Me.GroupBox9.Controls.Add(Me.Label28)
        Me.GroupBox9.Controls.Add(Me.Button16)
        Me.GroupBox9.Controls.Add(Me.Button15)
        Me.GroupBox9.Location = New System.Drawing.Point(15, 303)
        Me.GroupBox9.Name = "GroupBox9"
        Me.GroupBox9.Size = New System.Drawing.Size(202, 100)
        Me.GroupBox9.TabIndex = 92
        Me.GroupBox9.TabStop = False
        Me.GroupBox9.Text = "Matcher"
        '
        'ProgressBar1
        '
        Me.ProgressBar1.Location = New System.Drawing.Point(23, 78)
        Me.ProgressBar1.Name = "ProgressBar1"
        Me.ProgressBar1.Size = New System.Drawing.Size(150, 10)
        Me.ProgressBar1.Style = System.Windows.Forms.ProgressBarStyle.Continuous
        Me.ProgressBar1.TabIndex = 92
        '
        'Label28
        '
        Me.Label28.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label28.AutoSize = True
        Me.Label28.BackColor = System.Drawing.SystemColors.Control
        Me.Label28.Location = New System.Drawing.Point(148, 0)
        Me.Label28.Name = "Label28"
        Me.Label28.Size = New System.Drawing.Size(47, 13)
        Me.Label28.TabIndex = 89
        Me.Label28.Text = "Working"
        Me.Label28.Visible = False
        '
        'Button16
        '
        Me.Button16.Location = New System.Drawing.Point(23, 24)
        Me.Button16.Name = "Button16"
        Me.Button16.Size = New System.Drawing.Size(150, 23)
        Me.Button16.TabIndex = 91
        Me.Button16.Text = "Match collision to graphics"
        Me.Button16.UseVisualStyleBackColor = True
        '
        'Button15
        '
        Me.Button15.Location = New System.Drawing.Point(23, 47)
        Me.Button15.Name = "Button15"
        Me.Button15.Size = New System.Drawing.Size(150, 23)
        Me.Button15.TabIndex = 90
        Me.Button15.Text = "Match graphics to collision"
        Me.Button15.UseVisualStyleBackColor = True
        '
        'TabPage4
        '
        Me.TabPage4.Controls.Add(Me.GroupBox1)
        Me.TabPage4.Controls.Add(Me.GroupBox10)
        Me.TabPage4.Location = New System.Drawing.Point(4, 40)
        Me.TabPage4.Name = "TabPage4"
        Me.TabPage4.Size = New System.Drawing.Size(234, 507)
        Me.TabPage4.TabIndex = 3
        Me.TabPage4.Text = "Miscellaneous"
        Me.TabPage4.UseVisualStyleBackColor = True
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.Label30)
        Me.GroupBox1.Controls.Add(Me.PictureBox1)
        Me.GroupBox1.Controls.Add(Me.Button7)
        Me.GroupBox1.Controls.Add(Me.Button6)
        Me.GroupBox1.Controls.Add(Me.Label29)
        Me.GroupBox1.Controls.Add(Me.RadioButton3)
        Me.GroupBox1.Controls.Add(Me.RadioButton1)
        Me.GroupBox1.Controls.Add(Me.RadioButton2)
        Me.GroupBox1.Location = New System.Drawing.Point(12, 10)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(210, 178)
        Me.GroupBox1.TabIndex = 89
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Texture Viewer"
        '
        'Label30
        '
        Me.Label30.AutoSize = True
        Me.Label30.Location = New System.Drawing.Point(135, 131)
        Me.Label30.Name = "Label30"
        Me.Label30.Size = New System.Drawing.Size(0, 13)
        Me.Label30.TabIndex = 54
        '
        'PictureBox1
        '
        Me.PictureBox1.BackColor = System.Drawing.SystemColors.Desktop
        Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.PictureBox1.ErrorImage = CType(resources.GetObject("PictureBox1.ErrorImage"), System.Drawing.Image)
        Me.PictureBox1.Location = New System.Drawing.Point(6, 16)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(128, 128)
        Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
        Me.PictureBox1.TabIndex = 88
        Me.PictureBox1.TabStop = False
        '
        'Button7
        '
        Me.Button7.BackColor = System.Drawing.SystemColors.Control
        Me.Button7.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button7.Image = CType(resources.GetObject("Button7.Image"), System.Drawing.Image)
        Me.Button7.Location = New System.Drawing.Point(30, 148)
        Me.Button7.Name = "Button7"
        Me.Button7.Size = New System.Drawing.Size(25, 23)
        Me.Button7.TabIndex = 10
        Me.Button7.UseVisualStyleBackColor = True
        '
        'Button6
        '
        Me.Button6.BackColor = System.Drawing.SystemColors.Control
        Me.Button6.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button6.Image = CType(resources.GetObject("Button6.Image"), System.Drawing.Image)
        Me.Button6.Location = New System.Drawing.Point(6, 148)
        Me.Button6.Name = "Button6"
        Me.Button6.Size = New System.Drawing.Size(25, 23)
        Me.Button6.TabIndex = 9
        Me.Button6.UseVisualStyleBackColor = True
        '
        'Label29
        '
        Me.Label29.AutoSize = True
        Me.Label29.Location = New System.Drawing.Point(134, 87)
        Me.Label29.Name = "Label29"
        Me.Label29.Size = New System.Drawing.Size(0, 13)
        Me.Label29.TabIndex = 53
        '
        'RadioButton3
        '
        Me.RadioButton3.AutoSize = True
        Me.RadioButton3.Location = New System.Drawing.Point(138, 62)
        Me.RadioButton3.Name = "RadioButton3"
        Me.RadioButton3.Size = New System.Drawing.Size(52, 17)
        Me.RadioButton3.TabIndex = 8
        Me.RadioButton3.Text = "Zoom"
        Me.RadioButton3.UseVisualStyleBackColor = True
        '
        'RadioButton1
        '
        Me.RadioButton1.AutoSize = True
        Me.RadioButton1.Checked = True
        Me.RadioButton1.Location = New System.Drawing.Point(138, 16)
        Me.RadioButton1.Name = "RadioButton1"
        Me.RadioButton1.Size = New System.Drawing.Size(58, 17)
        Me.RadioButton1.TabIndex = 6
        Me.RadioButton1.TabStop = True
        Me.RadioButton1.Text = "Normal"
        Me.RadioButton1.UseVisualStyleBackColor = True
        '
        'RadioButton2
        '
        Me.RadioButton2.AutoSize = True
        Me.RadioButton2.Location = New System.Drawing.Point(138, 39)
        Me.RadioButton2.Name = "RadioButton2"
        Me.RadioButton2.Size = New System.Drawing.Size(59, 17)
        Me.RadioButton2.TabIndex = 7
        Me.RadioButton2.Text = "Stretch"
        Me.RadioButton2.UseVisualStyleBackColor = True
        '
        'GroupBox10
        '
        Me.GroupBox10.Controls.Add(Me.CheckBox5)
        Me.GroupBox10.Controls.Add(Me.CheckBox15)
        Me.GroupBox10.Controls.Add(Me.CheckBox14)
        Me.GroupBox10.Controls.Add(Me.CheckBox13)
        Me.GroupBox10.Location = New System.Drawing.Point(11, 194)
        Me.GroupBox10.Name = "GroupBox10"
        Me.GroupBox10.Size = New System.Drawing.Size(210, 104)
        Me.GroupBox10.TabIndex = 90
        Me.GroupBox10.TabStop = False
        Me.GroupBox10.Text = "Hide"
        '
        'CheckBox5
        '
        Me.CheckBox5.AutoSize = True
        Me.CheckBox5.Location = New System.Drawing.Point(10, 57)
        Me.CheckBox5.Name = "CheckBox5"
        Me.CheckBox5.Size = New System.Drawing.Size(105, 17)
        Me.CheckBox5.TabIndex = 3
        Me.CheckBox5.Text = "Link actor cubes"
        Me.CheckBox5.UseVisualStyleBackColor = True
        '
        'CheckBox15
        '
        Me.CheckBox15.AutoSize = True
        Me.CheckBox15.Location = New System.Drawing.Point(10, 75)
        Me.CheckBox15.Name = "CheckBox15"
        Me.CheckBox15.Size = New System.Drawing.Size(79, 17)
        Me.CheckBox15.TabIndex = 2
        Me.CheckBox15.Text = "Axis guides"
        Me.CheckBox15.UseVisualStyleBackColor = True
        '
        'CheckBox14
        '
        Me.CheckBox14.AutoSize = True
        Me.CheckBox14.Location = New System.Drawing.Point(10, 38)
        Me.CheckBox14.Name = "CheckBox14"
        Me.CheckBox14.Size = New System.Drawing.Size(116, 17)
        Me.CheckBox14.TabIndex = 1
        Me.CheckBox14.Text = "Scene actor cubes"
        Me.CheckBox14.UseVisualStyleBackColor = True
        '
        'CheckBox13
        '
        Me.CheckBox13.AutoSize = True
        Me.CheckBox13.Location = New System.Drawing.Point(10, 20)
        Me.CheckBox13.Name = "CheckBox13"
        Me.CheckBox13.Size = New System.Drawing.Size(113, 17)
        Me.CheckBox13.TabIndex = 0
        Me.CheckBox13.Text = "Room actor cubes"
        Me.CheckBox13.UseVisualStyleBackColor = True
        '
        'TabPage3
        '
        Me.TabPage3.BackColor = System.Drawing.Color.Transparent
        Me.TabPage3.Controls.Add(Me.GroupBox3)
        Me.TabPage3.Controls.Add(Me.GroupBox6)
        Me.TabPage3.Location = New System.Drawing.Point(4, 40)
        Me.TabPage3.Name = "TabPage3"
        Me.TabPage3.Size = New System.Drawing.Size(234, 507)
        Me.TabPage3.TabIndex = 2
        Me.TabPage3.Text = "Level Options"
        Me.TabPage3.UseVisualStyleBackColor = True
        '
        'GroupBox3
        '
        Me.GroupBox3.Controls.Add(Me.Button3)
        Me.GroupBox3.Controls.Add(Me.CheckBox7)
        Me.GroupBox3.Controls.Add(Me.CheckBox4)
        Me.GroupBox3.Controls.Add(Me.CheckBox3)
        Me.GroupBox3.Controls.Add(Me.CheckBox2)
        Me.GroupBox3.Controls.Add(Me.CheckBox1)
        Me.GroupBox3.Location = New System.Drawing.Point(16, 9)
        Me.GroupBox3.Name = "GroupBox3"
        Me.GroupBox3.Size = New System.Drawing.Size(179, 112)
        Me.GroupBox3.TabIndex = 41
        Me.GroupBox3.TabStop = False
        Me.GroupBox3.Text = "Environment Flags"
        '
        'Button3
        '
        Me.Button3.BackColor = System.Drawing.SystemColors.Control
        Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.Button3.Location = New System.Drawing.Point(10, 85)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(26, 21)
        Me.Button3.TabIndex = 6
        Me.Button3.Text = "..."
        Me.Button3.TextAlign = System.Drawing.ContentAlignment.TopCenter
        Me.Button3.UseVisualStyleBackColor = True
        '
        'CheckBox7
        '
        Me.CheckBox7.AutoSize = True
        Me.CheckBox7.Location = New System.Drawing.Point(91, 42)
        Me.CheckBox7.Name = "CheckBox7"
        Me.CheckBox7.Size = New System.Drawing.Size(81, 17)
        Me.CheckBox7.TabIndex = 4
        Me.CheckBox7.Text = "Unknown 4"
        Me.CheckBox7.UseVisualStyleBackColor = True
        '
        'CheckBox4
        '
        Me.CheckBox4.AutoSize = True
        Me.CheckBox4.Location = New System.Drawing.Point(11, 65)
        Me.CheckBox4.Name = "CheckBox4"
        Me.CheckBox4.Size = New System.Drawing.Size(61, 17)
        Me.CheckBox4.TabIndex = 2
        Me.CheckBox4.Text = "Skybox"
        Me.CheckBox4.UseVisualStyleBackColor = True
        '
        'CheckBox3
        '
        Me.CheckBox3.AutoSize = True
        Me.CheckBox3.Location = New System.Drawing.Point(11, 42)
        Me.CheckBox3.Name = "CheckBox3"
        Me.CheckBox3.Size = New System.Drawing.Size(81, 17)
        Me.CheckBox3.TabIndex = 1
        Me.CheckBox3.Text = "Unknown 3"
        Me.CheckBox3.UseVisualStyleBackColor = True
        '
        'CheckBox2
        '
        Me.CheckBox2.AutoSize = True
        Me.CheckBox2.Location = New System.Drawing.Point(91, 19)
        Me.CheckBox2.Name = "CheckBox2"
        Me.CheckBox2.Size = New System.Drawing.Size(81, 17)
        Me.CheckBox2.TabIndex = 3
        Me.CheckBox2.Text = "Unknown 2"
        Me.CheckBox2.UseVisualStyleBackColor = True
        '
        'CheckBox1
        '
        Me.CheckBox1.AutoSize = True
        Me.CheckBox1.Location = New System.Drawing.Point(11, 19)
        Me.CheckBox1.Name = "CheckBox1"
        Me.CheckBox1.Size = New System.Drawing.Size(81, 17)
        Me.CheckBox1.TabIndex = 0
        Me.CheckBox1.Text = "Unknown 1"
        Me.CheckBox1.UseVisualStyleBackColor = True
        '
        'GroupBox6
        '
        Me.GroupBox6.Controls.Add(Me.ComboBox6)
        Me.GroupBox6.Controls.Add(Me.Label2)
        Me.GroupBox6.Controls.Add(Me.Button11)
        Me.GroupBox6.Controls.Add(Me.TextBox13)
        Me.GroupBox6.Controls.Add(Me.Label21)
        Me.GroupBox6.Location = New System.Drawing.Point(16, 127)
        Me.GroupBox6.Name = "GroupBox6"
        Me.GroupBox6.Size = New System.Drawing.Size(180, 74)
        Me.GroupBox6.TabIndex = 77
        Me.GroupBox6.TabStop = False
        Me.GroupBox6.Text = "Ambience"
        '
        'ComboBox6
        '
        Me.ComboBox6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.ComboBox6.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.ComboBox6.FormattingEnabled = True
        Me.ComboBox6.Items.AddRange(New Object() {"No Change", "Morning", "Mid Day", "Night"})
        Me.ComboBox6.Location = New System.Drawing.Point(10, 36)
        Me.ComboBox6.Name = "ComboBox6"
        Me.ComboBox6.Size = New System.Drawing.Size(82, 21)
        Me.ComboBox6.TabIndex = 7
        '
        'Label2
        '
        Me.Label2.AutoSize = True
        Me.Label2.Location = New System.Drawing.Point(7, 20)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(65, 13)
        Me.Label2.TabIndex = 65
        Me.Label2.Text = "Time of day:"
        '
        'Button11
        '
        Me.Button11.BackColor = System.Drawing.SystemColors.Control
        Me.Button11.FlatStyle = System.Windows.Forms.FlatStyle.System
        Me.Button11.Location = New System.Drawing.Point(137, 35)
        Me.Button11.Name = "Button11"
        Me.Button11.Size = New System.Drawing.Size(23, 23)
        Me.Button11.TabIndex = 9
        Me.Button11.Text = "?"
        Me.Button11.UseVisualStyleBackColor = True
        '
        'TextBox13
        '
        Me.TextBox13.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox13.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox13.Location = New System.Drawing.Point(98, 37)
        Me.TextBox13.MaxLength = 2
        Me.TextBox13.Name = "TextBox13"
        Me.TextBox13.Size = New System.Drawing.Size(35, 20)
        Me.TextBox13.TabIndex = 8
        '
        'Label21
        '
        Me.Label21.AutoSize = True
        Me.Label21.Location = New System.Drawing.Point(95, 21)
        Me.Label21.Name = "Label21"
        Me.Label21.Size = New System.Drawing.Size(38, 13)
        Me.Label21.TabIndex = 74
        Me.Label21.Text = "Music:"
        '
        'TabPage2
        '
        Me.TabPage2.BackColor = System.Drawing.Color.Transparent
        Me.TabPage2.Controls.Add(Me.ComboBox5)
        Me.TabPage2.Controls.Add(Me.Button2)
        Me.TabPage2.Controls.Add(Me.ComboBox4)
        Me.TabPage2.Controls.Add(Me.TextBox6)
        Me.TabPage2.Controls.Add(Me.GroupBox4)
        Me.TabPage2.Controls.Add(Me.GroupBox5)
        Me.TabPage2.Location = New System.Drawing.Point(4, 40)
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage2.Size = New System.Drawing.Size(234, 507)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "Actor Options"
        Me.TabPage2.UseVisualStyleBackColor = True
        '
        'ComboBox5
        '
        Me.ComboBox5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.ComboBox5.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.ComboBox5.FormattingEnabled = True
        Me.ComboBox5.Location = New System.Drawing.Point(26, 87)
        Me.ComboBox5.Name = "ComboBox5"
        Me.ComboBox5.Size = New System.Drawing.Size(180, 21)
        Me.ComboBox5.TabIndex = 1
        '
        'Button2
        '
        Me.Button2.BackColor = System.Drawing.SystemColors.Control
        Me.Button2.Location = New System.Drawing.Point(70, 418)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(85, 23)
        Me.Button2.TabIndex = 14
        Me.Button2.Text = "Apply"
        Me.Button2.UseVisualStyleBackColor = True
        '
        'ComboBox4
        '
        Me.ComboBox4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.ComboBox4.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.ComboBox4.FormattingEnabled = True
        Me.ComboBox4.Location = New System.Drawing.Point(26, 180)
        Me.ComboBox4.Name = "ComboBox4"
        Me.ComboBox4.Size = New System.Drawing.Size(86, 21)
        Me.ComboBox4.TabIndex = 4
        '
        'TextBox6
        '
        Me.TextBox6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox6.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox6.Location = New System.Drawing.Point(27, 135)
        Me.TextBox6.MaxLength = 4
        Me.TextBox6.Name = "TextBox6"
        Me.TextBox6.Size = New System.Drawing.Size(85, 20)
        Me.TextBox6.TabIndex = 2
        '
        'GroupBox4
        '
        Me.GroupBox4.Controls.Add(Me.Button40)
        Me.GroupBox4.Controls.Add(Me.Button39)
        Me.GroupBox4.Controls.Add(Me.Button38)
        Me.GroupBox4.Controls.Add(Me.Label14)
        Me.GroupBox4.Controls.Add(Me.Label17)
        Me.GroupBox4.Controls.Add(Me.TextBox9)
        Me.GroupBox4.Controls.Add(Me.Label18)
        Me.GroupBox4.Controls.Add(Me.TextBox8)
        Me.GroupBox4.Controls.Add(Me.Label19)
        Me.GroupBox4.Controls.Add(Me.TextBox7)
        Me.GroupBox4.Controls.Add(Me.TextBox10)
        Me.GroupBox4.Controls.Add(Me.Label16)
        Me.GroupBox4.Controls.Add(Me.TextBox11)
        Me.GroupBox4.Controls.Add(Me.Label15)
        Me.GroupBox4.Controls.Add(Me.TextBox12)
        Me.GroupBox4.Location = New System.Drawing.Point(10, 260)
        Me.GroupBox4.Name = "GroupBox4"
        Me.GroupBox4.Size = New System.Drawing.Size(218, 142)
        Me.GroupBox4.TabIndex = 72
        Me.GroupBox4.TabStop = False
        Me.GroupBox4.Text = "Position"
        '
        'Button40
        '
        Me.Button40.BackColor = System.Drawing.SystemColors.Control
        Me.Button40.Location = New System.Drawing.Point(190, 111)
        Me.Button40.Name = "Button40"
        Me.Button40.Size = New System.Drawing.Size(22, 23)
        Me.Button40.TabIndex = 71
        Me.Button40.Text = "Button40"
        Me.Button40.UseVisualStyleBackColor = False
        '
        'Button39
        '
        Me.Button39.BackColor = System.Drawing.SystemColors.Control
        Me.Button39.Location = New System.Drawing.Point(190, 72)
        Me.Button39.Name = "Button39"
        Me.Button39.Size = New System.Drawing.Size(22, 23)
        Me.Button39.TabIndex = 70
        Me.Button39.Text = "Button39"
        Me.Button39.UseVisualStyleBackColor = False
        '
        'Button38
        '
        Me.Button38.BackColor = System.Drawing.SystemColors.Control
        Me.Button38.Location = New System.Drawing.Point(190, 34)
        Me.Button38.Name = "Button38"
        Me.Button38.Size = New System.Drawing.Size(22, 23)
        Me.Button38.TabIndex = 69
        Me.Button38.Text = "Button38"
        Me.Button38.UseVisualStyleBackColor = False
        '
        'Label14
        '
        Me.Label14.AutoSize = True
        Me.Label14.Location = New System.Drawing.Point(7, 20)
        Me.Label14.Name = "Label14"
        Me.Label14.Size = New System.Drawing.Size(66, 13)
        Me.Label14.TabIndex = 59
        Me.Label14.Text = "Actor X Pos."
        '
        'Label17
        '
        Me.Label17.AutoSize = True
        Me.Label17.Location = New System.Drawing.Point(99, 20)
        Me.Label17.Name = "Label17"
        Me.Label17.Size = New System.Drawing.Size(65, 13)
        Me.Label17.TabIndex = 66
        Me.Label17.Text = "Actor X Rot."
        '
        'TextBox9
        '
        Me.TextBox9.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox9.Location = New System.Drawing.Point(10, 114)
        Me.TextBox9.Name = "TextBox9"
        Me.TextBox9.Size = New System.Drawing.Size(84, 20)
        Me.TextBox9.TabIndex = 10
        '
        'Label18
        '
        Me.Label18.AutoSize = True
        Me.Label18.Location = New System.Drawing.Point(99, 59)
        Me.Label18.Name = "Label18"
        Me.Label18.Size = New System.Drawing.Size(65, 13)
        Me.Label18.TabIndex = 67
        Me.Label18.Text = "Actor Y Rot."
        '
        'TextBox8
        '
        Me.TextBox8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox8.Location = New System.Drawing.Point(10, 75)
        Me.TextBox8.Name = "TextBox8"
        Me.TextBox8.Size = New System.Drawing.Size(84, 20)
        Me.TextBox8.TabIndex = 9
        '
        'Label19
        '
        Me.Label19.AutoSize = True
        Me.Label19.Location = New System.Drawing.Point(99, 98)
        Me.Label19.Name = "Label19"
        Me.Label19.Size = New System.Drawing.Size(65, 13)
        Me.Label19.TabIndex = 68
        Me.Label19.Text = "Actor Z Rot."
        '
        'TextBox7
        '
        Me.TextBox7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox7.Location = New System.Drawing.Point(10, 36)
        Me.TextBox7.Name = "TextBox7"
        Me.TextBox7.Size = New System.Drawing.Size(84, 20)
        Me.TextBox7.TabIndex = 8
        '
        'TextBox10
        '
        Me.TextBox10.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox10.Location = New System.Drawing.Point(102, 36)
        Me.TextBox10.Name = "TextBox10"
        Me.TextBox10.Size = New System.Drawing.Size(83, 20)
        Me.TextBox10.TabIndex = 11
        '
        'Label16
        '
        Me.Label16.AutoSize = True
        Me.Label16.Location = New System.Drawing.Point(7, 98)
        Me.Label16.Name = "Label16"
        Me.Label16.Size = New System.Drawing.Size(66, 13)
        Me.Label16.TabIndex = 61
        Me.Label16.Text = "Actor Z Pos."
        '
        'TextBox11
        '
        Me.TextBox11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox11.Location = New System.Drawing.Point(102, 75)
        Me.TextBox11.Name = "TextBox11"
        Me.TextBox11.Size = New System.Drawing.Size(83, 20)
        Me.TextBox11.TabIndex = 12
        '
        'Label15
        '
        Me.Label15.AutoSize = True
        Me.Label15.Location = New System.Drawing.Point(7, 59)
        Me.Label15.Name = "Label15"
        Me.Label15.Size = New System.Drawing.Size(66, 13)
        Me.Label15.TabIndex = 60
        Me.Label15.Text = "Actor Y Pos."
        '
        'TextBox12
        '
        Me.TextBox12.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox12.Location = New System.Drawing.Point(102, 114)
        Me.TextBox12.Name = "TextBox12"
        Me.TextBox12.Size = New System.Drawing.Size(83, 20)
        Me.TextBox12.TabIndex = 13
        '
        'GroupBox5
        '
        Me.GroupBox5.Controls.Add(Me.Label45)
        Me.GroupBox5.Controls.Add(Me.Button23)
        Me.GroupBox5.Controls.Add(Me.Label7)
        Me.GroupBox5.Controls.Add(Me.TextBox4)
        Me.GroupBox5.Controls.Add(Me.Label8)
        Me.GroupBox5.Controls.Add(Me.Label6)
        Me.GroupBox5.Controls.Add(Me.TextBox5)
        Me.GroupBox5.Controls.Add(Me.Label22)
        Me.GroupBox5.Controls.Add(Me.Button5)
        Me.GroupBox5.Controls.Add(Me.ComboBox7)
        Me.GroupBox5.Controls.Add(Me.Label24)
        Me.GroupBox5.Location = New System.Drawing.Point(10, 9)
        Me.GroupBox5.Name = "GroupBox5"
        Me.GroupBox5.Size = New System.Drawing.Size(218, 247)
        Me.GroupBox5.TabIndex = 73
        Me.GroupBox5.TabStop = False
        Me.GroupBox5.Text = "Actors"
        '
        'Label45
        '
        Me.Label45.AutoSize = True
        Me.Label45.Location = New System.Drawing.Point(7, 194)
        Me.Label45.Name = "Label45"
        Me.Label45.Size = New System.Drawing.Size(0, 13)
        Me.Label45.TabIndex = 55
        '
        'Button23
        '
        Me.Button23.BackColor = System.Drawing.SystemColors.Control
        Me.Button23.Location = New System.Drawing.Point(133, 1)
        Me.Button23.Name = "Button23"
        Me.Button23.Size = New System.Drawing.Size(50, 23)
        Me.Button23.TabIndex = 54
        Me.Button23.Text = "Presets"
        Me.Button23.UseVisualStyleBackColor = False
        '
        'Label7
        '
        Me.Label7.AutoSize = True
        Me.Label7.Location = New System.Drawing.Point(62, 154)
        Me.Label7.Name = "Label7"
        Me.Label7.Size = New System.Drawing.Size(82, 13)
        Me.Label7.TabIndex = 39
        Me.Label7.Text = "Models (groups)"
        '
        'TextBox4
        '
        Me.TextBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox4.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox4.Location = New System.Drawing.Point(105, 126)
        Me.TextBox4.MaxLength = 4
        Me.TextBox4.Name = "TextBox4"
        Me.TextBox4.Size = New System.Drawing.Size(85, 20)
        Me.TextBox4.TabIndex = 3
        '
        'Label8
        '
        Me.Label8.AutoSize = True
        Me.Label8.Location = New System.Drawing.Point(13, 110)
        Me.Label8.Name = "Label8"
        Me.Label8.Size = New System.Drawing.Size(44, 13)
        Me.Label8.TabIndex = 33
        Me.Label8.Text = "Number"
        '
        'Label6
        '
        Me.Label6.AutoSize = True
        Me.Label6.Location = New System.Drawing.Point(102, 110)
        Me.Label6.Name = "Label6"
        Me.Label6.Size = New System.Drawing.Size(45, 13)
        Me.Label6.TabIndex = 34
        Me.Label6.Text = "Variable"
        '
        'TextBox5
        '
        Me.TextBox5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox5.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper
        Me.TextBox5.Location = New System.Drawing.Point(105, 172)
        Me.TextBox5.MaxLength = 4
        Me.TextBox5.Name = "TextBox5"
        Me.TextBox5.Size = New System.Drawing.Size(85, 20)
        Me.TextBox5.TabIndex = 5
        '
        'Label22
        '
        Me.Label22.AutoSize = True
        Me.Label22.Location = New System.Drawing.Point(13, 18)
        Me.Label22.Name = "Label22"
        Me.Label22.Size = New System.Drawing.Size(68, 13)
        Me.Label22.TabIndex = 52
        Me.Label22.Text = "Room Actors"
        '
        'Button5
        '
        Me.Button5.BackColor = System.Drawing.SystemColors.Control
        Me.Button5.Location = New System.Drawing.Point(62, 212)
        Me.Button5.Name = "Button5"
        Me.Button5.Size = New System.Drawing.Size(78, 23)
        Me.Button5.TabIndex = 7
        Me.Button5.Text = "Dump Values"
        Me.Button5.UseVisualStyleBackColor = True
        '
        'ComboBox7
        '
        Me.ComboBox7.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.ComboBox7.FlatStyle = System.Windows.Forms.FlatStyle.Flat
        Me.ComboBox7.FormattingEnabled = True
        Me.ComboBox7.Location = New System.Drawing.Point(16, 34)
        Me.ComboBox7.Name = "ComboBox7"
        Me.ComboBox7.Size = New System.Drawing.Size(180, 21)
        Me.ComboBox7.TabIndex = 0
        '
        'Label24
        '
        Me.Label24.AutoSize = True
        Me.Label24.Location = New System.Drawing.Point(14, 62)
        Me.Label24.Name = "Label24"
        Me.Label24.Size = New System.Drawing.Size(71, 13)
        Me.Label24.TabIndex = 53
        Me.Label24.Text = "Scene Actors"
        '
        'TabPage1
        '
        Me.TabPage1.BackColor = System.Drawing.Color.Transparent
        Me.TabPage1.Controls.Add(Me.Button12)
        Me.TabPage1.Controls.Add(Me.Label3)
        Me.TabPage1.Controls.Add(Me.Label4)
        Me.TabPage1.Controls.Add(Me.Label5)
        Me.TabPage1.Controls.Add(Me.TextBox1)
        Me.TabPage1.Controls.Add(Me.TextBox2)
        Me.TabPage1.Controls.Add(Me.GroupBox2)
        Me.TabPage1.Location = New System.Drawing.Point(4, 40)
        Me.TabPage1.Name = "TabPage1"
        Me.TabPage1.Padding = New System.Windows.Forms.Padding(3)
        Me.TabPage1.Size = New System.Drawing.Size(234, 507)
        Me.TabPage1.TabIndex = 0
        Me.TabPage1.Text = "Graphics"
        Me.TabPage1.UseVisualStyleBackColor = True
        '
        'Button12
        '
        Me.Button12.BackColor = System.Drawing.SystemColors.Control
        Me.Button12.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button12.Location = New System.Drawing.Point(143, 48)
        Me.Button12.Name = "Button12"
        Me.Button12.Size = New System.Drawing.Size(23, 23)
        Me.Button12.TabIndex = 3
        Me.Button12.UseVisualStyleBackColor = True
        '
        'Label3
        '
        Me.Label3.AutoSize = True
        Me.Label3.Location = New System.Drawing.Point(33, 36)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(54, 13)
        Me.Label3.TabIndex = 1
        Me.Label3.Text = "X Position"
        '
        'Label4
        '
        Me.Label4.AutoSize = True
        Me.Label4.Location = New System.Drawing.Point(33, 71)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(54, 13)
        Me.Label4.TabIndex = 2
        Me.Label4.Text = "Y Position"
        '
        'Label5
        '
        Me.Label5.AutoSize = True
        Me.Label5.Location = New System.Drawing.Point(33, 105)
        Me.Label5.Name = "Label5"
        Me.Label5.Size = New System.Drawing.Size(54, 13)
        Me.Label5.TabIndex = 3
        Me.Label5.Text = "Z Position"
        '
        'TextBox1
        '
        Me.TextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox1.Location = New System.Drawing.Point(37, 50)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.Size = New System.Drawing.Size(100, 20)
        Me.TextBox1.TabIndex = 0
        '
        'TextBox2
        '
        Me.TextBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox2.Location = New System.Drawing.Point(37, 84)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.Size = New System.Drawing.Size(100, 20)
        Me.TextBox2.TabIndex = 1
        '
        'GroupBox2
        '
        Me.GroupBox2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink
        Me.GroupBox2.Controls.Add(Me.CheckBox18)
        Me.GroupBox2.Controls.Add(Me.CheckBox17)
        Me.GroupBox2.Controls.Add(Me.CheckBox16)
        Me.GroupBox2.Controls.Add(Me.Button30)
        Me.GroupBox2.Controls.Add(Me.Button31)
        Me.GroupBox2.Controls.Add(Me.Button32)
        Me.GroupBox2.Controls.Add(Me.GroupBox11)
        Me.GroupBox2.Controls.Add(Me.Button33)
        Me.GroupBox2.Controls.Add(Me.Button34)
        Me.GroupBox2.Controls.Add(Me.Button28)
        Me.GroupBox2.Controls.Add(Me.Button10)
        Me.GroupBox2.Controls.Add(Me.Label41)
        Me.GroupBox2.Controls.Add(Me.Button29)
        Me.GroupBox2.Controls.Add(Me.Label42)
        Me.GroupBox2.Controls.Add(Me.TextBox21)
        Me.GroupBox2.Controls.Add(Me.TextBox22)
        Me.GroupBox2.Controls.Add(Me.Label27)
        Me.GroupBox2.Controls.Add(Me.Label20)
        Me.GroupBox2.Controls.Add(Me.Button20)
        Me.GroupBox2.Controls.Add(Me.Label26)
        Me.GroupBox2.Controls.Add(Me.Button19)
        Me.GroupBox2.Controls.Add(Me.Button17)
        Me.GroupBox2.Controls.Add(Me.Label25)
        Me.GroupBox2.Controls.Add(Me.Label9)
        Me.GroupBox2.Controls.Add(Me.Button18)
        Me.GroupBox2.Controls.Add(Me.Button14)
        Me.GroupBox2.Controls.Add(Me.Button1)
        Me.GroupBox2.Controls.Add(Me.Button4)
        Me.GroupBox2.Controls.Add(Me.Button13)
        Me.GroupBox2.Controls.Add(Me.TextBox3)
        Me.GroupBox2.Controls.Add(Me.Movement)
        Me.GroupBox2.Location = New System.Drawing.Point(16, 9)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(200, 598)
        Me.GroupBox2.TabIndex = 57
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "Vertices"
        '
        'CheckBox18
        '
        Me.CheckBox18.AutoSize = True
        Me.CheckBox18.Checked = True
        Me.CheckBox18.CheckState = System.Windows.Forms.CheckState.Checked
        Me.CheckBox18.Location = New System.Drawing.Point(64, 462)
        Me.CheckBox18.Name = "CheckBox18"
        Me.CheckBox18.Size = New System.Drawing.Size(73, 17)
        Me.CheckBox18.TabIndex = 57
        Me.CheckBox18.Text = "Snap to Z"
        Me.CheckBox18.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        Me.CheckBox18.UseVisualStyleBackColor = True
        '
        'CheckBox17
        '
        Me.CheckBox17.AutoSize = True
        Me.CheckBox17.Checked = True
        Me.CheckBox17.CheckState = System.Windows.Forms.CheckState.Checked
        Me.CheckBox17.Location = New System.Drawing.Point(64, 439)
        Me.CheckBox17.Name = "CheckBox17"
        Me.CheckBox17.Size = New System.Drawing.Size(73, 17)
        Me.CheckBox17.TabIndex = 56
        Me.CheckBox17.Text = "Snap to Y"
        Me.CheckBox17.UseVisualStyleBackColor = True
        '
        'CheckBox16
        '
        Me.CheckBox16.AutoSize = True
        Me.CheckBox16.Checked = True
        Me.CheckBox16.CheckState = System.Windows.Forms.CheckState.Checked
        Me.CheckBox16.Location = New System.Drawing.Point(64, 416)
        Me.CheckBox16.Name = "CheckBox16"
        Me.CheckBox16.Size = New System.Drawing.Size(73, 17)
        Me.CheckBox16.TabIndex = 55
        Me.CheckBox16.Text = "Snap to X"
        Me.CheckBox16.UseVisualStyleBackColor = True
        '
        'Button30
        '
        Me.Button30.BackColor = System.Drawing.SystemColors.Control
        Me.Button30.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button30.Image = CType(resources.GetObject("Button30.Image"), System.Drawing.Image)
        Me.Button30.Location = New System.Drawing.Point(155, 182)
        Me.Button30.Name = "Button30"
        Me.Button30.Size = New System.Drawing.Size(23, 23)
        Me.Button30.TabIndex = 53
        Me.Button30.UseVisualStyleBackColor = True
        Me.Button30.Visible = False
        '
        'Button31
        '
        Me.Button31.BackColor = System.Drawing.SystemColors.Control
        Me.Button31.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button31.Image = CType(resources.GetObject("Button31.Image"), System.Drawing.Image)
        Me.Button31.Location = New System.Drawing.Point(155, 145)
        Me.Button31.Name = "Button31"
        Me.Button31.Size = New System.Drawing.Size(23, 23)
        Me.Button31.TabIndex = 52
        Me.Button31.UseVisualStyleBackColor = True
        Me.Button31.Visible = False
        '
        'Button32
        '
        Me.Button32.BackColor = System.Drawing.SystemColors.Control
        Me.Button32.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button32.Image = CType(resources.GetObject("Button32.Image"), System.Drawing.Image)
        Me.Button32.Location = New System.Drawing.Point(155, 39)
        Me.Button32.Name = "Button32"
        Me.Button32.Size = New System.Drawing.Size(23, 23)
        Me.Button32.TabIndex = 49
        Me.Button32.UseVisualStyleBackColor = True
        Me.Button32.Visible = False
        '
        'GroupBox11
        '
        Me.GroupBox11.Controls.Add(Me.CheckBox19)
        Me.GroupBox11.Controls.Add(Me.Label44)
        Me.GroupBox11.Controls.Add(Me.Button37)
        Me.GroupBox11.Location = New System.Drawing.Point(23, 395)
        Me.GroupBox11.Name = "GroupBox11"
        Me.GroupBox11.Size = New System.Drawing.Size(159, 165)
        Me.GroupBox11.TabIndex = 58
        Me.GroupBox11.TabStop = False
        Me.GroupBox11.Text = "Snap to"
        '
        'CheckBox19
        '
        Me.CheckBox19.AutoSize = True
        Me.CheckBox19.Checked = True
        Me.CheckBox19.CheckState = System.Windows.Forms.CheckState.Checked
        Me.CheckBox19.Location = New System.Drawing.Point(5, 88)
        Me.CheckBox19.Name = "CheckBox19"
        Me.CheckBox19.Size = New System.Drawing.Size(154, 17)
        Me.CheckBox19.TabIndex = 59
        Me.CheckBox19.Text = "Auto-Switch off when done"
        Me.CheckBox19.UseVisualStyleBackColor = True
        '
        'Label44
        '
        Me.Label44.AutoSize = True
        Me.Label44.Location = New System.Drawing.Point(31, 141)
        Me.Label44.Name = "Label44"
        Me.Label44.Size = New System.Drawing.Size(97, 13)
        Me.Label44.TabIndex = 55
        Me.Label44.Text = "(Toggle with F key)"
        '
        'Button37
        '
        Me.Button37.BackColor = System.Drawing.SystemColors.Control
        Me.Button37.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Button37.Location = New System.Drawing.Point(13, 110)
        Me.Button37.Name = "Button37"
        Me.Button37.Size = New System.Drawing.Size(133, 24)
        Me.Button37.TabIndex = 54
        Me.Button37.Text = "Start snap mode"
        Me.Button37.UseVisualStyleBackColor = False
        '
        'Button33
        '
        Me.Button33.BackColor = System.Drawing.SystemColors.Control
        Me.Button33.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button33.Image = CType(resources.GetObject("Button33.Image"), System.Drawing.Image)
        Me.Button33.Location = New System.Drawing.Point(155, 74)
        Me.Button33.Name = "Button33"
        Me.Button33.Size = New System.Drawing.Size(23, 23)
        Me.Button33.TabIndex = 50
        Me.Button33.UseVisualStyleBackColor = True
        Me.Button33.Visible = False
        '
        'Button34
        '
        Me.Button34.BackColor = System.Drawing.SystemColors.Control
        Me.Button34.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button34.Image = CType(resources.GetObject("Button34.Image"), System.Drawing.Image)
        Me.Button34.Location = New System.Drawing.Point(155, 108)
        Me.Button34.Name = "Button34"
        Me.Button34.Size = New System.Drawing.Size(23, 23)
        Me.Button34.TabIndex = 51
        Me.Button34.UseVisualStyleBackColor = True
        Me.Button34.Visible = False
        '
        'Button28
        '
        Me.Button28.BackColor = System.Drawing.SystemColors.Control
        Me.Button28.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button28.Location = New System.Drawing.Point(127, 182)
        Me.Button28.Name = "Button28"
        Me.Button28.Size = New System.Drawing.Size(23, 23)
        Me.Button28.TabIndex = 48
        Me.Button28.UseVisualStyleBackColor = True
        '
        'Button10
        '
        Me.Button10.BackColor = System.Drawing.SystemColors.Control
        Me.Button10.Location = New System.Drawing.Point(21, 222)
        Me.Button10.Name = "Button10"
        Me.Button10.Size = New System.Drawing.Size(100, 23)
        Me.Button10.TabIndex = 6
        Me.Button10.UseVisualStyleBackColor = True
        '
        'Label41
        '
        Me.Label41.AutoSize = True
        Me.Label41.Location = New System.Drawing.Point(17, 133)
        Me.Label41.Name = "Label41"
        Me.Label41.Size = New System.Drawing.Size(69, 13)
        Me.Label41.TabIndex = 45
        Me.Label41.Text = "U Coordinate"
        '
        'Button29
        '
        Me.Button29.BackColor = System.Drawing.SystemColors.Control
        Me.Button29.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button29.Location = New System.Drawing.Point(127, 145)
        Me.Button29.Name = "Button29"
        Me.Button29.Size = New System.Drawing.Size(23, 23)
        Me.Button29.TabIndex = 47
        Me.Button29.UseVisualStyleBackColor = True
        '
        'Label42
        '
        Me.Label42.AutoSize = True
        Me.Label42.Location = New System.Drawing.Point(17, 170)
        Me.Label42.Name = "Label42"
        Me.Label42.Size = New System.Drawing.Size(68, 13)
        Me.Label42.TabIndex = 46
        Me.Label42.Text = "V Coordinate"
        '
        'TextBox21
        '
        Me.TextBox21.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox21.Location = New System.Drawing.Point(21, 184)
        Me.TextBox21.Name = "TextBox21"
        Me.TextBox21.Size = New System.Drawing.Size(100, 20)
        Me.TextBox21.TabIndex = 44
        '
        'TextBox22
        '
        Me.TextBox22.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox22.Location = New System.Drawing.Point(21, 147)
        Me.TextBox22.Name = "TextBox22"
        Me.TextBox22.Size = New System.Drawing.Size(100, 20)
        Me.TextBox22.TabIndex = 43
        '
        'Label27
        '
        Me.Label27.AutoSize = True
        Me.Label27.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label27.Location = New System.Drawing.Point(123, 271)
        Me.Label27.Name = "Label27"
        Me.Label27.Size = New System.Drawing.Size(14, 13)
        Me.Label27.TabIndex = 41
        Me.Label27.Text = "Z"
        '
        'Label20
        '
        Me.Label20.AutoSize = True
        Me.Label20.Location = New System.Drawing.Point(18, 207)
        Me.Label20.Name = "Label20"
        Me.Label20.Size = New System.Drawing.Size(31, 13)
        Me.Label20.TabIndex = 14
        Me.Label20.Text = "Color"
        '
        'Button20
        '
        Me.Button20.BackColor = System.Drawing.SystemColors.Control
        Me.Button20.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button20.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button20.Image = CType(resources.GetObject("Button20.Image"), System.Drawing.Image)
        Me.Button20.Location = New System.Drawing.Point(68, 296)
        Me.Button20.Name = "Button20"
        Me.Button20.Size = New System.Drawing.Size(29, 23)
        Me.Button20.TabIndex = 10
        Me.Button20.UseVisualStyleBackColor = True
        '
        'Label26
        '
        Me.Label26.AutoSize = True
        Me.Label26.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label26.Location = New System.Drawing.Point(203, 136)
        Me.Label26.Name = "Label26"
        Me.Label26.Size = New System.Drawing.Size(14, 13)
        Me.Label26.TabIndex = 21
        Me.Label26.Text = "Z"
        '
        'Button19
        '
        Me.Button19.BackColor = System.Drawing.SystemColors.Control
        Me.Button19.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button19.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button19.Image = CType(resources.GetObject("Button19.Image"), System.Drawing.Image)
        Me.Button19.Location = New System.Drawing.Point(138, 274)
        Me.Button19.Name = "Button19"
        Me.Button19.Size = New System.Drawing.Size(29, 23)
        Me.Button19.TabIndex = 12
        Me.Button19.UseVisualStyleBackColor = True
        '
        'Button17
        '
        Me.Button17.BackColor = System.Drawing.SystemColors.Control
        Me.Button17.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button17.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button17.Image = CType(resources.GetObject("Button17.Image"), System.Drawing.Image)
        Me.Button17.Location = New System.Drawing.Point(138, 296)
        Me.Button17.Name = "Button17"
        Me.Button17.Size = New System.Drawing.Size(29, 23)
        Me.Button17.TabIndex = 13
        Me.Button17.UseVisualStyleBackColor = True
        '
        'Label25
        '
        Me.Label25.AutoSize = True
        Me.Label25.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label25.Location = New System.Drawing.Point(25, 305)
        Me.Label25.Name = "Label25"
        Me.Label25.Size = New System.Drawing.Size(14, 13)
        Me.Label25.TabIndex = 18
        Me.Label25.Text = "X"
        '
        'Label9
        '
        Me.Label9.AutoSize = True
        Me.Label9.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label9.Location = New System.Drawing.Point(54, 271)
        Me.Label9.Name = "Label9"
        Me.Label9.Size = New System.Drawing.Size(14, 13)
        Me.Label9.TabIndex = 17
        Me.Label9.Text = "Y"
        '
        'Button18
        '
        Me.Button18.BackColor = System.Drawing.SystemColors.Control
        Me.Button18.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button18.Image = CType(resources.GetObject("Button18.Image"), System.Drawing.Image)
        Me.Button18.Location = New System.Drawing.Point(40, 296)
        Me.Button18.Name = "Button18"
        Me.Button18.Size = New System.Drawing.Size(29, 23)
        Me.Button18.TabIndex = 9
        Me.Button18.Text = " "
        Me.Button18.UseVisualStyleBackColor = True
        '
        'Button14
        '
        Me.Button14.BackColor = System.Drawing.SystemColors.Control
        Me.Button14.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button14.Location = New System.Drawing.Point(127, 74)
        Me.Button14.Name = "Button14"
        Me.Button14.Size = New System.Drawing.Size(23, 23)
        Me.Button14.TabIndex = 4
        Me.Button14.UseVisualStyleBackColor = True
        '
        'Button1
        '
        Me.Button1.BackColor = System.Drawing.SystemColors.Control
        Me.Button1.Location = New System.Drawing.Point(126, 222)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(53, 23)
        Me.Button1.TabIndex = 7
        Me.Button1.Text = "Apply"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'Button4
        '
        Me.Button4.BackColor = System.Drawing.SystemColors.Control
        Me.Button4.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button4.Image = CType(resources.GetObject("Button4.Image"), System.Drawing.Image)
        Me.Button4.Location = New System.Drawing.Point(96, 296)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(29, 23)
        Me.Button4.TabIndex = 11
        Me.Button4.UseVisualStyleBackColor = True
        '
        'Button13
        '
        Me.Button13.BackColor = System.Drawing.SystemColors.Control
        Me.Button13.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button13.Location = New System.Drawing.Point(127, 108)
        Me.Button13.Name = "Button13"
        Me.Button13.Size = New System.Drawing.Size(23, 23)
        Me.Button13.TabIndex = 5
        Me.Button13.UseVisualStyleBackColor = True
        '
        'TextBox3
        '
        Me.TextBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.TextBox3.Location = New System.Drawing.Point(21, 110)
        Me.TextBox3.Name = "TextBox3"
        Me.TextBox3.Size = New System.Drawing.Size(100, 20)
        Me.TextBox3.TabIndex = 2
        '
        'Movement
        '
        Me.Movement.Controls.Add(Me.Button24)
        Me.Movement.Controls.Add(Me.Label39)
        Me.Movement.Controls.Add(Me.Label40)
        Me.Movement.Controls.Add(Me.Button25)
        Me.Movement.Controls.Add(Me.Button26)
        Me.Movement.Controls.Add(Me.Button27)
        Me.Movement.Controls.Add(Me.Button8)
        Me.Movement.Location = New System.Drawing.Point(22, 249)
        Me.Movement.Name = "Movement"
        Me.Movement.Size = New System.Drawing.Size(159, 140)
        Me.Movement.TabIndex = 42
        Me.Movement.TabStop = False
        Me.Movement.Text = "Movement"
        '
        'Button24
        '
        Me.Button24.BackColor = System.Drawing.SystemColors.Control
        Me.Button24.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button24.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Button24.Image = CType(resources.GetObject("Button24.Image"), System.Drawing.Image)
        Me.Button24.Location = New System.Drawing.Point(47, 107)
        Me.Button24.Name = "Button24"
        Me.Button24.Size = New System.Drawing.Size(29, 23)
        Me.Button24.TabIndex = 21
        Me.Button24.UseVisualStyleBackColor = True
        '
        'Label39
        '
        Me.Label39.AutoSize = True
        Me.Label39.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label39.Location = New System.Drawing.Point(4, 116)
        Me.Label39.Name = "Label39"
        Me.Label39.Size = New System.Drawing.Size(15, 13)
        Me.Label39.TabIndex = 24
        Me.Label39.Text = "U"
        '
        'Label40
        '
        Me.Label40.AutoSize = True
        Me.Label40.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label40.Location = New System.Drawing.Point(32, 82)
        Me.Label40.Name = "Label40"
        Me.Label40.Size = New System.Drawing.Size(14, 13)
        Me.Label40.TabIndex = 23
        Me.Label40.Text = "V"
        '
        'Button25
        '
        Me.Button25.BackColor = System.Drawing.SystemColors.Control
        Me.Button25.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button25.Image = CType(resources.GetObject("Button25.Image"), System.Drawing.Image)
        Me.Button25.Location = New System.Drawing.Point(19, 107)
        Me.Button25.Name = "Button25"
        Me.Button25.Size = New System.Drawing.Size(29, 23)
        Me.Button25.TabIndex = 20
        Me.Button25.Text = " "
        Me.Button25.UseVisualStyleBackColor = True
        '
        'Button26
        '
        Me.Button26.BackColor = System.Drawing.SystemColors.Control
        Me.Button26.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button26.Image = CType(resources.GetObject("Button26.Image"), System.Drawing.Image)
        Me.Button26.Location = New System.Drawing.Point(47, 85)
        Me.Button26.Name = "Button26"
        Me.Button26.Size = New System.Drawing.Size(29, 23)
        Me.Button26.TabIndex = 19
        Me.Button26.UseVisualStyleBackColor = True
        '
        'Button27
        '
        Me.Button27.BackColor = System.Drawing.SystemColors.Control
        Me.Button27.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button27.Image = CType(resources.GetObject("Button27.Image"), System.Drawing.Image)
        Me.Button27.Location = New System.Drawing.Point(75, 107)
        Me.Button27.Name = "Button27"
        Me.Button27.Size = New System.Drawing.Size(29, 23)
        Me.Button27.TabIndex = 22
        Me.Button27.UseVisualStyleBackColor = True
        '
        'Button8
        '
        Me.Button8.BackColor = System.Drawing.SystemColors.Control
        Me.Button8.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button8.Image = CType(resources.GetObject("Button8.Image"), System.Drawing.Image)
        Me.Button8.Location = New System.Drawing.Point(46, 25)
        Me.Button8.Name = "Button8"
        Me.Button8.Size = New System.Drawing.Size(29, 23)
        Me.Button8.TabIndex = 8
        Me.Button8.UseVisualStyleBackColor = True
        '
        'TabControl1
        '
        Me.TabControl1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TabControl1.Controls.Add(Me.TabPage1)
        Me.TabControl1.Controls.Add(Me.TabPage2)
        Me.TabControl1.Controls.Add(Me.TabPage3)
        Me.TabControl1.Controls.Add(Me.TabPage4)
        Me.TabControl1.Controls.Add(Me.TabPage5)
        Me.TabControl1.Controls.Add(Me.TabPage6)
        Me.TabControl1.Controls.Add(Me.TabPage7)
        Me.TabControl1.HotTrack = True
        Me.TabControl1.Location = New System.Drawing.Point(550, 0)
        Me.TabControl1.Multiline = True
        Me.TabControl1.Name = "TabControl1"
        Me.TabControl1.SelectedIndex = 0
        Me.TabControl1.Size = New System.Drawing.Size(242, 551)
        Me.TabControl1.TabIndex = 3
        Me.TabControl1.Visible = False
        '
        'TabPage6
        '
        Me.TabPage6.Controls.Add(Me.Button41)
        Me.TabPage6.Controls.Add(Me.DebugTree)
        Me.TabPage6.Location = New System.Drawing.Point(4, 40)
        Me.TabPage6.Name = "TabPage6"
        Me.TabPage6.Size = New System.Drawing.Size(234, 507)
        Me.TabPage6.TabIndex = 5
        Me.TabPage6.Text = "Debug"
        Me.TabPage6.UseVisualStyleBackColor = True
        '
        'Button41
        '
        Me.Button41.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Button41.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink
        Me.Button41.Location = New System.Drawing.Point(156, 473)
        Me.Button41.Name = "Button41"
        Me.Button41.Size = New System.Drawing.Size(75, 23)
        Me.Button41.TabIndex = 1
        Me.Button41.Text = "Populate"
        Me.Button41.UseVisualStyleBackColor = True
        '
        'DebugTree
        '
        Me.DebugTree.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.DebugTree.CheckBoxes = True
        Me.DebugTree.ContextMenuStrip = Me.ContextMenuStrip2
        Me.DebugTree.HideSelection = False
        Me.DebugTree.HotTracking = True
        Me.DebugTree.Location = New System.Drawing.Point(3, 3)
        Me.DebugTree.Name = "DebugTree"
        Me.DebugTree.Size = New System.Drawing.Size(228, 234)
        Me.DebugTree.TabIndex = 0
        '
        'ContextMenuStrip2
        '
        Me.ContextMenuStrip2.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem3})
        Me.ContextMenuStrip2.Name = "ContextMenuStrip2"
        Me.ContextMenuStrip2.Size = New System.Drawing.Size(107, 26)
        '
        'ToolStripMenuItem3
        '
        Me.ToolStripMenuItem3.Name = "ToolStripMenuItem3"
        Me.ToolStripMenuItem3.Size = New System.Drawing.Size(106, 22)
        Me.ToolStripMenuItem3.Text = "Toggle"
        '
        'TabPage7
        '
        Me.TabPage7.Controls.Add(Me.FileTree)
        Me.TabPage7.Location = New System.Drawing.Point(4, 40)
        Me.TabPage7.Name = "TabPage7"
        Me.TabPage7.Size = New System.Drawing.Size(234, 507)
        Me.TabPage7.TabIndex = 6
        Me.TabPage7.Text = "ROM Files"
        Me.TabPage7.UseVisualStyleBackColor = True
        '
        'FileTree
        '
        Me.FileTree.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.FileTree.ContextMenuStrip = Me.ContextMenuStrip2
        Me.FileTree.HideSelection = False
        Me.FileTree.HotTracking = True
        Me.FileTree.Location = New System.Drawing.Point(3, 3)
        Me.FileTree.Name = "FileTree"
        Me.FileTree.Size = New System.Drawing.Size(228, 498)
        Me.FileTree.TabIndex = 1
        '
        'Label43
        '
        Me.Label43.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.Label43.AutoSize = True
        Me.Label43.Font = New System.Drawing.Font("Trebuchet MS", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label43.Location = New System.Drawing.Point(400, 553)
        Me.Label43.Name = "Label43"
        Me.Label43.Size = New System.Drawing.Size(89, 18)
        Me.Label43.TabIndex = 102
        Me.Label43.Text = "Camera speed:"
        '
        'TrackBar1
        '
        Me.TrackBar1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.TrackBar1.AutoSize = False
        Me.TrackBar1.Cursor = System.Windows.Forms.Cursors.Hand
        Me.TrackBar1.Location = New System.Drawing.Point(490, 554)
        Me.TrackBar1.Maximum = 40
        Me.TrackBar1.Minimum = 1
        Me.TrackBar1.Name = "TrackBar1"
        Me.TrackBar1.Size = New System.Drawing.Size(90, 15)
        Me.TrackBar1.TabIndex = 103
        Me.TrackBar1.Value = 20
        '
        'SimpleOpenGlControl1
        '
        Me.SimpleOpenGlControl1.AccumBits = CType(0, Byte)
        Me.SimpleOpenGlControl1.AllowDrop = True
        Me.SimpleOpenGlControl1.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.SimpleOpenGlControl1.AutoCheckErrors = False
        Me.SimpleOpenGlControl1.AutoFinish = True
        Me.SimpleOpenGlControl1.AutoMakeCurrent = True
        Me.SimpleOpenGlControl1.AutoSize = True
        Me.SimpleOpenGlControl1.AutoSwapBuffers = False
        Me.SimpleOpenGlControl1.AutoValidate = System.Windows.Forms.AutoValidate.EnablePreventFocusChange
        Me.SimpleOpenGlControl1.BackColor = System.Drawing.Color.Black
        Me.SimpleOpenGlControl1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch
        Me.SimpleOpenGlControl1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.SimpleOpenGlControl1.ColorBits = CType(32, Byte)
        Me.SimpleOpenGlControl1.Cursor = System.Windows.Forms.Cursors.Default
        Me.SimpleOpenGlControl1.DepthBits = CType(32, Byte)
        Me.SimpleOpenGlControl1.Location = New System.Drawing.Point(-4, 23)
        Me.SimpleOpenGlControl1.Name = "SimpleOpenGlControl1"
        Me.SimpleOpenGlControl1.Size = New System.Drawing.Size(796, 555)
        Me.SimpleOpenGlControl1.StencilBits = CType(0, Byte)
        Me.SimpleOpenGlControl1.TabIndex = 0
        '
        'ContextMenuStrip1
        '
        Me.ContextMenuStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripMenuItem1, Me.ToolStripMenuItem2})
        Me.ContextMenuStrip1.Name = "ContextMenuStrip1"
        Me.ContextMenuStrip1.Size = New System.Drawing.Size(100, 48)
        '
        'ToolStripMenuItem1
        '
        Me.ToolStripMenuItem1.Name = "ToolStripMenuItem1"
        Me.ToolStripMenuItem1.Size = New System.Drawing.Size(99, 22)
        Me.ToolStripMenuItem1.Text = "+90º"
        '
        'ToolStripMenuItem2
        '
        Me.ToolStripMenuItem2.Name = "ToolStripMenuItem2"
        Me.ToolStripMenuItem2.Size = New System.Drawing.Size(99, 22)
        Me.ToolStripMenuItem2.Text = "-90º"
        '
        'Button9
        '
        Me.Button9.BackColor = System.Drawing.SystemColors.Control
        Me.Button9.Location = New System.Drawing.Point(774, 10)
        Me.Button9.Name = "Button9"
        Me.Button9.Size = New System.Drawing.Size(86, 23)
        Me.Button9.TabIndex = 6
        Me.Button9.Text = "Add Actor"
        Me.Button9.UseVisualStyleBackColor = True
        Me.Button9.Visible = False
        '
        'MainWin
        '
        Me.AllowDrop = True
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit
        Me.ClientSize = New System.Drawing.Size(792, 573)
        Me.Controls.Add(Me.ComboBox3)
        Me.Controls.Add(Me.Label11)
        Me.Controls.Add(Me.Label12)
        Me.Controls.Add(Me.Label43)
        Me.Controls.Add(Me.TrackBar1)
        Me.Controls.Add(Me.TabControl1)
        Me.Controls.Add(Me.TrackBar4)
        Me.Controls.Add(Me.Button9)
        Me.Controls.Add(Me.StatusStrip1)
        Me.Controls.Add(Me.MenuStrip1)
        Me.Controls.Add(Me.SimpleOpenGlControl1)
        Me.DoubleBuffered = True
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MainMenuStrip = Me.MenuStrip1
        Me.Name = "MainWin"
        Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show
        Me.Text = "Utility of Time 0.95"
        Me.ContextMenuStrip4.ResumeLayout(False)
        Me.ContextMenuStrip5.ResumeLayout(False)
        CType(Me.TrackBar4, System.ComponentModel.ISupportInitialize).EndInit()
        Me.MenuStrip1.ResumeLayout(False)
        Me.MenuStrip1.PerformLayout()
        Me.ContextMenuStrip7.ResumeLayout(False)
        Me.TabPage5.ResumeLayout(False)
        Me.GroupBox7.ResumeLayout(False)
        Me.GroupBox7.PerformLayout()
        Me.GroupBox9.ResumeLayout(False)
        Me.GroupBox9.PerformLayout()
        Me.TabPage4.ResumeLayout(False)
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox10.ResumeLayout(False)
        Me.GroupBox10.PerformLayout()
        Me.TabPage3.ResumeLayout(False)
        Me.GroupBox3.ResumeLayout(False)
        Me.GroupBox3.PerformLayout()
        Me.GroupBox6.ResumeLayout(False)
        Me.GroupBox6.PerformLayout()
        Me.TabPage2.ResumeLayout(False)
        Me.TabPage2.PerformLayout()
        Me.GroupBox4.ResumeLayout(False)
        Me.GroupBox4.PerformLayout()
        Me.GroupBox5.ResumeLayout(False)
        Me.GroupBox5.PerformLayout()
        Me.TabPage1.ResumeLayout(False)
        Me.TabPage1.PerformLayout()
        Me.GroupBox2.ResumeLayout(False)
        Me.GroupBox2.PerformLayout()
        Me.GroupBox11.ResumeLayout(False)
        Me.GroupBox11.PerformLayout()
        Me.Movement.ResumeLayout(False)
        Me.Movement.PerformLayout()
        Me.TabControl1.ResumeLayout(False)
        Me.TabPage6.ResumeLayout(False)
        Me.ContextMenuStrip2.ResumeLayout(False)
        Me.TabPage7.ResumeLayout(False)
        CType(Me.TrackBar1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ContextMenuStrip1.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
#End Region
#Region "Variables"
    Private TexFormat As UInt32 = 0
    Private TexelSize As UInt32 = 0
    Private TMemAddress As UInt32 = 0
    Private CMT As UInt32 = 0
    Private MaskT As UInt32 = 0
    Private ShiftT As UInt32 = 0
    Private CMS As UInt32 = 0
    Private MaskS As UInt32 = 0
    Private ShiftS As UInt32 = 0
    Private BPP As Integer = 0
    Private ImageFormat As Integer = 0
    Private mapst As Integer = 0
    Private scenest As Integer = 0
    Private scbuffsize As Integer = 0
    Private mapbuffsize As Integer = 0
    Private objbuffsize As Integer = 0
    Private scfilename As String = ""
    Private mapfilename As String = ""
    Private objectfilename As String = ""
    Private ZFileBuffer As Byte()
    Private ZSceneBuffer As Byte()
    Private MapCount As Integer = 0
    Private SceneCount As Integer = 0
    Private ObjectCount As Integer = 0
    Private ROMFiles As New ROMData
    Private BlendSrcFactor As Integer = 0
    Private BlendDstFactor As Integer = 0
    Private AlphaFunc As Integer = 0
    Private AlphaRef As Single = 0.0
    Private combine As Boolean = False
    Private LineSize As UInteger = 0
    Private CMDLow As UInt32
    Private CMDHigh As UInt32
    Private ShaderProg As UInt32
    Private COMBINE0 As UInt32
    Private COMBINE1 As UInt32
    Private cA0 As UInt32
    Private cB0 As UInt32
    Private cC0 As UInt32
    Private cD0 As UInt32
    Private aA0 As UInt32
    Private aB0 As UInt32
    Private aC0 As UInt32
    Private aD0 As UInt32
    Private cA1 As UInt32
    Private cB1 As UInt32
    Private cC1 As UInt32
    Private cD1 As UInt32
    Private aA1 As UInt32
    Private aB1 As UInt32
    Private aC1 As UInt32
    Private aD1 As UInt32
    Private T_Scale As UInt32
    Private S_Scale As UInt32
    Private x As Int16
    Private y As Int16
    Private z As Int16
    Private u As Double
    Private v As Double
    Private r As Single
    Private g As Single
    Private b As Single
    Private a As Single
    Private CMDStr As String = ""
    Private oldvtoff As Integer = 0
    Private TempVx1 As Int16 = 0
    Private TempVx2 As Int16 = 0
    Private TempVx3 As Int16 = 0
    Private TempVy1 As Int16 = 0
    Private TempVy2 As Int16 = 0
    Private TempVy3 As Int16 = 0
    Private TempVz1 As Int16 = 0
    Private TempVz2 As Int16 = 0
    Private TempVz3 As Int16 = 0
    Private TempVr1 As Int16 = 0
    Private TempVg2 As Int16 = 0
    Private TempVb3 As Int16 = 0
    Private TempVa1 As Int16 = 0
    Private TempVa2 As Int16 = 0
    Private TempVa3 As Int16 = 0
    Private TempVu1 As Int16 = 0
    Private TempVu2 As Int16 = 0
    Private TempVu3 As Int16 = 0
    Private TempVv1 As Int16 = 0
    Private TempVv2 As Int16 = 0
    Private TempVv3 As Int16 = 0
    Private EnableLighting As Boolean = False
    Private PrimColor(3) As Single
    Private RefreshDebug As Boolean = True
    Private DataBuffer() As Byte
    Private ScDataBuffer() As Byte
    Private DLInfo() As DisplayList
    Private MaxAnisotropy() As Single = {0.0F}
    Private weldautooff As Boolean = True
    Private objtexcnt As Integer = 0
    Private changetexenvm As New ArrayList
    Private mpick As Boolean
    Private ul As Int16 = 0
    Private vl As Int16 = 0
    Private meshw As Integer = -1
    Private vertw As Integer = -1
    Private weld As Boolean = False
    Private changepos(5) As Boolean
    Private cmdoff As New ArrayList
    Private agrbuff As New ArrayList
    Private anobuff As New ArrayList
    Private avarbuff As New ArrayList
    Private canrun As Boolean
    Private adescbuff As New ArrayList
    Private working As Boolean
    Private CollisionVerts As VertexCollision
    Private CollisionPolies As PolygonCollision
    Private cv As Integer = 0
    Private sv As Integer = 0
    Private ShaderLines As New ArrayList
    Private hide0(3) As Boolean
    Private maininfo As String = ""
    Private beentex As New ArrayList
    Private draworder As New ArrayList
    Private reset() As Boolean
    Private vtmode As Integer = 0
    Private sellink As New ArrayList
    Private ctris() As CTriSelect
    Private cmdtext As String = ""
    Private vtoff As Integer = 0
    Private n() As String = {"(all)", "(single)", "(mesh)"}
    Private CombineArray() As ArrayList
    Private timerstr As String = ""
    Private typecol As Integer = 0
    Private axestr As String = "(X + Y)"
    Private crc As Process = New Process
    Private cfix As Process = New Process
    Private seltype As String = ""
    Private coltypes As New ArrayList
    Private coltypeoff As New ArrayList
    Private i As Integer = 0
    Private i1 As Integer = 0
    Private i2 As Integer = 0
    Private i3 As Integer = 0
    Private i4 As Integer = 0
    Private tr5 As New ArrayList
    Private tg5 As New ArrayList
    Private tb5 As New ArrayList
    Private physgrp() As Integer
    Private physgrpc() As Integer
    Private su As String = ""
    Private colch As Integer = 0
    Private foundt As Boolean = False
    Private lockstate As Boolean = False
    Private changevert() As Boolean = {False, False, False, False, False}
    Private meshc As Boolean = False
    Private texc As Boolean = False
    Private selvertc As New ArrayList
    Private actordb As StreamReader
    Private actorindex As String = ""
    Private OBJVertices() As OBJPoints = {}
    Private OBJPolygons() As OBJFaces = {}
    Private OBJTexCoord() As OBJUVs = {}
    Private toolsens As Single = 0
    Private btnno As Integer = 0
    Private texfil As Integer = 0
    Private Vertices As Vertex3D
    Private objtextures() As UInt32
    Private selvert As New ArrayList
    Private selmesh As New ArrayList
    Private FPSCount As Integer = 0
    Private FPSCountSTR As String = ""
    Private dlcount As Integer = 0
    Private dimensiontest(1) As Integer
    Private gameplaykeep As FileStream
    Private dangenkeep As FileStream
    Private fieldkeep As FileStream
    Private formattest(1) As Byte
    Private banktest As Byte
    Private wraptest(1) As Byte
    Private linesizetest(3) As Byte
    Private texoff As UInt32
    Private xmode As Integer
    Private ymode As Integer
    Private TexWidth As Integer = 0
    Private TexHeight As Integer = 0
    Private TextureW As Integer = 0
    Private TextureH As Integer = 0
    Private texbytes As Integer = 0
    Private imagearray() As Byte
    Private newimagearray() As Byte
    Private PalBank As Integer = 0
    Private PalOff As Integer = 0
    Private palette() As Byte
    Private extracted As color4c
    Private dump As Boolean = False
    Private returnto As Integer = 0
    Private bankuse As Integer = 0
    Private texfilename As New ArrayList
    Private ElapsedTime As Integer
    Private current As Integer = -1
    Private weldpos(2) As Boolean
    Private key_w, key_a, key_s, key_d, key_q, key_e, key_u, key_o, key_up, key_lf, key_dn, key_rt, key_ctrl, key_alt As Boolean
    Private question As Boolean = True
    Private SaveOff As Integer = 0
    Private rendersc As Boolean = True
    Private renderobj As Boolean = True
    Private MouseLeft As Boolean = False
    Private MouseRight As Boolean = False
    Private run As Integer = 20
    Private AxisGuideDList As UInt32 = 0
    Private MouseMiddle As Boolean = False
    Private dumpto As String = ""
    Private EPDLoad As Boolean = False
    Private xrot As Double = 0.0
    Private yrot As Double = 0.0
    Private zrot As Double = 0.0
    Private ActorBox As UInt32 = 0
    Private dbfile As String = Application.StartupPath & "/ext/actor_db.txt"
    Private iniwrite As New iniwriter(Application.StartupPath & "/uot.ini")
    Private wireframe As Boolean = False
    Private ArrayOff As New ArrayList
    Private PolyInd(0) As ArrayList
    Private PolyStart As New ArrayList
    Private viewport(3) As Integer
    Private newx As Double = 0.0
    Private newy As Double = 0.0
    Private oldx As Double = 0.0
    Private oldy As Double = 0.0
    Private getobjectsets(3) As Integer
    Private cmdno As Integer = 0
    Private scenefile As FileStream
    Private scene As BufferedStream
    Private maploaded As Boolean = False
    Private actorfound As Integer = 0
    Private actorposoff() As Integer = {}
    Private xrotd As Double = 0
    Private yrotd As Double = 0
    Private zrotd As Double = 0
    Private identity As String
    Private selmode As Boolean = False
    Private rand As New Random
    Private tr As New ArrayList
    Private tg As New ArrayList
    Private tb As New ArrayList
    Private tr1 As New ArrayList
    Private tg1 As New ArrayList
    Private tb1 As New ArrayList
    Private tr3 As New ArrayList
    Private tg3 As New ArrayList
    Private tb3 As New ArrayList
    Private objoff As Integer = 0
    Private LocalMouse As Point
    Private oldLocalMouse As Point
    Private actorsel As Boolean = True
    Private vertexsel As Boolean = False
    Private cameraonly As Boolean = False
    Private showcdialog As Boolean = False
    Private Dx As Integer = 0
    Private Dy As Integer = 0
    Private Dz As Integer = 0
    Private Dy1 As Integer = 0
    Private Dx1 As Integer = 0
    Private vertmode As Integer = 0
    Private pixel(2) As Byte
    Private actored As Boolean
    Private final3dpos(2) As Double
    Private clicks(2) As Integer
    Private oldposx, oldposy, oldposz As Double
    Private myownsc As Boolean = False
    Private myownrm As Boolean = False
    Private selectedind As Integer = 0
    Private selectedinddr As Integer = 0
    Private tick As Integer = 0
    Private selectedindcol As Integer = 0
    Private grabxyz As Integer = 0
    Private oldoff As String = ""
    Private savenameobj As String = ""
    Private savenamesc As String = ""
    Private watersave As Int32
    Private musicsave As Int32
    Private linkr As Integer = 0
    Private zlestart16 As Integer = 0
    Private zleend16 As Integer = 0
    Private zlestart6 As Integer = 0
    Private zleend6 As Integer = 0
    Private curcol As Integer = 0
    Private exitoff As Integer = 0
    Private colvar As New ArrayList
    Private trisel As Boolean = False
    Private movest As Integer = 0
    Private myownobj As Boolean = False
    Private filebuff As FileStream
    Private t As Integer = 0
    Private ff As Byte = 0
    Private imgstr As String = ""
    Private formatbyte As Byte = 0
    Private tm As Integer = 0
    Private t1 As Integer = 0
    Private tc As Boolean = False
    Private cA As UInt16 = 0
    Private cB As UInt16 = 0
    Private cC As UInt16 = 0
    Private comb5 As Integer = 0
    Private comb7 As Integer = 0
    Private EnvironmentColor() As Single = {0, 0, 0, 0}
    Private objects As New ArrayList
    Private objectss As New ArrayList
    Private DemoStart As Integer = 0
    Private fogCol(3) As Integer
    Private LAmbient() As Single = {0, 0, 0, 1}
    Private LDiffuse() As Single = {1, 1, 1, 1}
    Private LPosition() As Single = {1.0, 1.0, 0}
    Private TextureHRatio As Double = 0.0
    Private TextureWRatio As Double = 0.0
    Private NewTexture As Boolean = False
#End Region
    Private Sub Initialize()
        Glut.glutInit()
        Wgl.ReloadFunctions()
        Gl.ReloadFunctions()
        Gl.glEnable(Gl.GL_POINT_SMOOTH)
        Gl.glClearColor(0.2, 0.5, 0.7, 1)
        Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST)
        Gl.glShadeModel(Gl.GL_SMOOTH)
        Gl.glEnable(Gl.GL_DEPTH_TEST)
        Gl.glDepthFunc(Gl.GL_LEQUAL)
        Gl.glEnable(Gl.GL_COLOR_MATERIAL)
        Gl.glColorMaterial(Gl.GL_FRONT_AND_BACK, Gl.GL_AMBIENT_AND_DIFFUSE)
        Gl.glEnable(Gl.GL_LIGHT0)
        Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_EMISSION, LAmbient)
        Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_DIFFUSE, LDiffuse)
        Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, LPosition)
        Reshape()
        FatherLoop()
    End Sub
    Private Sub FatherLoop()
        Dim LastTime As Integer
        DemoStart = Kernel.GetTickCount
        Do
            If Not working Then
                LastTime = ElapsedTime
                ElapsedTime = Kernel.GetTickCount() - DemoStart
                ElapsedTime = (LastTime + ElapsedTime) \ 2
                Application.DoEvents()
                Gl.glDisable(Gl.GL_LIGHTING)
                Gl.glDisable(Gl.GL_NORMALIZE)
                Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB)
                MainLoop()
                SimpleOpenGlControl1.Invalidate()
                FPSCount += 1
            End If
        Loop
    End Sub
#Region "DList Processing"
    Private Sub SetCMDStr()
        Select Case DLInfo(i).Commands(i1).CMDDword(0)
            Case F3DEX2_VTX
                If Not DLInfo(i).Commands(i1 + 1).CMDDword(0) = 3 Then
                    cmdtext = "F3DEX2_VTX"
                Else
                    cmdtext = "F3DEX2_VTX (CULL)"
                End If
            Case F3DEX2_TRI1
                cmdtext = "F3DEX2_TRI1"
            Case F3DEX2_QUAD
                cmdtext = "F3DEX2_QUAD"
            Case F3DEX2_TRI2
                cmdtext = "F3DEX2_TRI2"
            Case F3DEX2_CULLDL
                cmdtext = "F3DEX2_CULLDL"
            Case F3DEX2_TEXTURE
                cmdtext = "F3DEX2_TEXTURE"
            Case G_SETFOGCOLOR
                cmdtext = "G_SETFOGCOLOR"
            Case F3DEX2_SETOTHERMODE_L
                cmdtext = "F3DEX2_SETOTHERMODE_L"
            Case F3DEX2_SETOTHERMODE_H
                cmdtext = "F3DEX2_SETOTHERMODE_H"
            Case F3DEX2_GEOMETRYMODE
                cmdtext = "F3DEX2_GEOMETRYMODE"
            Case G_SETCOMBINE
                cmdtext = "G_SETCOMBINE"
            Case G_RDPPIPESYNC
                cmdtext = "G_RDPPIPESYNC"
            Case G_SETENVCOLOR
                cmdtext = "G_SETENVCOLOR"
            Case G_LOADTLUT
                cmdtext = "G_SETTLUT"
            Case F3DEX2_DL
                cmdtext = "F3DEX2_DL"
            Case G_RDPTILESYNC
                cmdtext = "G_RDPTILESYNC"
            Case G_RDPLOADSYNC
                cmdtext = "G_RDPLOADSYNC"
            Case F3DEX2_MTX
                cmdtext = "F3DEX2_MTX"
            Case G_SETTILESIZE
                cmdtext = "G_SETTILESIZE"
            Case G_SETTILE
                cmdtext = "G_SETTILE"
            Case G_SETPRIMCOLOR
                cmdtext = "G_SETPRIMCOLOR"
            Case G_SETBLENDCOLOR
                cmdtext = "G_SETBLENDCOLOR"
            Case F3DEX2_ENDDL
                cmdtext = "F3DEX2_ENDDL"
            Case G_LOADBLOCK
                cmdtext = "G_LOADBLOCK"
            Case F3DEX2_MODIFYVTX
                cmdtext = "F3DEX2_MODIFYVTX"
            Case G_SETTIMG
                cmdtext = "G_SETTIMG"
            Case Else
                cmdtext = "UNKNOWN!"
        End Select
    End Sub

    Private Sub MODIFYVTX()
        Dim where As Integer = DLInfo(i).Commands(i1).CMDDword(1)
        Dim vtx As Integer = DLInfo(i).Commands(i1).CMDDword(3) \ 2
        Select Case where
            Case &H10

            Case &H14
                'Vertices.u(vtx)
                'Vertices.v(vtx)
            Case &H18

            Case &H1C

        End Select
    End Sub
    Private Sub ParseCurrentCommand()
        Select Case DLInfo(i).Commands(i1).CMDDword(0)
            Case F3DEX2_MODIFYVTX
                MODIFYVTX()
            Case F3DEX2_TEXTURE
                Gl.glEnable(Gl.GL_TEXTURE_2D)
                TEXTURESCALE()
            Case F3DEX2_GEOMETRYMODE
                GEOMETRYMODE()
            Case F3DEX2_SETOTHERMODE_L
                SETOTHERMODEL()
            Case F3DEX2_SETOTHERMODE_H
                SETOTHERMODEH()
            Case G_SETFOGCOLOR
                'SETFOGCOLOR()
            Case G_SETCOMBINE
                SETCOMBINE()
            Case F3DEX2_VTX
                If Not DLInfo(i).Commands(i1 + 1).CMDDword(0) = 3 And DLInfo(i).Commands(i1).CMDDword(4) = bankno Then
                    VTX()
                End If
            Case G_SETENVCOLOR
                ENVCOLOR()
            Case G_SETPRIMCOLOR
                SETPRIMCOLOR()
            Case F3DEX2_TRI1
                TRI1()
            Case F3DEX2_TRI2
                TRI2()
            Case G_SETTIMG
                SETTIMG()
            Case G_SETTILESIZE
                SETTILESIZE()
            Case G_SETTILE
                SETTILE()
            Case G_LOADTLUT
                LOADTLUT()
            Case F3DEX2_MOVEWORD
                MsgBox("mw")
            Case F3DEX2_MOVEMEM
                MsgBox("mm")
            Case F3DEX2_POPMTX
                Gl.glPopMatrix()
            Case F3DEX2_CULLDL

            Case G_RDPPIPESYNC

            Case F3DEX2_DL

            Case G_RDPTILESYNC

            Case G_RDPLOADSYNC

            Case F3DEX2_MTX
                MTX()
            Case G_SETBLENDCOLOR

            Case F3DEX2_ENDDL

            Case G_LOADBLOCK

        End Select
    End Sub

    Private Sub CreateShader()

        Dim shaderout As String = ""
        ShaderLines.Clear()
        ShaderLines.Add("!!ARBfp1.0")
        ShaderLines.Add("TEMP R0;")
        ShaderLines.Add("TEMP R1;")
        ShaderLines.Add("TEMP aR0;")
        ShaderLines.Add("TEMP aR1;")
        ShaderLines.Add("PARAM envcolor = program.env[0];")
        ShaderLines.Add("PARAM primcolor = program.env[1];")
        Select Case cA0
            Case 1
                ShaderLines.Add("TEX R0, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX R0, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV R0, primcolor;")
            Case 4
                ShaderLines.Add("MOV R0, fragment.color.primary;")
            Case 5
                ShaderLines.Add("MOV R0, envcolor;")
            Case 6
                ShaderLines.Add("MOV R0, {1.0,1.0,1.0,1.0};")
            Case Else
                ShaderLines.Add("MOV R0, {0,0,0,0};")
        End Select
        Select Case cB0
            Case 1
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV R1, primcolor;")
            Case 4
                ShaderLines.Add("MOV R1, fragment.color.primary;")
            Case 5
                ShaderLines.Add("MOV R1, envcolor;")
            Case Else
                ShaderLines.Add("MOV R1, {0,0,0,0};")
        End Select
        ShaderLines.Add("SUB R0, R0, R1;")
        Select Case cC0
            Case 1
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV R1, primcolor;")
            Case 4
                ShaderLines.Add("MOV R1, fragment.color.primary;")
            Case 5
                ShaderLines.Add("MOV R1, envcolor;")
            Case 8
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[0], 2D;")
                ShaderLines.Add("MOV R1, R1.aaaa;")
            Case 9
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[1], 2D;")
                ShaderLines.Add("MOV R1, R1.aaaa;")
            Case 10
                ShaderLines.Add("MOV R1, primcolor;")
                ShaderLines.Add("MOV R1, R1.aaaa;")
            Case 11
                ShaderLines.Add("MOV R1, fragment.color.primary;")
                ShaderLines.Add("MOV R1, R1.aaaa;")
            Case 12
                ShaderLines.Add("MOV R1, envcolor;")
                ShaderLines.Add("MOV R1, R1.aaaa;")
            Case Else
                ShaderLines.Add("MOV R1, {0,0,0,0};")
        End Select
        ShaderLines.Add("MUL R0, R0, R1;")
        Select Case cD0
            Case 1
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX R1, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV R1, primcolor;")
            Case 4
                ShaderLines.Add("MOV R1, fragment.color.primary;")
            Case 4
                ShaderLines.Add("MOV R1, envcolor;")
            Case 6
                ShaderLines.Add("MOV R1, {1.0,1.0,1.0,1.0};")
            Case Else
                ShaderLines.Add("MOV R1, {0.0,0.0,0.0,0.0};")
        End Select
        ShaderLines.Add("ADD R0, R0, R1;")
        Select Case aA0
            Case 1
                ShaderLines.Add("TEX aR0, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX aR0, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV aR0, primcolor;")
            Case 4
                ShaderLines.Add("MOV aR0, fragment.color.primary;")
            Case 5
                ShaderLines.Add("MOV aR0, envcolor;")
            Case 6
                ShaderLines.Add("MOV aR0, {1.0,1.0,1.0,1.0};")
            Case Else
                ShaderLines.Add("MOV aR0, {0,0,0,0};")
        End Select
        Select Case aB0
            Case 1
                ShaderLines.Add("TEX aR1, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX aR1, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV aR1, primcolor;")
            Case 4
                ShaderLines.Add("MOV aR1, fragment.color.primary;")
            Case 5
                ShaderLines.Add("MOV aR1, envcolor;")
            Case 6
                ShaderLines.Add("MOV aR1, {1.0,1.0,1.0,1.0};")
            Case Else
                ShaderLines.Add("MOV aR1, {0.0,0.0,0.0,0.0};")
        End Select
        ShaderLines.Add("SUB aR0, aR0, aR1;")
        Select Case aC0
            Case 1
                ShaderLines.Add("TEX aR1, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX aR1, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV aR1, primcolor;")
            Case 4
                ShaderLines.Add("MOV aR1, fragment.color.primary;")
            Case 5
                ShaderLines.Add("MOV aR1, envcolor;")
            Case 6
                ShaderLines.Add("MOV aR1, {1.0,1.0,1.0,1.0};")
            Case Else
                ShaderLines.Add("MOV aR1, {0.0,0.0,0.0,0.0};")
        End Select
        ShaderLines.Add("MUL aR0, aR0, aR1;")
        Select Case aD0
            Case 1
                ShaderLines.Add("TEX aR1, fragment.texcoord[0], texture[0], 2D;")
            Case 2
                ShaderLines.Add("TEX aR1, fragment.texcoord[0], texture[1], 2D;")
            Case 3
                ShaderLines.Add("MOV aR1, primcolor;")
            Case 4
                ShaderLines.Add("MOV aR1, fragment.color.primary;")
            Case 5
                ShaderLines.Add("MOV aR1, envcolor;")
            Case 6
                ShaderLines.Add("MOV aR1, {1.0,1.0,1.0,1.0};")
            Case Else
                ShaderLines.Add("MOV aR1, {0.0,0.0,0.0,0.0};")
        End Select
        ShaderLines.Add("ADD aR0, aR0, aR1;")
        ShaderLines.Add("MOV R0.a, aR0.a;")
        ShaderLines.Add("MOV result.color, R0;")
        ShaderLines.Add("END")
        For i4 = 0 To ShaderLines.Count - 1
            shaderout &= ShaderLines(i4) & Environment.NewLine
        Next
        ShaderLines.Clear()
        Dim shaderapp() As Byte = System.Text.Encoding.ASCII.GetBytes(shaderout)
        Gl.glGenProgramsARB(1, shaderprog)
        Gl.glBindProgramARB(Gl.GL_FRAGMENT_PROGRAM_ARB, shaderprog)
        Gl.glProgramStringARB(Gl.GL_FRAGMENT_PROGRAM_ARB, Gl.GL_PROGRAM_FORMAT_ASCII_ARB, shaderapp.Length, shaderapp)
        'Dim errpos As Integer = -1
        'Gl.glGetIntegerv(Gl.GL_PROGRAM_ERROR_POSITION_ARB, errpos)
        'If errpos > -1 Then
        '    MsgBox("CAN'T PARSE SHADER OPERATION: " & ShaderLines(CInt(Mid(Gl.glGetString(Gl.GL_PROGRAM_ERROR_STRING_ARB), 6, 2)) - 1))
        'End If
        Gl.glEnable(Gl.GL_FRAGMENT_PROGRAM_ARB)
    End Sub
    Private Sub SETCOMBINE()
        COMBINE0 = CMDLow And &HFFFFFF
        COMBINE1 = CMDHigh

        cA0 = (COMBINE0 >> 20) And &HF
        cB0 = (COMBINE1 >> 28) And &HF
        cC0 = (COMBINE0 >> 15) And &H1F
        cD0 = (COMBINE1 >> 15) And &H7

        aA0 = (COMBINE0 >> 12) And &H7
        aB0 = (COMBINE1 >> 12) And &H7
        aC0 = (COMBINE0 >> 9) And &H7
        aD0 = (COMBINE1 >> 9) And &H7

        cA1 = (COMBINE0 >> 5) And &HF
        cB1 = (COMBINE1 >> 24) And &HF
        cC1 = (COMBINE0) And &H1F
        cD1 = (COMBINE1 >> 6) And &H7

        aA1 = (COMBINE1 >> 21) And &H7
        aB1 = (COMBINE1 >> 3) And &H7
        aC1 = (COMBINE1 >> 18) And &H7
        aD1 = (COMBINE1) And &H7

        CreateShader()
    End Sub
    Private Sub ENVCOLOR()
        EnvironmentColor(0) = DLInfo(i).Commands(i1).CMDDword(4) / 255
        EnvironmentColor(1) = DLInfo(i).Commands(i1).CMDDword(5) / 255
        EnvironmentColor(2) = DLInfo(i).Commands(i1).CMDDword(6) / 255
        EnvironmentColor(3) = DLInfo(i).Commands(i1).CMDDword(7) / 255
        Gl.glProgramEnvParameter4fvARB(Gl.GL_FRAGMENT_PROGRAM_ARB, 0, EnvironmentColor)

    End Sub
    Private Sub SETPRIMCOLOR()
        PrimColor(0) = DLInfo(i).Commands(i1).CMDDword(4) / 255
        PrimColor(1) = DLInfo(i).Commands(i1).CMDDword(5) / 255
        PrimColor(2) = DLInfo(i).Commands(i1).CMDDword(6) / 255
        PrimColor(3) = DLInfo(i).Commands(i1).CMDDword(7) / 255
        Gl.glProgramEnvParameter4fvARB(Gl.GL_FRAGMENT_PROGRAM_ARB, 1, PrimColor)
    End Sub
    Private Sub MTX()
        Dim mtx(3, 3) As Double
        Dim seg As Integer = DLInfo(i).Commands(i1).CMDDword(2)
        Dim mtxdata(63) As Byte
        Dim cnt As Integer = 0
        Dim mtxextract(1) As UInt32
        Dim ActiveMatrix As Integer = DLInfo(i).Commands(i1).CMDDword(3)
        Dim address As UInt32 = Convert.ToUInt32(CByte(DLInfo(i).Commands(i1).CMDDword(5)).ToString("X2") & CByte(DLInfo(i).Commands(i1).CMDDword(6)).ToString("X2") & CByte(DLInfo(i).Commands(i1).CMDDword(7)).ToString("X2"), 16)
        If seg = bankno Then
            For i2 = 0 To 63
                mtxdata(i2) = DataBuffer(address + i2)
            Next
        Else
            Gl.glPopMatrix()
        End If
        For i3 = 0 To 3
            For i4 = 0 To 3
                mtxextract(0) = (mtxdata(cnt) * &H100) + mtxdata(cnt + 1)
                mtxextract(1) = (mtxdata(cnt + 32) * &H100) + mtxdata(cnt + 33)
                mtx(i3, i4) = ((mtxextract(0) << 16) Or mtxextract(1)) * 65535
                cnt += 2
            Next
        Next
        Select Case ActiveMatrix
            Case F3DEX2_MTX_MODELVIEW

            Case F3DEX2_MTX_PROJECTION

        End Select
        Gl.glPushMatrix()
        'Gl.glMultMatrixd(mtx)
    End Sub
    Private Sub VTX()
        vtoff = Convert.ToUInt32(CByte(DLInfo(i).Commands(i1).CMDDword(5)).ToString("X2") & CByte(DLInfo(i).Commands(i1).CMDDword(6)).ToString("X2") & CByte(DLInfo(i).Commands(i1).CMDDword(7)).ToString("X2"), 16)
        oldvtoff = vtoff
        Dim VTXNUM As UInt32 = DLInfo(i).Commands(i1).CMDDword(3) \ 2
        ReDim Vertices.x(VTXNUM - 1)
        ReDim Vertices.y(VTXNUM - 1)
        ReDim Vertices.z(VTXNUM - 1)
        ReDim Vertices.r(VTXNUM - 1)
        ReDim Vertices.g(VTXNUM - 1)
        ReDim Vertices.b(VTXNUM - 1)
        ReDim Vertices.a(VTXNUM - 1)
        ReDim Vertices.u(VTXNUM - 1)
        ReDim Vertices.v(VTXNUM - 1)
        If NewTexture Then LoadTex()
        For i2 = 0 To VTXNUM - 1
            x = ((ZFileBuffer(vtoff) * &H1000000) + (ZFileBuffer(vtoff + 1) * &H10000)) >> 16
            y = ((ZFileBuffer(vtoff + 2) * &H1000000) + (ZFileBuffer(vtoff + 3) * &H10000)) >> 16
            z = ((ZFileBuffer(vtoff + 4) * &H1000000) + (ZFileBuffer(vtoff + 5) * &H10000)) >> 16
            u = ((ZFileBuffer(vtoff + 8) * &H1000000) + (ZFileBuffer(vtoff + 9) * &H10000)) >> 16
            v = ((ZFileBuffer(vtoff + 10) * &H1000000) + (ZFileBuffer(vtoff + 11) * &H10000)) >> 16
            r = ZFileBuffer(vtoff + 12) / 255
            g = ZFileBuffer(vtoff + 13) / 255
            b = ZFileBuffer(vtoff + 14) / 255
            a = ZFileBuffer(vtoff + 15) / 255
            With Vertices
                'Vertex x(l)-y(w)-z(d) coordinates
                .x(i2) = x
                .y(i2) = y
                .z(i2) = z

                'Texture coordinates
                .u(i2) = u
                .v(i2) = v

                'Vertex colors
                .r(i2) = r
                .g(i2) = g
                .b(i2) = b
                .a(i2) = a
            End With
            vtoff += 16
        Next
    End Sub
    Private Sub SETOTHERMODEH()
        Select Case 32 - ((CMDLow >> 8) And &HFF) - (CMDLow And &HFF) - 1
            Case 4

            Case 6

            Case 8

            Case 9

            Case 12

            Case 14

            Case 16

            Case 17

            Case 19

            Case 20

            Case 22

            Case 23

        End Select
    End Sub
    Private Sub SETOTHERMODEL()
        Dim zmode As Byte = (CMDHigh >> 10) And 3
        Dim forceblend As Byte = (CMDHigh >> 14) And 1
        Dim cvgXalpha As Byte = (CMDHigh >> 12) And 1
        Dim alphacvgsel As Byte = (CMDHigh >> 13) And 1
        Dim zcompare As Byte = (CMDHigh >> 4) And 1
        Dim zupdate As Byte = (CMDHigh >> 5) And 1
        Select Case 32 - ((CMDLow >> 8) And &HFF) - (CMDLow And &HFF) - 1
            Case 0 'alphacompare
                MsgBox("alphacompare")
            Case 2 'zsrcsel
                MsgBox("zsrcsel")
            Case 3 'rendermode
                If zmode = 3 Then
                    Gl.glEnable(Gl.GL_POLYGON_OFFSET_FILL)
                    Gl.glPolygonOffset(-3, -3)
                Else
                    Gl.glDisable(Gl.GL_POLYGON_OFFSET_FILL)
                End If
                If forceblend = 1 Then
                    Gl.glEnable(Gl.GL_BLEND)
                Else
                    Gl.glDisable(Gl.GL_BLEND)
                End If
                If cvgXalpha = 1 Then
                    Gl.glAlphaFunc(Gl.GL_GREATER, 0.0F)
                    Gl.glEnable(Gl.GL_ALPHA_TEST)
                    Exit Sub
                Else
                    Gl.glDisable(Gl.GL_ALPHA_TEST)
                End If
                If zcompare = 1 Then
                    Gl.glDepthFunc(Gl.GL_LEQUAL)
                    Gl.glEnable(Gl.GL_DEPTH_TEST)
                Else
                    Gl.glDisable(Gl.GL_DEPTH_TEST)
                End If
            Case Else 'blender
                MsgBox("blender")
        End Select
        Dim c1 As UInt32
        Dim c2 As UInt32
        c1 = CMDHigh >> 16
        c2 = (CMDHigh << 16) >> 16
        Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA)
        Gl.glAlphaFunc(Gl.GL_GEQUAL, 0.5F)
        Select Case c1
            Case &HC811, &HC19
                Select Case c2
                    Case &H2078, &H3078
                        BlendSrcFactor = Gl.GL_ONE
                        BlendDstFactor = Gl.GL_ZERO
                        AlphaFunc = Gl.GL_GREATER
                        AlphaRef = 0.4
                End Select
            Case &H50, &H55
                Select Case c2
                    Case &H4B50
                        BlendSrcFactor = Gl.GL_SRC_ALPHA
                        BlendDstFactor = Gl.GL_ONE_MINUS_SRC_ALPHA
                        AlphaFunc = Gl.GL_GEQUAL
                        AlphaRef = 0.4
                End Select
            Case &HC18
                Select Case c2
                    Case &H49D8
                        BlendSrcFactor = Gl.GL_ONE_MINUS_DST_COLOR
                        BlendDstFactor = Gl.GL_DST_ALPHA
                        AlphaFunc = Gl.GL_GEQUAL
                        AlphaRef = 0.1
                    Case &H4B50
                        BlendSrcFactor = Gl.GL_SRC_ALPHA
                        BlendDstFactor = Gl.GL_ONE_MINUS_SRC_ALPHA
                        AlphaFunc = Gl.GL_GEQUAL
                        AlphaRef = 0.4
                    Case &H4F50
                        BlendSrcFactor = Gl.GL_ONE_MINUS_DST_COLOR
                        BlendDstFactor = Gl.GL_DST_ALPHA
                        AlphaFunc = Gl.GL_GEQUAL
                        AlphaRef = 0.4
                    Case &H4DD8
                        BlendSrcFactor = Gl.GL_ONE
                        BlendDstFactor = Gl.GL_ZERO
                        AlphaFunc = Gl.GL_GREATER
                        AlphaRef = 0.3
                        Gl.glEnable(Gl.GL_BLEND)
                        Gl.glEnable(Gl.GL_ALPHA_TEST)
                End Select
            Case &HC818
                Select Case c2
                    Case &H4F50
                        BlendSrcFactor = Gl.GL_SRC_ALPHA
                        BlendDstFactor = Gl.GL_ONE_MINUS_SRC_ALPHA
                        AlphaFunc = Gl.GL_NOTEQUAL
                        AlphaRef = 0.0
                End Select
            Case &HC810
                Select Case c2
                    Case &H49D8, &H4A50, &H4DD8, &H3478
                        BlendSrcFactor = Gl.GL_SRC_ALPHA
                        BlendDstFactor = Gl.GL_ONE_MINUS_SRC_ALPHA
                        AlphaFunc = Gl.GL_GREATER
                        AlphaRef = 0.0
                    Case &H4B50
                        BlendSrcFactor = Gl.GL_SRC_ALPHA
                        BlendDstFactor = Gl.GL_ONE_MINUS_SRC_ALPHA
                        AlphaFunc = Gl.GL_GEQUAL
                        AlphaRef = 0.4
                    Case &H4F50
                        BlendSrcFactor = Gl.GL_ONE_MINUS_DST_COLOR
                        BlendDstFactor = Gl.GL_DST_ALPHA
                        AlphaFunc = Gl.GL_GREATER
                        AlphaRef = 0.5
                End Select
            Case Else
        End Select
        Gl.glBlendFunc(BlendSrcFactor, BlendDstFactor)
        Gl.glAlphaFunc(AlphaFunc, AlphaRef)
    End Sub
    Private Sub TRI1()
        Try
            TempVx1 = (DLInfo(i).Commands(i1).CMDDword(1)) \ 2
            TempVy1 = (DLInfo(i).Commands(i1).CMDDword(2)) \ 2
            TempVz1 = (DLInfo(i).Commands(i1).CMDDword(3)) \ 2
            If highlight Then
                Gl.glDisable(Gl.GL_TEXTURE_2D)
                Gl.glEnable(Gl.GL_POLYGON_OFFSET_LINE)
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
                Gl.glColor3f(1, 0, 0)
                Gl.glBegin(Gl.GL_TRIANGLES)

                Gl.glVertex3f(Vertices.x(TempVx1), Vertices.y(TempVx1), Vertices.z(TempVx1))
                Gl.glVertex3f(Vertices.x(TempVy1), Vertices.y(TempVy1), Vertices.z(TempVy1))
                Gl.glVertex3f(Vertices.x(TempVz1), Vertices.y(TempVz1), Vertices.z(TempVz1))

                Gl.glEnd()
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
                Gl.glDisable(Gl.GL_POLYGON_OFFSET_LINE)
                Gl.glEnable(Gl.GL_TEXTURE_2D)
            End If

            Gl.glColor4fv(PrimColor)
            If EnableLighting Then
                Gl.glBegin(Gl.GL_TRIANGLES)

                Gl.glNormal3f(Vertices.r(TempVx1), Vertices.g(TempVx1), Vertices.b(TempVx1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVx1) * TextureWRatio, Vertices.v(TempVx1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVx1), Vertices.y(TempVx1), Vertices.z(TempVx1))

                Gl.glNormal3f(Vertices.r(TempVy1), Vertices.g(TempVy1), Vertices.b(TempVy1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVy1) * TextureWRatio, Vertices.v(TempVy1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVy1), Vertices.y(TempVy1), Vertices.z(TempVy1))

                Gl.glNormal3f(Vertices.r(TempVz1), Vertices.g(TempVz1), Vertices.b(TempVz1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVz1) * TextureWRatio, Vertices.v(TempVz1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVz1), Vertices.y(TempVz1), Vertices.z(TempVz1))
                Gl.glEnd()
            Else
                Gl.glBegin(Gl.GL_TRIANGLES)
                Gl.glColor4f(Vertices.r(TempVx1), Vertices.g(TempVx1), Vertices.b(TempVx1), Vertices.a(TempVx1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVx1) * TextureWRatio, Vertices.v(TempVx1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVx1), Vertices.y(TempVx1), Vertices.z(TempVx1))

                Gl.glColor4f(Vertices.r(TempVy1), Vertices.g(TempVy1), Vertices.b(TempVy1), Vertices.a(TempVy1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVy1) * TextureWRatio, Vertices.v(TempVy1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVy1), Vertices.y(TempVy1), Vertices.z(TempVy1))

                Gl.glColor4f(Vertices.r(TempVz1), Vertices.g(TempVz1), Vertices.b(TempVz1), Vertices.a(TempVz1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVz1) * TextureWRatio, Vertices.v(TempVz1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVz1), Vertices.y(TempVz1), Vertices.z(TempVz1))
                Gl.glEnd()
            End If
        Catch ex As Exception
            MsgBox("Error TRI1 - out of bounds!" & Environment.NewLine & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Error")
        End Try
    End Sub
    Private Sub TRI2()
        Try
            TempVx1 = DLInfo(i).Commands(i1).CMDDword(1) \ 2
            TempVy1 = DLInfo(i).Commands(i1).CMDDword(2) \ 2
            TempVz1 = DLInfo(i).Commands(i1).CMDDword(3) \ 2
            TempVr1 = DLInfo(i).Commands(i1).CMDDword(5) \ 2
            TempVg2 = DLInfo(i).Commands(i1).CMDDword(6) \ 2
            TempVa3 = DLInfo(i).Commands(i1).CMDDword(7) \ 2
            If highlight Then
                Gl.glDisable(Gl.GL_TEXTURE_2D)
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
                Gl.glEnable(Gl.GL_POLYGON_OFFSET_LINE)
                Gl.glColor3f(1, 0, 0)
                Gl.glBegin(Gl.GL_TRIANGLES)

                Gl.glVertex3f(Vertices.x(TempVx1), Vertices.y(TempVx1), Vertices.z(TempVx1))
                Gl.glVertex3f(Vertices.x(TempVy1), Vertices.y(TempVy1), Vertices.z(TempVy1))
                Gl.glVertex3f(Vertices.x(TempVz1), Vertices.y(TempVz1), Vertices.z(TempVz1))
                Gl.glVertex3f(Vertices.x(TempVr1), Vertices.y(TempVr1), Vertices.z(TempVr1))
                Gl.glVertex3f(Vertices.x(TempVg2), Vertices.y(TempVg2), Vertices.z(TempVg2))
                Gl.glVertex3f(Vertices.x(TempVa3), Vertices.y(TempVa3), Vertices.z(TempVa3))

                Gl.glEnd()
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
                Gl.glDisable(Gl.GL_POLYGON_OFFSET_LINE)
                Gl.glEnable(Gl.GL_TEXTURE_2D)
            End If
            Gl.glColor4fv(PrimColor)
            If EnableLighting Then
                Gl.glBegin(Gl.GL_TRIANGLES)

                Gl.glNormal3f(Vertices.r(TempVx1), Vertices.g(TempVx1), Vertices.b(TempVx1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVx1) * TextureWRatio, Vertices.v(TempVx1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVx1) * TextureWRatio, Vertices.v(TempVx1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVx1), Vertices.y(TempVx1), Vertices.z(TempVx1))

                Gl.glNormal3f(Vertices.r(TempVy1), Vertices.g(TempVy1), Vertices.b(TempVy1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVy1) * TextureWRatio, Vertices.v(TempVy1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVy1) * TextureWRatio, Vertices.v(TempVy1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVy1), Vertices.y(TempVy1), Vertices.z(TempVy1))

                Gl.glNormal3f(Vertices.r(TempVz1), Vertices.g(TempVz1), Vertices.b(TempVz1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVz1) * TextureWRatio, Vertices.v(TempVz1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVz1) * TextureWRatio, Vertices.v(TempVz1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVz1), Vertices.y(TempVz1), Vertices.z(TempVz1))

                Gl.glNormal3f(Vertices.r(TempVr1), Vertices.g(TempVr1), Vertices.b(TempVr1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVr1) * TextureWRatio, Vertices.v(TempVr1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVr1) * TextureWRatio, Vertices.v(TempVr1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVr1), Vertices.y(TempVr1), Vertices.z(TempVr1))

                Gl.glNormal3f(Vertices.r(TempVg2), Vertices.g(TempVg2), Vertices.b(TempVg2))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVg2) * TextureWRatio, Vertices.v(TempVg2) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVg2) * TextureWRatio, Vertices.v(TempVg2) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVg2), Vertices.y(TempVg2), Vertices.z(TempVg2))

                Gl.glNormal3f(Vertices.r(TempVa3), Vertices.g(TempVa3), Vertices.b(TempVa3))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVa3) * TextureWRatio, Vertices.v(TempVa3) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVa3) * TextureWRatio, Vertices.v(TempVa3) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVa3), Vertices.y(TempVa3), Vertices.z(TempVa3))

                Gl.glEnd()
            Else

                Gl.glBegin(Gl.GL_TRIANGLES)

                Gl.glColor4f(Vertices.r(TempVx1), Vertices.g(TempVx1), Vertices.b(TempVx1), Vertices.a(TempVx1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVx1) * TextureWRatio, Vertices.v(TempVx1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVx1) * TextureWRatio, Vertices.v(TempVx1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVx1), Vertices.y(TempVx1), Vertices.z(TempVx1))

                Gl.glColor4f(Vertices.r(TempVy1), Vertices.g(TempVy1), Vertices.b(TempVy1), Vertices.a(TempVy1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVy1) * TextureWRatio, Vertices.v(TempVy1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVy1) * TextureWRatio, Vertices.v(TempVy1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVy1), Vertices.y(TempVy1), Vertices.z(TempVy1))

                Gl.glColor4f(Vertices.r(TempVz1), Vertices.g(TempVz1), Vertices.b(TempVz1), Vertices.a(TempVz1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVz1) * TextureWRatio, Vertices.v(TempVz1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVz1) * TextureWRatio, Vertices.v(TempVz1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVz1), Vertices.y(TempVz1), Vertices.z(TempVz1))

                Gl.glColor4f(Vertices.r(TempVr1), Vertices.g(TempVr1), Vertices.b(TempVr1), Vertices.a(TempVr1))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVr1) * TextureWRatio, Vertices.v(TempVr1) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVr1) * TextureWRatio, Vertices.v(TempVr1) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVr1), Vertices.y(TempVr1), Vertices.z(TempVr1))

                Gl.glColor4f(Vertices.r(TempVg2), Vertices.g(TempVg2), Vertices.b(TempVg2), Vertices.a(TempVg2))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVg2) * TextureWRatio, Vertices.v(TempVg2) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVg2) * TextureWRatio, Vertices.v(TempVg2) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVg2), Vertices.y(TempVg2), Vertices.z(TempVg2))

                Gl.glColor4f(Vertices.r(TempVa3), Vertices.g(TempVa3), Vertices.b(TempVa3), Vertices.a(TempVa3))
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE0_ARB, Vertices.u(TempVa3) * TextureWRatio, Vertices.v(TempVa3) * TextureHRatio)
                Gl.glMultiTexCoord2fARB(Gl.GL_TEXTURE1_ARB, Vertices.u(TempVa3) * TextureWRatio, Vertices.v(TempVa3) * TextureHRatio)
                Gl.glVertex3f(Vertices.x(TempVa3), Vertices.y(TempVa3), Vertices.z(TempVa3))

                Gl.glEnd()
            End If

        Catch ex As Exception
            MsgBox("Error TRI2 - out of bounds!" & Environment.NewLine & Environment.NewLine & ex.Message, MsgBoxStyle.Critical, "Error")
        End Try
    End Sub
    Private Sub SETFOGCOLOR()
        fogCol(0) = DLInfo(i).Commands(i1).CMDDword(4) \ 255.0F
        fogCol(1) = DLInfo(i).Commands(i1).CMDDword(5) \ 255.0F
        fogCol(2) = DLInfo(i).Commands(i1).CMDDword(6) \ 255.0F
        fogCol(3) = DLInfo(i).Commands(i1).CMDDword(7) \ 255.0F
        Gl.glFogf(Gl.GL_FOG_START, 0.1)
        Gl.glFogf(Gl.GL_FOG_END, 0.5)
        Gl.glFogiv(Gl.GL_FOG_COLOR, fogCol)
        Gl.glEnable(Gl.GL_FOG)
    End Sub
    Private Sub GEOMETRYMODE()
        Dim packed(6) As Byte
        For i2 = 0 To 6
            packed(i2) = DLInfo(i).Commands(i1).CMDDword(i2 + 1)
        Next
        Dim unpack(3) As UInteger
        For i2 = 0 To 6
            For i3 = 0 To 3
                unpack(i3) = packed(i2) Mod 2
                packed(i2) >>= 1
            Next
            Select Case i2
                Case 0
                    If unpack(0) = 0 Then
                        Gl.glDisable(Gl.GL_FOG)
                    End If
                    If unpack(1) = 0 Then
                        Gl.glDisable(Gl.GL_LIGHTING)
                        Gl.glDisable(Gl.GL_NORMALIZE)
                        EnableLighting = False
                    End If
                Case 1
                    If unpack(1) = 0 Then
                        Gl.glDisable(Gl.GL_CULL_FACE)
                    End If
                    If unpack(2) = 0 Then
                        Gl.glDisable(Gl.GL_CULL_FACE)
                    End If
                Case 2

                Case 3

                Case 4
                    If unpack(0) = 1 Then
                        'Gl.glEnable(Gl.GL_FOG)
                    End If
                    If unpack(1) = 1 Then
                        'Gl.glEnable(Gl.GL_LIGHTING)
                        'Gl.glEnable(Gl.GL_NORMALIZE)
                        EnableLighting = True
                    End If
                Case 5
                    If unpack(1) = 1 Then
                        'Gl.glCullFace(Gl.GL_FRONT)
                        'Gl.glEnable(Gl.GL_CULL_FACE)
                    End If
                    If unpack(2) = 1 Then
                        Gl.glCullFace(Gl.GL_BACK)
                        Gl.glEnable(Gl.GL_CULL_FACE)
                    End If
                Case 6

            End Select
        Next
    End Sub

    Private Sub SETTILE()
        If DLInfo(i).Commands(i1).CMDDword(1) > 0 Then
            TexFormat = (CMDLow >> 21) And &H7
            TexelSize = (CMDLow >> 19) And &H3
            LineSize = (CMDLow >> 9) And &H1FF
            TMemAddress = (CMDLow) And &H1FF
            CMT = (CMDHigh >> 18) And &H3
            MaskT = (CMDHigh >> 14) And &HF
            ShiftT = (CMDHigh >> 10) And &HF
            CMS = (CMDHigh >> 8) And &H3
            MaskS = (CMDHigh >> 4) And &HF
            ShiftS = (CMDHigh) And &HF
            Select Case TexelSize
                Case 0
                    BPP = 4
                Case 1
                    BPP = 8
                Case 2
                    BPP = 16
                Case 3
                    BPP = 32
                Case Else
                    MsgBox("UNK TEXELSIZE!")
                    BPP = 0
            End Select
            Select Case TexFormat
                Case 0 'RGBA
                    ImageFormat = 2
                Case 1 'YUV - unused!

                Case 2 'CI
                    ImageFormat = 3
                Case 3 'IA
                    ImageFormat = 1
                Case 4 'I
                    ImageFormat = 0
                Case Else
                    MsgBox("UNK TEXFORMAT!")
                    ImageFormat = 4
            End Select
        End If
    End Sub
    Private Sub LOADTLUT()
        Dim palbytes As Integer = (((DLInfo(i).Commands(i1).CMDDword(5) * &H10000) + (DLInfo(i).Commands(i1).CMDDword(6) * &H100) + (DLInfo(i).Commands(i1).CMDDword(7)) And &HFFF000) >> 14) * 2
        ReDim palette(palbytes + 1)
        Select Case palbank
            Case bankno
                For i2 = 0 To palbytes - 1
                    palette(i2) = ZFileBuffer(PalOff + i2)
                Next
            Case 2
                For i2 = 0 To palbytes - 1
                    palette(i2) = ZSceneBuffer(PalOff + i2)
                Next
        End Select
        Dim rExtract As Byte
        Dim gExtract As UInt16
        Dim bExtract As Byte
        Dim aExtract As Byte
        extracted.r.Clear()
        extracted.g.Clear()
        extracted.b.Clear()
        extracted.a.Clear()
        For iw As Integer = 0 To palbytes Step 2
            rExtract = palette(iw) >> 3
            gExtract = palette(iw) * 256 Xor palette(iw + 1)
            gExtract >>= 6
            gExtract <<= 11
            gExtract >>= 11
            bExtract = palette(iw + 1) >> 1
            bExtract <<= 3
            bExtract >>= 3
            aExtract = palette(iw + 1) << 7
            aExtract >>= 7
            extracted.r.Add(rExtract * 8)
            extracted.g.Add(gExtract * 8)
            extracted.b.Add(bExtract * 8)
            If aExtract And 1 Then extracted.a.Add(255) Else extracted.a.Add(0)
        Next
    End Sub
    Private Sub SETTIMG()
        NewTexture = True
        Dim tmpoff As Integer = (CMDHigh << 8) >> 8
        Dim tmpbank As Integer = DLInfo(i).Commands(i1).CMDDword(4)
        If DLInfo(i).Commands(i1 + 1).CMDDword(0) = &HE8 Then
            PalOff = tmpoff
            PalBank = tmpbank
        Else
            texoff = tmpoff
            bankuse = tmpbank
        End If
    End Sub
    Private Sub TEXTURESCALE()
        S_Scale = CMDHigh >> 16
        T_Scale = CMDHigh And &HFFFF
    End Sub
    Private Sub SETTILESIZE()
        Dim TileSize_Temp1 As UInt32 = (DLInfo(i).Commands(i1).CMDDword(1) * &H10000) + (DLInfo(i).Commands(i1).CMDDword(2) * &H100) + DLInfo(i).Commands(i1).CMDDword(3)
        Dim TileSize_Temp2 As UInt32 = (DLInfo(i).Commands(i1).CMDDword(5) * &H10000) + (DLInfo(i).Commands(i1).CMDDword(6) * &H100) + DLInfo(i).Commands(i1).CMDDword(7)
        Dim ULS As Integer = (TileSize_Temp1 And &HFFF000) >> 14
        Dim ULT As Integer = (TileSize_Temp1 And &HFFF) >> 2
        Dim LRS As Integer = (TileSize_Temp2 And &HFFF000) >> 14
        Dim LRT As Integer = (TileSize_Temp2 And &HFFF) >> 2
        TextureW = ((LRS - ULS) + 1)
        TextureH = ((LRT - ULT) + 1)
        TextureHRatio = T_Scale / 65536 / 32 / TextureH
        TextureWRatio = S_Scale / 65536 / 32 / TextureW
        texbytes = (TextureW * TextureH) * 2
    End Sub
    Private Sub LoadTex()
        Select Case bankuse
            Case bankno, 2, 4, 5
                'teximg formats: 0 - I, 1 - IA, 2 - RGBA, 3 - CI, 4 - YUV (never used in Zelda)
                ReDim imagearray(texbytes - 1)
                Select Case bankuse
                    Case bankno 'Bank 06/03/01,  object, map, nintendo_rogo files respectively. IE, not seperate
                        For i2 = 0 To texbytes - 1
                            imagearray(i2) = ZFileBuffer(texoff + i2)
                        Next
                    Case 4 'Bank 04, "gameplay_keep"
                        gameplaykeep.Position = texoff
                        gameplaykeep.Read(imagearray, 0, texbytes)
                    Case 5 'Bank 05, "gameplay_dangeon_keep"
                        dangenkeep.Position = texoff
                        dangenkeep.Read(imagearray, 0, texbytes)
                    Case 2 'Bank 02, map's scene file
                        For i2 = 0 To texbytes - 1
                            imagearray(i2) = ZSceneBuffer(texoff + i2)
                        Next
                End Select
                ReDim newimagearray((texbytes * 2) - 1)
                If imageformat < 3 Then 'I (grayscale), IA (grayscale + alpha), RGBA16 (red5, green5, blue5, full alpha/no alpha1 - 5551)
                    If bpp = 16 Then
                        If imageformat = 2 Then
                            Dim rExtract As Byte
                            Dim gExtract As UInt16
                            Dim bExtract As Byte
                            Dim aExtract As Byte
                            For iw As Integer = 0 To imagearray.Length - 1 Step 2
                                rExtract = imagearray(iw) >> 3
                                gExtract = imagearray(iw) * 256 Xor imagearray(iw + 1)
                                gExtract >>= 6
                                gExtract <<= 11
                                gExtract >>= 11
                                bExtract = imagearray(iw + 1) >> 1
                                bExtract <<= 3
                                bExtract >>= 3
                                aExtract = imagearray(iw + 1) << 7
                                aExtract >>= 7
                                newimagearray(iw * 2) = rExtract * 8
                                newimagearray(iw * 2 + 1) = gExtract * 8
                                newimagearray(iw * 2 + 2) = bExtract * 8
                                newimagearray(iw * 2 + 3) = aExtract * 255
                            Next
                        ElseIf imageformat = 1 Then
                            Dim bright As Byte
                            For iw As Integer = 0 To texbytes - 1 Step 2
                                bright = imagearray(iw)
                                newimagearray(iw * 2) = bright
                                newimagearray(iw * 2 + 1) = bright
                                newimagearray(iw * 2 + 2) = bright
                                newimagearray(iw * 2 + 3) = imagearray(iw + 1)
                            Next
                        End If
                    ElseIf bpp = 8 Then
                        If imageformat = 1 Then
                            Dim bright As Byte = 0
                            Dim alpha As Byte = 0
                            For iw As Integer = 0 To (texbytes \ 2) - 1
                                bright = imagearray(iw) \ 16
                                alpha = imagearray(iw) * 16
                                alpha \= 16
                                newimagearray(iw * 4) = bright * 17
                                newimagearray(iw * 4 + 1) = bright * 17
                                newimagearray(iw * 4 + 2) = bright * 17
                                newimagearray(iw * 4 + 3) = alpha * 17
                            Next
                        ElseIf imageformat = 0 Then
                            Dim bright As Byte = 0
                            For iw As Integer = 0 To (texbytes \ 2) - 1
                                bright = imagearray(iw) \ 16
                                newimagearray(iw * 4) = bright * 17
                                newimagearray(iw * 4 + 1) = bright * 17
                                newimagearray(iw * 4 + 2) = bright * 17
                                newimagearray(iw * 4 + 3) = PrimColor(3) * 255
                            Next
                        End If
                    ElseIf bpp = 4 Then
                        Dim bright As Byte = 0
                        For iw As Integer = 0 To (texbytes \ 4) - 1
                            bright = imagearray(iw)
                            bright >>= 4
                            newimagearray(iw * 8) = bright * 17
                            newimagearray(iw * 8 + 1) = bright * 17
                            newimagearray(iw * 8 + 2) = bright * 17
                            newimagearray(iw * 8 + 3) = PrimColor(3) * 255
                            bright = imagearray(iw)
                            bright <<= 4
                            bright >>= 4
                            newimagearray(iw * 8 + 4) = bright * 17
                            newimagearray(iw * 8 + 5) = bright * 17
                            newimagearray(iw * 8 + 6) = bright * 17
                            newimagearray(iw * 8 + 7) = PrimColor(3) * 255
                        Next
                        Else
                            'MsgBox(bpp & "-bit " & imageformat)
                        End If
                Else 'Color indexed, 16bpp color palette with 4/8bpp array of indices
                    If bpp = 4 Then
                        Dim n1 As Byte = 0
                        Dim n2 As Byte = 0
                        For i4 As Integer = 0 To (texbytes \ 2) - 1 Step 2
                            n1 = imagearray(i4) >> 4
                            n2 = imagearray(i4) << 4
                            n2 >>= 4
                            newimagearray(i4 * 4) = CInt(extracted.r(n1))
                            newimagearray(i4 * 4 + 1) = CInt(extracted.g(n1))
                            newimagearray(i4 * 4 + 2) = CInt(extracted.b(n1))
                            newimagearray(i4 * 4 + 3) = CInt(extracted.a(n1))

                            newimagearray(i4 * 4 + 4) = CInt(extracted.r(n2))
                            newimagearray(i4 * 4 + 5) = CInt(extracted.g(n2))
                            newimagearray(i4 * 4 + 6) = CInt(extracted.b(n2))
                            newimagearray(i4 * 4 + 7) = CInt(extracted.a(n2))
                        Next
                    ElseIf bpp = 8 Then
                        For i4 As Integer = 0 To (texbytes \ 2) - 1
                            newimagearray(i4 * 4) = CInt(extracted.r(imagearray(i4)))
                            newimagearray(i4 * 4 + 1) = CInt(extracted.g(imagearray(i4)))
                            newimagearray(i4 * 4 + 2) = CInt(extracted.b(imagearray(i4)))
                            newimagearray(i4 * 4 + 3) = CInt(extracted.a(imagearray(i4)))
                        Next
                    End If
                End If
                ReDim imagearray(-1)
                Select Case imageformat
                    Case 0
                        imgstr = "I"
                    Case 1
                        imgstr = "IA"
                    Case 2
                        imgstr = "RGBA"
                    Case 3
                        imgstr = "CI"
                End Select
                Gl.glBindTexture(Gl.GL_TEXTURE_2D, 0)
                Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, TextureW, TextureH, 0, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, newimagearray)
                Select Case CMS
                    Case 2
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP_TO_EDGE)
                    Case 0
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT)
                    Case 1
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_MIRRORED_REPEAT)
                    Case Else
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT)
                End Select
                Select Case CMT
                    Case 2
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP_TO_EDGE)
                    Case 0
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT)
                    Case 1
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_MIRRORED_REPEAT)
                    Case Else
                        Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT)
                End Select
                If texfilt = 0 Then
                    Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_NEAREST)
                    Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_NEAREST)
                ElseIf texfilt = 1 Then
                    Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR)
                    Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR)
                End If
                If MaxAnisotropy(0) > 1 Then
                    Gl.glTexParameterf(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAX_ANISOTROPY_EXT, MaxAnisotropy(0))
                End If
                ReDim newimagearray(-1)
                Gl.glEnable(Gl.GL_TEXTURE_2D)
        End Select
    End Sub
#End Region
    Private Sub MainLoop()
        Try
            System.Threading.Thread.Sleep(frameskip * 5)
            Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT Or Gl.GL_COLOR_BUFFER_BIT)
            Gl.glLoadIdentity()
            LocalMouse = SimpleOpenGlControl1.PointToClient(Windows.Forms.Cursor.Position)
            newx = LocalMouse.X
            newy = LocalMouse.Y
            xrotd = (xrot / 180) * 3.141592654
            yrotd = (yrot / 180) * 3.141592654
            'zrotd = (zrot / 180) * 3.141592654
            If newx <> oldx Then
                Dx = (newx - oldx) * toolsens
                Dx1 = (oldx - newx) * toolsens
            End If
            If newy <> oldy Then
                Dy1 = (newy - oldy) * toolsens
                Dy = (oldy - newy) * toolsens
            End If
            If MouseLeft Then
                If oldx < newx Then
                    '(MOUSE MOVE RIGHT)
                    If mouse = 0 Then
                        yrot += (newx - oldx) * 0.2
                        If yrot > 360 Then
                            yrot = 0
                        End If
                    ElseIf mouse = 1 And (movest = 0 Or movest = 1) Then
                        If door Then
                            For i = 0 To selactorsc.Count - 1
                                i1 = selactorsc(i)
                                doorx(i1) += Cos(yrotd) * Dx
                                doorz(i1) += Sin(yrotd) * Dx
                            Next
                        ElseIf link Then
                            For i = 0 To sellink.Count - 1
                                linkx(sellink(i)) += Cos(yrotd) * Dx
                                linkz(sellink(i)) += Sin(yrotd) * Dx
                            Next
                        Else
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                actorx(i1) += Cos(yrotd) * Dx
                                actorz(i1) += Sin(yrotd) * Dx
                            Next
                        End If
                        UpdateActorPos()
                    ElseIf mouse = 2 And (movest = 0 Or movest = 1) Then
                        If renderobj And selmesh.Count > 0 Then
                            For i2 = 0 To selmesh.Count - 1
                                'Vertices(selmesh(i2)).x(selvert(i2)) += Cos(yrotd) * Dx
                                'Vertices(selmesh(i2)).z(selvert(i2)) += Sin(yrotd) * Dx
                            Next
                        End If
                        If rendersc Then
                            For i2 = 0 To selvertc.Count - 1
                                CollisionVerts.x(selvertc(i2)) += Cos(yrotd) * Dx
                                CollisionVerts.z(selvertc(i2)) += Sin(yrotd) * Dx
                            Next
                        End If
                        UpdateVertM()
                    End If
                End If
                If oldx > newx Then
                    '(MOUSE MOVE LEFT) 
                    If mouse = 0 Then
                        yrot -= (oldx - newx) * 0.2
                        If yrot < -360 Then
                            yrot = 0
                        End If
                    ElseIf mouse = 1 And (movest = 0 Or movest = 1) Then
                        If door Then
                            For i = 0 To selactorsc.Count - 1
                                i1 = selactorsc(i)
                                doorx(i1) -= Cos(yrotd) * Dx1
                                doorz(i1) -= Sin(yrotd) * Dx1
                            Next
                        ElseIf link Then
                            For i = 0 To sellink.Count - 1
                                linkx(sellink(i)) -= Cos(yrotd) * Dx1
                                linkz(sellink(i)) -= Sin(yrotd) * Dx1
                            Next
                        Else
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                actorx(i1) -= Cos(yrotd) * Dx1
                                actorz(i1) -= Sin(yrotd) * Dx1
                            Next
                        End If
                        UpdateActorPos()
                    ElseIf mouse = 2 And (movest = 0 Or movest = 1) Then
                        If renderobj And selmesh.Count > 0 Then
                            For i2 = 0 To selmesh.Count - 1
                                'Vertices(selmesh(i2)).x(selvert(i2)) -= Cos(yrotd) * Dx1
                                'Vertices(selmesh(i2)).z(selvert(i2)) -= Sin(yrotd) * Dx1
                            Next
                        End If
                        If rendersc Then
                            For i2 = 0 To selvertc.Count - 1
                                CollisionVerts.x(selvertc(i2)) -= Cos(yrotd) * Dx1
                                CollisionVerts.z(selvertc(i2)) -= Sin(yrotd) * Dx1
                            Next
                        End If
                        UpdateVertM()
                    End If
                End If
                If oldy > newy Then
                    '(MOUSE MOVE UP) 
                    If mouse = 0 Then
                        If xrot <= -90 Then
                            xrot = -90
                        Else
                            xrot -= (oldy - newy) * 0.2
                        End If
                    ElseIf mouse = 1 And (movest = 0 Or movest = 2) Then
                        If door Then
                            For i = 0 To selactorsc.Count - 1
                                doory(selactorsc(i)) += Dy
                            Next
                        ElseIf link Then
                            For i = 0 To sellink.Count - 1
                                linky(sellink(i)) += Dy
                            Next
                        Else
                            For i = 0 To selactor.Count - 1
                                actory(selactor(i)) += Dy
                            Next
                        End If
                        UpdateActorPos()
                    ElseIf mouse = 2 And (movest = 0 Or movest = 2) Then
                        If renderobj And selmesh.Count > 0 Then
                            For i2 = 0 To selmesh.Count - 1
                                'Vertices(selmesh(i2)).y(selvert(i2)) += Dy
                            Next
                        End If
                        If rendersc Then
                            For i2 = 0 To selvertc.Count - 1
                                CollisionVerts.y(selvertc(i2)) += Dy
                            Next
                        End If
                        UpdateVertM()
                    End If
                End If
                If oldy < newy Then
                    '(MOUSE MOVE DOWN) 
                    If mouse = 0 Then
                        If xrot >= 90 Then
                            xrot = 90
                        Else
                            xrot += (newy - oldy) * 0.2
                        End If
                    ElseIf mouse = 1 And (movest = 0 Or movest = 2) Then
                        If door Then
                            For i = 0 To selactorsc.Count - 1
                                doory(selactorsc(i)) -= Dy1
                            Next
                        ElseIf link Then
                            For i = 0 To sellink.Count - 1
                                linky(sellink(i)) -= Dy1
                            Next
                        Else
                            For i = 0 To selactor.Count - 1
                                actory(selactor(i)) -= Dy1
                            Next
                        End If
                        UpdateActorPos()
                    ElseIf mouse = 2 And (movest = 0 Or movest = 2) Then
                        If renderobj And selmesh.Count > 0 Then
                            For i2 = 0 To selmesh.Count - 1
                                'Vertices(selmesh(i2)).y(selvert(i2)) -= Dy1
                            Next
                        End If
                        If rendersc Then
                            For i2 = 0 To selvertc.Count - 1
                                CollisionVerts.y(selvertc(i2)) -= Dy1
                            Next
                        End If
                        UpdateVertM()
                    End If
                End If
            End If
            If MouseMiddle And MouseRight Then
                If oldy < newy Then
                    If mouse = 1 Then
                        If Not link Then
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                If actorzrot(i1) + (newy - oldy) * 180 > -32768 Then
                                    actorzrot(i1) += (newy - oldy) * 180
                                Else
                                    actorzrot(i1) = -32768
                                End If
                            Next
                        Else
                            For i = 0 To sellink.Count - 1
                                If linkzr(sellink(i)) + (newy - oldy) * 180 > -32768 Then
                                    linkzr(sellink(i)) += (newy - oldy) * 180
                                Else
                                    linkzr(sellink(i)) = -32768
                                End If
                            Next
                        End If
                        UpdateActorPos()
                    End If
                End If
                If oldy > newy Then
                    If mouse = 1 Then
                        If Not link Then
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                If actorzrot(i1) - (oldy - newy) * 180 < 32767 Then
                                    actorzrot(i1) -= (oldy - newy) * 180
                                Else
                                    actorzrot(i1) = 32767
                                End If
                            Next
                        Else
                            For i = 0 To sellink.Count - 1
                                If linkzr(sellink(i)) - (oldy - newy) * 180 < 32767 Then
                                    linkzr(sellink(i)) -= (oldy - newy) * 180
                                Else
                                    linkzr(sellink(i)) = 32767
                                End If
                            Next
                        End If
                        UpdateActorPos()
                    End If
                End If
            ElseIf MouseRight Then
                If oldy > newy Then
                    '(MOUSE MOVE UP) 
                    If mouse = 1 Then
                        If door Then
                            For i = 0 To selactorsc.Count - 1
                                i1 = selactorsc(i)
                                doorx(i1) -= Sin(yrotd) * Dy1
                                doorz(i1) += Cos(yrotd) * Dy1
                            Next
                        ElseIf link Then
                            For i = 0 To sellink.Count - 1
                                linkx(sellink(i)) -= Sin(yrotd) * Dy1
                                linkz(sellink(i)) += Cos(yrotd) * Dy1
                            Next
                        Else
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                actorx(i1) -= Sin(yrotd) * Dy1
                                actorz(i1) += Cos(yrotd) * Dy1
                            Next
                        End If
                        UpdateActorPos()
                    End If
                End If
                If oldy < newy Then
                    '(MOUSE MOVE DOWN) 
                    If mouse = 1 Then
                        If door Then
                            For i = 0 To selactorsc.Count - 1
                                i1 = selactorsc(i)
                                doorx(i1) += Sin(yrotd) * Dy
                                doorz(i1) -= Cos(yrotd) * Dy
                            Next
                        ElseIf link Then
                            For i = 0 To sellink.Count - 1
                                linkx(sellink(i)) += Sin(yrotd) * Dy
                                linkz(sellink(i)) -= Cos(yrotd) * Dy
                            Next
                        Else
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                actorx(i1) += Sin(yrotd) * Dy
                                actorz(i1) -= Cos(yrotd) * Dy
                            Next
                        End If
                        UpdateActorPos()
                    End If
                End If
            ElseIf MouseMiddle Then
                If oldx < newx Then
                    '(MOUSE MOVE RIGHT)
                    If mouse = 1 And (movest = 0 Or movest = 1) Then
                        If Not link Then
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                If actoryrot(i1) - (oldx - newx) * 180 < 32767 Then
                                    actoryrot(i1) -= (oldx - newx) * 180
                                Else
                                    actoryrot(i1) = 32767
                                End If
                            Next
                        Else
                            For i = 0 To sellink.Count - 1
                                If linkyr(sellink(i)) - (oldx - newx) * 180 < 32767 Then
                                    linkyr(sellink(i)) -= (oldx - newx) * 180
                                Else
                                    linkyr(sellink(i)) = 32767
                                End If
                            Next
                        End If
                        UpdateActorPos()
                    End If
                End If
                If oldx > newx Then
                    '(MOUSE MOVE LEFT) 
                    If mouse = 1 And (movest = 0 Or movest = 1) Then
                        If Not link Then
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                If actoryrot(i1) + (newx - oldx) * 180 > -32768 Then
                                    actoryrot(i1) += (newx - oldx) * 180
                                Else
                                    actoryrot(i1) = -32768
                                End If
                            Next
                        Else
                            For i = 0 To sellink.Count - 1
                                If linkyr(sellink(i)) + (newx - oldx) * 180 > -32768 Then
                                    linkyr(sellink(i)) += (newx - oldx) * 180
                                Else
                                    linkyr(sellink(i)) = -32768
                                End If
                            Next
                        End If
                        UpdateActorPos()
                    End If
                End If
                If oldy > newy Then
                    '(MOUSE MOVE UP) 
                    If mouse = 0 Then
                        finaly += (oldy - newy) * (run / 8)
                    ElseIf mouse = 1 And (movest = 0 Or movest = 2) Then
                        If Not link Then
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                If actorxrot(i1) - (oldy - newy) * 180 > -32768 Then
                                    actorxrot(i1) -= (oldy - newy) * 180
                                Else
                                    actorxrot(i1) = -32768
                                End If
                            Next
                        Else
                            For i = 0 To sellink.Count - 1
                                If linkxr(sellink(i)) - (oldy - newy) * 180 > -32768 Then
                                    linkxr(sellink(i)) -= (oldy - newy) * 180
                                Else
                                    linkxr(sellink(i)) = -32768
                                End If
                            Next
                        End If
                        UpdateActorPos()
                    ElseIf mouse = 2 Then
                        If renderobj Then
                            For i = 0 To selmesh.Count - 1
                                'Vertices(selmesh(i)).x(selvert(i)) -= Sin(yrotd) * Dy1
                                'Vertices(selmesh(i)).z(selvert(i)) += Cos(yrotd) * Dy1
                            Next
                        End If
                        If rendersc Then
                            For i2 = 0 To selvertc.Count - 1
                                CollisionVerts.x(selvertc(i2)) -= Sin(yrotd) * Dy1
                                CollisionVerts.z(selvertc(i2)) += Cos(yrotd) * Dy1
                            Next
                        End If
                    End If
                End If
                If oldy < newy Then
                    '(MOUSE MOVE DOWN) 
                    If mouse = 0 Then
                        finaly -= (newy - oldy) * (run / 8)
                    ElseIf mouse = 1 And (movest = 0 Or movest = 2) Then
                        If Not link Then
                            For i = 0 To selactor.Count - 1
                                i1 = selactor(i)
                                If actorxrot(i1) + (newy - oldy) * 180 > -32768 Then
                                    actorxrot(i1) += (newy - oldy) * 180
                                Else
                                    actorxrot(i1) = -32768
                                End If
                            Next
                        Else
                            For i = 0 To sellink.Count - 1
                                If linkxr(sellink(i)) + (newy - oldy) * 180 > -32768 Then
                                    linkxr(sellink(i)) += (newy - oldy) * 180
                                Else
                                    linkxr(sellink(i)) = -32768
                                End If
                            Next
                        End If
                        UpdateActorPos()
                    ElseIf mouse = 2 Then
                        If renderobj Then
                            For i = 0 To selmesh.Count - 1
                                'Vertices(selmesh(i)).x(selvert(i)) += Sin(yrotd) * Dy
                                'Vertices(selmesh(i)).z(selvert(i)) -= Cos(yrotd) * Dy
                            Next
                        End If
                        If rendersc Then
                            For i2 = 0 To selvertc.Count - 1
                                CollisionVerts.x(selvertc(i2)) += Sin(yrotd) * Dy
                                CollisionVerts.z(selvertc(i2)) -= Cos(yrotd) * Dy
                            Next
                        End If
                    End If
                End If
            End If
            oldx = oldLocalMouse.X
            oldy = oldLocalMouse.Y
            If key_w Then
                If xrot >= 83 Or xrot <= -83 Then
                    finaly += Sin(xrotd) * run
                Else
                    finalx -= Sin(yrotd) * run
                    finalz += Cos(yrotd) * run
                    finaly += Sin(xrotd) * run
                End If
            End If
            If key_s Then
                If xrot >= 83 Or xrot <= -83 Then
                    finaly -= Sin(xrotd) * run
                Else
                    finalx += Sin(yrotd) * run
                    finalz -= Cos(yrotd) * run
                    finaly -= Sin(xrotd) * run
                End If
            End If
            If key_d Then
                finalx -= Cos(yrotd) * run
                finalz -= Sin(yrotd) * run
            End If
            If key_a Then
                finalx += Cos(yrotd) * run
                finalz += Sin(yrotd) * run
            End If
            Gl.glDisable(Gl.GL_TEXTURE_2D)
            Gl.glDisable(Gl.GL_BLEND)
            Gl.glDisable(Gl.GL_ALPHA_TEST)
            Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB)
            If FPSCountSTR <> "" Then
                If CInt(FPSCountSTR) < 30 Then
                    ToolStripStatusLabel5.BackColor = Color.Red
                Else
                    ToolStripStatusLabel5.BackColor = Color.Green
                End If
            End If
            ToolStripStatusLabel5.Text = FPSCountSTR & " FPS"
            If osd Then
                GLPrint2D("X Pos: " & CInt(finalx.ToString), oglleft, ogltop - 25)
                GLPrint2D("Y Pos: " & CInt(finaly.ToString), oglleft, ogltop - 10)
                GLPrint2D("Z Pos: " & CInt(finalz.ToString), oglleft, ogltop + 5)
                GLPrint2D("X Rot: " & CInt(yrot.ToString), oglleft, ogltop + 20)
                GLPrint2D("Y Rot: " & CInt(xrot.ToString), oglleft, ogltop + 35)
                If maploaded Then
                    If Not link And Not door And selactor.Count = 1 And comb7 > -1 Then
                        GLPrint2D("Actor (rm): " & ComboBox7.SelectedItem.ToString, oglleft, winh - ogltop - 85)
                        GLPrint2D("X Pos: " & actorx(comb7).ToString, oglleft, winh - ogltop - 50)
                        GLPrint2D("Y Pos: " & actory(comb7).ToString, oglleft, winh - ogltop - 35)
                        GLPrint2D("Z Pos: " & actorz(comb7).ToString, oglleft, winh - ogltop - 20)
                        GLPrint2D("X Rot: " & actorxrot(comb7).ToString, oglleft, winh - ogltop - 5)
                        GLPrint2D("Y Rot: " & actoryrot(comb7).ToString, oglleft, winh - ogltop + 10)
                        GLPrint2D("Z Rot: " & actorzrot(comb7).ToString, oglleft, winh - ogltop + 25)
                    ElseIf door And selactorsc.Count = 1 And comb5 > -1 Then
                        GLPrint2D("Actor (sc): " & ComboBox5.SelectedItem.ToString, oglleft, winh - ogltop - 85)
                        GLPrint2D("X Pos: " & doorx(comb5).ToString, oglleft, winh - ogltop - 50)
                        GLPrint2D("Y Pos: " & doory(comb5).ToString, oglleft, winh - ogltop - 35)
                        GLPrint2D("Z Pos: " & doorz(comb5).ToString, oglleft, winh - ogltop - 20)
                    ElseIf link And sellink.Count = 1 Then
                        GLPrint2D("Actor (sc): " & ComboBox5.SelectedItem.ToString, oglleft, winh - ogltop - 85)
                        GLPrint2D("X Pos: " & linkx(sellink(0)).ToString, oglleft, winh - ogltop - 50)
                        GLPrint2D("Y Pos: " & linky(sellink(0)).ToString, oglleft, winh - ogltop - 35)
                        GLPrint2D("Z Pos: " & linkz(sellink(0)).ToString, oglleft, winh - ogltop - 20)
                        GLPrint2D("X Rot: " & linkxr(sellink(0)).ToString, oglleft, winh - ogltop - 5)
                        GLPrint2D("Y Rot: " & linkyr(sellink(0)).ToString, oglleft, winh - ogltop + 10)
                        GLPrint2D("Z Rot: " & linkzr(sellink(0)).ToString, oglleft, winh - ogltop + 25)
                    End If
                End If
            End If
            Gl.glPushMatrix()
            Gl.glLoadIdentity()
            Gl.glRotatef(xrot, 1.0F, 0.0F, 0.0F)
            Gl.glRotatef(yrot, 0.0F, 1.0F, 0.0F)
            Gl.glTranslatef(finalx, finaly, finalz)
            Gl.glColor4f(1, 1, 1, 1)
            If maploaded Then DrawActorBoxes()
            If highlight And Not wireframe Then DrawHighlight() Else If Not highlight And rendersc And Not wireframe Then DrawHighlight()
            If renderobj Then DrawLoaded() 'draws loaded file's parsed graphics
            If rendersc Then DrawCollision() 'draws loaded scene's collision
            Gl.glPopMatrix()
            SimpleOpenGlControl1.SwapBuffers()
        Catch err As Exception
            MsgBox("Fatal error! Sorry, unrecoverable; the program will now exit.", MsgBoxStyle.Critical, "Renderer died I think, damned bugs.")
            GC.Collect()
            End
            Me.Dispose()
        End Try
    End Sub

    Private Sub DrawActorBoxes()
        Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
        Gl.glDisable(Gl.GL_POLYGON_OFFSET_FILL)
        If actorfound > 0 And Not hide0(0) Then
            For i = 0 To actorx.Count - 1
                Gl.glPushMatrix()
                Gl.glTranslatef(actorx(i), actory(i), actorz(i))
                Gl.glRotated(actorxrot(i) \ 180, 1.0F, 0.0F, 0.0F)
                Gl.glRotated(actoryrot(i) \ 180, 0.0F, 1.0F, 0.0F)
                Gl.glRotated(actorzrot(i) \ 180, 0.0F, 0.0F, 1.0F)
                If selmode Then
                    Gl.glColor3ub(tr(i), tg(i), tb(i))
                    Glut.glutSolidCube(30D)
                Else
                    Gl.glScalef(13.0F, 13.0F, 13.0F)
                    Gl.glCallList(ActorBox)
                End If
                If Not selactor.Contains(i) Then
                    Gl.glColor3f(0, 0, 0)
                    Gl.glLineWidth(2)
                Else
                    If Not hide0(2) Then
                        Gl.glCallList(AxisGuideDList)
                    End If
                    Gl.glColor3f(0.0F, 0.6F, 0.2F)
                    Gl.glLineWidth(3)
                End If
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
                Glut.glutSolidCube(2.01F)
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
                Gl.glLineWidth(1)
                Gl.glPopMatrix()
            Next
        End If
        If scenedoorcnt > 0 And Not hide0(1) Then
            For i = 0 To doorx.Count - 1
                Gl.glPushMatrix()
                Gl.glTranslatef(doorx(i), doory(i), doorz(i))
                If selmode Then
                    Gl.glColor3ub(tr1(i), tg1(i), tb1(i))
                    Glut.glutSolidCube(30D)
                Else
                    Gl.glScalef(13.0F, 13.0F, 13.0F)
                    Gl.glCallList(ActorBox)
                End If
                If Not selactorsc.Contains(i) Then
                    Gl.glColor3f(0, 0, 0)
                    Gl.glLineWidth(2)
                Else
                    If Not hide0(2) Then
                        Gl.glCallList(AxisGuideDList)
                    End If
                    Gl.glColor3f(0.0F, 0.6F, 0.2F)
                    Gl.glLineWidth(3)
                End If
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
                Glut.glutSolidCube(2.01F)
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
                Gl.glLineWidth(1)
                Gl.glPopMatrix()
            Next
        End If
        If Not hide0(3) Then
            For i = 0 To linkx.Count - 1
                Gl.glPushMatrix()
                Gl.glTranslatef(linkx(i), linky(i), linkz(i))
                Gl.glRotated(linkxr(i) \ 180, 1.0F, 0.0F, 0.0F)
                Gl.glRotated(linkyr(i) \ 180, 0.0F, 1.0F, 0.0F)
                Gl.glRotated(linkzr(i) \ 180, 0.0F, 0.0F, 1.0F)
                If selmode Then
                    Gl.glColor3ub(lr(i), lg(i), lb(i))
                    Glut.glutSolidCube(30D)
                Else
                    Gl.glScalef(13.0F, 13.0F, 13.0F)
                    Gl.glCallList(ActorBox)
                End If
                If Not sellink.Contains(i) Then
                    Gl.glColor3f(0, 0, 0)
                    Gl.glLineWidth(2)
                Else
                    If Not hide0(2) Then
                        Gl.glCallList(AxisGuideDList)
                    End If
                    Gl.glColor3f(0.0F, 0.6F, 0.2F)
                    Gl.glLineWidth(3)
                End If
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
                Glut.glutSolidCube(2.01F)
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
                Gl.glLineWidth(1)
                Gl.glPopMatrix()
            Next
        End If
        If wireframe Then
            Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
        End If
    End Sub
    Private Sub DrawLoaded()
        If Not selmode Then
            If vertexsel Then
                Gl.glDisable(Gl.GL_TEXTURE_2D)
                Gl.glEnable(Gl.GL_BLEND)
                Gl.glDisable(Gl.GL_ALPHA_TEST)
                Gl.glPointSize(10)
                Gl.glColor4f(1, 1, 1, 0.5)
                'Gl.glBegin(Gl.GL_POINTS)
                'For i As Integer = 0 To Vertices.Length - 1
                '    For i1 = 0 To Vertices(i).x.Count - 1
                '        Gl.glVertex3i(Vertices(i).x(i1), Vertices(i).y(i1), Vertices(i).z(i1))
                '    Next
                'Next
                'Gl.glEnd()
                Gl.glPointSize(12)
                Gl.glColor3f(0, 0, 0)
                'Gl.glBegin(Gl.GL_POINTS)
                'For i As Integer = 0 To Vertices.Length - 1
                '    For i1 = 0 To Vertices(i).x.Count - 1
                '        Gl.glVertex3i(Vertices(i).x(i1), Vertices(i).y(i1), Vertices(i).z(i1))
                '    Next
                'Next
                'Gl.glEnd()
                If selmesh.Count > 0 Then
                    Gl.glPointSize(17)
                    Gl.glColor3f(1, 0, 0)
                    'Gl.glBegin(Gl.GL_POINTS)
                    'For i = 0 To selmesh.Count - 1
                    '    Gl.glVertex3i(Vertices(selmesh(i)).x(selvert(i)), Vertices(selmesh(i)).y(selvert(i)), Vertices(selmesh(i)).z(selvert(i)))
                    'Next
                    'Gl.glEnd()
                End If
            End If
            If refreshdebug Then
                DebugTree.Nodes.Clear()
            End If
            cmdno = 0
            If canrun Then
                For i = 0 To DLInfo.Length - 1
                    If Not DLInfo(i).skip Then
                        Gl.glDisable(Gl.GL_TEXTURE_2D)
                        Gl.glDisable(Gl.GL_FOG)
                        Gl.glDisable(Gl.GL_CULL_FACE)
                        Gl.glDisable(Gl.GL_LIGHTING)
                        Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB)
                        Gl.glBindTexture(Gl.GL_TEXTURE_2D, 1)
                        Gl.glDisable(Gl.GL_POLYGON_OFFSET_FILL)
                        NewTexture = False
                        If refreshdebug Then DebugTree.Nodes.Add(" - Display list " & (cmdno + 1).ToString & " -")
                        For i1 = 0 To DLInfo(i).CommandCount - 1
                            CMDHigh = Convert.ToUInt32(CByte(DLInfo(i).Commands(i1).CMDDword(4)).ToString("X2") & _
                                     CByte(DLInfo(i).Commands(i1).CMDDword(5)).ToString("X2") & _
                                     CByte(DLInfo(i).Commands(i1).CMDDword(6)).ToString("X2") & _
                                     CByte(DLInfo(i).Commands(i1).CMDDword(7)).ToString("X2"), 16)

                            CMDLow = Convert.ToUInt32(CByte(DLInfo(i).Commands(i1).CMDDword(1)).ToString("X2") & _
                                     CByte(DLInfo(i).Commands(i1).CMDDword(2)).ToString("X2") & _
                                     CByte(DLInfo(i).Commands(i1).CMDDword(3)).ToString("X2"), 16)

                            CMDStr = CByte(DLInfo(i).Commands(i1).CMDDword(0)).ToString("X2")
                            If Not DLInfo(i).Commands(i1).SkipCommand Then ParseCurrentCommand()
                            SetCMDStr()
                            If refreshdebug Then
                                DebugTree.Nodes(cmdno).Nodes.Add(cmdtext & " (0x" & CMDStr & ")")
                                Select Case cmdtext
                                    Case "G_SETPRIMCOLOR"
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("R: " & PrimColor(0))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("G: " & PrimColor(1))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("B: " & PrimColor(2))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("A: " & PrimColor(3))
                                    Case "G_SETENVCOLOR"
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("R: " & EnvironmentColor(0))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("G: " & EnvironmentColor(1))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("B: " & EnvironmentColor(2))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("A: " & EnvironmentColor(3))
                                    Case "G_SETCOMBINE"
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("cA0: " & cA0)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("cB0: " & cB0)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("cC0: " & cC0)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("cD0: " & cD0)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("aA0: " & aA0)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("aB0: " & aB0)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("aC0: " & aC0)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("aD0: " & aD0)
                                    Case "F3DEX2_TRI1"
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri1 - 1: " & DLInfo(i).Commands(i1).CMDDword(1) \ 2)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri1 - 2: " & DLInfo(i).Commands(i1).CMDDword(2) \ 2)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri1 - 3: " & DLInfo(i).Commands(i1).CMDDword(3) \ 2)
                                    Case "F3DEX2_TRI2"
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri1 - 1: " & DLInfo(i).Commands(i1).CMDDword(1) \ 2)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri1 - 2: " & DLInfo(i).Commands(i1).CMDDword(2) \ 2)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri1 - 3: " & DLInfo(i).Commands(i1).CMDDword(3) \ 2)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri2 - 1: " & DLInfo(i).Commands(i1).CMDDword(5) \ 2)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri2 - 2: " & DLInfo(i).Commands(i1).CMDDword(6) \ 2)
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Tri2 - 3: " & DLInfo(i).Commands(i1).CMDDword(7) \ 2)
                                    Case "F3DEX2_VTX"
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Bank: 0x" & Hex(DLInfo(i).Commands(i1).CMDDword(4)))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Offset: 0x" & Hex(oldvtoff))
                                        DebugTree.Nodes(cmdno).Nodes(DebugTree.Nodes(cmdno).Nodes.Count - 1).Nodes.Add("Count: " & DLInfo(i).Commands(i1).CMDDword(3) \ 2)
                                End Select
                            End If
                        Next
                        cmdno += 1
                    End If
                Next
            End If
            Gl.glDisable(Gl.GL_FRAGMENT_PROGRAM_ARB)
            If refreshdebug Then refreshdebug = False
        End If
    End Sub
    Sub DrawCollision()
        Gl.glDisable(Gl.GL_TEXTURE_2D)
        Gl.glEnable(Gl.GL_BLEND)
        If Not selmode Then
            Gl.glPolygonOffset(-6, -6)
            Gl.glEnable(Gl.GL_POLYGON_OFFSET_FILL)
            Gl.glBegin(Gl.GL_TRIANGLES)
            For i = 0 To CollisionPolies.A.Count - 1
                cA = CollisionPolies.A(i)
                cB = CollisionPolies.B(i)
                cC = CollisionPolies.C(i)
                Gl.glColor4f(1, ctris(i).g, ctris(i).b, 0.5)
                Gl.glVertex3i(CollisionVerts.x(cA), CollisionVerts.y(cA), CollisionVerts.z(cA))
                Gl.glVertex3i(CollisionVerts.x(cB), CollisionVerts.y(cB), CollisionVerts.z(cB))
                Gl.glVertex3i(CollisionVerts.x(cC), CollisionVerts.y(cC), CollisionVerts.z(cC))
            Next
            Gl.glEnd()

            If vertexsel Then
                Gl.glPointSize(10)
                Gl.glColor4f(1, 1, 1, 0.7)
                Gl.glBegin(Gl.GL_POINTS)
                For i = 0 To CollisionVerts.x.Count - 1
                    Gl.glVertex3i(CollisionVerts.x(i), CollisionVerts.y(i), CollisionVerts.z(i))
                Next
                Gl.glEnd()
                Gl.glPointSize(12)
                Gl.glColor3f(0, 0, 0)
                Gl.glBegin(Gl.GL_POINTS)
                For i = 0 To CollisionVerts.x.Count - 1
                    Gl.glVertex3i(CollisionVerts.x(i), CollisionVerts.y(i), CollisionVerts.z(i))
                Next
                Gl.glEnd()
                If selvertc.Count > 0 Then
                    Gl.glPointSize(17)
                    Gl.glColor3f(1, 0, 0)
                    Gl.glBegin(Gl.GL_POINTS)
                    For i = 0 To selvertc.Count - 1
                        Gl.glVertex3i(CollisionVerts.x(selvertc(i)), CollisionVerts.y(selvertc(i)), CollisionVerts.z(selvertc(i)))
                    Next
                    Gl.glEnd()
                End If
            End If
        Else
            If trisel Then
                Gl.glPolygonOffset(-9, -9)

                Gl.glEnable(Gl.GL_POLYGON_OFFSET_FILL)
                Gl.glBegin(Gl.GL_TRIANGLES)
                For i = 0 To CollisionPolies.A.Count - 1
                    cA = CollisionPolies.A(i)
                    cB = CollisionPolies.B(i)
                    cC = CollisionPolies.C(i)
                    Gl.glColor3ub(CollisionPolies.tr5(i), CollisionPolies.tg5(i), CollisionPolies.tb5(i))
                    Gl.glVertex3i(CollisionVerts.x(cA), CollisionVerts.y(cA), CollisionVerts.z(cA))
                    Gl.glVertex3i(CollisionVerts.x(cB), CollisionVerts.y(cB), CollisionVerts.z(cB))
                    Gl.glVertex3i(CollisionVerts.x(cC), CollisionVerts.y(cC), CollisionVerts.z(cC))
                Next
                Gl.glEnd()

                Gl.glDisable(Gl.GL_POLYGON_OFFSET_FILL)
            ElseIf vertexsel Then
                Gl.glDisable(Gl.GL_BLEND)
                Gl.glPointSize(23)
                Gl.glPolygonOffset(-1, -1)
                Gl.glEnable(Gl.GL_POLYGON_OFFSET_POINT)
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_POINT)
                Gl.glBegin(Gl.GL_TRIANGLES)
                For i = 0 To CollisionVerts.x.Count - 1
                    Gl.glColor3ub(CollisionVerts.tr3(i), CollisionVerts.tg3(i), CollisionVerts.tb3(i))
                    Gl.glVertex3i(CollisionVerts.x(i), CollisionVerts.y(i), CollisionVerts.z(i))
                Next
                Gl.glEnd()
                Gl.glDisable(Gl.GL_POLYGON_OFFSET_POINT)
                Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
            End If
        End If
        Gl.glDisable(Gl.GL_BLEND)
    End Sub
    Sub DrawHighlight()
        Gl.glPolygonOffset(-1.0, -1.0)
        Gl.glEnable(Gl.GL_POLYGON_OFFSET_LINE)
        If Not wireframe Then
            Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
        End If
        'If renderobj And highlight And Not wireframe Then
        '    Gl.glBegin(Gl.GL_TRIANGLES)
        '    Gl.glColor3f(1, 0, 0)
        '    For i = 0 To Polygons.Length - 1
        '        For i1 = 0 To Polygons(i).A.Count - 1
        '            A = Polygons(i).A(i1)
        '            B = Polygons(i).B(i1)
        '            C = Polygons(i).C(i1)
        '            'Gl.glVertex3i(Vertices(i).x(A), Vertices(i).y(A), Vertices(i).z(A))
        '            'Gl.glVertex3i(Vertices(i).x(B), Vertices(i).y(B), Vertices(i).z(B))
        '            'Gl.glVertex3i(Vertices(i).x(C), Vertices(i).y(C), Vertices(i).z(C))
        '        Next
        '    Next
        '    Gl.glEnd()
        'End If
        Gl.glPolygonOffset(-7.0, -7.0)
        If rendersc And Not wireframe Then

            Gl.glBegin(Gl.GL_TRIANGLES)
            Gl.glColor3f(0, 0, 0)
            For i = 0 To CollisionPolies.A.Count - 1
                cA = CollisionPolies.A(i)
                cB = CollisionPolies.B(i)
                cC = CollisionPolies.C(i)
                Gl.glVertex3i(CollisionVerts.x(cA), CollisionVerts.y(cA), CollisionVerts.z(cA))
                Gl.glVertex3i(CollisionVerts.x(cB), CollisionVerts.y(cB), CollisionVerts.z(cB))
                Gl.glVertex3i(CollisionVerts.x(cC), CollisionVerts.y(cC), CollisionVerts.z(cC))
            Next
            Gl.glEnd()

        End If
        Gl.glDisable(Gl.GL_POLYGON_OFFSET_LINE)
        If Not wireframe Then
            Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
        End If
    End Sub
    Sub UpdateVertM()
        'TextBox21.Enabled = True
        'TextBox22.Enabled = True
        'If renderobj And selvert.Count = 1 Then
        '    TextBox1.Text = CInt(Vertices(selmesh(0)).x(selvert(0)))
        '    If Mid(TextBox1.Text, 1, 1) = "-" Then
        '        Button12.Text = "+"
        '    Else
        '        Button12.Text = "-"
        '    End If
        '    TextBox2.Text = CInt(Vertices(selmesh(0)).y(selvert(0)))
        '    If Mid(TextBox2.Text, 1, 1) = "-" Then
        '        Button14.Text = "+"
        '    Else
        '        Button14.Text = "-"
        '    End If
        '    TextBox3.Text = CInt(Vertices(selmesh(0)).z(selvert(0)))
        '    If Mid(TextBox3.Text, 1, 1) = "-" Then
        '        Button13.Text = "+"
        '    Else
        '        Button13.Text = "-"
        '    End If
        '    TextBox22.Text = CInt(Vertices(selmesh(0)).u(selvert(0)))
        '    If Mid(TextBox22.Text, 1, 1) = "-" Then
        '        Button29.Text = "+"
        '    Else
        '        Button29.Text = "-"
        '    End If
        '    TextBox21.Text = CInt(Vertices(selmesh(0)).v(selvert(0)))
        '    If Mid(TextBox21.Text, 1, 1) = "-" Then
        '        Button28.Text = "+"
        '    Else
        '        Button28.Text = "-"
        '    End If
        '    Dim vcolor As String = "#" & zerofill2(Hex(CInt(Vertices(selmesh(0)).r(selvert(0))))) & zerofill2(Hex(CInt(Vertices(selmesh(0)).g(selvert(0))))) & zerofill2(Hex(CInt(Vertices(selmesh(0)).b(selvert(0)))))
        '    Button10.BackColor = ColorTranslator.FromHtml(vcolor)
        'Else
        '    TextBox1.Text = ""
        '    TextBox2.Text = ""
        '    TextBox3.Text = ""
        '    TextBox22.Text = ""
        '    TextBox21.Text = ""
        'End If
        'If rendersc And selvertc.Count = 1 Then
        '    TextBox1.Text = CInt(CollisionVerts.x(selvertc(0)))
        '    If Mid(TextBox1.Text, 1, 1) = "-" Then
        '        Button12.Text = "+"
        '    Else
        '        Button12.Text = "-"
        '    End If
        '    TextBox2.Text = CInt(CollisionVerts.y(selvertc(0)))
        '    If Mid(TextBox2.Text, 1, 1) = "-" Then
        '        Button14.Text = "+"
        '    Else
        '        Button14.Text = "-"
        '    End If
        '    TextBox3.Text = CInt(CollisionVerts.z(selvertc(0)))
        '    If Mid(TextBox3.Text, 1, 1) = "-" Then
        '        Button13.Text = "+"
        '    Else
        '        Button13.Text = "-"
        '    End If
        '    TextBox22.Enabled = False
        '    TextBox21.Enabled = False
        'End If
        'changevert(0) = False
        'changevert(1) = False
        'changevert(2) = False
        'changevert(3) = False
        'changevert(4) = False
    End Sub
    Sub FixCollision()
        cfix.Start()
        cfix.WaitForExit()
        File.Delete(Application.StartupPath & "\ext\collision_fixer.ini")
        File.Delete(Application.StartupPath & "\ext\romname.ini")
    End Sub
    Private Sub SimpleOpenGlControl1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles SimpleOpenGlControl1.KeyDown
        Select Case e.KeyCode
            Case Keys.E
                CameraSensitivity(True)
            Case Keys.Q
                CameraSensitivity(False)
            Case Keys.ControlKey
                If Not key_ctrl Then
                    key_ctrl = True
                End If
            Case Keys.F
                If vertexsel And vtmode = 1 Then
                    If Button37.Text = "Please select a vertex" Then
                        DisableWeld()
                    Else
                        If selmesh.Count = 1 Or selvertc.Count = 1 Then
                            EnableWeld()
                        End If
                    End If
                End If
            Case Keys.I
                btnno = 1
                Timer1.Start()
            Case Keys.K
                btnno = 2
                Timer1.Start()
            Case Keys.J
                btnno = 0
                Timer1.Start()
            Case Keys.L
                btnno = 3
                Timer1.Start()
            Case Keys.U
                btnno = 4
                Timer1.Start()
            Case Keys.O
                btnno = 5
                Timer1.Start()
            Case Keys.F2
                If texfilt = 0 Then
                    texfilt = 1
                Else
                    texfilt = 0
                End If
            Case Keys.F5
                If osd Then
                    osd = False
                Else
                    osd = True
                End If
            Case Keys.F6
                If osdshadow Then
                    osdshadow = False
                Else
                    osdshadow = True
                End If
            Case Keys.Q
                If Not key_q Then key_q = True
            Case Keys.E
                If Not key_e Then key_e = True
            Case Keys.W
                If Not key_w Then key_w = True
            Case Keys.D
                If Not key_d Then key_d = True
            Case Keys.S
                If Not key_s Then key_s = True
            Case Keys.A
                If Not key_a Then key_a = True
            Case Keys.V
                ResetVerts(0)
            Case Keys.F1
                ToggleWire()
            Case Keys.T
                btnno = 6
                Timer1.Start()
            Case Keys.Y
                btnno = 7
                Timer1.Start()
            Case Keys.G
                btnno = 8
                Timer1.Start()
            Case Keys.H
                btnno = 9
                Timer1.Start()
            Case Keys.B
                If maploaded Then
                    ResetSelActor()
                End If
            Case Keys.R
                If key_ctrl Then
                    If renderobj And Not rendersc Then
                        renderobj = False
                        rendersc = True
                        ViewingMeshToolStripMenuItem1.Checked = False
                        CollisionMeshToolStripMenuItem.Checked = True
                        timerstr = "Collision True, Graphics False"
                    ElseIf renderobj And rendersc Then
                        renderobj = True
                        rendersc = False
                        ViewingMeshToolStripMenuItem1.Checked = True
                        CollisionMeshToolStripMenuItem.Checked = False
                        timerstr = "Collision False, Graphics True"
                    Else
                        renderobj = True
                        rendersc = True
                        ViewingMeshToolStripMenuItem1.Checked = True
                        CollisionMeshToolStripMenuItem.Checked = True
                        timerstr = "Graphics and Collision True"
                    End If
                Else
                    ResetView()
                End If
            Case Keys.U
                key_u = True
            Case Keys.F3
                If highlight Then
                    highlight = False
                Else
                    highlight = True
                End If
            Case Keys.Alt
                key_alt = True
            Case Keys.D1
                meshw = -1
                vertw = -1
                CheckBox16.Enabled = False
                CheckBox17.Enabled = False
                CheckBox18.Enabled = False
                CheckBox19.Enabled = False
                Button37.Enabled = False
                Label44.Enabled = False
                ToolStripStatusLabel4.Text = "Tool: Camera only"
                actorsel = False
                vertexsel = False
                trisel = False
                VertexSelectorToolStripMenuItem.Checked = False
                ActorSelectorToolStripMenuItem.Checked = False
                TriangleEditorToolStripMenuItem.Checked = False
                AllSharedToolStripMenuItem.Checked = False
                SinglePointToolStripMenuItem.Checked = False
                PerMeshToolStripMenuItem.Checked = False
            Case Keys.D2
                If maploaded Then
                    meshw = -1
                    vertw = -1
                    CheckBox16.Enabled = False
                    CheckBox17.Enabled = False
                    CheckBox18.Enabled = False
                    CheckBox19.Enabled = False
                    Button37.Enabled = False
                    Label44.Enabled = False
                    ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
                    actorsel = True
                    vertexsel = False
                    trisel = False
                    VertexWelderToolStripMenuItem.Checked = False
                    VertexSelectorToolStripMenuItem.Checked = False
                    ActorSelectorToolStripMenuItem.Checked = True
                    TriangleEditorToolStripMenuItem.Checked = False
                    AllSharedToolStripMenuItem.Checked = False
                    SinglePointToolStripMenuItem.Checked = False
                    PerMeshToolStripMenuItem.Checked = False
                End If
            Case Keys.D3
                CheckBox16.Enabled = True
                CheckBox17.Enabled = True
                CheckBox18.Enabled = True
                CheckBox19.Enabled = True
                Button37.Enabled = True
                Label44.Enabled = True
                ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (single)"
                actorsel = False
                vertexsel = True
                trisel = False
                VertexWelderToolStripMenuItem.Checked = False
                VertexSelectorToolStripMenuItem.Checked = True
                ActorSelectorToolStripMenuItem.Checked = False
                TriangleEditorToolStripMenuItem.Checked = False
                AllSharedToolStripMenuItem.Checked = False
                SinglePointToolStripMenuItem.Checked = True
                PerMeshToolStripMenuItem.Checked = False
            Case Keys.D4
                vertw = -1
                meshw = -1
                CheckBox16.Enabled = False
                CheckBox17.Enabled = False
                CheckBox18.Enabled = False
                CheckBox19.Enabled = False
                Button37.Enabled = False
                Label44.Enabled = False
                ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (mesh)"
                actorsel = False
                vertexsel = True
                trisel = False
                VertexWelderToolStripMenuItem.Checked = False
                VertexSelectorToolStripMenuItem.Checked = True
                ActorSelectorToolStripMenuItem.Checked = False
                TriangleEditorToolStripMenuItem.Checked = False
                AllSharedToolStripMenuItem.Checked = False
                SinglePointToolStripMenuItem.Checked = False
                PerMeshToolStripMenuItem.Checked = True
            Case Keys.D5
                vertw = -1
                meshw = -1
                CheckBox16.Enabled = False
                CheckBox17.Enabled = False
                CheckBox18.Enabled = False
                CheckBox19.Enabled = False
                Button37.Enabled = False
                Label44.Enabled = False
                ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (all)"
                actorsel = False
                vertexsel = True
                trisel = False
                VertexWelderToolStripMenuItem.Checked = False
                VertexSelectorToolStripMenuItem.Checked = True
                ActorSelectorToolStripMenuItem.Checked = False
                TriangleEditorToolStripMenuItem.Checked = False
                AllSharedToolStripMenuItem.Checked = True
                SinglePointToolStripMenuItem.Checked = False
                PerMeshToolStripMenuItem.Checked = False
            Case Keys.D6
                meshw = -1
                vertw = -1
                CheckBox16.Enabled = False
                CheckBox17.Enabled = False
                CheckBox18.Enabled = False
                CheckBox19.Enabled = False
                Button37.Enabled = False
                Label44.Enabled = False
                ToolStripStatusLabel4.Text = "Tool: Collision triangle editor"
                actorsel = False
                vertexsel = False
                trisel = True
                VertexWelderToolStripMenuItem.Checked = False
                VertexSelectorToolStripMenuItem.Checked = False
                ActorSelectorToolStripMenuItem.Checked = False
                TriangleEditorToolStripMenuItem.Checked = True
                AllSharedToolStripMenuItem.Checked = False
                SinglePointToolStripMenuItem.Checked = False
                PerMeshToolStripMenuItem.Checked = False
            Case Keys.D8
                axestr = "(X + Y)"
                If actorsel = True Then
                    ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
                ElseIf vertexsel = True Then
                    ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr
                End If
                movest = 0
                ToolStripMenuItem7.Checked = True
                ToolStripMenuItem8.Checked = False
                ToolStripMenuItem6.Checked = False
            Case Keys.D9
                axestr = "(X)"
                If actorsel = True Then
                    ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
                ElseIf vertexsel = True Then
                    ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr
                End If
                movest = 1
                ToolStripMenuItem7.Checked = False
                ToolStripMenuItem8.Checked = True
                ToolStripMenuItem6.Checked = False
            Case Keys.D0
                axestr = "(Y)"
                If actorsel = True Then
                    ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
                ElseIf vertexsel = True Then
                    ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr
                End If
                movest = 2
                ToolStripMenuItem7.Checked = False
                ToolStripMenuItem8.Checked = False
                ToolStripMenuItem6.Checked = True
            Case Keys.P
                If key_ctrl And maploaded Then
                    ActorPresets.Show()
                    ActorPresets.Focus()
                    key_ctrl = False
                End If
        End Select
    End Sub
    Sub ToggleWire()
        If Not wireframe Then
            wireframe = True
            Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
            ToolStripButton12.Image = My.Resources.Clipboard01
            ToolStripButton12.Text = "Wire"
        Else
            wireframe = False
            Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
            ToolStripButton12.Image = My.Resources.Clipboard022
            ToolStripButton12.Text = "Filled"
        End If
    End Sub
    Sub ResetMesh()
        'If Vertices.Length > 0 Then
        '    key_ctrl = False
        '    VertResetPrefs.ShowDialog()
        '    If resetbools(0) Or resetbools(1) Or resetbools(2) Or resetbools(3) Or resetbools(4) Or resetbools(5) Then
        '        For i1 = 0 To Vertices.Length - 1
        '            For i = 0 To Vertices(i1).x.Count - 1
        '                If resetbools(0) Then Vertices(i1).x(i) = Vertices(i1).ox(i)
        '                If resetbools(1) Then Vertices(i1).y(i) = Vertices(i1).oy(i)
        '                If resetbools(2) Then Vertices(i1).z(i) = Vertices(i1).oz(i)
        '                If resetbools(3) Then Vertices(i1).u(i) = Vertices(i1).ou(i)
        '                If resetbools(4) Then Vertices(i1).v(i) = Vertices(i1).ov(i)
        '            Next
        '        Next
        '    End If
        'End If
    End Sub
    Sub ResetCollision()
        If CollisionVerts.x.Count > 0 Then
            key_ctrl = False
            VertResetPrefs.Text = "Reset all collision"
            VertResetPrefs.CheckBox4.Enabled = False
            VertResetPrefs.CheckBox5.Enabled = False
            VertResetPrefs.CheckBox6.Enabled = False
            VertResetPrefs.CheckBox4.Checked = False
            VertResetPrefs.CheckBox5.Checked = False
            VertResetPrefs.CheckBox6.Checked = False
            VertResetPrefs.ShowDialog()
            For i = 0 To CollisionVerts.x.Count - 1
                If resetbools(0) Then CollisionVerts.x(i) = CollisionVerts.ox(i)
                If resetbools(1) Then CollisionVerts.y(i) = CollisionVerts.oy(i)
                If resetbools(2) Then CollisionVerts.z(i) = CollisionVerts.oz(i)
            Next
        End If
    End Sub
    Sub BuildAxis()
        AxisGuideDList = Gl.glGenLists(1)
        Gl.glNewList(AxisGuideDList, Gl.GL_COMPILE)
        Gl.glBegin(Gl.GL_LINES)
        Gl.glColor3f(0, 0, 1)
        Gl.glVertex3f(420, 0.1, 0.1)
        Gl.glVertex3f(-420, 0.1, 0.1)
        Gl.glEnd()
        Gl.glBegin(Gl.GL_LINES)
        Gl.glColor3f(1, 0, 0)
        Gl.glVertex3f(0.1, 420, 0.1)
        Gl.glVertex3f(0.1, -420, 0.1)
        Gl.glEnd()
        Gl.glBegin(Gl.GL_LINES)
        Gl.glColor3f(0, 1, 0)
        Gl.glVertex3f(0.1, 0.1, 420)
        Gl.glVertex3f(0.1, 0.1, -420)
        Gl.glVertex3f(0.1, 0.1, 420)
        Gl.glEnd()
        Gl.glEndList()
        Gl.glLineWidth(1)

        ActorBox = Gl.glGenLists(1)
        Gl.glNewList(ActorBox, Gl.GL_COMPILE)

        Gl.glBegin(Gl.GL_QUADS)
        'top
        Gl.glColor3f(1, 1, 1)
        Gl.glVertex3f(1.0F, 1.0F, -1.0F)
        Gl.glVertex3f(-1.0F, 1.0F, -1.0F)
        Gl.glVertex3f(-1.0F, 1.0F, 1.0F)
        Gl.glVertex3f(1.0F, 1.0F, 1.0F)
        'bottom
        Gl.glColor3f(0, 0, 0)
        Gl.glVertex3f(1.0F, -1.0F, 1.0F)
        Gl.glVertex3f(-1.0F, -1.0F, 1.0F)
        Gl.glVertex3f(-1.0F, -1.0F, -1.0F)
        Gl.glVertex3f(1.0F, -1.0F, -1.0F)
        'front
        Gl.glColor3f(1, 0, 0)
        Gl.glVertex3f(1.0F, 1.0F, 1.0F)
        Gl.glVertex3f(-1.0F, 1.0F, 1.0F)
        Gl.glVertex3f(-1.0F, -1.0F, 1.0F)
        Gl.glVertex3f(1.0F, -1.0F, 1.0F)
        'back
        Gl.glColor3f(0, 1, 0)
        Gl.glVertex3f(1.0F, -1.0F, -1.0F)
        Gl.glVertex3f(-1.0F, -1.0F, -1.0F)
        Gl.glVertex3f(-1.0F, 1.0F, -1.0F)
        Gl.glVertex3f(1.0F, 1.0F, -1.0F)
        'left
        Gl.glColor3f(1, 1, 0)
        Gl.glVertex3f(-1.0F, 1.0F, 1.0F)
        Gl.glVertex3f(-1.0F, 1.0F, -1.0F)
        Gl.glVertex3f(-1.0F, -1.0F, -1.0F)
        Gl.glVertex3f(-1.0F, -1.0F, 1.0F)
        'right
        Gl.glColor3f(0, 0, 1)
        Gl.glVertex3f(1.0F, 1.0F, -1.0F)
        Gl.glVertex3f(1.0F, 1.0F, 1.0F)
        Gl.glVertex3f(1.0F, -1.0F, 1.0F)
        Gl.glVertex3f(1.0F, -1.0F, -1.0F)
        Gl.glEnd()
        Gl.glEndList()
    End Sub
    Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click, QuitToolStripMenuItem.Click
        Me.Close()
    End Sub
    Private Sub LoadZOBJToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click, OpenModelToolStripMenuItem.Click
        LoadROM.ShowDialog()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            extracted.r = New ArrayList
            extracted.g = New ArrayList
            extracted.b = New ArrayList
            extracted.a = New ArrayList
            ReDim DLInfo(-1)
            With CollisionPolies
                .A = New ArrayList
                .B = New ArrayList
                .C = New ArrayList
                .tr5 = New ArrayList
                .tg5 = New ArrayList
                .tb5 = New ArrayList
            End With
            With CollisionVerts
                .x = New ArrayList
                .y = New ArrayList
                .z = New ArrayList
                .ox = New ArrayList
                .oy = New ArrayList
                .oz = New ArrayList
                .tb3 = New ArrayList
                .tg3 = New ArrayList
                .tr3 = New ArrayList
            End With
            For i = 0 To 2
                weldpos(i) = True
            Next
            If Gl.glGetString(Gl.GL_EXTENSIONS).Contains("GL_EXT_texture_filter_anisotropic") Then
                Gl.glGetFloatv(Gl.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, MaxAnisotropy)
            End If
            weldautooff = True
            su = Application.StartupPath
            If Not File.Exists(su & "/uot.ini") Then
                File.Create(su & "/uot.ini")
            End If
            Dim objfile As New StreamReader(su & "\ext\objlist.txt")
            Dim curline As String = ""
            While objfile.Peek <> -1
                curline = objfile.ReadLine
                objects.Add(Mid(curline, 1, 4))
                objectss.Add(Mid(curline, 28))
            End While
            objfile.Dispose()
            ClearArrayLists()
            Il.ilInit()
            BuildAxis()
            Dim colpres As StreamReader = New StreamReader(su & "\ext\CollisionPresets.txt")
            Dim endpos As Integer = 0
            Dim no As Integer = 0
            While colpres.Peek <> -1
                curline = colpres.ReadLine
                If Mid(curline, 1, 1) = "!" Then
                    no = CInt(Mid(curline, curline.IndexOf("[") + 2, 1))
                    FlagsToolStripMenuItem.DropDownItems.Add(Mid(curline, 2))
                    curline = colpres.ReadLine
                    presets.Add(curline)
                    presetind.Add(no)
                End If
            End While
            colpres.Dispose()
            With cfix.StartInfo
                .UseShellExecute = True
                .CreateNoWindow = True
                .WindowStyle = ProcessWindowStyle.Hidden
                .FileName = su & "\ext\collision_fixer.exe"
                .WorkingDirectory = su & "\ext"
            End With
            With crc.StartInfo
                .UseShellExecute = True
                .CreateNoWindow = True
                .WindowStyle = ProcessWindowStyle.Hidden
                .FileName = Application.StartupPath & "\ext\rn64crc.exe"
            End With
            Dim acpres As StreamReader = New StreamReader(Application.StartupPath & "\ext\actor_db.txt")
            While acpres.Peek <> -1
                curline = acpres.ReadLine
                If curline <> "" And Not adescbuff.Contains(Mid(curline, 16)) Then
                    agrbuff.Add(Mid(curline, 6, 4))
                    anobuff.Add(Mid(curline, 1, 4))
                    avarbuff.Add(Mid(curline, 11, 4))
                    adescbuff.Add(Mid(curline, 16))
                End If
            End While
            acpres.Dispose()
            Dim config As String = ""
            Dim texupt As String = iniwrite.GetString("Settings", "TextureBPP", Nothing)
            Dim winw As String = iniwrite.GetString("Settings", "WinResW", Nothing)
            Dim osdt As String = iniwrite.GetString("Settings", "OSD", Nothing)
            Dim winh As String = iniwrite.GetString("Settings", "WinResH", Nothing)
            Dim toolst As String = iniwrite.GetString("Settings", "ToolSensitivity", Nothing)
            Dim camst As String = iniwrite.GetString("Settings", "CameraSpeed", Nothing)
            Dim dumpt As String = iniwrite.GetString("Settings", "DumpTextures", Nothing)
            Dim texfiltt As String = iniwrite.GetString("Settings", "TextureFiltering", Nothing)
            Dim osdst As String = iniwrite.GetString("Settings", "OSDShadow", Nothing)
            If osdst = "True" Then
                osdshadow = True
            Else
                osdshadow = False
            End If
            If texfiltt <> "" And (texfiltt = "0" Or texfiltt = "1") Then
                texfilt = CInt(texfiltt)
            Else
                texfilt = 1
            End If
            If dumpt = "True" Then
                Dim dumpdt As String = iniwrite.GetString("Settings", "DumpDirectory", Nothing)
                If Directory.Exists(dumpdt) Then
                    dump = True
                    dumpdir = dumpdt & "\"
                Else
                    dump = False
                    dumpdir = ""
                End If
            Else
                dump = False
            End If
            defrom = iniwrite.GetString("Settings", "DefaultROM", Nothing)
            If File.Exists(defrom) Then
                LoadROM.FileName = defrom
                canrun = False
                If filebuff IsNot Nothing Then
                    filebuff.Dispose()
                End If
                ToolStripButton3.Enabled = True
                LoadFile()
            End If
            If toolst <= 15 And toolst >= 1 And toolst <> "" Then
                TrackBar4.Value = CInt(toolst)
                toolsens = CSng(toolst) - 0.5
            Else
                TrackBar4.Value = 2
                toolsens = 1.5
            End If
            If camst <= 40 And camst >= 1 And camst <> "" Then
                TrackBar1.Value = CInt(camst)
                run = CInt(camst)
            Else
                TrackBar1.Value = 20
                run = 20
            End If
            If winw <> "" And winh <> "" Then
                Me.Size = New Size(winw, winh)
            End If
            config = iniwrite.GetString("Settings", "Configured", Nothing)
            dumpto = iniwrite.GetString("Settings", "DumpDirectory", Nothing)
            Dim dumpenable As String = iniwrite.GetString("Settings", "DumpTextures", Nothing)
            Dim frameskipt As String = iniwrite.GetString("Settings", "RenderDelay", Nothing)
            Dim toolt As String = iniwrite.GetString("Settings", "ToolSensitivity", Nothing)
            Dim hight As String = iniwrite.GetString("Settings", "WireframeHighlight", Nothing)
            If hight = "True" Then
                highlight = True
            Else
                highlight = False
            End If
            pjdir = iniwrite.GetString("Settings", "PJDir", Nothing)
            If osdt = "" Or osdt = "False" Then
                osd = False
            ElseIf osdt = "True" Then
                osd = True
            End If
            If frameskipt = "" Then
                frameskip = 0
            Else
                frameskip = CInt(frameskipt)
            End If
            winw = ""
            winh = ""
            dumpenable = ""
            If config <> "True" Then
                SetupDialog.Cancel_Button.Enabled = False
                SetupDialog.ShowDialog()
                SetupDialog.Text = "Utility of Time First Time Setup"
                SetupDialog.Focus()
                SetupDialog.ComboBox1.SelectedIndex = 3
            Else
                SetupDialog.Cancel_Button.Enabled = True
            End If
            gameplaykeep = New FileStream(Application.StartupPath & "/ext/renderer.zav", FileMode.Open)
            dangenkeep = New FileStream(Application.StartupPath & "/ext/renderer1.zav", FileMode.Open)
            fieldkeep = New FileStream(Application.StartupPath & "/ext/renderer3.zav", FileMode.Open)
            args = Environment.GetCommandLineArgs()
            If args.Length = 2 Then
                LoadROM.FileName = args(1)
                Start()
            End If
            ReDim args(-1)
            Me.Show()
            Me.Focus()
            GC.Collect()
            Initialize()
        Catch err As Exception
        End Try
    End Sub
    Private Sub ResetView() ' Reset to default view
        rendersc = False
        xrot = 0.0
        yrot = 0.0
        zrot = 0.0
        finalx = 0.0
        finaly = 0.0
        finalz = 0.0
        If LoadROM.FileName.Contains("gi_") Then
            finalz = -300
        Else
            finalz = -1400
        End If
    End Sub
    Private Sub StoreDisplayLists()
    End Sub
    Public Sub RipAndProcessDLists()
        Try
            Dim filename1 As String = GetFileName(LoadROM.FileName)
            If dump Then
                Directory.CreateDirectory(dumpdir)
            Else
                Directory.CreateDirectory("C:/TexCache/")
            End If
            Dim cmd(7) As Byte
            Dim start As Integer = 0
            For i = 0 To DLInfo.Length - 1
                start = DLInfo(i).startpos
                ReDim Preserve DLInfo(i).Commands(DLInfo(i).CommandCount - 1)
                For i1 = 0 To DLInfo(i).CommandCount - 1
                    ReDim DLInfo(i).Commands(i1).CMDDword(7)
                    DLInfo(i).Commands(i1).SkipCommand = False
                    For i2 = 0 To 7
                        DLInfo(i).Commands(i1).CMDDword(i2) = (ZFileBuffer(start + i2))
                    Next
                    start += 8
                Next
            Next
            i = 0
            canrun = True
        Catch err As Exception
            MsgBox("An error has occured in storing display lists: " & err.Message)
            Exit Sub
        End Try
    End Sub
    Private Sub GetCollision()
        Try
            Dim ptloopt(2) As Integer
            Dim loopamtt(1) As Integer
            Dim loopamt As Integer = 0
            Dim colvart(2) As Integer
            Dim gobackto As Integer = 0
            Dim fgoto As Integer = 0
            Dim returnto1 As Integer = 0
            Dim colx2 As Integer = 0
            Dim headercmd(1) As Integer
            ComboBox8.Items.Clear()
            colxsave.Clear()
            With CollisionPolies
                .A.Clear()
                .B.Clear()
                .C.Clear()
                .tr5.Clear()
                .tg5.Clear()
                .tb5.Clear()
            End With
            With CollisionVerts
                .x.Clear()
                .y.Clear()
                .z.Clear()
                .ox.Clear()
                .oy.Clear()
                .oz.Clear()
                .tb3.Clear()
                .tg3.Clear()
                .tr3.Clear()
            End With
            colvar.Clear()
            colvaroff.Clear()
            exits.Clear()
            Dim tb As String = ""
            Dim ta As String = ""
            ReDim ctris(0)
            If maploaded Then
                ComboBox8.Items.Add("Exit Selection")
                ComboBox8.Enabled = True
                TextBox16.Enabled = True
                scene.Position = 0
            Else
                filebuff.Position = 0
                ComboBox8.Items.Add("N/A")
                TextBox16.Enabled = False
                ComboBox8.Enabled = False
            End If
            ComboBox8.SelectedIndex = 0
            Dim r1 As Integer = 0
            If maploaded Then
                While scene.Position < scene.Length - 10
                    headercmd(0) = scene.ReadByte
                    scene.Position += 1
                    Select Case headercmd(0)
                        Case 20
                            Exit While
                        Case 19
                            scene.Position += 3
                            Dim pos As Integer = Convert.ToUInt32(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                            scene.Position += 5
                            Dim loopcnt1 As Integer = ((Convert.ToUInt32(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16) - pos) \ 2) - 1
                            exitoff = pos
                            scene.Position = pos
                            For i = 0 To loopcnt1
                                exits.Add(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"))
                                ComboBox8.Items.Add(i)
                            Next
                            Exit While
                        Case 3
                            scene.Position += 3
                            r1 = scene.Position + 3
                            collgoto1 = Convert.ToUInt32(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                            scene.Position = collgoto1 + 17
                            ptloop = Convert.ToUInt32(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                            loopamt = Convert.ToUInt32(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                            scene.Position += 3
                            fgoto = Convert.ToUInt32(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                            scene.Position += 1
                            Dim vargoto As Int32 = Convert.ToUInt32(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                            scene.Position = vargoto
                            ComboBox1.Items.Clear()
                            ComboBox1.Items.Add("Collision Types")
                            Dim int3 As Integer = 0
                            While scene.Position < fgoto
                                coltypeoff.Add(scene.Position + 1)
                                coltypes.Add(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"))
                                ComboBox1.Items.Add(int3)
                                int3 += 1
                            End While
                            ComboBox1.SelectedIndex = 0
                            scene.Position = fgoto
                            zlestart16 = fgoto
                            zlestart6 = ptloop
                            zleend6 = collgoto1
                            For i3 = 0 To loopamt - 1
                                colvaroff.Add(scene.Position)
                                colvar.Add(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"))
                                tb = Mid(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 2, 3)
                                CollisionPolies.A.Add(Convert.ToUInt32(tb, 16))
                                tb = Mid(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 2, 3)
                                CollisionPolies.B.Add(Convert.ToUInt32(tb, 16))
                                tb = Mid(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 2, 3)
                                CollisionPolies.C.Add(Convert.ToUInt32(tb, 16))
                                CollisionPolies.tr5.Add(rand.Next(0, 255))
                                CollisionPolies.tg5.Add(rand.Next(0, 255))
                                CollisionPolies.tb5.Add(rand.Next(0, 255))
                                scene.Position += 8
                            Next
                            ReDim ctris(colvar.Count - 1)
                            scene.Position = ptloop
                            Dim cx As Int16 = 0
                            Dim cy As Int16 = 0
                            Dim cz As Int16 = 0
                            While scene.Position < collgoto1
                                colxsave.Add(scene.Position)
                                cx = Convert.ToInt16(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                                CollisionVerts.x.Add(cx)
                                CollisionVerts.ox.Add(cx)
                                cy = Convert.ToInt16(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                                CollisionVerts.y.Add(cy)
                                CollisionVerts.oy.Add(cy)
                                cz = Convert.ToInt16(scene.ReadByte.ToString("X2") & scene.ReadByte.ToString("X2"), 16)
                                CollisionVerts.z.Add(cz)
                                CollisionVerts.oz.Add(cz)
                                CollisionVerts.tr3.Add(rand.Next(0, 255))
                                CollisionVerts.tg3.Add(rand.Next(0, 255))
                                CollisionVerts.tb3.Add(rand.Next(0, 255))
                            End While
                            ComboBox7.SelectedIndex = 0
                            ChangeColor()
                            scene.Position = r1
                        Case Else
                            scene.Position += 6
                    End Select
                End While
            Else
                While filebuff.Position < filebuff.Length - 14
                    filebuff.Position += 14
                    headercmd(0) = filebuff.ReadByte
                    headercmd(1) = filebuff.ReadByte
                    Select Case Mid(headercmd(0).ToString("X2") & headercmd(1).ToString("X2"), 1, 3)
                        Case "07C"
                            Do Until headercmd(0) = 6 And headercmd(1) = 0 Or filebuff.Position > filebuff.Length - 1
                                headercmd(0) = filebuff.ReadByte
                                headercmd(1) = filebuff.ReadByte
                            Loop
                            If filebuff.Position >= filebuff.Length - 1 Then
                                Exit While
                            End If
                            filebuff.Position -= 1
                            ptloop = Convert.ToUInt32(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                            loopamt = Convert.ToUInt32(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                            filebuff.Position += 3
                            fgoto = Convert.ToUInt32(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                            If fgoto > filebuff.Length - 1 Then
                                Exit While
                            End If
                            filebuff.Position += 1
                            Dim vargoto As Int32 = Convert.ToUInt32(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                            filebuff.Position = vargoto
                            ComboBox1.Items.Clear()
                            ComboBox1.Items.Add("Collision Types")
                            Dim int3 As Integer = 0
                            While filebuff.Position < fgoto
                                coltypeoff.Add(filebuff.Position + 1)
                                coltypes.Add(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"))
                                ComboBox1.Items.Add(int3)
                                int3 += 1
                            End While
                            filebuff.Position = fgoto
                            zlestart16 = fgoto
                            zlestart6 = ptloop
                            zleend6 = collgoto1
                            For i3 = 0 To loopamt - 1
                                colvaroff.Add(filebuff.Position)
                                colvar.Add(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"))
                                tb = Mid(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 2, 3)
                                CollisionPolies.A.Add(Convert.ToUInt32(tb, 16))
                                tb = Mid(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 2, 3)
                                CollisionPolies.B.Add(Convert.ToUInt32(tb, 16))
                                tb = Mid(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 2, 3)
                                CollisionPolies.C.Add(Convert.ToUInt32(tb, 16))
                                CollisionPolies.tr5.Add(rand.Next(0, 255))
                                CollisionPolies.tg5.Add(rand.Next(0, 255))
                                CollisionPolies.tb5.Add(rand.Next(0, 255))
                                filebuff.Position += 8
                            Next
                            filebuff.Position = ptloop
                            Dim yx As Int16 = 0
                            Dim yy As Int16 = 0
                            Dim yz As Int16 = 0
                            While filebuff.Position < collgoto1
                                colxsave.Add(filebuff.Position)
                                yx = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                                CollisionVerts.x.Add(yx)
                                CollisionVerts.ox.Add(yx)
                                yy = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                                CollisionVerts.y.Add(yy)
                                CollisionVerts.oy.Add(yy)
                                yz = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                                CollisionVerts.z.Add(yz)
                                CollisionVerts.oz.Add(yz)
                                CollisionVerts.tr3.Add(rand.Next(0, 255))
                                CollisionVerts.tg3.Add(rand.Next(0, 255))
                                CollisionVerts.tb3.Add(rand.Next(0, 255))
                            End While
                            If ComboBox7.Items.Count > 0 Then
                                ComboBox7.SelectedIndex = 0
                            End If
                            ChangeColor()
                            filebuff.Position = r1
                            Exit While
                    End Select
                End While
            End If
            GC.Collect()
        Catch err As Exception
            colx.Clear()
            coly.Clear()
            colz.Clear()
            colvar.Clear()
            colvaroff.Clear()
            MsgBox("Error in collision reading: " & Environment.NewLine & Environment.NewLine & "Debug Info: " & err.Message)
            Exit Sub
        End Try
    End Sub
    Private Sub GetEntryPoints()
        Try
            Dim TempPos(0, 0) As Int16
            Dim epcnt As Integer = 0
            Dim gobackto As Integer = 0
            Dim cp As Integer = 0
            Dim endd As Integer = 0
            Dim cpold As Integer = 0
            Dim currep As Integer = 0
            ReDim DLInfo(-1)
            epcnt = 0
            ComboBox3.Items.Clear()
            ComboBox3.Items.Add("Render all")
            For cp = 0 To ZFileBuffer.Length - 8 Step 8
                If ZFileBuffer(cp) = &HE7 And ZFileBuffer(cp + 1) = 0 And ZFileBuffer(cp + 2) = 0 _
                And ZFileBuffer(cp + 3) = 0 And ZFileBuffer(cp + 4) = 0 And ZFileBuffer(cp + 5) = 0 _
                And ZFileBuffer(cp + 6) = 0 And ZFileBuffer(cp + 7) = 0 Then
                    cpold = cp
                    ReDim Preserve DLInfo(epcnt)
                    DLInfo(epcnt) = New DisplayList
                    DLInfo(epcnt).startpos = cp
                    DLInfo(epcnt).skip = True
                    Do
                        DLInfo(epcnt).CommandCount += 1
                        If ZFileBuffer(cp) = &HDF Then
                            DLInfo(epcnt).endpos = cp
                            Exit Do
                        End If
                        cp += 8
                    Loop
                    ComboBox3.Items.Add("0x" & Hex(cpold))
                    epcnt += 1
                End If
            Next
            epcnt = 0
            GC.Collect()
        Catch err As System.Exception
            MsgBox("Error in entry point searching: " & Environment.NewLine & Environment.NewLine & "Debug Info: " & err.Message)
            Exit Sub
        End Try
    End Sub
    Private Sub ClearArrayLists()
        lr.Clear()
        lb.Clear()
        lg.Clear()
        sellink.Clear()
        linkx.Clear()
        linky.Clear()
        linkz.Clear()
        linkxr.Clear()
        linkyr.Clear()
        linkzr.Clear()
        linkno.Clear()
        linkvar.Clear()
        objxsave.Clear()
        meshw = -1
        vertw = -1
        actorgr.Clear()
        texfilename.Clear()
        PolyStart.Clear()
        ArrayOff.Clear()
        selactor.Clear()
        selmesh.Clear()
        selvert.Clear()
        selvertc.Clear()
        actorx.Clear()
        actory.Clear()
        actorz.Clear()
        actorxrot.Clear()
        actoryrot.Clear()
        actorzrot.Clear()
        oactorx.Clear()
        oactory.Clear()
        oactorz.Clear()
        oactorxrot.Clear()
        oactoryrot.Clear()
        oactorzrot.Clear()
        actorno.Clear()
        actorvar.Clear()
        actorvaroff.Clear()
        actornooff.Clear()
    End Sub
    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        AboutBoxDialog.Show()
        AboutBoxDialog.Focus()
    End Sub
    Private Sub DetectExtension()
        Button10.Enabled = True
        Label28.Visible = False
        Label45.Text = ""
        If mapfilename.Contains("room_") Then
            bankno = 3
            EPDLoad = False
            renderobj = True
            maploaded = True
            RenderModeToolStripMenuItem.Enabled = True
            ViewingMeshToolStripMenuItem1.Checked = True
            CollisionMeshToolStripMenuItem.Checked = True
            ActorSelectorToolStripMenuItem.Enabled = True
            ComboBox3.Enabled = True
            TabControl1.TabPages.Remove(TabPage2)
            TabControl1.TabPages.Remove(TabPage3)
            TabControl1.TabPages.Remove(TabPage1)
            TabControl1.TabPages.Add(TabPage2)
            TabControl1.TabPages.Add(TabPage3)
            TabControl1.TabPages.Add(TabPage1)
            ComboBox3.Items.Clear()
        ElseIf objectfilename.Contains("object_") Then
            bankno = 6
            renderobj = True
            rendersc = False
            maploaded = False
            actorsel = False
            ComboBox3.Enabled = True
            ActorSelectorToolStripMenuItem.Enabled = False
            ActorSelectorToolStripMenuItem.Checked = False
            EPDLoad = True
            TabControl1.TabPages.Remove(TabPage2)
            TabControl1.TabPages.Remove(TabPage3)
            TabControl1.TabPages.Remove(TabPage1)
            TabControl1.TabPages.Add(TabPage1)
            ComboBox3.Items.Clear()
        Else
            bankno = 1
            renderobj = True
            rendersc = False
            maploaded = False
            actorsel = False
            ComboBox3.Enabled = True
            ActorSelectorToolStripMenuItem.Enabled = False
            ActorSelectorToolStripMenuItem.Checked = False
            EPDLoad = True
            TabControl1.TabPages.Remove(TabPage1)
            TabControl1.TabPages.Add(TabPage1)
        End If
    End Sub

    Private Sub GetMapActors()
        Try
            Dim findgroup As Byte = 0
            Dim envvar(3) As Byte
            Dim returntooff As Integer = 0
            Dim actornumtest As Integer = 0
            Dim finalgrouptest As String = ""
            Dim identity As String = ""
            ComboBox7.Items.Clear()
            ComboBox7.Items.Add("Room Actor Selection")
            ComboBox7.SelectedIndex = 0
            ComboBox6.SelectedIndex = 0
            actorfound = 0
            groupcnt = 0
            ObjectSetDialog.ComboBox1.Items.Clear()
            filebuff.Position = objectset
            Do Until envvar(0).ToString("X2") & envvar(1).ToString("X2") & envvar(2).ToString("X2") & envvar(3).ToString("X2") = "12000000" Or filebuff.Position > objectset + 96
                envvar(0) = filebuff.ReadByte
                envvar(1) = filebuff.ReadByte
                envvar(2) = filebuff.ReadByte
                envvar(3) = filebuff.ReadByte
            Loop
            envlightoff = filebuff.Position + 9
            TextBox4.Text = ""
            TextBox5.Text = ""
            TextBox6.Text = ""
            TextBox4.Enabled = True
            TextBox5.Enabled = True
            TextBox6.Enabled = True
            ComboBox4.Items.Clear()
            Do Until findgroup = 11 Or filebuff.Position > objectset + 96
                findgroup = filebuff.ReadByte
                filebuff.Position += 1
            Loop
            filebuff.Position -= 1
            If filebuff.Position > objectset + 96 Or findgroup <> 11 Then
                TextBox4.Text = ""
                TextBox4.Enabled = False
                TextBox5.Text = ""
                TextBox5.Enabled = False
                TextBox6.Text = ""
                TextBox6.Enabled = False
                ComboBox4.Items.Clear()
                ComboBox4.Items.Add("None")
                ComboBox4.SelectedIndex = 0
                ComboBox4.Enabled = False
                ComboBox7.Items.Clear()
                ComboBox7.Items.Add("None")
                ComboBox7.SelectedIndex = 0
                ComboBox7.Enabled = False
                Exit Sub
            Else
                TextBox4.Enabled = True
                TextBox5.Enabled = True
                TextBox6.Enabled = True
                ComboBox4.Enabled = True
                ComboBox7.Enabled = True
            End If
            groupcntoff = filebuff.Position
            groupcnt = filebuff.ReadByte
            If groupcnt = 0 Then
                TextBox4.Text = ""
                TextBox4.Enabled = False
                TextBox5.Text = ""
                TextBox5.Enabled = False
                TextBox6.Text = ""
                TextBox6.Enabled = False
                ComboBox4.Items.Clear()
                ComboBox4.Items.Add("None")
                ComboBox4.SelectedIndex = 0
                ComboBox4.Enabled = False
                ComboBox7.Items.Clear()
                ComboBox7.Items.Add("None")
                ComboBox7.SelectedIndex = 0
                ComboBox7.Enabled = False
                Exit Sub
            Else
                TextBox4.Enabled = True
                TextBox5.Enabled = True
                TextBox6.Enabled = True
                ComboBox4.Enabled = True
                ComboBox7.Enabled = True
            End If
            filebuff.Position += 3
            grppoff = filebuff.Position + 4
            filebuff.Position = Convert.ToUInt32(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
            actorgroff = filebuff.Position + 1
            For grabxyz = 0 To groupcnt
                actorgr.Add(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"))
                ComboBox4.Items.Add((grabxyz + 1).ToString)
            Next
            ComboBox4.SelectedIndex = 0
            filebuff.Position = grppoff
            Dim ax As Int16 = 0
            Dim ay As Int16 = 0
            Dim az As Int16 = 0
            Dim axr As Int16 = 0
            Dim ayr As Int16 = 0
            Dim azr As Int16 = 0
            ReDim actorposoff(0)
            ReDim physgrp(0)
            If filebuff.Position < filebuff.Length - 10 Then
                actorfound = filebuff.ReadByte
                For e As Integer = 0 To actorfound - 1
                    tr.Add(rand.Next(0, 255))
                    tg.Add(rand.Next(0, 255))
                    tb.Add(rand.Next(0, 255))
                Next
                ReDim actorposoff(actorfound - 1)
                ReDim physgrp(actorfound - 1)
                Dim loopgroup As Integer = 0
                filebuff.Position += 3
                actorpoff = filebuff.Position
                filebuff.Position = Convert.ToUInt32(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                ComboBox7.Items.Clear()
                ComboBox7.Items.Add("Room Actor Selection")
                ComboBox7.SelectedIndex = 0
                If actorfound > 0 Then
                    For i = 0 To actorfound - 1
                        'Position, number, and identification
                        actornooff.Add(filebuff.Position)
                        actorno.Add(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"))
                        filebuff.Position += 12
                        actorvaroff.Add(filebuff.Position)
                        actorvar.Add(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"))
                        filebuff.Position -= 14
                        actordb = New StreamReader(Application.StartupPath & "/ext/actor_db.txt")
                        identity = "?"
                        While actordb.Peek <> -1
                            actorindex = actordb.ReadLine
                            If Mid(actorindex, 6, 4) = "0001" Then
                                If Mid(actorindex, 1, 4) = actorno(i) And Mid(actorindex, 11, 4) = actorvar(i) Then
                                    identity = Mid(actorindex, 16)
                                    Exit While
                                End If
                            Else

                                For i1 = 0 To groupcnt - 1
                                    If Mid(actorindex, 1, 9) = actorno(i) & ":" & actorgr(i1) And Mid(actorindex, 11, 4) = actorvar(i) Then
                                        identity = Mid(actorindex, 16)
                                        Dim grpint As Integer = actorgr.IndexOf(Mid(actorindex, 6, 4))
                                        If grpint > -1 Then
                                            physgrp(i) = grpint
                                        End If
                                        Exit While
                                    End If
                                Next
                            End If
                        End While
                        ComboBox7.Items.Add((i).ToString & " - " & identity)
                        actorposoff(i) = filebuff.Position
                        ax = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                        ay = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16) + 10
                        az = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)

                        axr = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                        ayr = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)
                        azr = Convert.ToInt16(filebuff.ReadByte.ToString("X2") & filebuff.ReadByte.ToString("X2"), 16)

                        actorx.Add(ax)
                        actory.Add(ay)
                        actorz.Add(az)

                        actorxrot.Add(axr)
                        actoryrot.Add(ayr)
                        actorzrot.Add(azr)

                        oactorx.Add(ax)
                        oactory.Add(ay)
                        oactorz.Add(az)

                        oactorxrot.Add(axr)
                        oactoryrot.Add(ayr)
                        oactorzrot.Add(azr)
                        filebuff.Position += 2
                    Next
                    ComboBox7.SelectedIndex = 0
                End If
            End If
        Catch err As Exception
            actorfound = 0
            MsgBox("Error in grabbing actors: " & Environment.NewLine & Environment.NewLine & "Debug Info: " & err.Message)
            Exit Sub
        End Try
    End Sub
    Private Sub YesScene()
        Try
            TextBox13.Enabled = True
            ComboBox5.Enabled = True
            TextBox6.ReadOnly = False
            TextBox4.ReadOnly = False
        Catch err As Exception
            MsgBox("Error in scene setup: " & Environment.NewLine & Environment.NewLine & "Debug Info: " & err.Message)
            Exit Sub
        End Try
    End Sub
    Private Sub ShowObjSetD()
        If ObjectSetDialog.ComboBox1.Items.Count > 1 Or ObjectSetDialog.ComboBox2.Items.Count > 1 Then
            If ObjectSetDialog.ComboBox1.Items.Count < 1 Then
                ObjectSetDialog.ComboBox1.Enabled = False
            Else
                ObjectSetDialog.ComboBox1.SelectedIndex = 0
            End If
            If ObjectSetDialog.ComboBox2.Items.Count < 1 Then
                ObjectSetDialog.ComboBox2.Enabled = False
            Else
                ObjectSetDialog.ComboBox2.SelectedIndex = 0
            End If
            ObjectSetDialog.ShowDialog()
            ObjectSetDialog.Focus()
        Else
            objectset = 0
            sceneobjset = 0
        End If
    End Sub
    Private Sub ClearActors()
        actorno.Clear()
        actorvar.Clear()
        actorx.Clear()
        actory.Clear()
        actorz.Clear()
        actorxrot.Clear()
        actoryrot.Clear()
        actorzrot.Clear()
        doorno1.Clear()
        doorx.Clear()
        doory.Clear()
        doorz.Clear()
    End Sub

    Private Sub LoadActorGFX_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles LoadROM.FileOk
        canrun = False
        If filebuff IsNot Nothing Then
            filebuff.Dispose()
        End If
        ToolStripButton3.Enabled = True
        LoadFile()
    End Sub
    Private Sub GetROMFileTable(ByVal segoff As UInt32, ByVal nameoff As UInt32)
        Dim curfilebyte() As Byte = {}
        Dim nameinc As Integer = 0
        Dim seginc As Integer = 0
        Dim namebuffpos As Integer = 0
        Dim segbuffpos As Integer = 0
        Dim curnamepos As Integer = 0
        Dim cursegpos As Integer = 0
        Dim curfilename As String = ""
        Dim sccount As Integer = -1
        Dim othercount As Integer = 0
        Dim mapcount As Integer = 0
        Dim objcount As Integer = 0
        Dim scinc As Integer = 0
        Dim scfile As Integer = -1
        Dim done As Boolean = False
        Dim endb As Integer = 0
        Dim startb As Integer = 0
        Dim tempstart() As UInt32 = {}
        Dim tempend() As UInt32 = {}
        FileTree.Nodes.Clear()
        FileTree.Nodes.Add("Actor models")
        FileTree.Nodes.Add("Levels")
        FileTree.Nodes.Add("Others")
        namebuffpos = 0
        curnamepos = nameoff
        segbuffpos = segoff
        While 1 = 1
            startb = DataBuffer(segbuffpos) * &H1000000 + _
                        DataBuffer(segbuffpos + 1) * &H10000 + _
                        DataBuffer(segbuffpos + 2) * &H100 + _
                        DataBuffer(segbuffpos + 3)
            endb = DataBuffer(segbuffpos + 4) * &H1000000 + _
                        DataBuffer(segbuffpos + 5) * &H10000 + _
                        DataBuffer(segbuffpos + 6) * &H100 + _
                        DataBuffer(segbuffpos + 7)
            If startb = 0 And endb = 0 Then
                Exit While
            End If
            ReDim Preserve tempstart(seginc)
            ReDim Preserve tempend(seginc)
            tempend(seginc) = endb
            tempstart(seginc) = startb
            segbuffpos += 16
            seginc += 1
        End While
        While nameinc <= seginc - 1
            namebuffpos = 0
            If DataBuffer(curnamepos) = 0 Then
                Do Until DataBuffer(curnamepos) <> 0
                    curnamepos += 1
                Loop
            End If
            Do Until DataBuffer(curnamepos) = 0
                ReDim Preserve curfilebyte(namebuffpos)
                curfilebyte(namebuffpos) = DataBuffer(curnamepos)
                curnamepos += 1
                namebuffpos += 1
            Loop
            curfilename = System.Text.Encoding.UTF8.GetString(curfilebyte, 0, namebuffpos)
            If curfilename.Contains("_scene") Then
                sccount += 1
                ReDim Preserve ROMFiles.Levels(sccount)
                ROMFiles.Levels(sccount).filename = curfilename
                ROMFiles.Levels(sccount).startoff = tempstart(nameinc)
                ROMFiles.Levels(sccount).endoff = tempend(nameinc)
                FileTree.Nodes(1).Nodes.Add(curfilename)
                mapcount = 0
            ElseIf curfilename.Contains("room_") Then
                ReDim Preserve ROMFiles.Levels(sccount).Maps(mapcount)
                ROMFiles.Levels(sccount).Maps(mapcount).filename = curfilename
                ROMFiles.Levels(sccount).Maps(mapcount).startoff = tempstart(nameinc)
                ROMFiles.Levels(sccount).Maps(mapcount).endoff = tempend(nameinc)
                FileTree.Nodes(1).Nodes(sccount).Nodes.Add(curfilename)
                mapcount += 1
            ElseIf Mid(curfilename, 1, 7) = "object_" Then
                ReDim Preserve ROMFiles.Objects(objcount)
                ROMFiles.Objects(objcount).filename = curfilename
                ROMFiles.Objects(objcount).startoff = tempstart(nameinc)
                ROMFiles.Objects(objcount).endoff = tempend(nameinc)
                FileTree.Nodes(0).Nodes.Add(curfilename)
                objcount += 1
                mapcount = 0
                sccount = -1
            Else
                ReDim Preserve ROMFiles.Others(othercount)
                ROMFiles.Others(othercount).filename = curfilename
                ROMFiles.Others(othercount).startoff = tempstart(nameinc)
                ROMFiles.Others(othercount).endoff = tempend(nameinc)
                FileTree.Nodes(2).Nodes.Add(curfilename)
                othercount += 1
                mapcount = 0
                sccount = -1
            End If
            nameinc += 1
        End While
        Dim img1 As New Bitmap(My.Resources.ChestOpen)
        ToolStripButton1.Image = img1
        TabControl1.SelectedTab = TabControl1.TabPages(6)
        If Not TabControl1.Visible Then
            SimpleOpenGlControl1.Width -= 235
            TabControl1.Visible = True
        End If
        Reshape()
        GC.Collect()
    End Sub
    Private Sub Start()
        working = True
        filebuff = New FileStream(LoadROM.FileName, FileMode.Open)
        If filebuff IsNot Nothing Then
            ReDim DataBuffer(filebuff.Length - 1)
            filebuff.Position = 0
            filebuff.Read(DataBuffer, 0, filebuff.Length - 1)
        End If
        Me.Text = "Utility of Time 0.95 - " & LoadROM.FileName
        ReDim DLInfo(-1)
        seltype = 0
        ComboBox5.Items.Clear()
        ComboBox7.Items.Clear()
        ComboBox4.Items.Clear()
        PictureBox1.Image = Nothing
        Label29.Text = ""
        Label30.Text = ""
        GetROMFileTable(&H12F80, &HBE80)

        GC.Collect()
        working = False
    End Sub
    Private Sub Reshape()
        winw = SimpleOpenGlControl1.Width
        winh = SimpleOpenGlControl1.Height
        ogltop = SimpleOpenGlControl1.Top
        oglleft = SimpleOpenGlControl1.Left
        Gl.glViewport(0, 0, SimpleOpenGlControl1.Width, SimpleOpenGlControl1.Height)
        Gl.glMatrixMode(Gl.GL_PROJECTION)
        Gl.glLoadIdentity()
        Glu.gluPerspective(45.0F, SimpleOpenGlControl1.Width / SimpleOpenGlControl1.Height, 1.0F, 999999)
        Gl.glMatrixMode(Gl.GL_MODELVIEW)
        Gl.glLoadIdentity()
    End Sub
    Private Sub Form1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Enter
        Me.Focus()
    End Sub
    Private Sub KeyCheckUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
        Select Case e.KeyCode
            Case Keys.Alt
                key_alt = False
            Case Keys.ControlKey
                key_ctrl = False
            Case Keys.I, Keys.J, Keys.K, Keys.L, Keys.U, Keys.O, Keys.T, Keys.Y, Keys.G, Keys.H
                Timer1.Stop()
            Case Keys.W
                key_w = False
            Case Keys.D
                key_d = False
            Case Keys.S
                key_s = False
            Case Keys.A
                key_a = False
            Case Keys.O
                key_o = False
            Case Keys.U
                key_u = False
            Case Keys.Q
                key_q = False
            Case Keys.E
                key_e = False
        End Select
    End Sub
    Private Sub SimpleOpenGlControl1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles SimpleOpenGlControl1.KeyUp
        KeyCheckUp(sender, e)
    End Sub
    Private Sub SetupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SetupDialog.ShowDialog()
    End Sub
    Private Sub MousePixelRead()
        selmode = True
        Gl.glDisable(Gl.GL_TEXTURE_2D)
        Gl.glPushMatrix()
        Gl.glLoadIdentity()
        Gl.glRotatef(xrot, 1.0F, 0.0F, 0.0F)
        Gl.glRotatef(yrot, 0.0F, 1.0F, 0.0F)
        Gl.glRotatef(zrot, 0.0F, 0.0F, 1.0F)
        Gl.glTranslatef(finalx, finaly, finalz)
        If actorsel Then
            DrawActorBoxes()
        ElseIf vertexsel Or trisel Then
            If renderobj Then
                DrawLoaded()
            End If
            If rendersc Then
                DrawCollision()
            End If
        End If
        Gl.glPopMatrix()
        selmode = False
        mpick = False
        Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport)
        Gl.glReadPixels(newx, viewport(3) - newy, 1, 1, Gl.GL_RGB, Gl.GL_UNSIGNED_BYTE, pixel)
        If maploaded Then
            If actorsel Then
                For g As Integer = 0 To tr.Count - 1
                    If pixel(0) = tr(g) And pixel(1) = tg(g) And pixel(2) = tb(g) Then
                        mpick = True
                        ComboBox5.SelectedIndex = 0
                        selactorsc.Clear()
                        sellink.Clear()
                        If Not key_ctrl Then
                            selactor.Clear()
                            selactor.Add(g)
                            ComboBox7.SelectedIndex = g + 1
                        Else
                            If selactor.Contains(g) Then
                                selactor.Remove(g)
                            Else
                                selactor.Add(g)
                            End If
                            If selactor.Count = 1 Then
                                ComboBox7.SelectedIndex = selactor(0) + 1
                            Else
                                ComboBox7.SelectedIndex = 0
                            End If
                        End If
                        mouse = 1
                        UpdateActorPos()
                        Exit Sub
                    End If
                Next
                For g As Integer = 0 To tr1.Count - 1
                    If pixel(0) = tr1(g) And pixel(1) = tg1(g) And pixel(2) = tb1(g) Then
                        mpick = True
                        ComboBox7.SelectedIndex = 0
                        selactor.Clear()
                        sellink.Clear()
                        If Not key_ctrl Then
                            selactorsc.Clear()
                            selactorsc.Add(g)
                            ComboBox5.SelectedIndex = g + linkx.Count + 1
                        Else
                            If selactorsc.Contains(g) Then
                                selactorsc.Remove(g)
                            Else
                                selactorsc.Add(g)
                            End If
                            If selactorsc.Count = 1 Then
                                ComboBox5.SelectedIndex = selactorsc(0) + linkx.Count + 1
                            Else
                                ComboBox5.SelectedIndex = 0
                            End If
                        End If
                        mouse = 1
                        UpdateActorPos()
                        Exit Sub
                    End If
                Next
                For g As Integer = 0 To lr.Count - 1
                    If pixel(0) = lr(g) And pixel(1) = lg(g) And pixel(2) = lb(g) Then
                        mpick = True
                        ComboBox7.SelectedIndex = 0
                        selactor.Clear()
                        selactorsc.Clear()
                        If Not key_ctrl Then
                            sellink.Clear()
                            sellink.Add(g)
                            ComboBox5.SelectedIndex = g + 1
                        Else
                            If sellink.Contains(g) Then
                                sellink.Remove(g)
                            Else
                                sellink.Add(g)
                            End If
                            If sellink.Count = 1 Then
                                ComboBox5.SelectedIndex = sellink(0) + 1
                            Else
                                ComboBox5.SelectedIndex = 0
                            End If
                        End If
                        mouse = 1
                        UpdateActorPos()
                        Exit Sub
                    End If
                Next
            ElseIf vertexsel Then
                VertexSelect()
            ElseIf trisel And rendersc Then
                TriangleSelect()
            End If
        Else
            If vertexsel Then
                VertexSelect()
            ElseIf trisel And rendersc Then
                TriangleSelect()
            Else
                If pixel(0) = 7 And pixel(1) = 212 And pixel(2) = 95 Then
                    mouse = 3
                    Exit Sub
                End If
            End If
        End If
    End Sub
    Private Sub TriangleSelect()
        If Not showcdialog Then
            For i1 = 0 To CollisionPolies.A.Count - 1
                If pixel(0) = CollisionPolies.tr5(i1) And pixel(1) = CollisionPolies.tg5(i1) And pixel(2) = CollisionPolies.tb5(i1) Then
                    TextBox14.Text = colvar(i1)
                    Dim sel As Integer = Convert.ToUInt32(Mid(colvar(i1), 3, 2), 16)
                    ComboBox1.SelectedIndex = sel + 1
                    TextBox14.Text = zerofill1(Hex(sel))
                    Dim v1 As String = Convert.ToString(Convert.ToUInt32(Mid(coltypes(sel), 1, 2), 16), 2)
                    Dim v2 As String = Convert.ToString(Convert.ToUInt32(Mid(coltypes(sel), 3, 4), 16), 2)
                    Dim v3 As String = Convert.ToString(Convert.ToUInt32(Mid(coltypes(sel), 7, 2), 16), 2)
                    Dim v4 As String = Convert.ToString(Convert.ToUInt32(Mid(coltypes(sel), 10, 8), 16), 2)
                    pixel(0) = 0
                    pixel(1) = 0
                    pixel(2) = 0
                End If
            Next
        End If
    End Sub
    Private Sub VertexSelect()
        If renderobj Then
            '            For g As Integer = 0 To Vertices.Length - 1
            '                For h As Integer = 0 To Vertices(g).x.Count - 1
            '                    If pixel(0) = Vertices(g).tr2(h) And pixel(1) = Vertices(g).tg2(h) And pixel(2) = Vertices(g).tb2(h) Then
            '                        selvertc.Clear()
            '                        mouse = 2
            '                        If key_ctrl Then
            '                            If showcdialog Then
            '                                If selvert.Contains(h) And selmesh.Contains(g) Then
            '                                    selvert.Remove(h)
            '                                    selmesh.Remove(g)
            '                                    pixel(0) = 0
            '                                    pixel(1) = 0
            '                                    pixel(2) = 0
            '                                    Exit Sub
            '                                End If
            '                            End If
            '                            If selvert.Contains(h) And selmesh.Contains(g) Then
            '                                GoTo def
            '                            End If
            '                            If PerMeshToolStripMenuItem.Checked Then
            '                                For i = 0 To Vertices(g).x.Count - 1
            '                                    selmesh.Add(g)
            '                                    selvert.Add(i)
            '                                Next
            '                            ElseIf AllSharedToolStripMenuItem.Checked Then
            '                                For i1 = 0 To Vertices.Length - 1
            '                                    For i2 = 0 To Vertices(i1).x.Count - 1
            '                                        If Vertices(i1).ox(i2) = Vertices(g).ox(h) And Vertices(i1).oy(i2) = Vertices(g).oy(h) And Vertices(i1).oz(i2) = Vertices(g).oz(h) Then
            '                                            selmesh.Add(i1)
            '                                            selvert.Add(i2)
            '                                        End If
            '                                    Next
            '                                Next
            '                            Else
            '                                selmesh.Add(g)
            '                                selvert.Add(h)
            '                            End If
            'def:                        pixel(0) = 0
            '                            pixel(1) = 0
            '                            pixel(2) = 0
            '                            UpdateVertM()
            '                        Else
            '                            If selmesh.Count > 1 Then
            '                                If showcdialog Then
            '                                    If selvert.Contains(h) And selmesh.Contains(g) Then
            '                                        ColorChange()
            '                                        pixel(0) = 0
            '                                        pixel(1) = 0
            '                                        pixel(2) = 0
            '                                        UpdateVertM()
            '                                        Exit Sub
            '                                    End If
            '                                End If
            '                                selvert.Clear()
            '                                selmesh.Clear()
            '                                If PerMeshToolStripMenuItem.Checked Then
            '                                    For i = 0 To Vertices(g).x.Count - 1
            '                                        selmesh.Add(g)
            '                                        selvert.Add(i)
            '                                    Next
            '                                ElseIf AllSharedToolStripMenuItem.Checked Then
            '                                    For i1 = 0 To Vertices.Length - 1
            '                                        For i2 = 0 To Vertices(i1).x.Count - 1
            '                                            If Vertices(i1).ox(i2) = Vertices(g).ox(h) And Vertices(i1).oy(i2) = Vertices(g).oy(h) And Vertices(i1).oz(i2) = Vertices(g).oz(h) Then
            '                                                selmesh.Add(i1)
            '                                                selvert.Add(i2)
            '                                            End If
            '                                        Next
            '                                    Next
            '                                Else
            '                                    selmesh.Add(g)
            '                                    selvert.Add(h)
            '                                End If
            '                                pixel(0) = 0
            '                                pixel(1) = 0
            '                                pixel(2) = 0
            '                                UpdateVertM()
            '                                Exit Sub
            '                            Else
            '                                If weld Then
            '                                    If weldpos(0) Then Vertices(meshw).x(vertw) = Vertices(g).x(h)
            '                                    If weldpos(1) Then Vertices(meshw).y(vertw) = Vertices(g).y(h)
            '                                    If weldpos(2) Then Vertices(meshw).z(vertw) = Vertices(g).z(h)
            '                                    If weldautooff Then DisableWeld()
            '                                Else
            '                                    selvert.Clear()
            '                                    selmesh.Clear()
            '                                    If PerMeshToolStripMenuItem.Checked Then
            '                                        For i = 0 To Vertices(g).x.Count - 1
            '                                            selmesh.Add(g)
            '                                            selvert.Add(i)
            '                                        Next
            '                                    ElseIf AllSharedToolStripMenuItem.Checked Then
            '                                        For i1 = 0 To Vertices.Length - 1
            '                                            For i2 = 0 To Vertices(i1).x.Count - 1
            '                                                If Vertices(i1).ox(i2) = Vertices(g).ox(h) And Vertices(i1).oy(i2) = Vertices(g).oy(h) And Vertices(i1).oz(i2) = Vertices(g).oz(h) Then
            '                                                    selmesh.Add(i1)
            '                                                    selvert.Add(i2)
            '                                                End If
            '                                            Next
            '                                        Next
            '                                    Else
            '                                        selmesh.Add(g)
            '                                        selvert.Add(h)
            '                                    End If
            '                                    If showcdialog Then
            '                                        ColorChange()
            '                                    End If
            '                                End If
            '                                pixel(0) = 0
            '                                pixel(1) = 0
            '                                pixel(2) = 0
            '                                UpdateVertM()
            '                                Exit Sub
            '                            End If
            '                        End If
            '                    End If
            '                Next
            '            Next
            '        End If
            '        If rendersc Then
            '            For g As Integer = 0 To CollisionVerts.tr3.Count - 1
            '                If pixel(0) = CollisionVerts.tr3(g) And pixel(1) = CollisionVerts.tg3(g) And pixel(2) = CollisionVerts.tb3(g) Then
            '                    selvert.Clear()
            '                    selmesh.Clear()
            '                    If key_ctrl Then
            '                        If showcdialog Then
            '                            If selvertc.Contains(g) Then
            '                                selvertc.Remove(g)
            '                                pixel(0) = 0
            '                                pixel(1) = 0
            '                                pixel(2) = 0
            '                                GoTo def2
            '                            End If
            '                        End If
            '                        If Not selvertc.Contains(g) Then
            '                            selvertc.Add(g)
            '                        End If
            '                    Else
            '                        If selvertc.Count > 1 Then
            '                            selvertc.Clear()
            '                            selvertc.Add(g)
            '                        Else
            '                            If weld Then
            '                                If weldpos(0) Then CollisionVerts.x(vertw) = CollisionVerts.x(g)
            '                                If weldpos(1) Then CollisionVerts.y(vertw) = CollisionVerts.y(g)
            '                                If weldpos(2) Then CollisionVerts.z(vertw) = CollisionVerts.z(g)
            '                                If weldautooff Then DisableWeld()
            '                            Else
            '                                selvertc.Clear()
            '                                selvertc.Add(g)
            '                            End If
            '                        End If
            '                    End If
            'def2:               mouse = 2
            '                    pixel(0) = 0
            '                    pixel(1) = 0
            '                    pixel(2) = 0
            '                    UpdateVertM()
            '                    Exit Sub
            '                End If
            'Next
        End If
    End Sub
    Private Sub SimpleOpenGlControl1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SimpleOpenGlControl1.MouseDown
        If e.Button = Windows.Forms.MouseButtons.Right Then
            showcdialog = True
            MousePixelRead()
        Else
            showcdialog = False
            MousePixelRead()
        End If
        Select Case e.Button
            Case MouseButtons.Left
                MouseLeft = True
            Case MouseButtons.Right
                MouseRight = True
            Case MouseButtons.Middle
                MouseMiddle = True
        End Select
    End Sub
    Private Sub SimpleOpenGlControl1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SimpleOpenGlControl1.MouseUp
        MouseUp1(sender, e)
    End Sub
    Private Sub MouseUp1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        mouse = 0
        Select Case e.Button
            Case MouseButtons.Left
                MouseLeft = False
            Case MouseButtons.Right
                MouseRight = False
            Case MouseButtons.Middle
                MouseMiddle = False
        End Select
    End Sub
    Private Sub UpdateActorPos()
        If Not link And Not door Then
            If ComboBox7.SelectedIndex > 0 Then
                Dim c7 As Integer = ComboBox7.SelectedIndex - 1
                TextBox7.Text = CInt(actorx(c7))
                TextBox8.Text = CInt(actory(c7))
                TextBox9.Text = CInt(actorz(c7))
                TextBox10.Text = CInt(actorxrot(c7))
                TextBox11.Text = CInt(actoryrot(c7))
                TextBox12.Text = CInt(actorzrot(c7))
                TextBox10.Enabled = True
                TextBox11.Enabled = True
                TextBox12.Enabled = True
            End If
        ElseIf link And Not door Then
            If sellink.Count = 1 Then
                TextBox7.Text = CInt(linkx(sellink(0)))
                TextBox8.Text = CInt(linky(sellink(0)))
                TextBox9.Text = CInt(linkz(sellink(0)))
                TextBox10.Text = CInt(linkxr(sellink(0)))
                TextBox11.Text = CInt(linkyr(sellink(0)))
                TextBox12.Text = CInt(linkzr(sellink(0)))
                TextBox10.Enabled = True
                TextBox11.Enabled = True
                TextBox12.Enabled = True
            End If
        ElseIf Not link And door Then
            If ComboBox5.SelectedIndex > 1 Then
                TextBox7.Text = CInt(doorx(ComboBox5.SelectedIndex - linkx.Count - 1))
                TextBox8.Text = CInt(doory(ComboBox5.SelectedIndex - linkx.Count - 1))
                TextBox9.Text = CInt(doorz(ComboBox5.SelectedIndex - linkx.Count - 1))
                TextBox10.Enabled = False
                TextBox11.Enabled = False
                TextBox12.Enabled = False
            End If
        End If
        changepos(0) = False
        changepos(1) = False
        changepos(2) = False
        changepos(3) = False
        changepos(4) = False
        changepos(5) = False
    End Sub
    Private Sub SaveGraphics()
        Dim vertsaveoff As Integer = 0
        Dim i01 As Integer = 0
        '    For i1 = 0 To Vertices.Length - 1
        '        For i = 0 To Vertices(i1).x.Count - 1
        '            vertsaveoff = CInt(objxsave(i01))
        '            If Hex(Vertices(i1).x(i)).ToString.Length > 4 Then
        '                FilePut(8, Hex2(Mid(Hex(Vertices(i1).x(i)), 5, 4)), vertsaveoff)
        '            Else
        '                FilePut(8, Hex2(zerofill1(Hex(Vertices(i1).x(i)))), vertsaveoff)
        '            End If
        '            If Hex(Vertices(i1).y(i)).ToString.Length > 4 Then
        '                FilePut(8, Hex2(Mid(Hex(Vertices(i1).y(i)), 5, 4)), vertsaveoff + 2)
        '            Else
        '                FilePut(8, Hex2(zerofill1(Hex(Vertices(i1).y(i)))), vertsaveoff + 2)
        '            End If
        '            If Hex(Vertices(i1).z(i)).ToString.Length > 4 Then
        '                FilePut(8, Hex2(Mid(Hex(Vertices(i1).z(i)), 5, 4)), vertsaveoff + 4)
        '            Else
        '                FilePut(8, Hex2(zerofill1(Hex(Vertices(i1).z(i)))), vertsaveoff + 4)
        '            End If
        '            If Hex(CInt(Vertices(i1).u(i))).ToString.Length > 4 Then
        '                FilePut(8, Hex2(Mid(Hex(CInt(Vertices(i1).u(i))), 5, 4)), vertsaveoff + 8)
        '            Else
        '                FilePut(8, Hex2(zerofill1(Hex(CInt(Vertices(i1).u(i))))), vertsaveoff + 8)
        '            End If
        '            If Hex(CInt(Vertices(i1).v(i))).ToString.Length > 4 Then
        '                FilePut(8, Hex2(Mid(Hex(CInt(Vertices(i1).v(i))), 5, 4)), vertsaveoff + 10)
        '            Else
        '                FilePut(8, Hex2(zerofill1(Hex(CInt(Vertices(i1).v(i))))), vertsaveoff + 10)
        '            End If
        '            FilePut(8, Hex2(Hex(Vertices(i1).r(i))), vertsaveoff + 12)
        '            FilePut(8, Hex2(Hex(Vertices(i1).g(i))), vertsaveoff + 13)
        '            FilePut(8, Hex2(Hex(Vertices(i1).b(i))), vertsaveoff + 14)
        '            i01 += 1
        '        Next
        '    Next
    End Sub

    Private Sub SaveActor()
        Try
            FileOpen(8, LoadROM.FileName, OpenMode.Binary)
            SaveGraphics()
            'If CollisionVerts.x.Count > 0 Then
            '    Dim vertsaveoff As Integer = 0
            '    For i = 0 To CollisionVerts.x.Count - 1
            '        vertsaveoff = CInt(colxsave(i))
            '        If Hex(CollisionVerts.x(i)).ToString.Length > 4 Then
            '            FilePut(9, Hex2(Mid(Hex(CollisionVerts.x(i)), 5, 4)), vertsaveoff + 1)
            '        Else
            '            FilePut(9, Hex2(zerofill1(Hex(CollisionVerts.x(i)))), vertsaveoff + 1)
            '        End If
            '        If Hex(CollisionVerts.y(i)).ToString.Length > 4 Then
            '            FilePut(9, Hex2(Mid(Hex(CollisionVerts.y(i)), 5, 4)), vertsaveoff + 3)
            '        Else
            '            FilePut(9, Hex2(zerofill1(Hex(CollisionVerts.y(i)))), vertsaveoff + 3)
            '        End If
            '        If Hex(CollisionVerts.z(i)).ToString.Length > 4 Then
            '            FilePut(9, Hex2(Mid(Hex(CollisionVerts.z(i)), 5, 4)), vertsaveoff + 5)
            '        Else
            '            FilePut(9, Hex2(zerofill1(Hex(CollisionVerts.z(i)))), vertsaveoff + 5)
            '        End If
            '    Next
            '    Dim zleini As StreamWriter = New StreamWriter(Application.StartupPath & "\ext\collision_fixer.ini")
            '    Dim zlerom As StreamWriter = New StreamWriter(Application.StartupPath & "\ext\romname.ini")
            '    zleini.WriteLine("'6-byte")
            '    zleini.WriteLine(zerofill2(Hex(zlestart6)))
            '    zleini.WriteLine(zerofill2(Hex(zleend6)))
            '    zleini.WriteLine("'16-byte")
            '    zleini.WriteLine(zerofill2(Hex(zlestart16)))
            '    zleini.WriteLine(zerofill2(Hex(zlestart6)))
            '    zlerom.WriteLine("'Rom you want to edit")
            '    zlerom.WriteLine(OpenFileDialog1.FileName)
            '    zleini.Close()
            '    zlerom.Close()
            '    FixCollision()
            '    For i = 0 To coltypes.Count - 1
            '        FilePut(8, Hex2(coltypes(i)), CInt(coltypeoff(i)))
            '    Next
            '    For i = 0 To colvar.Count - 1
            '        FilePut(8, Hex2(colvar(i)), CInt(colvaroff(i)))
            '    Next
            'End If
            FileClose(8)
            If question Then
                Dim question0 As Integer = MsgBox("Object changes have been saved successfully! Inject into your default ROM now?", MsgBoxStyle.YesNo, "Saved")
                If question0 = DialogResult.Yes Then
                    SaveToRom()
                End If
            End If
        Catch err As Exception
        End Try
    End Sub
    Private Sub ToolStripButton12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton12.Click
        ToggleWire()
        SimpleOpenGlControl1.Focus()
    End Sub
    Private Sub ToolStripButton13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton13.Click, SaveChangesToolStripMenuItem.Click
        Try
            working = True
            Timer3.Stop()
            question = True
            If maploaded Then
                SaveRoom()
                timerstr = "Room/Scene saved"
            Else
                SaveActor()
                timerstr = "Actor saved"
            End If
            working = False
            GC.Collect()
        Catch err As Exception
            MsgBox("An error has occured: " & err.Message)
            Exit Sub
        End Try
    End Sub
    Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        SetupDialog.ShowDialog()
        SetupDialog.Focus()
    End Sub

    Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
        AboutBoxDialog.Show()
        AboutBoxDialog.Focus()
    End Sub

    Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ControlsInfoToolStripMenuItem.Click
        ControlsHelp.Show()
        ControlsHelp.Focus()
    End Sub
    Private Sub EndVals()
        texfilename.Clear()
        If PictureBox1.Image IsNot Nothing Then PictureBox1.Image.Dispose()
        If Directory.Exists("C:/TexCache") Then Directory.Delete("C:/TexCache", True)
        iniwrite.WriteString("Settings", "ToolSensitivity", TrackBar4.Value.ToString)
        iniwrite.WriteString("Settings", "CameraSpeed", TrackBar1.Value.ToString)
    End Sub
    Private Sub MainWin_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Try
            question = False
            Dim asku1 As String = MsgBox("Would you like to save any changes you have made?", MsgBoxStyle.YesNoCancel, "Save Changes?")
            If asku1 = DialogResult.Yes Then
                If maploaded Then
                    SaveRoom()
                Else
                    SaveActor()
                End If
                EndVals()
                e.Cancel = False
                End
            ElseIf asku1 = DialogResult.No Then
                texfilename.Clear()
                EndVals()
                e.Cancel = False
                End
            ElseIf asku1 = DialogResult.Cancel Then
                e.Cancel = True
            End If
        Catch err As Exception
            e.Cancel = False
            End
        End Try
    End Sub
    Private Sub ToolStripButton17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton17.Click, LaunchROMInPJ64ToolStripMenuItem.Click
        If Not File.Exists(pjdir) Then
            MsgBox("Either your configured PJ64 exe is invalid, or you have not configured one. You can do so by clicking the Setup button in the Preferences menu.", MsgBoxStyle.Critical, "PJ64 Launch Failed")
            Exit Sub
        End If
        If Not File.Exists(defrom) Then
            MsgBox("Either your configured default ROM is invalid, or you have not configured one. You can do so by clicking the Setup button in the Preferences menu.", MsgBoxStyle.Critical, "PJ64 Launch Failed")
            Exit Sub
        End If
        Process.Start(pjdir, defrom)
    End Sub

    Private Sub ToolStripButton18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton18.Click, MouseToolToolStripMenuItem.Click
        ContextMenuStrip4.Show(MousePosition.X, MousePosition.Y)
    End Sub

    Private Sub ActorSelectorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ActorSelectorToolStripMenuItem.Click
        meshw = -1
        vertw = -1
        CheckBox16.Enabled = False
        CheckBox17.Enabled = False
        CheckBox18.Enabled = False
        CheckBox19.Enabled = False
        Button37.Enabled = False
        Label44.Enabled = False
        ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
        actorsel = True
        vertexsel = False
        trisel = False
        VertexWelderToolStripMenuItem.Checked = False
        VertexSelectorToolStripMenuItem.Checked = False
        ActorSelectorToolStripMenuItem.Checked = True
        TriangleEditorToolStripMenuItem.Checked = False
        AllSharedToolStripMenuItem.Checked = False
        SinglePointToolStripMenuItem.Checked = False
        PerMeshToolStripMenuItem.Checked = False
    End Sub
    Private Sub cameraonlyerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VertexWelderToolStripMenuItem.Click
        meshw = -1
        vertw = -1
        CheckBox16.Enabled = False
        CheckBox17.Enabled = False
        CheckBox18.Enabled = False
        CheckBox19.Enabled = False
        Button37.Enabled = False
        Label44.Enabled = False
        ToolStripStatusLabel4.Text = "Tool: Camera only"
        actorsel = False
        vertexsel = False
        trisel = False
        VertexSelectorToolStripMenuItem.Checked = False
        ActorSelectorToolStripMenuItem.Checked = False
        TriangleEditorToolStripMenuItem.Checked = False
        AllSharedToolStripMenuItem.Checked = False
        SinglePointToolStripMenuItem.Checked = False
        PerMeshToolStripMenuItem.Checked = False
    End Sub
    Private Sub Get3dCoord(ByVal x As Integer, ByVal y As Integer)
        Dim viewport(3) As Integer
        Dim modelview(15) As Double
        Dim projection(15) As Double
        Dim winz, winy As Single
        Gl.glGetDoublev(Gl.GL_MODELVIEW_MATRIX, modelview)
        Gl.glGetDoublev(Gl.GL_PROJECTION_MATRIX, projection)
        Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport)
        winy = viewport(3) - y
        Gl.glReadPixels(x, CInt(Round(winy)), 1, 1, Gl.GL_DEPTH_COMPONENT, Gl.GL_FLOAT, winz)
        If winz > 0 Then
            MsgBox("LOL")
        End If
        Glu.gluUnProject(x, y, 0, modelview, projection, viewport, final3dpos(0), final3dpos(1), final3dpos(2))
    End Sub
    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            If selmesh.Count > 0 Then
                For i2 = 0 To selmesh.Count - 1
                    'If changevert(0) And IsNumeric(TextBox1.Text) Then
                    '    Vertices(selmesh(i2)).x(selvert(i2)) = CInt(TextBox1.Text)
                    'End If
                    'If changevert(1) And IsNumeric(TextBox2.Text) Then
                    '    Vertices(selmesh(i2)).y(selvert(i2)) = CInt(TextBox2.Text)
                    'End If
                    'If changevert(2) And IsNumeric(TextBox3.Text) Then
                    '    Vertices(selmesh(i2)).z(selvert(i2)) = CInt(TextBox3.Text)
                    'End If
                    'If changevert(3) And IsNumeric(TextBox22.Text) Then
                    '    Vertices(selmesh(i2)).u(selvert(i2)) = CInt(TextBox22.Text)
                    'End If
                    'If changevert(4) And IsNumeric(TextBox21.Text) Then
                    '    Vertices(selmesh(i2)).v(selvert(i2)) = CInt(TextBox21.Text)
                    'End If
                Next
            ElseIf selvertc.Count > 0 Then
                For i1 = 0 To selvertc.Count - 1
                    If changevert(0) And IsNumeric(TextBox1.Text) Then
                        CollisionVerts.x(selvertc(i1)) = CInt(TextBox1.Text)
                    End If
                    If changevert(1) And IsNumeric(TextBox2.Text) Then
                        CollisionVerts.y(selvertc(i1)) = CInt(TextBox2.Text)
                    End If
                    If changevert(2) And IsNumeric(TextBox3.Text) Then
                        CollisionVerts.z(selvertc(i1)) = CInt(TextBox3.Text)
                    End If
                Next
            End If
        Catch err As Exception
        End Try
    End Sub
    Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged
        If actorgr.Count > 0 Then
            TextBox5.Text = actorgr(ComboBox4.SelectedIndex)
            Dim objind As Integer = objects.IndexOf(TextBox5.Text)
            If objind > -1 Then
                Label45.Text = objectss(objind)
            Else
                Label45.Text = "Unknown!"
            End If
        End If
    End Sub
    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ContextMenuStrip5.Show(MousePosition.X, MousePosition.Y)
    End Sub
    'Private Sub Button8_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    If ColorDialog2.ShowDialog() = DialogResult.Cancel Then
    '        ColorDialog2.Dispose()
    '    Else
    '        fogcolor = Drawing.ColorTranslator.ToOle(ColorDialog2.Color).ToString("X6")
    '        fogcolor = Mid(fogcolor, 5, 2) & Mid(fogcolor, 3, 2) & Mid(fogcolor, 1, 2) 'swap from OLE to standard HTML format that OoT uses
    '    End If
    'End Sub
    Public Sub SaveRoom()
        Try
            'Using deprecated FileOpen, FileGet, FilePut for simplicity over FileStream
            'FileOpen(9, OpenFileDialog1.FileName, OpenMode.Binary)
            FileOpen(8, LoadROM.FileName, OpenMode.Binary)
            If TextBox13.Text.Length = 2 Then
                FilePut(9, Hex2(TextBox13.Text), musicsave)
            End If
            If ComboBox8.SelectedIndex > 0 Then
                exits(ComboBox8.SelectedIndex - 1) = zerofill1(TextBox16.Text)
            End If
            For i = 0 To exits.Count - 1
                FilePut(9, Hex2(exits(i)), (exitoff + (i * 2)) + 1)
            Next
            Dim doorsaveoff As Integer = 0
            For i = 0 To scenedoorcnt - 1
                doorsaveoff = CInt(doorxoff(i)) + 1
                FilePut(9, Hex2(doorno1(i)), doorsaveoff - 2)
                FilePut(9, Hex2(doorvar(i)), doorsaveoff + 8)
                If Hex(doorx(i)).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(doorx(i)), 5)), doorsaveoff)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(doorx(i)))), doorsaveoff)
                End If
                If Hex(doory(i) - 10).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(doory(i) - 10), 5)), doorsaveoff + 2)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(doory(i) - 10))), doorsaveoff + 2)
                End If
                If Hex(doorz(i)).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(doorz(i)), 5)), doorsaveoff + 4)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(doorz(i)))), doorsaveoff + 4)
                End If
            Next
            If ComboBox1.SelectedIndex > 0 Then
                coltypes(ComboBox1.SelectedIndex - 1) = TextBox15.Text & TextBox18.Text & TextBox17.Text & TextBox19.Text & TextBox20.Text
            End If
            For i = 0 To coltypes.Count - 1
                FilePut(9, Hex2(coltypes(i)), CInt(coltypeoff(i)))
            Next
            i = 0
            Dim finalskyb As String = ""
            For i = 0 To skyflagss.Length - 1
                finalskyb += skyflagss(i)
            Next
            For i = 0 To colvar.Count - 1
                FilePut(9, Hex2(colvar(i)), CInt(colvaroff(i) + 1))
            Next
            FilePut(9, Hex2(finalskyb), envboxoff + 1)
            Dim loff As UInt32 = 0
            For i = 0 To linkx.Count - 1
                loff = CInt(linkxoff(i))
                If Hex(linkx(i)).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(linkx(i)), 5)), loff + 1)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(linkx(i)))), loff + 1)
                End If
                If Hex(linky(i) - 10).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(linky(i) - 10), 5)), loff + 3)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(linky(i) - 10))), loff + 3)
                End If
                If Hex(linkz(i)).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(linkz(i)), 5)), loff + 5)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(linkz(i)))), loff + 5)
                End If
                If Hex(linkxr(i)).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(linkxr(i)), 5)), loff + 7)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(linkxr(i)))), loff + 7)
                End If
                If Hex(linkyr(i)).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(linkyr(i)), 5)), loff + 9)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(linkyr(i)))), loff + 9)
                End If
                If Hex(linkzr(i)).Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(linkzr(i)), 5)), loff + 11)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(linkzr(i)))), loff + 11)
                End If
            Next
            Dim vertsaveoff As Integer = 0
            For i = 0 To CollisionVerts.x.Count - 1
                vertsaveoff = CInt(colxsave(i))
                If Hex(CollisionVerts.x(i)).ToString.Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(CollisionVerts.x(i)), 5, 4)), vertsaveoff + 1)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(CollisionVerts.x(i)))), vertsaveoff + 1)
                End If
                If Hex(CollisionVerts.y(i)).ToString.Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(CollisionVerts.y(i)), 5, 4)), vertsaveoff + 3)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(CollisionVerts.y(i)))), vertsaveoff + 3)
                End If
                If Hex(CollisionVerts.z(i)).ToString.Length > 4 Then
                    FilePut(9, Hex2(Mid(Hex(CollisionVerts.z(i)), 5, 4)), vertsaveoff + 5)
                Else
                    FilePut(9, Hex2(zerofill1(Hex(CollisionVerts.z(i)))), vertsaveoff + 5)
                End If
            Next
            FileClose(9)
            Dim zleini As StreamWriter = New StreamWriter(Application.StartupPath & "\ext\collision_fixer.ini")
            Dim zlerom As StreamWriter = New StreamWriter(Application.StartupPath & "\ext\romname.ini")
            zleini.WriteLine(zerofill2(Hex(zlestart6)))
            zleini.WriteLine(zerofill2(Hex(zleend6)))
            zleini.WriteLine(zerofill2(Hex(zlestart16)))
            zleini.WriteLine(zerofill2(Hex(zlestart6)))
            zleini.Dispose()
            zlerom.Dispose()
            SaveGraphics()
            For i = 0 To actorfound - 1
                FilePut(8, Hex2(actorno(i)), CInt(actornooff(i)) + 1)
                FilePut(8, Hex2(actorvar(i)), CInt(actorvaroff(i)) + 1)
                If Hex(actorx(i)).ToString.Length > 4 Then
                    FilePut(8, Hex2(Mid(Hex(actorx(i)), 5)), actorposoff(i) + 1)
                Else
                    FilePut(8, Hex2(zerofill1(Hex(actorx(i)))), actorposoff(i) + 1)
                End If
                If Hex(actory(i) - 10).ToString.Length > 4 Then
                    FilePut(8, Hex2(Mid(Hex(actory(i) - 10), 5)), actorposoff(i) + 3)
                Else
                    FilePut(8, Hex2(zerofill1(Hex(actory(i) - 10))), actorposoff(i) + 3)
                End If
                If Hex(actorz(i)).ToString.Length > 4 Then
                    FilePut(8, Hex2(Mid(Hex(actorz(i)), 5)), actorposoff(i) + 5)
                Else
                    FilePut(8, Hex2(zerofill1(Hex(actorz(i)))), actorposoff(i) + 5)
                End If
                If Hex(actorxrot(i)).Length > 4 Then
                    FilePut(8, Hex2(Mid(Hex(actorxrot(i)), 5)), actorposoff(i) + 7)
                Else
                    FilePut(8, Hex2(zerofill1(Hex(actorxrot(i)))), actorposoff(i) + 7)
                End If
                If Hex(actoryrot(i)).Length > 4 Then
                    FilePut(8, Hex2(Mid(Hex(actoryrot(i)), 5)), actorposoff(i) + 9)
                Else
                    FilePut(8, Hex2(zerofill1(Hex(actoryrot(i)))), actorposoff(i) + 9)
                End If
                If Hex(actorzrot(i)).Length > 4 Then
                    FilePut(8, Hex2(Mid(Hex(actorzrot(i)), 5)), actorposoff(i) + 11)
                Else
                    FilePut(8, Hex2(zerofill1(Hex(actorzrot(i)))), actorposoff(i) + 11)
                End If
            Next
            If ComboBox6.SelectedItem.ToString = "Night" Then
                FilePut(8, Hex2("0000"), envlightoff)
            ElseIf ComboBox6.SelectedItem.ToString = "Morning" Then
                FilePut(8, Hex2("01CC"), envlightoff)
            ElseIf ComboBox6.SelectedItem.ToString = "Mid Day" Then
                FilePut(8, Hex2("FFFF"), envlightoff)
            End If
            For i = 0 To actorgr.Count - 1
                FilePut(8, Hex2(actorgr(i)), (actorgroff + (i * 2)))
            Next
            FixCollision()
            FileClose(8)
            If Not File.Exists(defrom) Then
                MsgBox("File Saved! To configure a default ROM to save this data to, go to the setup dialog (Options).", MsgBoxStyle.Information, "Default ROM not defined")
            Else
                Dim question As String = MsgBox("Map changes have been saved successfully. Inject into your default ROM now?", MsgBoxStyle.YesNo, "Saved")
                If question = DialogResult.Yes Then
                    SaveToRom()
                End If
            End If
        Catch err As Global.System.Exception
            FileClose(8, 9)
            MsgBox("An error has occured: " & err.ToString & " Can not continue!", MsgBoxStyle.Critical, "Error!")
            Exit Sub
        End Try
    End Sub
    Private Sub SaveToRom()
        Try
            If Not File.Exists(defrom) Then
                MsgBox("Either your configured default ROM is invalid, or you have not configured one. You can do so in the main setup dialog (Options).", MsgBoxStyle.Critical, "Default ROM")
                Exit Sub
            End If
            Dim foff As Integer = 0
            Dim inpbox As String = ""
            Dim rom As New FileStream(defrom, FileMode.Open)
            Dim romwr As New BufferedStream(rom, rom.Length)
            If maploaded Then

            Else
            End If
            crc.StartInfo.Arguments = "-u " & defrom
            crc.Start()
        Catch err As Global.System.Exception
            MsgBox("An error has occured: " & err.Message & " Can not continue!", MsgBoxStyle.Critical, "Error!")
            Exit Sub
        End Try
    End Sub

    Private Sub ClearSkyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearSkyToolStripMenuItem.Click
        CloudySkyToolStripMenuItem.Checked = False
        ClearSkyToolStripMenuItem.Checked = True
        skyflagss(4) = "00"
        skyflags(4) = False
    End Sub
    Private Sub CloudySkyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloudySkyToolStripMenuItem.Click
        CloudySkyToolStripMenuItem.Checked = True
        ClearSkyToolStripMenuItem.Checked = False
        skyflagss(4) = "01"
        skyflags(4) = True
    End Sub

    Private Sub ComboBox7_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox7.SelectedIndexChanged
        Try
            comb7 = ComboBox7.SelectedIndex - 1
            If ComboBox7.SelectedIndex = 0 Then
                TextBox4.Text = ""
                TextBox6.Text = ""
                TextBox7.Text = ""
                TextBox8.Text = ""
                TextBox9.Text = ""
                TextBox10.Text = ""
                TextBox11.Text = ""
                TextBox12.Text = ""
                mouse = 0
                If Not mpick Then
                    selactor.Clear()
                Else
                    mpick = False
                End If
            Else
                ComboBox5.SelectedIndex = 0
                link = False
                door = False
                TextBox6.Enabled = True
                TextBox4.Enabled = True
                Dim c7 As Integer = ComboBox7.SelectedIndex - 1
                TextBox6.Text = actorno(c7)
                TextBox4.Text = actorvar(c7)
                TextBox7.Text = actorx(c7)
                TextBox8.Text = actory(c7)
                TextBox9.Text = actorz(c7)
                TextBox10.Text = actorxrot(c7)
                TextBox11.Text = actoryrot(c7)
                TextBox12.Text = actorzrot(c7)
                TextBox10.Enabled = True
                TextBox11.Enabled = True
                TextBox12.Enabled = True
                selectedind = c7
                ComboBox4.SelectedIndex = physgrp(c7)
                If Not mpick Then
                    selactor.Clear()
                    selactor.Add(c7)
                Else
                    mpick = False
                End If
            End If
        Catch err As Exception
            MsgBox("Error in room actor selection processing." & Environment.NewLine & Environment.NewLine & "Debug Info: " & err.Message, MsgBoxStyle.Critical)
            ComboBox7.SelectedIndex = 0
            ComboBox5.SelectedIndex = 0
            Exit Sub
        End Try
    End Sub

    Private Sub ComboBox5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexChanged
        Try
            comb5 = ComboBox5.SelectedIndex - linkx.Count - 1
            If ComboBox5.SelectedIndex = 0 Then
                link = False
                door = False
                mouse = 0
                TextBox4.Text = ""
                TextBox6.Text = ""
                TextBox7.Text = ""
                TextBox8.Text = ""
                TextBox9.Text = ""
                TextBox10.Text = ""
                TextBox11.Text = ""
                TextBox12.Text = ""
                If Not mpick Then
                    selactorsc.Clear()
                    sellink.Clear()
                Else
                    mpick = False
                End If
            Else
                ComboBox7.SelectedIndex = 0
                If ComboBox5.SelectedIndex - 1 < linkx.Count Then
                    ComboBox4.SelectedIndex = Nothing
                    door = False
                    link = True
                    TextBox10.Enabled = True
                    TextBox11.Enabled = True
                    TextBox12.Enabled = True
                    TextBox6.Text = linkno(ComboBox5.SelectedIndex - 1)
                    TextBox4.Text = linkvar(ComboBox5.SelectedIndex - 1)
                    TextBox7.Text = linkx(ComboBox5.SelectedIndex - 1)
                    TextBox8.Text = linky(ComboBox5.SelectedIndex - 1)
                    TextBox9.Text = linkz(ComboBox5.SelectedIndex - 1)
                    TextBox10.Text = linkxr(ComboBox5.SelectedIndex - 1)
                    TextBox11.Text = linkyr(ComboBox5.SelectedIndex - 1)
                    TextBox12.Text = linkzr(ComboBox5.SelectedIndex - 1)
                    TextBox6.Enabled = False
                    TextBox4.Enabled = False
                    selactor.Clear()
                    selactorsc.Clear()
                    If Not mpick Then
                        sellink.Clear()
                        sellink.Add(ComboBox5.SelectedIndex - 1)
                    Else
                        mpick = False
                    End If
                Else
                    linkr = 0
                    door = True
                    link = False
                    TextBox10.Enabled = False
                    TextBox11.Enabled = False
                    TextBox12.Enabled = False
                    TextBox7.Text = doorx(ComboBox5.SelectedIndex - linkx.Count - 1)
                    TextBox8.Text = doory(ComboBox5.SelectedIndex - linkx.Count - 1)
                    TextBox9.Text = doorz(ComboBox5.SelectedIndex - linkx.Count - 1)
                    TextBox6.Text = doorno1(ComboBox5.SelectedIndex - linkx.Count - 1)
                    TextBox4.Text = doorvar(ComboBox5.SelectedIndex - linkx.Count - 1)
                    TextBox6.Enabled = True
                    TextBox4.Enabled = True
                    ComboBox4.SelectedIndex = physgrpc(ComboBox5.SelectedIndex - linkx.Count - 1)
                    sellink.Clear()
                    selactor.Clear()
                    If Not mpick Then
                        selactorsc.Clear()
                        selactorsc.Add(ComboBox5.SelectedIndex - linkx.Count - 1)
                    Else
                        mpick = False
                    End If
                End If
                selectedinddr = ComboBox5.SelectedIndex - 1
            End If
        Catch err As Exception
            MsgBox("Error in scene actor selection processing." & Environment.NewLine & Environment.NewLine & "Debug Info: " & err.Message, MsgBoxStyle.Critical)
            ComboBox5.SelectedIndex = 0
            ComboBox7.SelectedIndex = 0
            Exit Sub
        End Try
    End Sub
    Private Sub Button3_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ContextMenuStrip5.Show(MousePosition.X, MousePosition.Y)
    End Sub
    Private Sub CheckBox9_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not myownrm Then
            myownrm = True
        Else
            myownrm = False
        End If
    End Sub
    Private Sub CheckBox8_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not myownrm Then
            myownrm = True
        Else
            myownrm = False
        End If
    End Sub
    Private Sub CheckBox1_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If Not working Then
            If skyflags(0) = True Then
                skyflags(0) = False
                skyflagss(0) = "00"
            ElseIf skyflags(0) = False Then
                skyflags(0) = True
                skyflagss(0) = "01"
            End If
        End If
    End Sub
    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If Not working Then
            If skyflags(1) Then
                skyflags(1) = False
                skyflagss(1) = "00"
            Else
                skyflags(1) = True
                skyflagss(1) = "01"
            End If
        End If
    End Sub
    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If Not working Then
            If skyflags(2) Then
                skyflags(2) = False
                skyflagss(2) = "00"
            Else
                skyflags(2) = True
                skyflagss(2) = "01"
            End If
        End If
    End Sub
    Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
        If Not working Then
            If skyflags(3) Then
                skyflags(3) = False
                skyflagss(3) = "00"
            Else
                skyflags(3) = True
                skyflagss(3) = "01"
            End If
        End If
    End Sub
    Private Sub CheckBox6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not working Then
            If skyflags(5) Then
                skyflags(5) = False
                skyflagss(5) = "00"
            Else
                skyflags(5) = True
                skyflagss(5) = "01"
            End If
        End If
    End Sub
    Private Sub CheckBox7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox7.CheckedChanged
        If Not working Then
            If skyflags(6) Then
                skyflags(6) = False
                skyflagss(6) = "00"
            Else
                skyflags(6) = True
                skyflagss(6) = "01"
            End If
        End If
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            Dim c7 As Integer = ComboBox7.SelectedIndex
            If door Then
                For i = 0 To selactorsc.Count - 1
                    i1 = selactorsc(i)
                    If TextBox6.Text.Length = 4 Then
                        doorno1(i1) = zerofill1(TextBox6.Text)
                    End If
                    If TextBox4.Text.Length = 4 Then
                        doorvar(i1) = zerofill1(TextBox4.Text)
                    End If
                    If IsNumeric(TextBox7.Text) And changepos(0) Then doorx(i1) = CInt(TextBox7.Text)
                    If IsNumeric(TextBox8.Text) And changepos(1) Then doory(i1) = CInt(TextBox8.Text)
                    If IsNumeric(TextBox9.Text) And changepos(2) Then doorz(i1) = CInt(TextBox9.Text)
                Next
            ElseIf link Then
                For i = 0 To sellink.Count - 1
                    i1 = sellink(i)
                    If IsNumeric(TextBox7.Text) And changepos(0) Then
                        linkx(i1) = CInt(TextBox7.Text)
                    End If
                    If IsNumeric(TextBox8.Text) And changepos(1) Then
                        linky(i1) = CInt(TextBox8.Text)
                    End If
                    If IsNumeric(TextBox9.Text) And changepos(2) Then
                        linkz(i1) = CInt(TextBox9.Text)
                    End If
                    If IsNumeric(TextBox10.Text) And changepos(3) Then
                        linkxr(i1) = CInt(TextBox10.Text)
                    End If
                    If IsNumeric(TextBox11.Text) And changepos(4) Then
                        linkyr(i1) = CInt(TextBox11.Text)
                    End If
                    If IsNumeric(TextBox12.Text) And changepos(5) Then
                        linkzr(i1) = CInt(TextBox12.Text)
                    End If
                Next
            Else
                For i = 0 To selactor.Count - 1
                    i1 = selactor(i)
                    If IsNumeric(TextBox7.Text) And changepos(0) Then
                        actorx(i1) = CInt(TextBox7.Text)
                    End If
                    If IsNumeric(TextBox8.Text) And changepos(1) Then
                        actory(i1) = CInt(TextBox8.Text)
                    End If
                    If IsNumeric(TextBox9.Text) And changepos(2) Then
                        actorz(i1) = CInt(TextBox9.Text)
                    End If
                    If IsNumeric(TextBox10.Text) And changepos(3) Then
                        actorxrot(i1) = CInt(TextBox10.Text)
                    End If
                    If IsNumeric(TextBox11.Text) And changepos(4) Then
                        actoryrot(i1) = CInt(TextBox11.Text)
                    End If
                    If IsNumeric(TextBox12.Text) And changepos(5) Then
                        actorzrot(i1) = CInt(TextBox12.Text)
                    End If
                    If TextBox6.Text.Length = 4 Then
                        actorno(i1) = zerofill1(TextBox6.Text)
                    End If
                    If TextBox4.Text.Length = 4 Then
                        actorvar(i1) = zerofill1(TextBox4.Text)
                    End If
                Next
            End If
            Dim identity As String = ""
            Dim oldint As Integer = 0
            actorgr(ComboBox4.SelectedIndex) = zerofill1(TextBox5.Text)
            If Not door And Not link Then
                oldint = c7
                ComboBox7.Items.Clear()
                ComboBox7.Items.Add("Room Actor Selection")
                For i = 0 To actorx.Count - 1
                    actordb = New StreamReader(Application.StartupPath & "/ext/actor_db.txt")
                    identity = "?"
                    While actordb.Peek <> -1
                        actorindex = actordb.ReadLine
                        If Mid(actorindex, 6, 4) = "0001" Then
                            If Mid(actorindex, 1, 4) = actorno(i) And Mid(actorindex, 11, 4) = actorvar(i) Then
                                identity = Mid(actorindex, 16)
                                Exit While
                            End If
                        Else
                            For i1 = 0 To groupcnt - 1
                                If Mid(actorindex, 1, 9) = actorno(i) & ":" & actorgr(i1) And Mid(actorindex, 11, 4) = actorvar(i) Then
                                    identity = Mid(actorindex, 16)
                                    Dim grpint As Integer = actorgr.IndexOf(Mid(actorindex, 6, 4))
                                    If grpint > -1 Then
                                        physgrp(i) = grpint
                                    End If
                                    Exit While
                                End If
                            Next
                        End If
                    End While
                    ComboBox7.Items.Add((i).ToString & " - " & identity)
                    actordb.Dispose()
                Next
                If selactor.Count = 1 Then
                    ComboBox7.SelectedIndex = oldint
                End If
            ElseIf door And Not link Then
                oldint = ComboBox5.SelectedIndex
                For i = 1 To linkx.Count
                    linkarray.Add(ComboBox5.Items.Item(i))
                Next
                ComboBox5.Items.Clear()
                ComboBox5.Items.Add("Scene Actor Selection")
                For i = 0 To linkx.Count - 1
                    ComboBox5.Items.Add(linkarray(i))
                Next
                linkarray.Clear()
                For i As Integer = 0 To doorx.Count - 1
                    actordb = New StreamReader(Application.StartupPath & "/ext/actor_db.txt")
                    identity = "?"
                    While actordb.Peek <> -1
                        actorindex = actordb.ReadLine
                        If Mid(actorindex, 6, 4) = "0001" Then
                            If Mid(actorindex, 1, 4) = doorno1(i) And Mid(actorindex, 11, 4) = doorvar(i) Then
                                identity = Mid(actorindex, 16)
                                Exit While
                            End If
                        Else
                            For i1 = 0 To groupcnt - 1
                                If Mid(actorindex, 1, 9) = doorno1(i) & ":" & actorgr(i1) And Mid(actorindex, 11, 4) = doorvar(i) Then
                                    identity = Mid(actorindex, 16)
                                    Dim grpint As Integer = actorgr.IndexOf(Mid(actorindex, 6, 4))
                                    If grpint > -1 Then
                                        physgrp(i) = grpint
                                    End If
                                    Exit While
                                End If
                            Next
                        End If
                    End While
                    ComboBox5.Items.Add((linkx.Count + 1 + i).ToString & " - " & identity)
                    actordb.Dispose()
                Next
                If selactorsc.Count = 1 Then
                    ComboBox5.SelectedIndex = oldint
                End If
            End If
        Catch err As Exception
        End Try
    End Sub
    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Application.DoEvents()
        FPSCountSTR = FPSCount.ToString
        FPSCount = 0
    End Sub
    Private Sub TrackBar4_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar4.Scroll
        toolsens = TrackBar4.Value - 0.5
    End Sub
    Private Sub ScrollSensitivity(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SimpleOpenGlControl1.MouseWheel
        If e.Delta < 0 Then
            If TrackBar4.Value > TrackBar4.Minimum Then
                TrackBar4.Value -= 1
            End If
        Else
            If TrackBar4.Value < TrackBar4.Maximum Then
                TrackBar4.Value += 1
            End If
        End If
        If TrackBar4.Value = TrackBar4.Minimum Then
            toolsens = 0
        Else
            toolsens = TrackBar4.Value - 0.5
        End If
    End Sub
    Private Sub CameraSensitivity(ByVal up As Boolean)
        If Not up Then
            If TrackBar1.Value > TrackBar1.Minimum Then
                TrackBar1.Value -= 1
            End If
        Else
            If TrackBar1.Value < TrackBar1.Maximum Then
                TrackBar1.Value += 1
            End If
        End If
        run = TrackBar1.Value
    End Sub
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If maploaded Then
            SaveFileDialog2.FileName = NoExt(GetFileName(LoadROM.FileName)) & "_actors.txt"
            If SaveFileDialog2.ShowDialog = DialogResult.Cancel Then
                SaveFileDialog2.Dispose()
            Else
                Dim file As StreamWriter = New StreamWriter(SaveFileDialog2.FileName, True)
                file.Write("Model files _" & Environment.NewLine & Environment.NewLine)
                For i = 0 To groupcnt - 1
                    file.Write("0x" & actorgr(i) & " - " & objectss(objects.IndexOf(actorgr(i))) & Environment.NewLine)
                Next
                file.Write(Environment.NewLine & "Number - Description (Actor:Variable) _" & Environment.NewLine & Environment.NewLine)
                For i = 0 To actorfound - 1
                    file.Write(ComboBox7.Items.Item(i + 1) & " (0x" & actorno(i) & ":0x" & actorvar(i) & ")" & Environment.NewLine)
                Next
                file.Dispose()
            End If
        End If
    End Sub
    Private Sub ColorChange()
        If MouseLeft Then MouseLeft = False
        If MouseRight Then MouseRight = False
        If MouseMiddle Then MouseMiddle = False
        mouse = 0
        key_ctrl = False
        If ColorDialog1.ShowDialog() = DialogResult.Cancel Then
            ColorDialog1.Dispose()
        Else
            For i2 = 0 To selmesh.Count - 1
                If selmesh(i2) <> -1 Then
                    'Vertices(selmesh(i2)).r(selvert(i2)) = Convert.ToByte(Mid(ColorTranslator.ToOle(ColorDialog1.Color).ToString("X6"), 5, 2), 16)
                    'Vertices(selmesh(i2)).g(selvert(i2)) = Convert.ToByte(Mid(ColorTranslator.ToOle(ColorDialog1.Color).ToString("X6"), 3, 2), 16)
                    'Vertices(selmesh(i2)).b(selvert(i2)) = Convert.ToByte(Mid(ColorTranslator.ToOle(ColorDialog1.Color).ToString("X6"), 1, 2), 16)
                End If
            Next
        End If
        If selmesh.Count = 1 Then
            'Dim vcolor As String = "#" & zerofill2(Hex(CInt(Vertices(selmesh(0)).r(selvert(0))))) & zerofill2(Hex(CInt(Vertices(selmesh(0)).g(selvert(0))))) & zerofill2(Hex(CInt(Vertices(selmesh(0)).b(selvert(0)))))
            'Button10.BackColor = ColorTranslator.FromHtml(vcolor)
        End If
    End Sub
    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        ColorChange()
    End Sub
    'Private Sub Button8_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    If ColorDialog1.ShowDialog() = DialogResult.Cancel Then
    '        ColorDialog1.Dispose()
    '    Else
    '        fogcolor = Drawing.ColorTranslator.ToOle(ColorDialog1.Color).ToString("X6")
    '        fogcolor = Mid(fogcolor, 5, 2) & Mid(fogcolor, 3, 2) & Mid(fogcolor, 1, 2) 'swap from OLE to standard HTML format that OoT uses
    '    End If
    'End Sub
    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        MusicModValues.Show()
    End Sub
    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        If IsNumeric(TextBox1.Text) Then
            If Mid(TextBox1.Text, 1, 1) = "-" Then
                TextBox1.Text = Mid(TextBox1.Text, 2)
                Button12.Text = "-"
            Else
                TextBox1.Text = "-" & TextBox1.Text
                Button12.Text = "+"
            End If
        End If
    End Sub
    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        If IsNumeric(TextBox2.Text) Then
            If Mid(TextBox2.Text, 1, 1) = "-" Then
                TextBox2.Text = Mid(TextBox2.Text, 2)
                Button14.Text = "-"
            Else
                TextBox2.Text = "-" & TextBox2.Text
                Button14.Text = "+"
            End If
        End If
    End Sub
    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        If IsNumeric(TextBox3.Text) Then
            If Mid(TextBox3.Text, 1, 1) = "-" Then
                TextBox3.Text = Mid(TextBox3.Text, 2)
                Button13.Text = "-"
            Else
                TextBox3.Text = "-" & TextBox3.Text
                Button13.Text = "+"
            End If
        End If
    End Sub
    Private Sub MatchCollision(ByVal mm As Integer)
        working = True
        Label28.Show()
        ProgressBar1.Maximum = CollisionVerts.x.Count
        For i = 0 To CollisionVerts.x.Count - 1
            ProgressBar1.Value += 1
            ProgressBar1.Refresh()
            'For i0 As Integer = 0 To Vertices.Length - 1
            '    For i1 = 0 To Vertices(i0).x.Count - 1
            '        If Vertices(i0).ox(i1) = CollisionVerts.ox(i) And Vertices(i0).oy(i1) = CollisionVerts.oy(i) And Vertices(i0).oz(i1) = CollisionVerts.oz(i) Then
            '            Select Case mm
            '                Case 0
            '                    CollisionVerts.x(i) = Vertices(i0).x(i1)
            '                    CollisionVerts.y(i) = Vertices(i0).y(i1)
            '                    CollisionVerts.z(i) = Vertices(i0).z(i1)
            '                Case 1
            '                    Vertices(i0).x(i1) = CollisionVerts.x(i)
            '                    Vertices(i0).y(i1) = CollisionVerts.y(i)
            '                    Vertices(i0).z(i1) = CollisionVerts.z(i)
            '            End Select
            '        End If
            '    Next
            'Next
        Next
        ProgressBar1.Value = 0
        Label28.Hide()
        working = False
    End Sub
    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MatchCollision(1)
    End Sub
    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MatchCollision(0)
    End Sub

    Private Sub CollisionMeshToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        rendersc = True
        renderobj = False
    End Sub
    Private Sub BothToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        renderobj = True
        rendersc = True
    End Sub

    Private Sub FilledToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FilledToolStripMenuItem.Click
        wireframe = False
        Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_FILL)
        ToolStripButton12.Image = My.Resources.Clipboard022
    End Sub
    Private Sub WireframeToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WireframeToolStripMenuItem.Click
        wireframe = True
        Gl.glPolygonMode(Gl.GL_FRONT_AND_BACK, Gl.GL_LINE)
        ToolStripButton12.Image = My.Resources.Clipboard01
    End Sub
    Private Sub SimpleOpenGlControl1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles SimpleOpenGlControl1.MouseMove
        oldLocalMouse = SimpleOpenGlControl1.PointToClient(Windows.Forms.Cursor.Position)
    End Sub
    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
        If ComboBox3.SelectedIndex = 0 Then
            For i4 = 0 To DLInfo.Length - 1
                DLInfo(i4).skip = False
            Next
        Else
            For i4 = 0 To DLInfo.Length - 1
                If Not i4 = ComboBox3.SelectedIndex - 1 Then
                    DLInfo(i4).skip = True
                Else
                    DLInfo(i4).skip = False
                End If
            Next
        End If
        EntryPointLoad()
    End Sub
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PictureBox1.SizeMode = PictureBoxSizeMode.Normal
    End Sub
    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    End Sub
    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
    End Sub
    Public Sub ToggleTabs()
        If TabControl1.Visible Then
            Dim img1 As New Bitmap(My.Resources.ChestClosed)
            ToolStripButton1.Image = img1
            TabControl1.Visible = False
            SimpleOpenGlControl1.Width += 235
            Reshape()
        Else
            Dim img1 As New Bitmap(My.Resources.ChestOpen)
            ToolStripButton1.Image = img1
            TabControl1.Visible = True
            SimpleOpenGlControl1.Width -= 235
            Reshape()
        End If
    End Sub
    Private Sub Button18_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button18.MouseDown
        btnno = 0
        Timer1.Start()
    End Sub
    Private Sub Button18_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button18.MouseUp
        Timer1.Stop()
    End Sub
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        'cv = Cos(yrotd) * toolsens
        'sv = Sin(yrotd) * toolsens
        'If vertexsel Then
        '    If selmesh.Count > 0 Then
        '        For i2 = 0 To selmesh.Count - 1
        '            'Dim xorig As Int16 = Vertices(selmesh(i2)).x(selvert(i2))
        '            'Dim zorig As Int16 = Vertices(selmesh(i2)).z(selvert(i2))
        '            Select Case btnno
        '                Case 0
        '                    Vertices(selmesh(i2)).x(selvert(i2)) -= cv
        '                    Vertices(selmesh(i2)).z(selvert(i2)) -= sv
        '                Case 1
        '                    Vertices(selmesh(i2)).y(selvert(i2)) += toolsens
        '                Case 2
        '                    Vertices(selmesh(i2)).y(selvert(i2)) -= toolsens
        '                Case 3
        '                    Vertices(selmesh(i2)).x(selvert(i2)) += cv
        '                    Vertices(selmesh(i2)).z(selvert(i2)) += sv
        '                Case 4
        '                    Vertices(selmesh(i2)).x(selvert(i2)) -= sv
        '                    Vertices(selmesh(i2)).z(selvert(i2)) += cv
        '                Case 5
        '                    Vertices(selmesh(i2)).x(selvert(i2)) += sv
        '                    Vertices(selmesh(i2)).z(selvert(i2)) -= cv
        '                Case 6
        '                    Vertices(selmesh(i2)).v(selvert(i2)) += 15
        '                Case 7
        '                    Vertices(selmesh(i2)).v(selvert(i2)) -= 15
        '                Case 8
        '                    Vertices(selmesh(i2)).u(selvert(i2)) -= 15
        '                Case 9
        '                    Vertices(selmesh(i2)).u(selvert(i2)) += 15
        '            End Select
        '        Next
        '        UpdateVertM()
        '    ElseIf selvertc.Count > 0 Then
        '        For i1 = 0 To selvertc.Count - 1
        '            Select Case btnno
        '                Case 0
        '                    CollisionVerts.x(selvertc(i1)) -= cv
        '                    CollisionVerts.z(selvertc(i1)) -= sv
        '                Case 1
        '                    CollisionVerts.y(selvertc(i1)) += toolsens
        '                Case 2
        '                    CollisionVerts.y(selvertc(i1)) -= toolsens
        '                Case 3
        '                    CollisionVerts.x(selvertc(i1)) += cv
        '                    CollisionVerts.z(selvertc(i1)) += sv
        '                Case 4
        '                    CollisionVerts.x(selvertc(i1)) -= sv
        '                    CollisionVerts.z(selvertc(i1)) += cv
        '                Case 5
        '                    CollisionVerts.x(selvertc(i1)) += sv
        '                    CollisionVerts.z(selvertc(i1)) -= cv
        '            End Select
        '        Next
        '        UpdateVertM()
        '    End If
        'ElseIf actorsel Then
        '    Select Case btnno
        '        Case 0
        '            If door Then
        '                For i = 0 To selactorsc.Count - 1
        '                    i1 = selactorsc(i)
        '                    doorx(i1) -= cv
        '                    doorz(i1) -= sv
        '                Next
        '            ElseIf link Then
        '                For i = 0 To sellink.Count - 1
        '                    linkx(sellink(i)) -= Cos(yrotd) * toolsens
        '                    linkz(sellink(i)) -= Sin(yrotd) * toolsens
        '                Next
        '            Else
        '                For i = 0 To selactor.Count - 1
        '                    actorx(selactor(i)) -= cv
        '                    actorz(selactor(i)) -= sv
        '                Next
        '            End If
        '        Case 1
        '            If door Then
        '                For i = 0 To selactorsc.Count - 1
        '                    doory(selactorsc(i)) += toolsens
        '                Next
        '            ElseIf link Then
        '                For i = 0 To sellink.Count - 1
        '                    linky(sellink(i)) += toolsens
        '                Next
        '            Else
        '                For i = 0 To selactor.Count - 1
        '                    actory(selactor(i)) += toolsens
        '                Next
        '            End If
        '        Case 2
        '            If door Then
        '                For i = 0 To selactorsc.Count - 1
        '                    doory(selactorsc(i)) -= toolsens
        '                Next
        '            ElseIf link Then
        '                For i = 0 To sellink.Count - 1
        '                    linky(sellink(i)) -= toolsens
        '                Next
        '            Else
        '                For i = 0 To selactor.Count - 1
        '                    actory(selactor(i)) -= toolsens
        '                Next
        '            End If
        '        Case 3
        '            If door Then
        '                For i = 0 To selactorsc.Count - 1
        '                    i1 = selactorsc(i)
        '                    doorx(i1) += cv
        '                    doorz(i1) += sv
        '                Next
        '            ElseIf link Then
        '                For i = 0 To sellink.Count - 1
        '                    linkx(sellink(i)) += cv
        '                    linkz(sellink(i)) += sv
        '                Next
        '            Else
        '                For i = 0 To selactor.Count - 1
        '                    actorx(selactor(i)) += cv
        '                    actorz(selactor(i)) += sv
        '                Next
        '            End If
        '        Case 4
        '            If door Then
        '                For i = 0 To selactorsc.Count - 1
        '                    i1 = selactorsc(i)
        '                    doorx(i1) -= sv
        '                    doorz(i1) += cv
        '                Next
        '            ElseIf link Then
        '                For i = 0 To sellink.Count - 1
        '                    linkx(sellink(i)) -= sv
        '                    linkz(sellink(i)) += cv
        '                Next
        '            Else
        '                For i = 0 To selactor.Count - 1
        '                    actorx(selactor(i)) -= sv
        '                    actorz(selactor(i)) += cv
        '                Next
        '            End If
        '        Case 5
        '            If door Then
        '                For i = 0 To selactorsc.Count - 1
        '                    i1 = selactorsc(i)
        '                    doorx(i1) += sv
        '                    doorz(i1) -= cv
        '                Next
        '            ElseIf link Then
        '                For i = 0 To sellink.Count - 1
        '                    linkx(sellink(i)) += sv
        '                    linkz(sellink(i)) -= cv
        '                Next
        '            Else
        '                For i = 0 To selactor.Count - 1
        '                    actorx(selactor(i)) += sv
        '                    actorz(selactor(i)) -= cv
        '                Next
        '            End If
        '    End Select
        '    UpdateActorPos()
        'End If
    End Sub

    Private Sub Button8_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button8.MouseDown
        btnno = 1
        Timer1.Start()
    End Sub

    Private Sub Button8_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button8.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button20_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button20.MouseDown
        btnno = 2
        Timer1.Start()
    End Sub

    Private Sub Button20_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button20.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button4_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button4.MouseDown
        btnno = 3
        Timer1.Start()
    End Sub

    Private Sub Button4_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button4.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button19_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button19.MouseDown
        btnno = 5
        Timer1.Start()
    End Sub

    Private Sub Button19_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button19.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button17_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button17.MouseDown
        btnno = 4
        Timer1.Start()
    End Sub

    Private Sub Button17_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button17.MouseUp
        Timer1.Stop()
    End Sub
    Private Sub SetupToolStripMenuItem_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SetupToolStripMenuItem.Click
        SetupDialog.ShowDialog()
    End Sub
    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        changevert(0) = True
    End Sub
    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        changevert(1) = True
    End Sub
    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged
        changevert(2) = True
    End Sub
    Private Sub CollisionMeshToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CollisionMeshToolStripMenuItem.Click
        If rendersc = False Then
            rendersc = True
            CollisionMeshToolStripMenuItem.Checked = True
        Else
            rendersc = False
            CollisionMeshToolStripMenuItem.Checked = False
        End If
    End Sub
    Private Sub MainWin_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        End
    End Sub
    Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MatchCollision(2)
    End Sub
    Private Sub ResetVerts(ByVal mode As Integer)
        'VertResetPrefs.Text = "Reset selected vertices"
        'key_ctrl = False
        'If mode = 0 Then
        '    If selvert.Count > 0 Then
        '        VertResetPrefs.CheckBox4.Enabled = True
        '        VertResetPrefs.CheckBox5.Enabled = True
        '        VertResetPrefs.CheckBox6.Enabled = True
        '        VertResetPrefs.CheckBox4.Checked = True
        '        VertResetPrefs.CheckBox5.Checked = True
        '        VertResetPrefs.CheckBox6.Checked = True
        '        VertResetPrefs.ShowDialog()
        '        For i2 = 0 To selmesh.Count - 1
        '            If resetbools(0) Then Vertices(selmesh(i2)).x(selvert(i2)) = Vertices(selmesh(i2)).ox(selvert(i2))
        '            If resetbools(1) Then Vertices(selmesh(i2)).y(selvert(i2)) = Vertices(selmesh(i2)).oy(selvert(i2))
        '            If resetbools(2) Then Vertices(selmesh(i2)).z(selvert(i2)) = Vertices(selmesh(i2)).oz(selvert(i2))
        '            If resetbools(3) Then Vertices(selmesh(i2)).u(selvert(i2)) = Vertices(selmesh(i2)).ou(selvert(i2))
        '            If resetbools(4) Then Vertices(selmesh(i2)).v(selvert(i2)) = Vertices(selmesh(i2)).ov(selvert(i2))
        '            If resetbools(5) Then
        '                Vertices(selmesh(i2)).r(selvert(i2)) = Vertices(selmesh(i2)).r0(selvert(i2))
        '                Vertices(selmesh(i2)).g(selvert(i2)) = Vertices(selmesh(i2)).g0(selvert(i2))
        '                Vertices(selmesh(i2)).b(selvert(i2)) = Vertices(selmesh(i2)).b0(selvert(i2))
        '            End If
        '        Next
        '    ElseIf selvertc.Count > 0 Then
        '        VertResetPrefs.CheckBox4.Enabled = False
        '        VertResetPrefs.CheckBox5.Enabled = False
        '        VertResetPrefs.CheckBox6.Enabled = False
        '        VertResetPrefs.CheckBox4.Checked = False
        '        VertResetPrefs.CheckBox5.Checked = False
        '        VertResetPrefs.CheckBox6.Checked = False
        '        VertResetPrefs.ShowDialog()
        '        For i2 = 0 To selvertc.Count - 1
        '            If resetbools(0) Then CollisionVerts.x(selvertc(i2)) = CollisionVerts.ox(selvertc(i2))
        '            If resetbools(1) Then CollisionVerts.y(selvertc(i2)) = CollisionVerts.oy(selvertc(i2))
        '            If resetbools(2) Then CollisionVerts.z(selvertc(i2)) = CollisionVerts.oz(selvertc(i2))
        '        Next
        '    End If
        'Else
        '    VertResetPrefs.CheckBox4.Enabled = True
        '    VertResetPrefs.CheckBox5.Enabled = True
        '    VertResetPrefs.CheckBox6.Enabled = True
        '    VertResetPrefs.CheckBox4.Checked = True
        '    VertResetPrefs.CheckBox5.Checked = True
        '    VertResetPrefs.CheckBox6.Checked = True
        '    VertResetPrefs.Text = "Reset all vertices"
        '    VertResetPrefs.ShowDialog()
        '    'For i = 0 To Vertices.Length - 1
        '    '    For i1 = 0 To Vertices(i).x.Count - 1
        '    '        If resetbools(0) Then Vertices(i).x(i1) = Vertices(i).ox(i1)
        '    '        If resetbools(1) Then Vertices(i).y(i1) = Vertices(i).oy(i1)
        '    '        If resetbools(2) Then Vertices(i).z(i1) = Vertices(i).oz(i1)
        '    '        If resetbools(3) Then Vertices(i).u(i1) = Vertices(i).ou(i1)
        '    '        If resetbools(4) Then Vertices(i).v(i1) = Vertices(i).ov(i1)
        '    '        If resetbools(5) Then
        '    '            Vertices(i).r(i1) = Vertices(i).r0(i1)
        '    '            Vertices(i).g(i1) = Vertices(i).g0(i1)
        '    '            Vertices(i).b(i1) = Vertices(i).b0(i1)
        '    '        End If
        '    '    Next
        '    'Next
        'End If
    End Sub
    Private Sub ResetAllGraphicsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetAllGraphicsToolStripMenuItem.Click
        ResetVerts(1)
        Timer3.Stop()
    End Sub
    Private Sub ResetAllCollisionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetAllCollisionToolStripMenuItem.Click
        ResetCollision()
    End Sub
    Private Sub ToolStripMenuItem3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        vertexsel = False
        actorsel = False
        trisel = True
    End Sub
    Private Sub ToolStripMenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem7.Click
        If Not vertexsel Then
            meshw = -1
            vertw = -1
            CheckBox16.Enabled = False
            CheckBox17.Enabled = False
            CheckBox18.Enabled = False
            CheckBox19.Enabled = False
            Button37.Enabled = False
            Label44.Enabled = False
        End If
        axestr = "(X + Y)"
        If actorsel Then
            ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
        ElseIf vertexsel Then
            ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " " & n(vtmode)
        End If
        movest = 0
        ToolStripMenuItem7.Checked = True
        ToolStripMenuItem8.Checked = False
        ToolStripMenuItem6.Checked = False
    End Sub
    Private Sub ToolStripMenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem8.Click
        If Not vertexsel Then
            meshw = -1
            vertw = -1
            CheckBox16.Enabled = False
            CheckBox17.Enabled = False
            CheckBox18.Enabled = False
            CheckBox19.Enabled = False
            Button37.Enabled = False
            Label44.Enabled = False
        End If
        axestr = "(X)"
        If actorsel Then
            ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
        ElseIf vertexsel Then
            ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " " & n(vtmode)
        End If
        movest = 1
        ToolStripMenuItem7.Checked = False
        ToolStripMenuItem8.Checked = True
        ToolStripMenuItem6.Checked = False
    End Sub
    Private Sub ToolStripMenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripMenuItem6.Click
        If Not vertexsel Then
            meshw = -1
            vertw = -1
            CheckBox16.Enabled = False
            CheckBox17.Enabled = False
            CheckBox18.Enabled = False
            CheckBox19.Enabled = False
            Button37.Enabled = False
            Label44.Enabled = False
        End If
        axestr = "(Y)"
        If actorsel Then
            ToolStripStatusLabel4.Text = "Tool: Actor mover " & axestr
        ElseIf vertexsel Then
            ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " " & n(vtmode)
        End If
        movest = 2
        ToolStripMenuItem7.Checked = False
        ToolStripMenuItem8.Checked = False
        ToolStripMenuItem6.Checked = True
    End Sub

    Private Sub TriangleEditorToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriangleEditorToolStripMenuItem.Click
        meshw = -1
        vertw = -1
        CheckBox16.Enabled = False
        CheckBox17.Enabled = False
        CheckBox18.Enabled = False
        CheckBox19.Enabled = False
        Button37.Enabled = False
        Label44.Enabled = False
        ToolStripStatusLabel4.Text = "Tool: Collision triangle editor"
        actorsel = False
        vertexsel = False
        trisel = True
        VertexWelderToolStripMenuItem.Checked = False
        VertexSelectorToolStripMenuItem.Checked = False
        ActorSelectorToolStripMenuItem.Checked = False
        TriangleEditorToolStripMenuItem.Checked = True
        AllSharedToolStripMenuItem.Checked = False
        SinglePointToolStripMenuItem.Checked = False
        PerMeshToolStripMenuItem.Checked = False
    End Sub



    Private Sub CheckBox9_CheckedChanged_2(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not myownrm Then
            myownrm = True
        Else
            myownrm = False
        End If
    End Sub

    Private Sub CheckBox8_CheckedChanged_2(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not myownobj Then
            myownobj = True
        Else
            myownobj = False
        End If
    End Sub

    Private Sub CheckBox12_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not myownsc Then
            myownsc = True
        Else
            myownsc = False
        End If
    End Sub

    Private Sub RadioButton3_CheckedChanged_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
    End Sub

    Private Sub RadioButton2_CheckedChanged_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
    End Sub

    Private Sub RadioButton1_CheckedChanged_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage
    End Sub

    Private Sub MainWin_ResizeEnd(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.ResizeEnd
        If Me.Width < 800 Then
            Me.Width = 800
        End If
        If Me.Height < 600 Then
            Me.Height = 600
        End If
        Reshape()
    End Sub

    Private Sub MainWin_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
        Reshape()
    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        typecol = 0
    End Sub

    Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        typecol = 1
    End Sub

    Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        typecol = 2
    End Sub

    Private Sub ContextMenuStrip7_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ContextMenuStrip7.ItemClicked
        If e.ClickedItem.ToString = "Add Preset..." Then
            ColPresetDialog.ShowDialog()
        End If
    End Sub

    Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ChangeColor()
    End Sub

    Private Sub ChangeColor()
        If TextBox14.Text <> "" Then
            For i = 0 To colvar.Count - 1
                If TextBox14.Text = colvar(i) Then
                    ctris(i).g = 0
                    ctris(i).b = 0
                Else
                    ctris(i).g = 1
                    ctris(i).b = 1
                End If
            Next
        Else
            For i = 0 To colvar.Count - 1
                ctris(i).g = 1
                ctris(i).b = 1
            Next
        End If
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex > 0 Then
            seltype = coltypes(ComboBox1.SelectedIndex - 1)
            Dim v1 As String = Mid(seltype, 1, 4)
            Dim v2 As String = Mid(seltype, 5, 4)
            Dim v3 As String = Mid(seltype, 9, 4)
            Dim v4 As String = Mid(seltype, 13, 4)
            TextBox15.Text = v1
            TextBox18.Text = v2
            TextBox17.Text = v3
            TextBox19.Text = Mid(v4, 1, 3)
            TextBox20.Text = Mid(v4, 4, 1)
            TextBox15.Enabled = True
            TextBox17.Enabled = True
            TextBox18.Enabled = True
            TextBox19.Enabled = True
            ChangeColor()
        Else
            TextBox15.Text = ""
            TextBox17.Text = ""
            TextBox18.Text = ""
            TextBox19.Text = ""
            TextBox20.Text = ""
            TextBox20.Enabled = False
            TextBox15.Enabled = False
            TextBox17.Enabled = False
            TextBox18.Enabled = False
            TextBox19.Enabled = False
            ChangeColor()
        End If
    End Sub
    Private Sub Button22_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button22.Click
        If colvar.Count > 0 Then
            If ComboBox8.SelectedIndex > 0 Then
                exits(ComboBox8.SelectedIndex - 1) = zerofill1(TextBox16.Text)
            End If
            coltypes(ComboBox1.SelectedIndex - 1) = TextBox15.Text & TextBox18.Text & TextBox17.Text & TextBox19.Text & TextBox20.Text
        End If
    End Sub
    Private Sub Button21_Click_2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
        ContextMenuStrip7.Show(MousePosition.X, MousePosition.Y)
    End Sub
    Private Sub ComboBox8_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox8.SelectedIndexChanged
        If ComboBox8.SelectedIndex > 0 Then
            TextBox16.Enabled = True
            TextBox16.Text = exits(ComboBox8.SelectedIndex - 1)
        Else
            TextBox16.Enabled = False
            TextBox16.Text = ""
        End If
    End Sub
    Private Sub Button16_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        MatchCollision(0)
    End Sub

    Private Sub Button15_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        MatchCollision(1)
    End Sub
    Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ExitSelectDialog.ComboBox1.Items.Clear()
        For i = 0 To ComboBox8.Items.Count - 1
            ExitSelectDialog.ComboBox1.Items.Add(ComboBox8.Items.Item(i))
        Next
        ExitSelectDialog.ShowDialog()
    End Sub
    Private Sub ImportCSVToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImportCSVToolStripMenuItem.Click
        If OpenFileDialog3.ShowDialog = DialogResult.Cancel Then
            OpenFileDialog3.Dispose()
        End If
    End Sub
    Structure OBJPoints
        Dim x As Double
        Dim y As Double
        Dim z As Double
    End Structure
    Structure OBJUVs
        Dim u As Single
        Dim v As Single
    End Structure
    Structure OBJFaces
        Dim A As ArrayList
        Dim B As ArrayList
        Dim C As ArrayList
        Dim D As ArrayList
        Dim E As ArrayList
        Dim F As ArrayList
        Dim Rc As ArrayList
        Dim Gc As ArrayList
        Dim Bc As ArrayList
        Dim Ra As ArrayList
        Dim Ga As ArrayList
        Dim Ba As ArrayList
    End Structure
    Private Sub OpenFileDialog3_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog3.FileOk
        Dim objfile As StreamReader = New StreamReader(OpenFileDialog3.FileName)
        Dim matfile As StreamReader
        Dim curline As String = ""
        objtexcnt = 0
        Dim matfilename As String = ""
        Dim ObjLines() As String = {}
        Dim MatLines() As String = {}
        Dim texfn As String = ""
        Dim grpcnt As Integer = -1
        Dim tricnt As Integer = 0
        Dim pointcnt As Integer = -1
        Dim vtcnt As Integer = -1
        Dim mattexfilename As String = ""
        Dim tr As Double = 0.0
        Dim tg As Double = 0.0
        Dim tb As Double = 0.0
        Dim tra As Double = 0.0
        Dim tga As Double = 0.0
        Dim tba As Double = 0.0
        Dim oldgrcnt As Integer = 0
        Dim filesdir As String = Path.GetDirectoryName(OpenFileDialog3.FileName)
        Dim lineno As Integer = 0
        Dim fA() As String
        FileOpen(1, "c:/test.zmap", OpenMode.Binary)
        While objfile.Peek <> -1
            curline = objfile.ReadLine
            If lineno = 0 Then
                If Not curline.Contains("3ds Max") Then
                    MsgBox("Due to strict specifics in formatting, the model importer currently only supports 3D Studio Max made .obj files. Import this model into 3DS Max and export it back out to .obj format make it compatible.", MsgBoxStyle.Critical, "Not a 3DS Max export!")
                    FileClose(1)
                    objfile.Close()
                    Exit Sub
                End If
            End If
            ObjLines = curline.Split(" ")
            Select Case ObjLines(0)
                Case "mtllib"
                    matfilename = ObjLines(1)
                Case "g"
                    If ObjLines.Length > 1 Then
                        grpcnt += 1
                        curline = objfile.ReadLine
                        ObjLines = curline.Split(" ")
                        If ObjLines(0) = "usemtl" Then
                            matfile = New StreamReader(filesdir & "\" & matfilename)
                            While matfile.Peek <> -1
                                curline = matfile.ReadLine
                                MatLines = curline.Split(" ")
                                If MatLines(0) = "newmtl" Then
                                    If MatLines(1) = ObjLines(1) Then
                                        Do Until MatLines(0) = ""
                                            curline = matfile.ReadLine
                                            If curline = Nothing Then
                                                Exit Do
                                            End If
                                            MatLines = curline.Split(" ")
                                            Select Case MatLines(0)
                                                Case "Kd", ControlChars.Tab & "Kd"
                                                    If MatLines(1) = "" Then
                                                        tr = CDbl(MatLines(2))
                                                        tg = CDbl(MatLines(3))
                                                        tb = CDbl(MatLines(4))
                                                    Else
                                                        tr = CDbl(MatLines(1))
                                                        tg = CDbl(MatLines(2))
                                                        tb = CDbl(MatLines(3))
                                                    End If
                                                Case "Ks", ControlChars.Tab & "Ks"
                                                    If MatLines(1) = "" Then
                                                        tra = CDbl(MatLines(2))
                                                        tga = CDbl(MatLines(3))
                                                        tba = CDbl(MatLines(4))
                                                    Else
                                                        tra = CDbl(MatLines(1))
                                                        tga = CDbl(MatLines(2))
                                                        tba = CDbl(MatLines(3))
                                                    End If
                                                Case "map_Ka", "map_Kd", ControlChars.Tab & "map_Ka", ControlChars.Tab & "map_Kd"
                                                    If MatLines(1).Contains("\") Then
                                                        mattexfilename = MatLines(1)
                                                    Else
                                                        mattexfilename = filesdir & "\" & GetFileName(MatLines(1))
                                                    End If
                                            End Select
                                        Loop
                                        'Exit While
                                    End If
                                End If
                            End While
                            If File.Exists(mattexfilename) Then
                                Il.ilLoadImage(mattexfilename)
                                Il.ilConvertImage(Il.IL_RGBA, Il.IL_UNSIGNED_BYTE)
                                Dim texh As Integer = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT)
                                Dim texw As Integer = Il.ilGetInteger(Il.IL_IMAGE_WIDTH)
                                Gl.glBindTexture(Gl.GL_TEXTURE_2D, grpcnt)
                                Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Il.ilGetInteger(Il.IL_IMAGE_BPP), texw, texh, 0, Il.ilGetInteger(Il.IL_IMAGE_FORMAT), Gl.GL_UNSIGNED_BYTE, Il.ilGetData())
                                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT)
                                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT)
                                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR)
                                Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR)
                                objtexcnt += 1
                            End If
                        End If
                        ReDim Preserve OBJPolygons(grpcnt)
                        With OBJPolygons(grpcnt)
                            .A = New ArrayList
                            .B = New ArrayList
                            .C = New ArrayList
                            .D = New ArrayList
                            .E = New ArrayList
                            .F = New ArrayList
                            .Rc = New ArrayList
                            .Gc = New ArrayList
                            .Bc = New ArrayList
                        End With
                    End If
                Case "v"
                    pointcnt += 1
                    ReDim Preserve OBJVertices(pointcnt)
                    With OBJVertices(pointcnt)
                        If ObjLines.Length = 7 Then
                            .x = CDbl(ObjLines(2))
                            .y = CDbl(ObjLines(4))
                            .z = CDbl(ObjLines(6))
                        Else
                            If ObjLines(1) = "" Then
                                .x = CDbl(ObjLines(2))
                                .y = CDbl(ObjLines(3))
                                .z = CDbl(ObjLines(4))
                            Else
                                .x = CDbl(ObjLines(1))
                                .y = CDbl(ObjLines(2))
                                .z = CDbl(ObjLines(3))
                            End If
                        End If

                    End With
                Case "vt"
                    vtcnt += 1
                    ReDim Preserve OBJTexCoord(vtcnt)
                    With OBJTexCoord(vtcnt)
                        If ObjLines(1) = "" Then
                            .u = CDbl(ObjLines(2))
                            .v = CDbl(ObjLines(3))
                        Else
                            .u = CDbl(ObjLines(1))
                            .v = CDbl(ObjLines(2))
                        End If
                    End With
                Case "f"
                    If ObjLines(1) <> "" Then
                        tricnt += 1
                        With OBJPolygons(grpcnt)
                            If ObjLines(1).IndexOf("/") = -1 Then
                                .A.Add(CInt(ObjLines(1)) - 1)
                                .B.Add(CInt(ObjLines(2)) - 1)
                                .C.Add(CInt(ObjLines(3)) - 1)
                            Else
                                For i = 1 To 3
                                    fA = ObjLines(i).Split("/")
                                    Select Case i
                                        Case 1
                                            .A.Add(CInt(fA(0)) - 1)
                                            .D.Add(CInt(fA(1)) - 1)
                                        Case 2
                                            .B.Add(CInt(fA(0)) - 1)
                                            .E.Add(CInt(fA(1)) - 1)
                                        Case 3
                                            .C.Add(CInt(fA(0)) - 1)
                                            .F.Add(CInt(fA(1)) - 1)
                                    End Select
                                Next
                            End If
                            .Rc.Add(tr)
                            .Gc.Add(tg)
                            .Bc.Add(tb)
                        End With
                    End If
            End Select
            If lineno = 0 Then lineno += 1
        End While
        objfile.Close()
        FileClose(1)
        ResetView()
        GC.Collect()
    End Sub
    Private Sub ResetSelectedVerticesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetSelectedVerticesToolStripMenuItem.Click
        Timer3.Stop()
        ResetVerts(0)
    End Sub
    Private Sub AllPointsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        vtmode = 0
        SinglePointToolStripMenuItem.Checked = False
        ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (all)"
        actorsel = False
        vertexsel = True
        trisel = False
        VertexWelderToolStripMenuItem.Checked = False
        VertexSelectorToolStripMenuItem.Checked = True
        ActorSelectorToolStripMenuItem.Checked = False
        TriangleEditorToolStripMenuItem.Checked = False
        PerMeshToolStripMenuItem.Checked = False
        AllSharedToolStripMenuItem.Checked = False
    End Sub
    Private Sub SinglePointToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SinglePointToolStripMenuItem.Click
        CheckBox16.Enabled = True
        CheckBox17.Enabled = True
        CheckBox18.Enabled = True
        CheckBox19.Enabled = True
        Button37.Enabled = True
        Label44.Enabled = True
        vtmode = 1
        SinglePointToolStripMenuItem.Checked = True
        ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (single)"
        actorsel = False
        vertexsel = True
        trisel = False
        VertexWelderToolStripMenuItem.Checked = False
        VertexSelectorToolStripMenuItem.Checked = True
        ActorSelectorToolStripMenuItem.Checked = False
        TriangleEditorToolStripMenuItem.Checked = False
        PerMeshToolStripMenuItem.Checked = False
        AllSharedToolStripMenuItem.Checked = False
    End Sub
    Private Sub PerMeshToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PerMeshToolStripMenuItem.Click
        CheckBox16.Enabled = False
        CheckBox17.Enabled = False
        CheckBox18.Enabled = False
        CheckBox19.Enabled = False
        Button37.Enabled = False
        Label44.Enabled = False
        vertw = -1
        vtmode = 2
        SinglePointToolStripMenuItem.Checked = False
        ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (mesh)"
        actorsel = False
        vertexsel = True
        trisel = False
        VertexWelderToolStripMenuItem.Checked = False
        VertexSelectorToolStripMenuItem.Checked = True
        ActorSelectorToolStripMenuItem.Checked = False
        TriangleEditorToolStripMenuItem.Checked = False
        PerMeshToolStripMenuItem.Checked = True
        AllSharedToolStripMenuItem.Checked = False
    End Sub
    Private Sub CheckBox13_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If hide0(0) Then
            hide0(0) = False
        Else
            hide0(0) = True
        End If
    End Sub
    Private Sub CheckBox14_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If hide0(1) Then
            hide0(1) = False
        Else
            hide0(1) = True
        End If
    End Sub
    Private Sub CheckBox15_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If hide0(2) Then
            hide0(2) = False
        Else
            hide0(2) = True
        End If
    End Sub
    Private Sub FlagsToolStripMenuItem_DropDownItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles FlagsToolStripMenuItem.DropDownItemClicked
        If e.ClickedItem.ToString.Contains("Exit") Then
            ExitSelectDialog.ComboBox1.Items.Clear()
            For i = 0 To exits.Count - 1
                ExitSelectDialog.ComboBox1.Items.Add(exits(i))
            Next
            ExitSelectDialog.ShowDialog()
        Else
            Dim tind As String = presetind(FlagsToolStripMenuItem.DropDownItems.IndexOf(e.ClickedItem))
            Dim tstr As String = presets(FlagsToolStripMenuItem.DropDownItems.IndexOf(e.ClickedItem))
            Select Case tind
                Case "1"
                    TextBox15.Text = tstr
                Case "2"
                    TextBox18.Text = tstr
                Case "3"
                    TextBox17.Text = tstr
            End Select
        End If
    End Sub
    Private Sub AllSharedToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllSharedToolStripMenuItem.Click
        CheckBox16.Enabled = False
        CheckBox17.Enabled = False
        CheckBox18.Enabled = False
        CheckBox19.Enabled = False
        Button37.Enabled = False
        Label44.Enabled = False
        vtmode = 3
        SinglePointToolStripMenuItem.Checked = False
        ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (all shared)"
        actorsel = False
        vertexsel = True
        trisel = False
        VertexWelderToolStripMenuItem.Checked = False
        VertexSelectorToolStripMenuItem.Checked = True
        ActorSelectorToolStripMenuItem.Checked = False
        TriangleEditorToolStripMenuItem.Checked = False
        PerMeshToolStripMenuItem.Checked = False
        AllSharedToolStripMenuItem.Checked = True
    End Sub

    Private Sub AddPresetToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddPresetToolStripMenuItem.Click
        ColPresetDialog.ShowDialog()
    End Sub
    Private Sub Button23_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
        ActorPresets.Show()
        ActorPresets.Focus()
    End Sub

    Private Sub TextBox22_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox22.TextChanged
        changevert(3) = True
    End Sub

    Private Sub TextBox21_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox21.TextChanged
        changevert(4) = True
    End Sub

    Private Sub Button26_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button26.MouseDown
        btnno = 6
        Timer1.Start()
    End Sub

    Private Sub Button26_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button26.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button24_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button24.MouseDown
        btnno = 7
        Timer1.Start()
    End Sub

    Private Sub Button24_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button24.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button27_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button27.MouseDown
        btnno = 8
        Timer1.Start()
    End Sub

    Private Sub Button27_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button27.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button25_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button25.MouseDown
        btnno = 9
        Timer1.Start()
    End Sub

    Private Sub Button25_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button25.MouseUp
        Timer1.Stop()
    End Sub

    Private Sub Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button29.Click
        If IsNumeric(TextBox22.Text) Then
            If Mid(TextBox22.Text, 1, 1) = "-" Then
                TextBox22.Text = Mid(TextBox22.Text, 2)
                Button29.Text = "-"
            Else
                TextBox22.Text = "-" & TextBox22.Text
                Button29.Text = "+"
            End If
        End If
    End Sub

    Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button28.Click
        If IsNumeric(TextBox21.Text) Then
            If Mid(TextBox21.Text, 1, 1) = "-" Then
                TextBox21.Text = Mid(TextBox21.Text, 2)
                Button28.Text = "-"
            Else
                TextBox21.Text = "-" & TextBox21.Text
                Button28.Text = "+"
            End If
        End If
    End Sub
    Private Sub ResetSelectedActorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetSelectedActorToolStripMenuItem.Click
        ResetSelActor()
    End Sub
    Private Sub ResetAllActorsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetAllActorsToolStripMenuItem.Click
        For i = 0 To actorx.Count - 1
            actorx(i) = oactorx(i)
            actory(i) = oactory(i)
            actorz(i) = oactorz(i)
            actorxrot(i) = oactorxrot(i)
            actoryrot(i) = oactoryrot(i)
            actorzrot(i) = oactorzrot(i)
        Next
    End Sub
    Private Sub ResetAllSceneActorsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetAllSceneActorsToolStripMenuItem.Click
        For i = 0 To doorx.Count - 1
            doorx(i) = odoorx(i)
            doory(i) = odoory(i)
            doorz(i) = odoorz(i)
        Next
        For i = 0 To linkx.Count - 1
            linkx(i) = olinkx(i)
            linky(i) = olinky(i)
            linkz(i) = olinkz(i)
            linkxr(i) = olinkxr(i)
            linkyr(i) = olinkyr(i)
            linkzr(i) = olinkzr(i)
        Next
    End Sub
    Private Sub ResetSelActor()
        If Not link And Not door Then
            For i = 0 To selactor.Count - 1
                i1 = selactor(i)
                actorx(i1) = oactorx(i1)
                actory(i1) = oactory(i1)
                actorz(i1) = oactorz(i1)
                actorxrot(i1) = oactorxrot(i1)
                actoryrot(i1) = oactoryrot(i1)
                actorzrot(i1) = oactorzrot(i1)
            Next
        ElseIf Not link And door Then
            For i = 0 To selactorsc.Count - 1
                i1 = selactorsc(i)
                doorx(i1) = odoorx(i1)
                doory(i1) = odoory(i1)
                doorz(i1) = odoorz(i1)
            Next
        ElseIf link And Not door Then
            If link Then
                For i = 0 To sellink.Count - 1
                    i1 = sellink(i)
                    linkx(i1) = olinkx(i1)
                    linky(i1) = olinky(i1)
                    linkz(i1) = olinkz(i1)
                    linkxr(i1) = olinkxr(i1)
                    linkyr(i1) = olinkyr(i1)
                    linkzr(i1) = olinkzr(i1)
                Next
            End If
        End If
    End Sub
    Public Sub DelimitActors()
        Dim curline As String = ""
        Dim gp As String = ""
        Dim np As String = ""
        Dim ap As String = ""
        Dim desc As String = ""
        actorgp.Clear()
        actornp.Clear()
        actorvp.Clear()
        actorgpu.Clear()
        actornpu.Clear()
        actorvpu.Clear()
        ActorPresets.ListBox1.Items.Clear()
        ActorPresets.ListBox2.Items.Clear()
        For i = 0 To agrbuff.Count - 1
            gp = CStr(agrbuff(i))
            np = CStr(anobuff(i))
            ap = CStr(avarbuff(i))
            desc = CStr(adescbuff(i))
            If actorgr.Contains(gp) Or gp = "0001" Then
                ActorPresets.ListBox1.Items.Add(desc)
                actorgp.Add(gp)
                actornp.Add(np)
                actorvp.Add(ap)
            Else
                ActorPresets.ListBox2.Items.Add(desc)
                actorgpu.Add(gp)
                actornpu.Add(np)
                actorvpu.Add(ap)
            End If
        Next
    End Sub

    Private Sub AvailableToolStripMenuItem_DropDownItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)

    End Sub

    Private Sub NeedGroupsToolStripMenuItem_DropDownItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs)

    End Sub

    Private Sub EditDatabaseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Process.Start(Application.StartupPath & "\ext\actor_db.txt")
    End Sub

    Private Sub CheckBox13_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox13.CheckedChanged
        If hide0(0) Then
            hide0(0) = False
        Else
            hide0(0) = True
        End If
    End Sub
    Private Sub CheckBox14_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox14.CheckedChanged
        If hide0(1) Then
            hide0(1) = False
        Else
            hide0(1) = True
        End If
    End Sub
    Private Sub CheckBox15_CheckedChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox15.CheckedChanged
        If hide0(2) Then
            hide0(2) = False
        Else
            hide0(2) = True
        End If
    End Sub

    Private Sub Button35_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not ComboBox3.Items.Count = 0 Then
            If ComboBox3.SelectedIndex - 1 < 0 Then
                ComboBox3.SelectedIndex = ComboBox3.Items.Count - 1
            Else
                ComboBox3.SelectedIndex -= 1
            End If
        End If
    End Sub

    Private Sub Button36_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If Not ComboBox3.Items.Count = 0 Then
            If ComboBox3.SelectedIndex + 1 > ComboBox3.Items.Count - 1 Then
                ComboBox3.SelectedIndex = 0
            Else
                ComboBox3.SelectedIndex += 1
            End If
        End If
    End Sub

    Private Sub SelectAllRoomActorsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllRoomActorsToolStripMenuItem.Click
        If actorx.Count > 0 Then
            mpick = True
            selactor.Clear()
            selactorsc.Clear()
            For i = 0 To actorfound - 1
                selactor.Add(i)
            Next
            ComboBox7.SelectedIndex = 0
        End If
    End Sub

    Private Sub SelectAllSceneActorsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllSceneActorsToolStripMenuItem.Click
        If doorx.Count > 0 Then
            mpick = True
            selactor.Clear()
            selactorsc.Clear()
            For i = 0 To scenedoorcnt - 1
                selactorsc.Add(i)
            Next
            ComboBox5.SelectedIndex = 0
        End If
    End Sub

    Private Sub TextBox7_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox7.TextChanged
        changepos(0) = True
    End Sub

    Private Sub TextBox8_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox8.TextChanged
        changepos(1) = True
    End Sub

    Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
        changepos(2) = True
    End Sub

    Private Sub TextBox10_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox10.TextChanged
        changepos(3) = True
    End Sub

    Private Sub TextBox11_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox11.TextChanged
        changepos(4) = True
    End Sub

    Private Sub TextBox12_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox12.TextChanged
        changepos(5) = True
    End Sub
    Private Sub EnableWeld()
        weld = True
        If selvertc.Count = 1 Then
            meshw = -1
            vertw = selvertc(0)
        ElseIf selmesh.Count = 1 Then
            meshw = selmesh(0)
            vertw = selvert(0)
        End If
        Button37.Text = "Please select a vertex"
        Timer3.Stop()
        timerstr = "Vertex weld mode ON"
        ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (single - Weld)"
        WeldModesingleAndAllSharedOnlyToolStripMenuItem.Checked = True
    End Sub
    Private Sub DisableWeld()
        weld = False
        meshw = -1
        vertw = -1
        Button37.Text = "Start snap mode"
        timerstr = "Vertex weld mode OFF"
        ToolStripStatusLabel4.Text = "Tool: Vertex editor " & axestr & " (single)"
        WeldModesingleAndAllSharedOnlyToolStripMenuItem.Checked = False
    End Sub
    Private Sub Button37_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button37.Click
        If Button37.Text = "Please select a vertex" & Environment.NewLine & "(click to cancel)" Then
            DisableWeld()
        Else
            If selmesh.Count = 1 Or selvertc.Count = 1 Then
                EnableWeld()
            End If
        End If
    End Sub

    Private Sub WeldModesingleAndAllSharedOnlyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WeldModesingleAndAllSharedOnlyToolStripMenuItem.Click
        If Button37.Text = "Please select a vertex" & Environment.NewLine & "(click to cancel)" Then
            DisableWeld()
        Else
            If selmesh.Count = 1 Then
                EnableWeld()
            End If
        End If
    End Sub

    Private Sub CheckBox16_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox16.CheckedChanged
        If weldpos(0) Then
            weldpos(0) = False
        Else
            weldpos(0) = True
        End If
    End Sub

    Private Sub CheckBox17_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox17.CheckedChanged
        If weldpos(1) Then
            weldpos(1) = False
        Else
            weldpos(1) = True
        End If
    End Sub

    Private Sub CheckBox18_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox18.CheckedChanged
        If weldpos(2) Then
            weldpos(2) = False
        Else
            weldpos(2) = True
        End If
    End Sub

    Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        run = TrackBar1.Value
    End Sub

    Private Sub CheckBox19_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox19.CheckedChanged
        If weldautooff Then
            weldautooff = False
        Else
            weldautooff = True
        End If
    End Sub

    Private Sub TabPage1_PreviewKeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles TabPage1.PreviewKeyDown
        Select Case e.KeyCode
            Case Keys.F
                If vertexsel And vtmode = 1 Then
                    If Button37.Text = "Please select a vertex" Then
                        DisableWeld()
                    Else
                        If selmesh.Count = 1 Or selvertc.Count = 1 Then
                            EnableWeld()
                        End If
                    End If
                End If
        End Select
    End Sub
    Private Sub LoadFile()
        If Not working Then
            Application.DoEvents()
            ClearArrayLists()
            Start()
        End If
    End Sub
    Private Sub Reload()
        If Not working Then
            Dim oc3 As Integer = 0
            If ComboBox3.SelectedIndex > -1 Then
                oc3 = ComboBox3.SelectedIndex
                LoadFile()
                ComboBox3.SelectedIndex = oc3
            Else
                LoadFile()
            End If
        End If
    End Sub
    Private Sub ReloadCurrentFileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReloadCurrentFileToolStripMenuItem.Click
        Reload()
    End Sub

    Private Sub CheckBox5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox5.CheckedChanged
        If hide0(3) Then
            hide0(3) = False
        Else
            hide0(3) = True
        End If
    End Sub

    Private Sub ViewingMeshToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewingMeshToolStripMenuItem1.Click
        If renderobj Then
            renderobj = False
            ViewingMeshToolStripMenuItem1.Checked = False
            timerstr = "Graphics False"
        ElseIf Not renderobj Then
            renderobj = True
            ViewingMeshToolStripMenuItem1.Checked = True
            timerstr = "Graphics True"
        End If
    End Sub

    Private Sub SearchForUpdatesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchForUpdatesToolStripMenuItem.Click
        Try
            Dim ask As MsgBoxResult = MsgBox("Search for program updates? Requires an active internet connection.", MsgBoxStyle.YesNo, "Update UoT")
            If ask = DialogResult.Yes Then
                File.WriteAllText(Application.StartupPath & "\vercomp.txt", Application.ProductVersion)
                Dim uotupdate As Process = New Process()
                uotupdate.StartInfo.FileName = Application.StartupPath & "\UoT_Updater.exe"
                uotupdate.Start()
            End If
        Catch err As Exception
            File.Delete(Application.StartupPath & "\vernew.txt")
            File.Delete(Application.StartupPath & "\vercomp.txt")
            File.Delete(Application.StartupPath & "\UoTTemp.zip")
        End Try
    End Sub
    Private Sub SelectAllGraphicsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllGraphicsToolStripMenuItem.Click
        'selvertc.Clear()
        'selmesh.Clear()
        'selvert.Clear()
        'For i = 0 To Vertices.Length - 1
        '    For i1 = 0 To Vertices(i).x.Count - 1
        '        selmesh.Add(i)
        '        selvert.Add(i1)
        '    Next
        'Next
    End Sub
    Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
        Reload()
    End Sub
    Private Sub Button38_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button38.Click
        ContextMenuStrip1.Show(MousePosition.X, MousePosition.Y)
    End Sub
    Private Sub Button41_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button41.Click
        refreshdebug = True
    End Sub
    Private Sub DebugTree_AfterCheck(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles DebugTree.AfterCheck
        'MsgBox(e.Node.Parent.Index & " " & e.Node.Index)
        If ComboBox3.SelectedIndex < 1 Then
            If e.Node.Checked Then
                DLInfo(e.Node.Parent.Index).Commands(e.Node.Index).SkipCommand = True
            Else
                DLInfo(e.Node.Parent.Index).Commands(e.Node.Index).SkipCommand = False
            End If
        Else
            Dim c3 As Integer = (ComboBox3.SelectedIndex - 1) + e.Node.Parent.Index
            If e.Node.Checked Then
                DLInfo(c3).Commands(e.Node.Index).SkipCommand = True
            Else
                DLInfo(c3).Commands(e.Node.Index).SkipCommand = False
            End If
        End If
    End Sub

    Private Sub FileTree_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles FileTree.AfterSelect
        Dim curnodestr1 As String = FileTree.SelectedNode.Text
        Select Case curnodestr1
            Case "Actor models", "Levels", "Others"
                Exit Sub
        End Select
        Dim curnodestr As String = FileTree.SelectedNode.Parent.Text
        Dim filetype As Integer = FileTree.SelectedNode.Parent.Index
        Dim filename As Integer = FileTree.SelectedNode.Index
        Dim oldmapst As Integer = 0
        Dim oldscst As Integer = 0
        If curnodestr.Contains("_scene") Then
            filename -= 1
            scenest = ROMFiles.Levels(filetype).startoff
            mapst = ROMFiles.Levels(filetype).Maps(filename).startoff

            mapbuffsize = (ROMFiles.Levels(filetype).Maps(filename).endoff - mapst)
            scbuffsize = (ROMFiles.Levels(filetype).endoff - scenest)

            mapfilename = ROMFiles.Levels(filetype).Maps(filename).filename
            scfilename = ROMFiles.Levels(filetype).filename

            ReDim ZSceneBuffer(scbuffsize - 1)
            filebuff.Position = scenest
            filebuff.Read(ZSceneBuffer, 0, scbuffsize)

            ReDim ZFileBuffer(mapbuffsize - 1)
            filebuff.Position = mapst
            filebuff.Read(ZFileBuffer, 0, mapbuffsize)
        Else
            Select Case curnodestr
                Case "Actor models"
                    filename -= 1
                    objectfilename = ROMFiles.Objects(filename).filename
                    objbuffsize = (ROMFiles.Objects(filename).endoff - ROMFiles.Objects(filename).startoff)
                    ReDim ZFileBuffer(objbuffsize - 1)
                    filebuff.Position = ROMFiles.Objects(filename).startoff
                    filebuff.Read(ZFileBuffer, 0, objbuffsize)
                Case "Levels"
                    Exit Sub
                Case "Others"
                    Exit Sub
                Case Else
                    Exit Sub
            End Select
        End If
        DetectExtension()
        GetEntryPoints()
    End Sub

    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
        LoadROM.ShowDialog()
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub OptionsToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem1.Click
        SetupDialog.ShowDialog()
    End Sub

    Private Sub ContentsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContentsToolStripMenuItem.Click
        ControlsHelp.Show()
    End Sub

    Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click
        ToggleTabs()
    End Sub
End Class