diff --git a/Z64Utils/F3DZEX/Render/Renderer.cs b/Z64Utils/F3DZEX/Render/Renderer.cs index f4c29d8..d197e9c 100644 --- a/Z64Utils/F3DZEX/Render/Renderer.cs +++ b/Z64Utils/F3DZEX/Render/Renderer.cs @@ -22,11 +22,22 @@ namespace F3DZEX.Render { public class Config { + public event EventHandler OnGridScaleChanged; + + private float _gridScale = 5000; + + public bool RenderTextures { get; set; } = true; - public float GridScale { get; set; } = 5000; + public float GridScale { + get => _gridScale; + set { + _gridScale = value; + OnGridScaleChanged?.Invoke(this, new EventArgs()); + } + } public bool ShowGrid { get; set; } = true; public bool ShowAxis { get; set; } = true; - public bool DiffuseLight { get; set; } = false; + //public bool DiffuseLight { get; set; } = false; } @@ -148,6 +159,12 @@ namespace F3DZEX.Render _rdpVtxDrawer.SetData(_vtxBuffer, BufferUsageHint.DynamicDraw); + CurrentConfig.OnGridScaleChanged += (o, e) => + { + float[] vertices = RenderHelper.GenerateGridVertices(CurrentConfig.GridScale, 6, false); + _gridDrawer.SetSubData(vertices, 0); + }; + CheckGLErros(); _initialized = true; } @@ -295,7 +312,6 @@ namespace F3DZEX.Render - static int TexDecodeCount = 0; private void DecodeTexIfRequired() { @@ -456,7 +472,6 @@ namespace F3DZEX.Render var settile = info.Convert(); - _mirrorV = settile.cmT.HasFlag(Enums.ClampMirrorFlag.G_TX_MIRROR); _mirrorH = settile.cmS.HasFlag(Enums.ClampMirrorFlag.G_TX_MIRROR); diff --git a/Z64Utils/F3DZEX/Render/SimpleVertexDrawer.cs b/Z64Utils/F3DZEX/Render/SimpleVertexDrawer.cs index 282e46d..947e9d1 100644 --- a/Z64Utils/F3DZEX/Render/SimpleVertexDrawer.cs +++ b/Z64Utils/F3DZEX/Render/SimpleVertexDrawer.cs @@ -37,5 +37,9 @@ namespace F3DZEX.Render { _attrs.SetData(data, data.Length * sizeof(float), hint); } + public void SetSubData(float[] data, int off = 0) + { + _attrs.SetSubData(data, off, data.Length * sizeof(float)); + } } } diff --git a/Z64Utils/Forms/RenderSettingsForm.Designer.cs b/Z64Utils/Forms/RenderSettingsForm.Designer.cs index f4855ec..63aecf8 100644 --- a/Z64Utils/Forms/RenderSettingsForm.Designer.cs +++ b/Z64Utils/Forms/RenderSettingsForm.Designer.cs @@ -29,119 +29,24 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RenderSettingsForm)); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.value_gridScale = new System.Windows.Forms.NumericUpDown(); - this.checkBox_showAxis = new System.Windows.Forms.CheckBox(); - this.checkBox_showGrid = new System.Windows.Forms.CheckBox(); - this.checkBox_renderTextures = new System.Windows.Forms.CheckBox(); - this.groupBox2 = new System.Windows.Forms.GroupBox(); - this.groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.value_gridScale)).BeginInit(); - this.groupBox2.SuspendLayout(); + this.propertyGrid1 = new System.Windows.Forms.PropertyGrid(); this.SuspendLayout(); // - // groupBox1 + // propertyGrid1 // - this.groupBox1.Controls.Add(this.label3); - this.groupBox1.Controls.Add(this.value_gridScale); - this.groupBox1.Controls.Add(this.checkBox_showAxis); - this.groupBox1.Controls.Add(this.checkBox_showGrid); - this.groupBox1.Location = new System.Drawing.Point(12, 12); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(174, 85); - this.groupBox1.TabIndex = 6; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Render Control Settings"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(6, 56); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(56, 13); - this.label3.TabIndex = 3; - this.label3.Text = "Grid Scale"; - // - // value_gridScale - // - this.value_gridScale.Location = new System.Drawing.Point(65, 53); - this.value_gridScale.Maximum = new decimal(new int[] { - 1000000, - 0, - 0, - 0}); - this.value_gridScale.Minimum = new decimal(new int[] { - 1, - 0, - 0, - 0}); - this.value_gridScale.Name = "value_gridScale"; - this.value_gridScale.Size = new System.Drawing.Size(103, 20); - this.value_gridScale.TabIndex = 2; - this.value_gridScale.Value = new decimal(new int[] { - 5000, - 0, - 0, - 0}); - this.value_gridScale.ValueChanged += new System.EventHandler(this.UpdateSettings); - // - // checkBox_showAxis - // - this.checkBox_showAxis.AutoSize = true; - this.checkBox_showAxis.Checked = true; - this.checkBox_showAxis.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBox_showAxis.Location = new System.Drawing.Point(9, 17); - this.checkBox_showAxis.Name = "checkBox_showAxis"; - this.checkBox_showAxis.Size = new System.Drawing.Size(75, 17); - this.checkBox_showAxis.TabIndex = 1; - this.checkBox_showAxis.Text = "Show Axis"; - this.checkBox_showAxis.UseVisualStyleBackColor = true; - this.checkBox_showAxis.CheckedChanged += new System.EventHandler(this.UpdateSettings); - // - // checkBox_showGrid - // - this.checkBox_showGrid.AutoSize = true; - this.checkBox_showGrid.Checked = true; - this.checkBox_showGrid.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBox_showGrid.Location = new System.Drawing.Point(9, 35); - this.checkBox_showGrid.Name = "checkBox_showGrid"; - this.checkBox_showGrid.Size = new System.Drawing.Size(75, 17); - this.checkBox_showGrid.TabIndex = 0; - this.checkBox_showGrid.Text = "Show Grid"; - this.checkBox_showGrid.UseVisualStyleBackColor = true; - this.checkBox_showGrid.CheckedChanged += new System.EventHandler(this.UpdateSettings); - // - // checkBox_renderTextures - // - this.checkBox_renderTextures.AutoSize = true; - this.checkBox_renderTextures.Checked = true; - this.checkBox_renderTextures.CheckState = System.Windows.Forms.CheckState.Checked; - this.checkBox_renderTextures.Location = new System.Drawing.Point(23, 30); - this.checkBox_renderTextures.Name = "checkBox_renderTextures"; - this.checkBox_renderTextures.Size = new System.Drawing.Size(105, 17); - this.checkBox_renderTextures.TabIndex = 4; - this.checkBox_renderTextures.Text = "Render Textures"; - this.checkBox_renderTextures.UseVisualStyleBackColor = true; - this.checkBox_renderTextures.CheckedChanged += new System.EventHandler(this.UpdateSettings); - // - // groupBox2 - // - this.groupBox2.Controls.Add(this.checkBox_renderTextures); - this.groupBox2.Location = new System.Drawing.Point(12, 103); - this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(174, 61); - this.groupBox2.TabIndex = 7; - this.groupBox2.TabStop = false; - this.groupBox2.Text = "Renderer Settings"; + this.propertyGrid1.HelpVisible = false; + this.propertyGrid1.Location = new System.Drawing.Point(3, 9); + this.propertyGrid1.Name = "propertyGrid1"; + this.propertyGrid1.Size = new System.Drawing.Size(249, 174); + this.propertyGrid1.TabIndex = 8; + this.propertyGrid1.PropertyValueChanged += new System.Windows.Forms.PropertyValueChangedEventHandler(this.propertyGrid1_PropertyValueChanged); // // RenderSettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(198, 174); - this.Controls.Add(this.groupBox2); - this.Controls.Add(this.groupBox1); + this.ClientSize = new System.Drawing.Size(257, 187); + this.Controls.Add(this.propertyGrid1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; @@ -149,23 +54,11 @@ this.Name = "RenderSettingsForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Render Settings"; - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.value_gridScale)).EndInit(); - this.groupBox2.ResumeLayout(false); - this.groupBox2.PerformLayout(); this.ResumeLayout(false); } #endregion - - private System.Windows.Forms.GroupBox groupBox1; - private System.Windows.Forms.CheckBox checkBox_renderTextures; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.NumericUpDown value_gridScale; - private System.Windows.Forms.CheckBox checkBox_showAxis; - private System.Windows.Forms.CheckBox checkBox_showGrid; - private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.PropertyGrid propertyGrid1; } } \ No newline at end of file diff --git a/Z64Utils/Forms/RenderSettingsForm.cs b/Z64Utils/Forms/RenderSettingsForm.cs index 0a79f78..fe68ca6 100644 --- a/Z64Utils/Forms/RenderSettingsForm.cs +++ b/Z64Utils/Forms/RenderSettingsForm.cs @@ -18,24 +18,22 @@ namespace Z64.Forms Renderer.Config _rendererCfg; - public RenderSettingsForm(Renderer.Config rendererCfg) + public RenderSettingsForm(Renderer.Config cfg) { InitializeComponent(); - _rendererCfg = rendererCfg; - checkBox_renderTextures.Checked = _rendererCfg.RenderTextures; - value_gridScale.Value = (decimal)_rendererCfg.GridScale; - checkBox_showAxis.Checked = _rendererCfg.ShowAxis; - checkBox_showGrid.Checked = _rendererCfg.ShowGrid; + _rendererCfg = cfg; + + propertyGrid1.SelectedObject = _rendererCfg; } private void UpdateSettings(object sender, EventArgs e) { - _rendererCfg.RenderTextures = checkBox_renderTextures.Checked; - _rendererCfg.GridScale = (float)value_gridScale.Value; - _rendererCfg.ShowAxis = checkBox_showAxis.Checked; - _rendererCfg.ShowGrid = checkBox_showGrid.Checked; + SettingsChanged?.Invoke(this, EventArgs.Empty); + } + private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) + { SettingsChanged?.Invoke(this, EventArgs.Empty); } } diff --git a/Z64Utils/Forms/RenderSettingsForm.resx b/Z64Utils/Forms/RenderSettingsForm.resx index 922f6b6..f9be381 100644 --- a/Z64Utils/Forms/RenderSettingsForm.resx +++ b/Z64Utils/Forms/RenderSettingsForm.resx @@ -1,64 +1,4 @@ - - - + @@ -117,8 +57,8 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + + AAABAAUAEBAAAAEAIABoBAAAVgAAABgYAAABACAAiAkAAL4EAAAgIAAAAQAgAKgQAABGDgAAMDAAAAEA IACoJQAA7h4AAGBgAAABACAAqJQAAJZEAAAoAAAAEAAAACAAAAABACAAAAAAAAAEAAAAAAAAAAAAAAAA diff --git a/Z64Utils/Forms/SkeletonViewerForm.Designer.cs b/Z64Utils/Forms/SkeletonViewerForm.Designer.cs index b3d8a6d..838ac03 100644 --- a/Z64Utils/Forms/SkeletonViewerForm.Designer.cs +++ b/Z64Utils/Forms/SkeletonViewerForm.Designer.cs @@ -137,6 +137,7 @@ namespace Z64.Forms this.toolStripSegmentsBtn.Name = "toolStripSegmentsBtn"; this.toolStripSegmentsBtn.Size = new System.Drawing.Size(63, 22); this.toolStripSegmentsBtn.Text = "Segments"; + this.toolStripSegmentsBtn.Click += ToolStripSegmentsBtn_Click; // // toolStrip2 // diff --git a/Z64Utils/Shaders/rdpVtx.frag b/Z64Utils/Shaders/rdpVtx.frag index c297b5b..e237229 100644 --- a/Z64Utils/Shaders/rdpVtx.frag +++ b/Z64Utils/Shaders/rdpVtx.frag @@ -2,6 +2,7 @@ in vec2 v_VtxTexCoords; in vec4 v_VtxColor; +flat in int v_VtxId; uniform vec3 u_DirLight; uniform sampler2D u_Tex; @@ -22,4 +23,14 @@ void main() /* highlight */ gl_FragColor = mix(gl_FragColor, u_HighlightColor, vec4(u_HighlightColor.a)); //gl_FragColor = vec4(1, 0, 0, 1); + + /* Debug Vertex ID */ + /* + if (v_VtxId % 3 == 0) + gl_FragColor = vec4(1, 0, 0, 1); + else if (v_VtxId % 3 == 1) + gl_FragColor = vec4(0, 1, 0, 1); + else + gl_FragColor = vec4(0, 0, 1, 1); + */ } \ No newline at end of file diff --git a/Z64Utils/Shaders/rdpVtx.vert b/Z64Utils/Shaders/rdpVtx.vert index 22a7398..5e9da0e 100644 --- a/Z64Utils/Shaders/rdpVtx.vert +++ b/Z64Utils/Shaders/rdpVtx.vert @@ -12,6 +12,7 @@ uniform sampler2D u_Tex; out vec2 v_VtxTexCoords; out vec4 v_VtxColor; +flat out int v_VtxId; float S105ToFloat(int fp) { @@ -26,6 +27,8 @@ vec2 decodeTexCoords(sampler2D tex, ivec2 coords) void main() { + v_VtxId = gl_VertexID; + /* The vertices coordinates are multiplied by the model view matrix during the G_VTX command processing */ gl_Position = u_Projection * u_View /* u_Model*/ * vec4(pos, 1); v_VtxTexCoords = decodeTexCoords(u_Tex, texCoords);