Fixed issues with light editor, upgraded ModelForm toolbar

This commit is contained in:
dexy 2022-01-01 00:03:52 +11:00
parent f91ef89580
commit 8af20945cb
9 changed files with 1152 additions and 730 deletions

View File

@ -4547,7 +4547,45 @@ namespace CodeWalker.GameFiles
public MetaHash ProjectedTextureHash { get; set; } public MetaHash ProjectedTextureHash { get; set; }
public uint Unknown_A4h { get; set; } // 0x00000000 public uint Unknown_A4h { get; set; } // 0x00000000
public bool HasChanged = false; //used by model light form public bool UpdateRenderable = false; //used by model light form
public Quaternion Orientation
{
get
{
Vector3 tx = new Vector3();
Vector3 ty = new Vector3();
switch (Type)
{
case LightType.Point:
return Quaternion.Identity;
case LightType.Spot:
tx = Vector3.Normalize(Tangent);
ty = Vector3.Normalize(Vector3.Cross(Direction, Tangent));
break;
case LightType.Capsule:
tx = -Vector3.Normalize(Tangent);
ty = Vector3.Normalize(Vector3.Cross(Direction, Tangent));
break;
}
var m = new Matrix();
m.Row1 = new Vector4(tx, 0);
m.Row2 = new Vector4(ty, 0);
m.Row3 = new Vector4(Direction, 0);
return Quaternion.RotationMatrix(m);
}
set
{
var inv = Quaternion.Invert(Orientation);
var delta = value * inv;
Direction = Vector3.Normalize(delta.Multiply(Direction));
Tangent = Vector3.Normalize(delta.Multiply(Tangent));
}
}
public override void Read(ResourceDataReader reader, params object[] parameters) public override void Read(ResourceDataReader reader, params object[] parameters)
{ {
@ -4729,39 +4767,6 @@ namespace CodeWalker.GameFiles
ProjectedTextureHash = XmlMeta.GetHash(Xml.GetChildInnerText(node, "ProjectedTextureHash")); ProjectedTextureHash = XmlMeta.GetHash(Xml.GetChildInnerText(node, "ProjectedTextureHash"));
} }
public Quaternion GetRotation()
{
Vector3 tx = new Vector3();
Vector3 ty = new Vector3();
switch (Type)
{
case LightType.Point:
return Quaternion.Identity;
case LightType.Spot:
tx = Vector3.Normalize(Direction.GetPerpVec());
ty = Vector3.Normalize(Vector3.Cross(Direction, Tangent));
break;
case LightType.Capsule:
tx = -Vector3.Normalize(Direction.GetPerpVec());
ty = Vector3.Normalize(Vector3.Cross(Direction, Tangent));
break;
}
var m = new Matrix();
m.Row1 = new Vector4(tx, 0);
m.Row2 = new Vector4(ty, 0);
m.Row3 = new Vector4(Direction, 0);
return Quaternion.RotationMatrix(m);
}
public void SetRotation(Quaternion rot)
{
var inv = Quaternion.Invert(GetRotation());
var delta = rot * inv;
Direction = Vector3.Normalize(delta.Multiply(Direction));
Tangent = Vector3.Normalize(Direction.GetPerpVec());
}
} }

View File

@ -40,6 +40,14 @@
this.ToolsPanel = new System.Windows.Forms.Panel(); this.ToolsPanel = new System.Windows.Forms.Panel();
this.MainToolbarPanel = new System.Windows.Forms.Panel(); this.MainToolbarPanel = new System.Windows.Forms.Panel();
this.MainToolbar = new System.Windows.Forms.ToolStrip(); this.MainToolbar = new System.Windows.Forms.ToolStrip();
this.ToolbarMaterialEditorButton = new System.Windows.Forms.ToolStripButton();
this.ToolbarTextureEditorButton = new System.Windows.Forms.ToolStripButton();
this.ToolbarLightEditorButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.ToolbarMoveButton = new System.Windows.Forms.ToolStripButton();
this.ToolbarRotateButton = new System.Windows.Forms.ToolStripButton();
this.ToolbarScaleButton = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.SaveButton = new System.Windows.Forms.ToolStripSplitButton(); this.SaveButton = new System.Windows.Forms.ToolStripSplitButton();
this.SaveMenuButton = new System.Windows.Forms.ToolStripMenuItem(); this.SaveMenuButton = new System.Windows.Forms.ToolStripMenuItem();
this.SaveAsMenuButton = new System.Windows.Forms.ToolStripMenuItem(); this.SaveAsMenuButton = new System.Windows.Forms.ToolStripMenuItem();
@ -52,13 +60,14 @@
this.ClipDictComboBox = new System.Windows.Forms.ComboBox(); this.ClipDictComboBox = new System.Windows.Forms.ComboBox();
this.ModelsTreeView = new CodeWalker.WinForms.TreeViewFix(); this.ModelsTreeView = new CodeWalker.WinForms.TreeViewFix();
this.ToolsMaterialsTabPage = new System.Windows.Forms.TabPage(); this.ToolsMaterialsTabPage = new System.Windows.Forms.TabPage();
this.TextureViewerButton = new System.Windows.Forms.Button(); this.TextureEditorButton = new System.Windows.Forms.Button();
this.TexturesTreeView = new CodeWalker.WinForms.TreeViewFix(); this.TexturesTreeView = new CodeWalker.WinForms.TreeViewFix();
this.MaterialEditorButton = new System.Windows.Forms.Button();
this.ToolsDetailsTabPage = new System.Windows.Forms.TabPage(); this.ToolsDetailsTabPage = new System.Windows.Forms.TabPage();
this.DetailsPropertyGrid = new CodeWalker.WinForms.ReadOnlyPropertyGrid(); this.DetailsPropertyGrid = new CodeWalker.WinForms.ReadOnlyPropertyGrid();
this.ToolsOptionsTabPage = new System.Windows.Forms.TabPage(); this.ToolsOptionsTabPage = new System.Windows.Forms.TabPage();
this.OptionsTabControl = new System.Windows.Forms.TabControl(); this.OptionsTabControl = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage(); this.OptionsRenderTabPage = new System.Windows.Forms.TabPage();
this.RenderModeComboBox = new System.Windows.Forms.ComboBox(); this.RenderModeComboBox = new System.Windows.Forms.ComboBox();
this.FragGlassCheckBox = new System.Windows.Forms.CheckBox(); this.FragGlassCheckBox = new System.Windows.Forms.CheckBox();
this.label14 = new System.Windows.Forms.Label(); this.label14 = new System.Windows.Forms.Label();
@ -78,8 +87,9 @@
this.GridSizeComboBox = new System.Windows.Forms.ComboBox(); this.GridSizeComboBox = new System.Windows.Forms.ComboBox();
this.StatusBarCheckBox = new System.Windows.Forms.CheckBox(); this.StatusBarCheckBox = new System.Windows.Forms.CheckBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.tabPage2 = new System.Windows.Forms.TabPage(); this.OptionsLightingTabPage = new System.Windows.Forms.TabPage();
this.DeferredShadingCheckBox = new System.Windows.Forms.CheckBox(); this.DeferredShadingCheckBox = new System.Windows.Forms.CheckBox();
this.LightEditorButton = new System.Windows.Forms.Button();
this.HDLightsCheckBox = new System.Windows.Forms.CheckBox(); this.HDLightsCheckBox = new System.Windows.Forms.CheckBox();
this.label19 = new System.Windows.Forms.Label(); this.label19 = new System.Windows.Forms.Label();
this.HDRRenderingCheckBox = new System.Windows.Forms.CheckBox(); this.HDRRenderingCheckBox = new System.Windows.Forms.CheckBox();
@ -88,9 +98,6 @@
this.ControlLightDirCheckBox = new System.Windows.Forms.CheckBox(); this.ControlLightDirCheckBox = new System.Windows.Forms.CheckBox();
this.SkydomeCheckBox = new System.Windows.Forms.CheckBox(); this.SkydomeCheckBox = new System.Windows.Forms.CheckBox();
this.TimeOfDayLabel = new System.Windows.Forms.Label(); this.TimeOfDayLabel = new System.Windows.Forms.Label();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.LightEditorButton = new System.Windows.Forms.Button();
this.MaterialEditorButton = new System.Windows.Forms.Button();
this.ToolsPanelHideButton = new System.Windows.Forms.Button(); this.ToolsPanelHideButton = new System.Windows.Forms.Button();
this.ToolsDragPanel = new System.Windows.Forms.Panel(); this.ToolsDragPanel = new System.Windows.Forms.Panel();
this.ToolsPanelShowButton = new System.Windows.Forms.Button(); this.ToolsPanelShowButton = new System.Windows.Forms.Button();
@ -106,10 +113,9 @@
this.ToolsDetailsTabPage.SuspendLayout(); this.ToolsDetailsTabPage.SuspendLayout();
this.ToolsOptionsTabPage.SuspendLayout(); this.ToolsOptionsTabPage.SuspendLayout();
this.OptionsTabControl.SuspendLayout(); this.OptionsTabControl.SuspendLayout();
this.tabPage1.SuspendLayout(); this.OptionsRenderTabPage.SuspendLayout();
this.tabPage2.SuspendLayout(); this.OptionsLightingTabPage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).BeginInit();
this.tabPage3.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// StatsUpdateTimer // StatsUpdateTimer
@ -195,27 +201,110 @@
// //
// MainToolbarPanel // MainToolbarPanel
// //
this.MainToolbarPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.MainToolbarPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainToolbarPanel.BackColor = System.Drawing.SystemColors.ControlDark; this.MainToolbarPanel.BackColor = System.Drawing.SystemColors.ControlDark;
this.MainToolbarPanel.Controls.Add(this.MainToolbar); this.MainToolbarPanel.Controls.Add(this.MainToolbar);
this.MainToolbarPanel.Location = new System.Drawing.Point(193, 2); this.MainToolbarPanel.Location = new System.Drawing.Point(39, 2);
this.MainToolbarPanel.Name = "MainToolbarPanel"; this.MainToolbarPanel.Name = "MainToolbarPanel";
this.MainToolbarPanel.Size = new System.Drawing.Size(34, 24); this.MainToolbarPanel.Size = new System.Drawing.Size(188, 24);
this.MainToolbarPanel.TabIndex = 4; this.MainToolbarPanel.TabIndex = 4;
// //
// MainToolbar // MainToolbar
// //
this.MainToolbar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.MainToolbar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
this.MainToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.MainToolbar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolbarMaterialEditorButton,
this.ToolbarTextureEditorButton,
this.ToolbarLightEditorButton,
this.toolStripSeparator1,
this.ToolbarMoveButton,
this.ToolbarRotateButton,
this.ToolbarScaleButton,
this.toolStripSeparator2,
this.SaveButton}); this.SaveButton});
this.MainToolbar.Location = new System.Drawing.Point(0, 0); this.MainToolbar.Location = new System.Drawing.Point(0, 0);
this.MainToolbar.Name = "MainToolbar"; this.MainToolbar.Name = "MainToolbar";
this.MainToolbar.Size = new System.Drawing.Size(34, 25); this.MainToolbar.Size = new System.Drawing.Size(188, 25);
this.MainToolbar.TabIndex = 7; this.MainToolbar.TabIndex = 7;
this.MainToolbar.Text = "Main Toolbar"; this.MainToolbar.Text = "Main Toolbar";
// //
// ToolbarMaterialEditorButton
//
this.ToolbarMaterialEditorButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ToolbarMaterialEditorButton.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarMaterialEditorButton.Image")));
this.ToolbarMaterialEditorButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ToolbarMaterialEditorButton.Name = "ToolbarMaterialEditorButton";
this.ToolbarMaterialEditorButton.Size = new System.Drawing.Size(23, 22);
this.ToolbarMaterialEditorButton.Text = "Material Editor";
this.ToolbarMaterialEditorButton.Click += new System.EventHandler(this.ToolbarMaterialEditorButton_Click);
//
// ToolbarTextureEditorButton
//
this.ToolbarTextureEditorButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ToolbarTextureEditorButton.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarTextureEditorButton.Image")));
this.ToolbarTextureEditorButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ToolbarTextureEditorButton.Name = "ToolbarTextureEditorButton";
this.ToolbarTextureEditorButton.Size = new System.Drawing.Size(23, 22);
this.ToolbarTextureEditorButton.Text = "Texture Editor";
this.ToolbarTextureEditorButton.Click += new System.EventHandler(this.ToolbarTextureEditorButton_Click);
//
// ToolbarLightEditorButton
//
this.ToolbarLightEditorButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ToolbarLightEditorButton.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarLightEditorButton.Image")));
this.ToolbarLightEditorButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ToolbarLightEditorButton.Name = "ToolbarLightEditorButton";
this.ToolbarLightEditorButton.Size = new System.Drawing.Size(23, 22);
this.ToolbarLightEditorButton.Text = "Light Editor";
this.ToolbarLightEditorButton.Click += new System.EventHandler(this.ToolbarLightEditorButton_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25);
//
// ToolbarMoveButton
//
this.ToolbarMoveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ToolbarMoveButton.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarMoveButton.Image")));
this.ToolbarMoveButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ToolbarMoveButton.Name = "ToolbarMoveButton";
this.ToolbarMoveButton.Size = new System.Drawing.Size(23, 22);
this.ToolbarMoveButton.Text = "Move";
this.ToolbarMoveButton.ToolTipText = "Move";
this.ToolbarMoveButton.Click += new System.EventHandler(this.ToolbarMoveButton_Click);
//
// ToolbarRotateButton
//
this.ToolbarRotateButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ToolbarRotateButton.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarRotateButton.Image")));
this.ToolbarRotateButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ToolbarRotateButton.Name = "ToolbarRotateButton";
this.ToolbarRotateButton.Size = new System.Drawing.Size(23, 22);
this.ToolbarRotateButton.Text = "Rotate";
this.ToolbarRotateButton.ToolTipText = "Rotate";
this.ToolbarRotateButton.Click += new System.EventHandler(this.ToolbarRotateButton_Click);
//
// ToolbarScaleButton
//
this.ToolbarScaleButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.ToolbarScaleButton.Image = ((System.Drawing.Image)(resources.GetObject("ToolbarScaleButton.Image")));
this.ToolbarScaleButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.ToolbarScaleButton.Name = "ToolbarScaleButton";
this.ToolbarScaleButton.Size = new System.Drawing.Size(23, 22);
this.ToolbarScaleButton.Text = "Scale";
this.ToolbarScaleButton.ToolTipText = "Scale";
this.ToolbarScaleButton.Click += new System.EventHandler(this.ToolbarScaleButton_Click);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25);
//
// SaveButton // SaveButton
// //
this.SaveButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
this.SaveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.SaveButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.SaveButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.SaveButton.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.SaveMenuButton, this.SaveMenuButton,
@ -223,7 +312,7 @@
this.SaveButton.Image = ((System.Drawing.Image)(resources.GetObject("SaveButton.Image"))); this.SaveButton.Image = ((System.Drawing.Image)(resources.GetObject("SaveButton.Image")));
this.SaveButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.SaveButton.ImageTransparentColor = System.Drawing.Color.Magenta;
this.SaveButton.Name = "SaveButton"; this.SaveButton.Name = "SaveButton";
this.SaveButton.Size = new System.Drawing.Size(32, 22); this.SaveButton.Size = new System.Drawing.Size(32, 20);
this.SaveButton.Text = "Save"; this.SaveButton.Text = "Save";
this.SaveButton.ButtonClick += new System.EventHandler(this.SaveButton_ButtonClick); this.SaveButton.ButtonClick += new System.EventHandler(this.SaveButton_ButtonClick);
// //
@ -349,8 +438,9 @@
// //
// ToolsMaterialsTabPage // ToolsMaterialsTabPage
// //
this.ToolsMaterialsTabPage.Controls.Add(this.TextureViewerButton); this.ToolsMaterialsTabPage.Controls.Add(this.TextureEditorButton);
this.ToolsMaterialsTabPage.Controls.Add(this.TexturesTreeView); this.ToolsMaterialsTabPage.Controls.Add(this.TexturesTreeView);
this.ToolsMaterialsTabPage.Controls.Add(this.MaterialEditorButton);
this.ToolsMaterialsTabPage.Location = new System.Drawing.Point(4, 22); this.ToolsMaterialsTabPage.Location = new System.Drawing.Point(4, 22);
this.ToolsMaterialsTabPage.Name = "ToolsMaterialsTabPage"; this.ToolsMaterialsTabPage.Name = "ToolsMaterialsTabPage";
this.ToolsMaterialsTabPage.Padding = new System.Windows.Forms.Padding(3); this.ToolsMaterialsTabPage.Padding = new System.Windows.Forms.Padding(3);
@ -359,27 +449,37 @@
this.ToolsMaterialsTabPage.Text = "Materials"; this.ToolsMaterialsTabPage.Text = "Materials";
this.ToolsMaterialsTabPage.UseVisualStyleBackColor = true; this.ToolsMaterialsTabPage.UseVisualStyleBackColor = true;
// //
// TextureViewerButton // TextureEditorButton
// //
this.TextureViewerButton.Location = new System.Drawing.Point(111, 6); this.TextureEditorButton.Location = new System.Drawing.Point(111, 3);
this.TextureViewerButton.Name = "TextureViewerButton"; this.TextureEditorButton.Name = "TextureEditorButton";
this.TextureViewerButton.Size = new System.Drawing.Size(91, 23); this.TextureEditorButton.Size = new System.Drawing.Size(100, 23);
this.TextureViewerButton.TabIndex = 2; this.TextureEditorButton.TabIndex = 2;
this.TextureViewerButton.Text = "Texture viewer"; this.TextureEditorButton.Text = "Texture editor...";
this.TextureViewerButton.UseVisualStyleBackColor = true; this.TextureEditorButton.UseVisualStyleBackColor = true;
this.TextureViewerButton.Click += new System.EventHandler(this.TextureViewerButton_Click); this.TextureEditorButton.Click += new System.EventHandler(this.TextureEditorButton_Click);
// //
// TexturesTreeView // TexturesTreeView
// //
this.TexturesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.TexturesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.TexturesTreeView.Location = new System.Drawing.Point(0, 34); this.TexturesTreeView.Location = new System.Drawing.Point(0, 32);
this.TexturesTreeView.Name = "TexturesTreeView"; this.TexturesTreeView.Name = "TexturesTreeView";
this.TexturesTreeView.ShowRootLines = false; this.TexturesTreeView.ShowRootLines = false;
this.TexturesTreeView.Size = new System.Drawing.Size(205, 466); this.TexturesTreeView.Size = new System.Drawing.Size(217, 468);
this.TexturesTreeView.TabIndex = 1; this.TexturesTreeView.TabIndex = 1;
// //
// MaterialEditorButton
//
this.MaterialEditorButton.Location = new System.Drawing.Point(6, 3);
this.MaterialEditorButton.Name = "MaterialEditorButton";
this.MaterialEditorButton.Size = new System.Drawing.Size(100, 23);
this.MaterialEditorButton.TabIndex = 3;
this.MaterialEditorButton.Text = "Material editor...";
this.MaterialEditorButton.UseVisualStyleBackColor = true;
this.MaterialEditorButton.Click += new System.EventHandler(this.MaterialEditorButton_Click);
//
// ToolsDetailsTabPage // ToolsDetailsTabPage
// //
this.ToolsDetailsTabPage.Controls.Add(this.DetailsPropertyGrid); this.ToolsDetailsTabPage.Controls.Add(this.DetailsPropertyGrid);
@ -400,7 +500,7 @@
this.DetailsPropertyGrid.Name = "DetailsPropertyGrid"; this.DetailsPropertyGrid.Name = "DetailsPropertyGrid";
this.DetailsPropertyGrid.PropertySort = System.Windows.Forms.PropertySort.NoSort; this.DetailsPropertyGrid.PropertySort = System.Windows.Forms.PropertySort.NoSort;
this.DetailsPropertyGrid.ReadOnly = true; this.DetailsPropertyGrid.ReadOnly = true;
this.DetailsPropertyGrid.Size = new System.Drawing.Size(205, 497); this.DetailsPropertyGrid.Size = new System.Drawing.Size(217, 497);
this.DetailsPropertyGrid.TabIndex = 1; this.DetailsPropertyGrid.TabIndex = 1;
this.DetailsPropertyGrid.ToolbarVisible = false; this.DetailsPropertyGrid.ToolbarVisible = false;
// //
@ -416,9 +516,8 @@
// //
// OptionsTabControl // OptionsTabControl
// //
this.OptionsTabControl.Controls.Add(this.tabPage1); this.OptionsTabControl.Controls.Add(this.OptionsRenderTabPage);
this.OptionsTabControl.Controls.Add(this.tabPage2); this.OptionsTabControl.Controls.Add(this.OptionsLightingTabPage);
this.OptionsTabControl.Controls.Add(this.tabPage3);
this.OptionsTabControl.Dock = System.Windows.Forms.DockStyle.Fill; this.OptionsTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.OptionsTabControl.Location = new System.Drawing.Point(0, 0); this.OptionsTabControl.Location = new System.Drawing.Point(0, 0);
this.OptionsTabControl.Name = "OptionsTabControl"; this.OptionsTabControl.Name = "OptionsTabControl";
@ -426,34 +525,34 @@
this.OptionsTabControl.Size = new System.Drawing.Size(217, 500); this.OptionsTabControl.Size = new System.Drawing.Size(217, 500);
this.OptionsTabControl.TabIndex = 26; this.OptionsTabControl.TabIndex = 26;
// //
// tabPage1 // OptionsRenderTabPage
// //
this.tabPage1.Controls.Add(this.RenderModeComboBox); this.OptionsRenderTabPage.Controls.Add(this.RenderModeComboBox);
this.tabPage1.Controls.Add(this.FragGlassCheckBox); this.OptionsRenderTabPage.Controls.Add(this.FragGlassCheckBox);
this.tabPage1.Controls.Add(this.label14); this.OptionsRenderTabPage.Controls.Add(this.label14);
this.tabPage1.Controls.Add(this.HDTexturesCheckBox); this.OptionsRenderTabPage.Controls.Add(this.HDTexturesCheckBox);
this.tabPage1.Controls.Add(this.AnisotropicFilteringCheckBox); this.OptionsRenderTabPage.Controls.Add(this.AnisotropicFilteringCheckBox);
this.tabPage1.Controls.Add(this.SkeletonsCheckBox); this.OptionsRenderTabPage.Controls.Add(this.SkeletonsCheckBox);
this.tabPage1.Controls.Add(this.label10); this.OptionsRenderTabPage.Controls.Add(this.label10);
this.tabPage1.Controls.Add(this.TextureCoordsComboBox); this.OptionsRenderTabPage.Controls.Add(this.TextureCoordsComboBox);
this.tabPage1.Controls.Add(this.TextureSamplerComboBox); this.OptionsRenderTabPage.Controls.Add(this.TextureSamplerComboBox);
this.tabPage1.Controls.Add(this.label11); this.OptionsRenderTabPage.Controls.Add(this.label11);
this.tabPage1.Controls.Add(this.WireframeCheckBox); this.OptionsRenderTabPage.Controls.Add(this.WireframeCheckBox);
this.tabPage1.Controls.Add(this.ShowCollisionMeshesCheckBox); this.OptionsRenderTabPage.Controls.Add(this.ShowCollisionMeshesCheckBox);
this.tabPage1.Controls.Add(this.GridCheckBox); this.OptionsRenderTabPage.Controls.Add(this.GridCheckBox);
this.tabPage1.Controls.Add(this.GridCountComboBox); this.OptionsRenderTabPage.Controls.Add(this.GridCountComboBox);
this.tabPage1.Controls.Add(this.label2); this.OptionsRenderTabPage.Controls.Add(this.label2);
this.tabPage1.Controls.Add(this.ErrorConsoleCheckBox); this.OptionsRenderTabPage.Controls.Add(this.ErrorConsoleCheckBox);
this.tabPage1.Controls.Add(this.GridSizeComboBox); this.OptionsRenderTabPage.Controls.Add(this.GridSizeComboBox);
this.tabPage1.Controls.Add(this.StatusBarCheckBox); this.OptionsRenderTabPage.Controls.Add(this.StatusBarCheckBox);
this.tabPage1.Controls.Add(this.label1); this.OptionsRenderTabPage.Controls.Add(this.label1);
this.tabPage1.Location = new System.Drawing.Point(4, 22); this.OptionsRenderTabPage.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1"; this.OptionsRenderTabPage.Name = "OptionsRenderTabPage";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3); this.OptionsRenderTabPage.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(209, 474); this.OptionsRenderTabPage.Size = new System.Drawing.Size(209, 474);
this.tabPage1.TabIndex = 0; this.OptionsRenderTabPage.TabIndex = 0;
this.tabPage1.Text = "Render"; this.OptionsRenderTabPage.Text = "Render";
this.tabPage1.UseVisualStyleBackColor = true; this.OptionsRenderTabPage.UseVisualStyleBackColor = true;
// //
// RenderModeComboBox // RenderModeComboBox
// //
@ -681,24 +780,25 @@
this.label1.TabIndex = 18; this.label1.TabIndex = 18;
this.label1.Text = "Grid unit size:"; this.label1.Text = "Grid unit size:";
// //
// tabPage2 // OptionsLightingTabPage
// //
this.tabPage2.Controls.Add(this.DeferredShadingCheckBox); this.OptionsLightingTabPage.Controls.Add(this.DeferredShadingCheckBox);
this.tabPage2.Controls.Add(this.HDLightsCheckBox); this.OptionsLightingTabPage.Controls.Add(this.LightEditorButton);
this.tabPage2.Controls.Add(this.label19); this.OptionsLightingTabPage.Controls.Add(this.HDLightsCheckBox);
this.tabPage2.Controls.Add(this.HDRRenderingCheckBox); this.OptionsLightingTabPage.Controls.Add(this.label19);
this.tabPage2.Controls.Add(this.TimeOfDayTrackBar); this.OptionsLightingTabPage.Controls.Add(this.HDRRenderingCheckBox);
this.tabPage2.Controls.Add(this.ShadowsCheckBox); this.OptionsLightingTabPage.Controls.Add(this.TimeOfDayTrackBar);
this.tabPage2.Controls.Add(this.ControlLightDirCheckBox); this.OptionsLightingTabPage.Controls.Add(this.ShadowsCheckBox);
this.tabPage2.Controls.Add(this.SkydomeCheckBox); this.OptionsLightingTabPage.Controls.Add(this.ControlLightDirCheckBox);
this.tabPage2.Controls.Add(this.TimeOfDayLabel); this.OptionsLightingTabPage.Controls.Add(this.SkydomeCheckBox);
this.tabPage2.Location = new System.Drawing.Point(4, 22); this.OptionsLightingTabPage.Controls.Add(this.TimeOfDayLabel);
this.tabPage2.Name = "tabPage2"; this.OptionsLightingTabPage.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Padding = new System.Windows.Forms.Padding(3); this.OptionsLightingTabPage.Name = "OptionsLightingTabPage";
this.tabPage2.Size = new System.Drawing.Size(209, 474); this.OptionsLightingTabPage.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.TabIndex = 1; this.OptionsLightingTabPage.Size = new System.Drawing.Size(209, 474);
this.tabPage2.Text = "Lighting"; this.OptionsLightingTabPage.TabIndex = 1;
this.tabPage2.UseVisualStyleBackColor = true; this.OptionsLightingTabPage.Text = "Lighting";
this.OptionsLightingTabPage.UseVisualStyleBackColor = true;
// //
// DeferredShadingCheckBox // DeferredShadingCheckBox
// //
@ -711,6 +811,16 @@
this.DeferredShadingCheckBox.UseVisualStyleBackColor = true; this.DeferredShadingCheckBox.UseVisualStyleBackColor = true;
this.DeferredShadingCheckBox.CheckedChanged += new System.EventHandler(this.DeferredShadingCheckBox_CheckedChanged); this.DeferredShadingCheckBox.CheckedChanged += new System.EventHandler(this.DeferredShadingCheckBox_CheckedChanged);
// //
// LightEditorButton
//
this.LightEditorButton.Location = new System.Drawing.Point(7, 214);
this.LightEditorButton.Name = "LightEditorButton";
this.LightEditorButton.Size = new System.Drawing.Size(90, 23);
this.LightEditorButton.TabIndex = 37;
this.LightEditorButton.Text = "Light editor...";
this.LightEditorButton.UseVisualStyleBackColor = true;
this.LightEditorButton.Click += new System.EventHandler(this.LightEditorButton_Click);
//
// HDLightsCheckBox // HDLightsCheckBox
// //
this.HDLightsCheckBox.AutoSize = true; this.HDLightsCheckBox.AutoSize = true;
@ -788,6 +898,8 @@
// SkydomeCheckBox // SkydomeCheckBox
// //
this.SkydomeCheckBox.AutoSize = true; this.SkydomeCheckBox.AutoSize = true;
this.SkydomeCheckBox.Checked = true;
this.SkydomeCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.SkydomeCheckBox.Location = new System.Drawing.Point(7, 75); this.SkydomeCheckBox.Location = new System.Drawing.Point(7, 75);
this.SkydomeCheckBox.Name = "SkydomeCheckBox"; this.SkydomeCheckBox.Name = "SkydomeCheckBox";
this.SkydomeCheckBox.Size = new System.Drawing.Size(70, 17); this.SkydomeCheckBox.Size = new System.Drawing.Size(70, 17);
@ -805,38 +917,6 @@
this.TimeOfDayLabel.TabIndex = 5; this.TimeOfDayLabel.TabIndex = 5;
this.TimeOfDayLabel.Text = "12:00"; this.TimeOfDayLabel.Text = "12:00";
// //
// tabPage3
//
this.tabPage3.Controls.Add(this.LightEditorButton);
this.tabPage3.Controls.Add(this.MaterialEditorButton);
this.tabPage3.Location = new System.Drawing.Point(4, 22);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(209, 474);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "Editors";
this.tabPage3.UseVisualStyleBackColor = true;
//
// LightEditorButton
//
this.LightEditorButton.Location = new System.Drawing.Point(6, 35);
this.LightEditorButton.Name = "LightEditorButton";
this.LightEditorButton.Size = new System.Drawing.Size(197, 23);
this.LightEditorButton.TabIndex = 37;
this.LightEditorButton.Text = "Light editor";
this.LightEditorButton.UseVisualStyleBackColor = true;
this.LightEditorButton.Click += new System.EventHandler(this.LightEditorButton_Click);
//
// MaterialEditorButton
//
this.MaterialEditorButton.Location = new System.Drawing.Point(6, 6);
this.MaterialEditorButton.Name = "MaterialEditorButton";
this.MaterialEditorButton.Size = new System.Drawing.Size(197, 23);
this.MaterialEditorButton.TabIndex = 3;
this.MaterialEditorButton.Text = "Material editor";
this.MaterialEditorButton.UseVisualStyleBackColor = true;
this.MaterialEditorButton.Click += new System.EventHandler(this.MaterialEditorButton_Click);
//
// ToolsPanelHideButton // ToolsPanelHideButton
// //
this.ToolsPanelHideButton.Location = new System.Drawing.Point(3, 3); this.ToolsPanelHideButton.Location = new System.Drawing.Point(3, 3);
@ -911,12 +991,11 @@
this.ToolsDetailsTabPage.ResumeLayout(false); this.ToolsDetailsTabPage.ResumeLayout(false);
this.ToolsOptionsTabPage.ResumeLayout(false); this.ToolsOptionsTabPage.ResumeLayout(false);
this.OptionsTabControl.ResumeLayout(false); this.OptionsTabControl.ResumeLayout(false);
this.tabPage1.ResumeLayout(false); this.OptionsRenderTabPage.ResumeLayout(false);
this.tabPage1.PerformLayout(); this.OptionsRenderTabPage.PerformLayout();
this.tabPage2.ResumeLayout(false); this.OptionsLightingTabPage.ResumeLayout(false);
this.tabPage2.PerformLayout(); this.OptionsLightingTabPage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).EndInit();
this.tabPage3.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -967,7 +1046,7 @@
private System.Windows.Forms.Label label19; private System.Windows.Forms.Label label19;
private System.Windows.Forms.TrackBar TimeOfDayTrackBar; private System.Windows.Forms.TrackBar TimeOfDayTrackBar;
private System.Windows.Forms.CheckBox SkeletonsCheckBox; private System.Windows.Forms.CheckBox SkeletonsCheckBox;
private System.Windows.Forms.Button TextureViewerButton; private System.Windows.Forms.Button TextureEditorButton;
private System.Windows.Forms.CheckBox HDTexturesCheckBox; private System.Windows.Forms.CheckBox HDTexturesCheckBox;
private System.Windows.Forms.Button MaterialEditorButton; private System.Windows.Forms.Button MaterialEditorButton;
private System.Windows.Forms.Panel MainToolbarPanel; private System.Windows.Forms.Panel MainToolbarPanel;
@ -983,11 +1062,18 @@
private System.Windows.Forms.ComboBox ClipDictComboBox; private System.Windows.Forms.ComboBox ClipDictComboBox;
private System.Windows.Forms.CheckBox FragGlassCheckBox; private System.Windows.Forms.CheckBox FragGlassCheckBox;
private System.Windows.Forms.TabControl OptionsTabControl; private System.Windows.Forms.TabControl OptionsTabControl;
private System.Windows.Forms.TabPage tabPage1; private System.Windows.Forms.TabPage OptionsRenderTabPage;
private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage OptionsLightingTabPage;
private System.Windows.Forms.CheckBox HDLightsCheckBox; private System.Windows.Forms.CheckBox HDLightsCheckBox;
private System.Windows.Forms.CheckBox DeferredShadingCheckBox; private System.Windows.Forms.CheckBox DeferredShadingCheckBox;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.Button LightEditorButton; private System.Windows.Forms.Button LightEditorButton;
private System.Windows.Forms.ToolStripButton ToolbarMaterialEditorButton;
private System.Windows.Forms.ToolStripButton ToolbarTextureEditorButton;
private System.Windows.Forms.ToolStripButton ToolbarLightEditorButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripButton ToolbarMoveButton;
private System.Windows.Forms.ToolStripButton ToolbarRotateButton;
private System.Windows.Forms.ToolStripButton ToolbarScaleButton;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
} }
} }

View File

@ -176,9 +176,11 @@ namespace CodeWalker.Forms
Widget.Position = new Vector3(0f, 0f, 0f); Widget.Position = new Vector3(0f, 0f, 0f);
Widget.Rotation = Quaternion.Identity; Widget.Rotation = Quaternion.Identity;
Widget.Scale = Vector3.One; Widget.Scale = Vector3.One;
Widget.SnapAngleDegrees = 0;
Widget.Visible = false; Widget.Visible = false;
Widget.OnPositionChange += Widget_OnPositionChange; Widget.OnPositionChange += Widget_OnPositionChange;
Widget.OnRotationChange += Widget_OnRotationChange; Widget.OnRotationChange += Widget_OnRotationChange;
Widget.OnScaleChange += Widget_OnScaleChange;
ShaderParamNames[] texsamplers = RenderableGeometry.GetTextureSamplerList(); ShaderParamNames[] texsamplers = RenderableGeometry.GetTextureSamplerList();
foreach (var texsampler in texsamplers) foreach (var texsampler in texsamplers)
@ -568,50 +570,24 @@ namespace CodeWalker.Forms
{ {
Widget.Update(camera); Widget.Update(camera);
} }
public void UpdateWidget(bool rotate = false) public void SetWidgetTransform(Vector3 p, Quaternion q, Vector3 s)
{ {
if(selectedLight != null) Widget.Position = p;
{
if (!rotate)
{
SetWidgetPosition(selectedLight.Position);
}
else
{
SetWidgetRotation(selectedLight.GetRotation());
}
}
}
public void SetWidgetPosition(Vector3 pos)
{
SetWidgetMode("Position");
Widget.Position = pos;
}
public void SetWidgetRotation(Quaternion q)
{
SetWidgetMode("Rotation");
Widget.Rotation = q; Widget.Rotation = q;
Widget.Scale = s;
} }
public void SetWidgetMode(string mode) public void SetWidgetMode(WidgetMode mode)
{ {
lock (Renderer.RenderSyncRoot) lock (Renderer.RenderSyncRoot)
{ {
switch (mode) Widget.Mode = mode;
{
case "Default":
Widget.Mode = WidgetMode.Default;
break;
case "Position":
Widget.Mode = WidgetMode.Position;
break;
case "Rotation":
Widget.Mode = WidgetMode.Rotation;
break;
case "Scale":
Widget.Mode = WidgetMode.Scale;
break;
}
} }
ToolbarMoveButton.Checked = (mode == WidgetMode.Position);
ToolbarRotateButton.Checked = (mode == WidgetMode.Rotation);
ToolbarScaleButton.Checked = (mode == WidgetMode.Scale);
lightForm?.SetWidgetModeUI(mode);
} }
private void Widget_OnPositionChange(Vector3 newpos, Vector3 oldpos) private void Widget_OnPositionChange(Vector3 newpos, Vector3 oldpos)
{ {
@ -619,15 +595,23 @@ namespace CodeWalker.Forms
if (newpos == oldpos) return; if (newpos == oldpos) return;
if (selectedLight == null || lightForm == null || !editingLights) return; if (selectedLight == null || lightForm == null || !editingLights) return;
selectedLight.Position = newpos; selectedLight.Position = newpos;
selectedLight.HasChanged = true; selectedLight.UpdateRenderable = true;
} }
private void Widget_OnRotationChange(Quaternion newrot, Quaternion oldrot) private void Widget_OnRotationChange(Quaternion newrot, Quaternion oldrot)
{ {
//called during UpdateWidgets() //called during UpdateWidgets()
if (newrot == oldrot) return; if (newrot == oldrot) return;
if (selectedLight == null || lightForm == null || !editingLights) return; if (selectedLight == null || lightForm == null || !editingLights) return;
selectedLight.SetRotation(newrot); selectedLight.Orientation = newrot;
selectedLight.HasChanged = true; selectedLight.UpdateRenderable = true;
}
private void Widget_OnScaleChange(Vector3 newscale, Vector3 oldscale)
{
//called during UpdateWidgets()
if (newscale == oldscale) return;
if (selectedLight == null || lightForm == null || !editingLights) return;
selectedLight.Falloff = newscale.Z;
selectedLight.UpdateRenderable = true;
} }
@ -2053,7 +2037,7 @@ namespace CodeWalker.Forms
StatusStrip.Visible = StatusBarCheckBox.Checked; StatusStrip.Visible = StatusBarCheckBox.Checked;
} }
private void TextureViewerButton_Click(object sender, EventArgs e) private void TextureEditorButton_Click(object sender, EventArgs e)
{ {
TextureDictionary td = null; TextureDictionary td = null;
@ -2189,6 +2173,7 @@ namespace CodeWalker.Forms
} }
lightForm.Focus(); lightForm.Focus();
} }
DeferredShadingCheckBox.Checked = true; //make sure we can see the lights we're editing (maybe this is bad for potatoes but meh)
} }
private void SaveButton_ButtonClick(object sender, EventArgs e) private void SaveButton_ButtonClick(object sender, EventArgs e)
@ -2230,5 +2215,35 @@ namespace CodeWalker.Forms
{ {
Renderer.renderlights = HDLightsCheckBox.Checked; Renderer.renderlights = HDLightsCheckBox.Checked;
} }
private void ToolbarMaterialEditorButton_Click(object sender, EventArgs e)
{
MaterialEditorButton_Click(sender, e);
}
private void ToolbarTextureEditorButton_Click(object sender, EventArgs e)
{
TextureEditorButton_Click(sender, e);
}
private void ToolbarLightEditorButton_Click(object sender, EventArgs e)
{
LightEditorButton_Click(sender, e);
}
private void ToolbarMoveButton_Click(object sender, EventArgs e)
{
SetWidgetMode(ToolbarMoveButton.Checked ? WidgetMode.Default : WidgetMode.Position);
}
private void ToolbarRotateButton_Click(object sender, EventArgs e)
{
SetWidgetMode(ToolbarRotateButton.Checked ? WidgetMode.Default : WidgetMode.Rotation);
}
private void ToolbarScaleButton_Click(object sender, EventArgs e)
{
SetWidgetMode(ToolbarScaleButton.Checked ? WidgetMode.Default : WidgetMode.Scale);
}
} }
} }

View File

@ -126,11 +126,75 @@
<metadata name="MainToolbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="MainToolbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>276, 17</value> <value>276, 17</value>
</metadata> </metadata>
<metadata name="MainToolbar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>276, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="SaveButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="ToolbarMaterialEditorButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKmSURBVDhPjVPbTlpREOUL+jn8gIn3xHiPEW8YNHIIKiJq
rKAiQUtVij2aoqA0Ira1SSWRi1a8Ja0WqtZL40MrDaXxwfqoDz64emZA09Y+dJLJSfaZWbPWmr1lf8fl
5aX86urKKX3jUl6nM54+k6fL7sfNzc0DqcB78fMC0WgUS0sBzPvmMT09A8+MB8FgCGdnZ6Aaqk23pYIO
pAk7Jycn3Ph2ZRWrqxEEAyEsLLyGy+XGyMgo+vv7sbW5Bar9A4RQj48/w7/ox+bGFvZ29/Fp/wDb2zsI
h8LwSUzGxycwMGCBXq9HJBJhJrfN8vPzc6YbCoYRi8YQP/2GZPIHDg+PsL6+wSycz5wYtA7CYDBAUAvS
/ySByGVkzlpkDd5ZLwNEP8Tw9cspvieSODyQANbW7wCsVisDNKga4Ha7SYqTGMRJ44xk1uIbP0/8GNvF
3t4+3r/bZtC5OR9EcZwltLXpUV9fD41GQwziBHA9NDTEGokF+bC8vMJGBiRDX71cgGvKheHhEfT0GKHV
alFTU4OSkhICuGYAk6kXtkc2TEggHs9zNm3e9wKzEuDk5BTs9icwm81obzegsbERFRUVKCgouAOIWywW
GI1GNsk+aof4VGTKY44x2GyPpfWZ0dHRCUEQUF1djaKiItTW1qYkkBGksaWlBV2dXTAZTTyNsq+3D93d
D3l1arWam0pLS5GXlweHw3FnopxWQtSamprQrG1Ga6sOOp2OQQVBA5VKxZOpOT8/Hzk5OUgkEqk1pu+C
NxwOo7Kykg2qq1NCqVTyxCpFFcrLy1FYWIjc3FxkZGTA7/dTc+oiUdxe5UAggLKyMhQXF3OSVjKLKGdm
ZiI7O5ubqfaf74FQiZooijydGrKysqBQKFhzmvb9x/R7kC4yR/r+x3OWyX4BFI2EuwQc/DwAAAAASUVO
RK5CYII=
</value>
</data>
<data name="ToolbarTextureEditorButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAC3SURBVDhPrZPREcIgEEQpxVqoxDpozhJSStQIfOK98+Jg
JMFJ3Blmsne7O3AQt0TO+RxjvKSUSr2o0TPZN6R5EuEQH7GEEIr3vlzHmy6+qdFDg9ZsL5h5nO7T27AM
mDkatB8hpNLYMtbcQgY1cy62tmVocTx4HcNpnbnHdSbiZfs/GVocrwb0hGv8fwE94RrXgMNDPHyNQLay
/yEBnqUU9j9lYCH7fqYanIvhiFCnPC9q9ExmcO4J1fij9+UBu9sAAAAASUVORK5CYII=
</value>
</data>
<data name="ToolbarLightEditorButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEcSURBVDhPnZI7boQwEIY5wh4hR8gRcpQcJQV9aqocJUdI
w0NAESGEEAhwwav0+iO2Fzksq+SXRtY8/n/GY3suhBCXeZ7flmURwzDIruskp/IlcV12DMiq8KttW5kk
iQzD0FoURbKua0Q+dPlv0AHynuiaFjmehLHdzq4xCXWacsM0Tc/c1RT2fS/VlazhQybHXtZ1fdHUHxDY
C0Aqy1JmWSaLongsANi0KYrjeBNJ03Q78YmTH8eR2EXTblAC7yxpP4URMLHTl0BVJT+rqrLFCDRNs/nE
eebD7gZa5DvPc9sV43XY/inZQC3o1f0Pp+/vgi4s1LXDzd8DBN/3rf1LwLW/CoggCLbunFrgSacfg6+t
fp/gJ6qd3OnueVecFABPrjJDigAAAABJRU5ErkJggg==
</value>
</data>
<data name="ToolbarMoveButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACrSURBVDhPpVJbDoAgDONInoHD8c9J/SH8Kl02rZORGJs0
DNaWh6YZWmtb730vpRwgaqxpew0255yFn0K82YeoLMYQXQY2Y0RPZU/YsSEAdbcrgNeU93X8nVUoYRww
00jIpLGkD0m24AnxrGbC+z8Ax7CQWquIVzQtxjHfo0cU2k429+bXl2AhRg7g4MH4rzSj7cY1eiqLgXQ2
cwh6Kovh34TN4bE9OGRtTukExpYH+BWfUFQAAAAASUVORK5CYII=
</value>
</data>
<data name="ToolbarRotateButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFRSURBVDhPfZMxboNAEEU5Qo6QI+QIET1SWncp6OmpUrm1
6JFSuuQGuKaioQ89xRYYKDfz1jt4TYhX+trRnz9/2Z0h+m9N0/Q1z7MFxJ5+vpZleRfx9ziOP03T2MPh
4EAMRw6Nl9+XkK+SvHDaMAy2KAobx/ED4Mj5L7oYY17WYiENApJd19k0Tf8YwJFDU5Ylu3iIiQQVBCKS
SZLYuq6dSIuJ4cihUY4rYbAKwzjPc3d3QLynIV4NjsfjQxJwIgg5NGg1dgacIHu7NdgDGoHxNTcDf7oz
oG17hUC/Mqi5X+F8Pjti20Z9VKCdQkvuwQBkWeaEcDwerdOdPAZoVO8MGIrwRE0I2r7vd2cCUENtdL1e
30Rs9GUBBhRvO6Dw9zfUumn0Jq32HIOtKdDZ4L9Yi8MlY/0phRUGahpOZGB+8iXPF7OOiXbB/0yV3P3j
poiiXxmvX1sw0rqWAAAAAElFTkSuQmCC
</value>
</data>
<data name="ToolbarScaleButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAB4SURBVDhP3ZC7DcAgDEQZKTMwHOvSIFriS7BlEB+HMic9
QJbvFThLUkpXzjkSpaeuzMPlEELx3jdsBauyCHBY6UWYPQI93KEljQD3jL6EGzN6x0bASyNYwkKU8Udm
gd6TMnIikDJyIqjVNz8T7FgKrAwFX6lVinM3aJ05lWDPRRcAAAAASUVORK5CYII=
</value>
</data>
<data name="SaveMenuButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABWSURBVDhPY6AK+Pbt238S8PsvX74YQLVCAEjCyckJjj+8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABWSURBVDhPY6AK+Pbt238S8PsvX74YQLVCAEjCyckJjj+8
@ -138,7 +202,7 @@
lQAAAABJRU5ErkJggg== lQAAAABJRU5ErkJggg==
</value> </value>
</data> </data>
<data name="SaveMenuButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="SaveButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABWSURBVDhPY6AK+Pbt238S8PsvX74YQLVCAEjCyckJjj+8 YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAABWSURBVDhPY6AK+Pbt238S8PsvX74YQLVCAEjCyckJjj+8

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
using CodeWalker.GameFiles; using CodeWalker.GameFiles;
using CodeWalker.World;
using SharpDX; using SharpDX;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -92,7 +93,7 @@ namespace CodeWalker.Forms
{ {
var tnc = LightsTreeView.Nodes; var tnc = LightsTreeView.Nodes;
var light = lights[mi]; var light = lights[mi];
string mprefix = "Light" + (mi + 1).ToString(); string mprefix = "Light" + (mi + 1).ToString() + " : " + light.Type.ToString();
var mnode = parent == null ? tnc.Add(mprefix) : parent.Nodes.Add(mprefix); var mnode = parent == null ? tnc.Add(mprefix) : parent.Nodes.Add(mprefix);
mnode.Tag = light; mnode.Tag = light;
mnode.Expand(); mnode.Expand();
@ -108,37 +109,40 @@ namespace CodeWalker.Forms
if(light == null) if(light == null)
{ {
DeleteLightButton.Enabled = false;
EditDeleteLightMenu.Enabled = false;
populatingui = true; populatingui = true;
PositionTextBox.Text = ""; PositionTextBox.Text = "";
DirectionTextBox.Text = ""; DirectionTextBox.Text = "";
TangentTextBox.Text = "";
TypeComboBox.SelectedItem = "Point"; TypeComboBox.SelectedItem = "Point";
ColourRUpDown.Value = 0; ColourRUpDown.Value = 0;
ColourGUpDown.Value = 0; ColourGUpDown.Value = 0;
ColourBUpDown.Value = 0; ColourBUpDown.Value = 0;
IntensityUpDown.Value = 0; IntensityTextBox.Text = "";
FlashinessTextBox.Text = ""; FlashinessUpDown.Value = 0;
BoneIDTextBox.Text = ""; BoneIDUpDown.Value = 0;
GroupIDTextBox.Text = ""; GroupIDUpDown.Value = 0;
FalloffTextBox.Text = ""; FalloffTextBox.Text = "";
FalloffExponentTextBox.Text = ""; FalloffExponentTextBox.Text = "";
InnerAngleUpDown.Value = 0; InnerAngleTextBox.Text = "";
OuterAngleUpDown.Value = 0; OuterAngleTextBox.Text = "";
CoronaSizeTextBox.Text = ""; CoronaSizeTextBox.Text = "";
CoronaIntensityUpDown.Value = 0; CoronaIntensityTextBox.Text = "";
ExtentTextBox.Text = ""; ExtentTextBox.Text = "";
ShadowBlurTextBox.Text = ""; ShadowBlurUpDown.Value = 0;
LightFadeDistanceTextBox.Text = ""; LightFadeDistanceUpDown.Value = 0;
CoronaZBiasTextBox.Text = ""; CoronaZBiasTextBox.Text = "";
HashTextBox.Text = ""; TextureHashTextBox.Text = "";
VolumeIntensityTextBox.Text = ""; VolumeIntensityTextBox.Text = "";
VolumeSizeScaleTextBox.Text = ""; VolumeSizeScaleTextBox.Text = "";
VolumeColorRUpDown.Value = 0; VolumeColorRUpDown.Value = 0;
VolumeColorGUpDown.Value = 0; VolumeColorGUpDown.Value = 0;
VolumeColorBUpDown.Value = 0; VolumeColorBUpDown.Value = 0;
VolumeOuterExponentTextBox.Text = ""; VolumeOuterExponentTextBox.Text = "";
ShadowFadeDistanceTextBox.Text = ""; ShadowFadeDistanceUpDown.Value = 0;
SpecularFadeDistanceTextBox.Text = ""; SpecularFadeDistanceUpDown.Value = 0;
VolumetricFadeDistanceTextBox.Text = ""; VolumetricFadeDistanceUpDown.Value = 0;
ShadowNearClipTextBox.Text = ""; ShadowNearClipTextBox.Text = "";
CullingPlaneNormalTextBox.Text = ""; CullingPlaneNormalTextBox.Text = "";
CullingPlaneOffsetTextBox.Text = ""; CullingPlaneOffsetTextBox.Text = "";
@ -147,29 +151,32 @@ namespace CodeWalker.Forms
} }
else else
{ {
DeleteLightButton.Enabled = true;
EditDeleteLightMenu.Enabled = true;
populatingui = true; populatingui = true;
PositionTextBox.Text = FloatUtil.GetVector3String(light.Position); PositionTextBox.Text = FloatUtil.GetVector3String(light.Position);
DirectionTextBox.Text = FloatUtil.GetVector3String(light.Direction); DirectionTextBox.Text = FloatUtil.GetVector3String(light.Direction);
TangentTextBox.Text = FloatUtil.GetVector3String(light.Tangent);
TypeComboBox.SelectedItem = light.Type.ToString(); TypeComboBox.SelectedItem = light.Type.ToString();
ColourRUpDown.Value = light.ColorR; ColourRUpDown.Value = light.ColorR;
ColourGUpDown.Value = light.ColorG; ColourGUpDown.Value = light.ColorG;
ColourBUpDown.Value = light.ColorB; ColourBUpDown.Value = light.ColorB;
ColourLabel.BackColor = System.Drawing.Color.FromArgb(light.ColorR, light.ColorG, light.ColorB); ColourLabel.BackColor = System.Drawing.Color.FromArgb(light.ColorR, light.ColorG, light.ColorB);
IntensityUpDown.Value = (decimal)light.Intensity > IntensityUpDown.Maximum ? IntensityUpDown.Maximum : (decimal)light.Intensity; IntensityTextBox.Text = FloatUtil.ToString(light.Intensity);
FlashinessTextBox.Text = FloatUtil.ToString(light.Flashiness); FlashinessUpDown.Value = light.Flashiness;
BoneIDTextBox.Text = FloatUtil.ToString(light.BoneId); BoneIDUpDown.Value = light.BoneId;
GroupIDTextBox.Text = FloatUtil.ToString(light.GroupId); GroupIDUpDown.Value = light.GroupId;
FalloffTextBox.Text = FloatUtil.ToString(light.Falloff); FalloffTextBox.Text = FloatUtil.ToString(light.Falloff);
FalloffExponentTextBox.Text = FloatUtil.ToString(light.FalloffExponent); FalloffExponentTextBox.Text = FloatUtil.ToString(light.FalloffExponent);
InnerAngleUpDown.Value = (decimal)light.ConeInnerAngle > InnerAngleUpDown.Maximum ? InnerAngleUpDown.Maximum : (decimal)light.ConeInnerAngle; InnerAngleTextBox.Text = FloatUtil.ToString(light.ConeInnerAngle);
OuterAngleUpDown.Value = (decimal)light.ConeOuterAngle > OuterAngleUpDown.Maximum ? OuterAngleUpDown.Maximum : (decimal)light.ConeOuterAngle; OuterAngleTextBox.Text = FloatUtil.ToString(light.ConeOuterAngle);
CoronaSizeTextBox.Text = FloatUtil.ToString(light.CoronaSize); CoronaSizeTextBox.Text = FloatUtil.ToString(light.CoronaSize);
CoronaIntensityUpDown.Value = (decimal)light.CoronaIntensity > CoronaIntensityUpDown.Maximum ? CoronaIntensityUpDown.Maximum : (decimal)light.CoronaIntensity; CoronaIntensityTextBox.Text = FloatUtil.ToString(light.CoronaIntensity);
ExtentTextBox.Text = FloatUtil.GetVector3String(light.Extent); ExtentTextBox.Text = FloatUtil.GetVector3String(light.Extent);
ShadowBlurTextBox.Text = FloatUtil.ToString(light.ShadowBlur); ShadowBlurUpDown.Value = light.ShadowBlur;
LightFadeDistanceTextBox.Text = FloatUtil.ToString(light.LightFadeDistance); LightFadeDistanceUpDown.Value = light.LightFadeDistance;
CoronaZBiasTextBox.Text = FloatUtil.ToString(light.CoronaZBias); CoronaZBiasTextBox.Text = FloatUtil.ToString(light.CoronaZBias);
HashTextBox.Text = light.ProjectedTextureHash.Hash.ToString(); TextureHashTextBox.Text = light.ProjectedTextureHash.ToCleanString();
VolumeIntensityTextBox.Text = FloatUtil.ToString(light.VolumeIntensity); VolumeIntensityTextBox.Text = FloatUtil.ToString(light.VolumeIntensity);
VolumeSizeScaleTextBox.Text = FloatUtil.ToString(light.VolumeSizeScale); VolumeSizeScaleTextBox.Text = FloatUtil.ToString(light.VolumeSizeScale);
VolumeColorRUpDown.Value = light.VolumeOuterColorR; VolumeColorRUpDown.Value = light.VolumeOuterColorR;
@ -177,9 +184,9 @@ namespace CodeWalker.Forms
VolumeColorBUpDown.Value = light.VolumeOuterColorB; VolumeColorBUpDown.Value = light.VolumeOuterColorB;
VolumeColorLabel.BackColor = System.Drawing.Color.FromArgb(light.VolumeOuterColorR, light.VolumeOuterColorG, light.VolumeOuterColorB); VolumeColorLabel.BackColor = System.Drawing.Color.FromArgb(light.VolumeOuterColorR, light.VolumeOuterColorG, light.VolumeOuterColorB);
VolumeOuterExponentTextBox.Text = FloatUtil.ToString(light.VolumeOuterExponent); VolumeOuterExponentTextBox.Text = FloatUtil.ToString(light.VolumeOuterExponent);
ShadowFadeDistanceTextBox.Text = FloatUtil.ToString(light.ShadowFadeDistance); ShadowFadeDistanceUpDown.Value = light.ShadowFadeDistance;
SpecularFadeDistanceTextBox.Text = FloatUtil.ToString(light.SpecularFadeDistance); SpecularFadeDistanceUpDown.Value = light.SpecularFadeDistance;
VolumetricFadeDistanceTextBox.Text = FloatUtil.ToString(light.VolumetricFadeDistance); VolumetricFadeDistanceUpDown.Value = light.VolumetricFadeDistance;
ShadowNearClipTextBox.Text = FloatUtil.ToString(light.ShadowNearClip); ShadowNearClipTextBox.Text = FloatUtil.ToString(light.ShadowNearClip);
CullingPlaneNormalTextBox.Text = FloatUtil.GetVector3String(light.CullingPlaneNormal); CullingPlaneNormalTextBox.Text = FloatUtil.GetVector3String(light.CullingPlaneNormal);
CullingPlaneOffsetTextBox.Text = FloatUtil.ToString(light.CullingPlaneOffset); CullingPlaneOffsetTextBox.Text = FloatUtil.ToString(light.CullingPlaneOffset);
@ -191,7 +198,8 @@ namespace CodeWalker.Forms
public void UpdateLightParams() public void UpdateLightParams()
{ {
selectedLight.HasChanged = true; if (selectedLight == null) return;
selectedLight.UpdateRenderable = true;
} }
@ -199,8 +207,8 @@ namespace CodeWalker.Forms
{ {
LightAttributes light = new LightAttributes(); LightAttributes light = new LightAttributes();
light.Direction = Vector3.BackwardLH; light.Direction = Vector3.BackwardLH;
light.Tangent = Vector3.Normalize(Vector3.BackwardLH.GetPerpVec()); light.Tangent = Vector3.Right;
light.Intensity = 20; light.Intensity = 5;
light.ConeInnerAngle = 5; light.ConeInnerAngle = 5;
light.ConeOuterAngle = 35; light.ConeOuterAngle = 35;
light.Extent = Vector3.One; light.Extent = Vector3.One;
@ -209,6 +217,7 @@ namespace CodeWalker.Forms
light.ColorR = 255; light.ColorR = 255;
light.ColorG = 255; light.ColorG = 255;
light.ColorB = 255; light.ColorB = 255;
light.TimeFlags = 14680191;
return light; return light;
} }
private void SelectLight(LightAttributes light) private void SelectLight(LightAttributes light)
@ -218,30 +227,57 @@ namespace CodeWalker.Forms
selectedLight = null; selectedLight = null;
ModelForm.selectedLight = null; ModelForm.selectedLight = null;
UpdateUI(); UpdateUI();
ModelForm.UpdateWidget();
} }
else else
{ {
selectedLight = light; selectedLight = light;
ModelForm.selectedLight = light; ModelForm.selectedLight = light;
UpdateUI(); UpdateUI();
ModelForm.UpdateWidget(); ModelForm.SetWidgetTransform(light.Position, light.Orientation, new Vector3(light.Falloff));
}
}
private void SelectLightTreeNode(LightAttributes light)
{
foreach (TreeNode rn in LightsTreeView.Nodes)
{
if (rn.Tag == light)
{
LightsTreeView.SelectedNode = rn;
break;
}
var found = false;
foreach (TreeNode tn in rn.Nodes)
{
if (tn.Tag == light)
{
LightsTreeView.SelectedNode = tn;
found = true;
break;
}
}
if (found)
{
break;
}
} }
} }
private void CreateLight() private void CreateLight()
{ {
selectedLight = NewLightAttribute();
if(Drawable != null) if(Drawable != null)
{ {
List<LightAttributes> lights = Drawable.LightAttributes.data_items.ToList(); if (Drawable.LightAttributes == null) Drawable.LightAttributes = new ResourceSimpleList64<LightAttributes>();
lights.Add(NewLightAttribute()); List<LightAttributes> lights = Drawable.LightAttributes.data_items?.ToList() ?? new List<LightAttributes>();
lights.Add(selectedLight);
Drawable.LightAttributes.data_items = lights.ToArray(); Drawable.LightAttributes.data_items = lights.ToArray();
UpdateLightParams(); UpdateLightParams();
LoadModel(Drawable); LoadModel(Drawable);
} }
else if(FragDrawable != null) else if(FragDrawable != null)
{ {
List<LightAttributes> lights = FragDrawable.OwnerFragment.LightAttributes.data_items.ToList(); if (FragDrawable.OwnerFragment.LightAttributes == null) FragDrawable.OwnerFragment.LightAttributes = new ResourceSimpleList64<LightAttributes>();
lights.Add(NewLightAttribute()); List<LightAttributes> lights = FragDrawable.OwnerFragment.LightAttributes.data_items?.ToList() ?? new List<LightAttributes>();
lights.Add(selectedLight);
FragDrawable.OwnerFragment.LightAttributes.data_items = lights.ToArray(); FragDrawable.OwnerFragment.LightAttributes.data_items = lights.ToArray();
UpdateLightParams(); UpdateLightParams();
LoadModel(FragDrawable); LoadModel(FragDrawable);
@ -255,14 +291,16 @@ namespace CodeWalker.Forms
if (dr == null) { dr = n.Parent.Tag as Drawable; } //try parent node tag also if (dr == null) { dr = n.Parent.Tag as Drawable; } //try parent node tag also
if (dr!= null) if (dr!= null)
{ {
List<LightAttributes> lights = dr.LightAttributes.data_items.ToList(); if (dr.LightAttributes == null) dr.LightAttributes = new ResourceSimpleList64<LightAttributes>();
lights.Add(NewLightAttribute()); List<LightAttributes> lights = dr.LightAttributes.data_items?.ToList() ?? new List<LightAttributes>();
lights.Add(selectedLight);
dr.LightAttributes.data_items = lights.ToArray(); dr.LightAttributes.data_items = lights.ToArray();
UpdateLightParams(); UpdateLightParams();
LoadModels(DrawableDict); LoadModels(DrawableDict);
} }
} }
} }
SelectLightTreeNode(selectedLight);
} }
private void DeleteLight() private void DeleteLight()
{ {
@ -372,6 +410,21 @@ namespace CodeWalker.Forms
} }
} }
public void SetWidgetModeUI(WidgetMode mode)
{
MoveMenuItem.Checked = (mode == WidgetMode.Position);
MoveMenuItem.BackColor = (mode == WidgetMode.Position) ? SystemColors.GradientActiveCaption : SystemColors.Control;
RotateMenuItem.Checked = (mode == WidgetMode.Rotation);
RotateMenuItem.BackColor = (mode == WidgetMode.Rotation) ? SystemColors.GradientActiveCaption : SystemColors.Control;
ScaleMenuItem.Checked = (mode == WidgetMode.Scale);
ScaleMenuItem.BackColor = (mode == WidgetMode.Scale) ? SystemColors.GradientActiveCaption : SystemColors.Control;
}
private void LightsTreeView_AfterSelect(object sender, TreeViewEventArgs e) private void LightsTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{ {
SelectLight(e.Node.Tag as LightAttributes); SelectLight(e.Node.Tag as LightAttributes);
@ -387,12 +440,6 @@ namespace CodeWalker.Forms
ModelForm.SetCameraPosition(selectedLight.Position, selectedLight.Falloff * 2f); ModelForm.SetCameraPosition(selectedLight.Position, selectedLight.Falloff * 2f);
} }
private void NormalizeDirectionButton_Click(object sender, EventArgs e)
{
Vector3 d = Vector3.Normalize(FloatUtil.ParseVector3String(DirectionTextBox.Text));
DirectionTextBox.Text = FloatUtil.GetVector3String(d);
}
private void PositionTextBox_TextChanged(object sender, EventArgs e) private void PositionTextBox_TextChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
@ -425,11 +472,11 @@ namespace CodeWalker.Forms
UpdateLightParams(); UpdateLightParams();
} }
private void IntensityUpDown_ValueChanged(object sender, EventArgs e) private void IntensityTextBox_TextChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(IntensityUpDown.Text); float v = FloatUtil.Parse(IntensityTextBox.Text);
if (selectedLight.Intensity != v) if (selectedLight.Intensity != v)
{ {
selectedLight.Intensity = v; selectedLight.Intensity = v;
@ -488,11 +535,11 @@ namespace CodeWalker.Forms
} }
} }
private void InnerAngleUpDown_ValueChanged(object sender, EventArgs e) private void InnerAngleTextBox_TextChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(InnerAngleUpDown.Text); float v = FloatUtil.Parse(InnerAngleTextBox.Text);
if (selectedLight.ConeInnerAngle != v) if (selectedLight.ConeInnerAngle != v)
{ {
selectedLight.ConeInnerAngle = v; selectedLight.ConeInnerAngle = v;
@ -500,11 +547,11 @@ namespace CodeWalker.Forms
} }
} }
private void OuterAngleUpDown_ValueChanged(object sender, EventArgs e) private void OuterAngleTextBox_TextChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(OuterAngleUpDown.Text); float v = FloatUtil.Parse(OuterAngleTextBox.Text);
if (selectedLight.ConeOuterAngle != v) if (selectedLight.ConeOuterAngle != v)
{ {
selectedLight.ConeOuterAngle = v; selectedLight.ConeOuterAngle = v;
@ -512,11 +559,11 @@ namespace CodeWalker.Forms
} }
} }
private void CoronaIntensityUpDown_ValueChanged(object sender, EventArgs e) private void CoronaIntensityTextBox_TextChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(CoronaIntensityUpDown.Text); float v = FloatUtil.Parse(CoronaIntensityTextBox.Text);
if (selectedLight.CoronaIntensity != v) if (selectedLight.CoronaIntensity != v)
{ {
selectedLight.CoronaIntensity = v; selectedLight.CoronaIntensity = v;
@ -544,43 +591,79 @@ namespace CodeWalker.Forms
if (selectedLight.Direction != v) if (selectedLight.Direction != v)
{ {
selectedLight.Direction = v; selectedLight.Direction = v;
selectedLight.Tangent = Vector3.Normalize(selectedLight.Direction.GetPerpVec());
UpdateLightParams(); UpdateLightParams();
} }
} }
private void FlashinessTextBox_TextChanged(object sender, EventArgs e) private void NormalizeDirectionButton_Click(object sender, EventArgs e)
{
Vector3 d = Vector3.Normalize(FloatUtil.ParseVector3String(DirectionTextBox.Text));
DirectionTextBox.Text = FloatUtil.GetVector3String(d);
}
private void TangentTextBox_TextChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(FlashinessTextBox.Text); Vector3 v = FloatUtil.ParseVector3String(TangentTextBox.Text);
if (selectedLight.Tangent != v)
{
selectedLight.Tangent = v;
UpdateLightParams();
}
}
private void NormalizeTangentButton_Click(object sender, EventArgs e)
{
Vector3 t = Vector3.Normalize(FloatUtil.ParseVector3String(TangentTextBox.Text));
TangentTextBox.Text = FloatUtil.GetVector3String(t);
}
private void FlagsTextBox_TextChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (selectedLight == null) return;
uint.TryParse(FlagsTextBox.Text, out uint v);
if (selectedLight.Flags != v)
{
selectedLight.Flags = v;
UpdateLightParams();
}
}
private void FlashinessUpDown_ValueChanged(object sender, EventArgs e)
{
if (populatingui) return;
if (selectedLight == null) return;
var v = (byte)FlashinessUpDown.Value;
if (selectedLight.Flashiness != v) if (selectedLight.Flashiness != v)
{ {
selectedLight.Flashiness = (byte)v; selectedLight.Flashiness = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
private void BoneIDTextBox_TextChanged(object sender, EventArgs e) private void BoneIDUpDown_ValueChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(BoneIDTextBox.Text); var v = (ushort)BoneIDUpDown.Value;
if (selectedLight.BoneId != v) if (selectedLight.BoneId != v)
{ {
selectedLight.BoneId = (ushort)v; selectedLight.BoneId = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
private void GroupIDTextBox_TextChanged(object sender, EventArgs e) private void GroupIDUpDown_ValueChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(GroupIDTextBox.Text); var v = (byte)GroupIDUpDown.Value;
if (selectedLight.GroupId != v) if (selectedLight.GroupId != v)
{ {
selectedLight.GroupId = (byte)v; selectedLight.GroupId = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
@ -597,26 +680,26 @@ namespace CodeWalker.Forms
} }
} }
private void ShadowBlurTextBox_TextChanged(object sender, EventArgs e) private void ShadowBlurUpDown_ValueChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(ShadowBlurTextBox.Text); var v = (byte)ShadowBlurUpDown.Value;
if (selectedLight.ShadowBlur != v) if (selectedLight.ShadowBlur != v)
{ {
selectedLight.ShadowBlur = (byte)v; selectedLight.ShadowBlur = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
private void LightFadeDistanceTextBox_TextChanged(object sender, EventArgs e) private void LightFadeDistanceUpDown_ValueChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(LightFadeDistanceTextBox.Text); var v = (byte)LightFadeDistanceUpDown.Value;
if (selectedLight.LightFadeDistance != v) if (selectedLight.LightFadeDistance != v)
{ {
selectedLight.LightFadeDistance = (byte)v; selectedLight.LightFadeDistance = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
@ -669,38 +752,38 @@ namespace CodeWalker.Forms
} }
} }
private void ShadowFadeDistanceTextBox_TextChanged(object sender, EventArgs e) private void ShadowFadeDistanceUpDown_ValueChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(ShadowFadeDistanceTextBox.Text); var v = (byte)ShadowFadeDistanceUpDown.Value;
if (selectedLight.ShadowFadeDistance != v) if (selectedLight.ShadowFadeDistance != v)
{ {
selectedLight.ShadowFadeDistance = (byte)v; selectedLight.ShadowFadeDistance = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
private void SpecularFadeDistanceTextBox_TextChanged(object sender, EventArgs e) private void SpecularFadeDistanceUpDown_ValueChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(SpecularFadeDistanceTextBox.Text); var v = (byte)SpecularFadeDistanceUpDown.Value;
if (selectedLight.SpecularFadeDistance != v) if (selectedLight.SpecularFadeDistance != v)
{ {
selectedLight.SpecularFadeDistance = (byte)v; selectedLight.SpecularFadeDistance = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
private void VolumetricFadeDistance_TextChanged(object sender, EventArgs e) private void VolumetricFadeDistanceUpDown_ValueChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
float v = FloatUtil.Parse(VolumetricFadeDistanceTextBox.Text); var v = (byte)VolumetricFadeDistanceUpDown.Value;
if (selectedLight.VolumetricFadeDistance != v) if (selectedLight.VolumetricFadeDistance != v)
{ {
selectedLight.VolumetricFadeDistance = (byte)v; selectedLight.VolumetricFadeDistance = v;
UpdateLightParams(); UpdateLightParams();
} }
} }
@ -790,11 +873,14 @@ namespace CodeWalker.Forms
populatingui = false; populatingui = false;
} }
private void HashTextBox_TextChanged(object sender, EventArgs e) private void TextureHashTextBox_TextChanged(object sender, EventArgs e)
{ {
if (populatingui) return; if (populatingui) return;
if (selectedLight == null) return; if (selectedLight == null) return;
uint.TryParse(HashTextBox.Text, out uint v); if (!uint.TryParse(TextureHashTextBox.Text, out uint v))
{
v = JenkHash.GenHash(TextureHashTextBox.Text);
}
if (selectedLight.ProjectedTextureHash != v) if (selectedLight.ProjectedTextureHash != v)
{ {
selectedLight.ProjectedTextureHash = v; selectedLight.ProjectedTextureHash = v;
@ -824,54 +910,51 @@ namespace CodeWalker.Forms
} }
} }
private void lightToolStripMenuItem_Click(object sender, EventArgs e) private void EditNewLightMenu_Click(object sender, EventArgs e)
{ {
CreateLight(); CreateLight();
} }
private void deleteLightToolStripMenuItem_Click(object sender, EventArgs e) private void EditDeleteLightMenu_Click(object sender, EventArgs e)
{ {
DeleteLight(); DeleteLight();
} }
private void showGizmosToolStripMenuItem_Click(object sender, EventArgs e) private void OptionsShowOutlinesMenu_Click(object sender, EventArgs e)
{ {
showGizmosToolStripMenuItem.Checked = !showGizmosToolStripMenuItem.Checked; OptionsShowOutlinesMenu.Checked = !OptionsShowOutlinesMenu.Checked;
ModelForm.showLightGizmos = showGizmosToolStripMenuItem.Checked; ModelForm.showLightGizmos = OptionsShowOutlinesMenu.Checked;
} }
private void moveToolStripMenuItem_Click(object sender, EventArgs e) private void MoveMenuItem_Click(object sender, EventArgs e)
{ {
moveToolStripMenuItem.Checked = !moveToolStripMenuItem.Checked; var mode = MoveMenuItem.Checked ? WidgetMode.Default : WidgetMode.Position;
if (moveToolStripMenuItem.Checked) SetWidgetModeUI(mode);
{ ModelForm.SetWidgetMode(mode);
moveToolStripMenuItem.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
rotateToolStripMenuItem.Checked = false;
rotateToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control;
ModelForm.SetWidgetMode("Position");
}
else
{
moveToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control;
ModelForm.SetWidgetMode("Default");
}
} }
private void rotateToolStripMenuItem_Click(object sender, EventArgs e) private void RotateMenuItem_Click(object sender, EventArgs e)
{ {
rotateToolStripMenuItem.Checked = !rotateToolStripMenuItem.Checked; var mode = RotateMenuItem.Checked ? WidgetMode.Default : WidgetMode.Rotation;
if (rotateToolStripMenuItem.Checked) SetWidgetModeUI(mode);
{ ModelForm.SetWidgetMode(mode);
rotateToolStripMenuItem.BackColor = System.Drawing.SystemColors.GradientActiveCaption; }
moveToolStripMenuItem.Checked = false;
moveToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; private void ScaleMenuItem_Click(object sender, EventArgs e)
ModelForm.SetWidgetMode("Rotation"); {
} var mode = ScaleMenuItem.Checked ? WidgetMode.Default : WidgetMode.Scale;
else SetWidgetModeUI(mode);
{ ModelForm.SetWidgetMode(mode);
rotateToolStripMenuItem.BackColor = System.Drawing.SystemColors.Control; }
ModelForm.SetWidgetMode("Default");
} private void NewLightButton_Click(object sender, EventArgs e)
{
CreateLight();
}
private void DeleteLightButton_Click(object sender, EventArgs e)
{
DeleteLight();
} }
} }
} }

View File

@ -117,11 +117,11 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="menuStripFix1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="MainMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="moveToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="MoveMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vAAADrwBlbxySQAAAKtJREFUOE+lUlsOgCAM40iegcPxz0n9IfwqXTatk5EYmzQM1paHphlaa1vvfS+l vAAADrwBlbxySQAAAKtJREFUOE+lUlsOgCAM40iegcPxz0n9IfwqXTatk5EYmzQM1paHphlaa1vvfS+l
@ -130,7 +130,7 @@
ZG1O6QTGlgf4FZ9QVAAAAABJRU5ErkJggg== ZG1O6QTGlgf4FZ9QVAAAAABJRU5ErkJggg==
</value> </value>
</data> </data>
<data name="rotateToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="RotateMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value> <value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
vAAADrwBlbxySQAAAVFJREFUOE99kzFug0AQRTlCjpAj5AgRPVJadyno6alSubXokVK65Aa4pqKhDz3F vAAADrwBlbxySQAAAVFJREFUOE99kzFug0AQRTlCjpAj5AgRPVJadyno6alSubXokVK65Aa4pqKhDz3F
@ -140,6 +140,14 @@
O2LbRn1UoJ1CS+7BAGRZ5oRwPB6t0508BmhU7wwYivBETQjavu93ZwJQQ210vV7fRGz0ZQEGFG87oPD3 O2LbRn1UoJ1CS+7BAGRZ5oRwPB6t0508BmhU7wwYivBETQjavu93ZwJQQ210vV7fRGz0ZQEGFG87oPD3
N9S6afQmrfYcg60p0Nngv1iLwyVj/SmFFQZqGk5kYH7yJc8Xs46JdsH/TJXc/eOmiKJfGa9fWzDSupYA N9S6afQmrfYcg60p0Nngv1iLwyVj/SmFFQZqGk5kYH7yJc8Xs46JdsH/TJXc/eOmiKJfGa9fWzDSupYA
AAAASUVORK5CYII= AAAASUVORK5CYII=
</value>
</data>
<data name="ScaleMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHhJREFUOE/dkLsNwCAMRBkpMzAc69IgWuJLsGUQH4cyJz1Alu8VOEtSSlfOORKl
p67Mw+UQQvHeN2wFq7IIcFjpRZg9Aj3coSWNAPeMvoQbM3rHRsBLI1jCQpTxR2aB3pMyciKQMnIiqNU3
PxPsWAqsDAVfqVWKczdonTmVYM9FFwAAAABJRU5ErkJggg==
</value> </value>
</data> </data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@ -325,15 +325,7 @@ namespace CodeWalker.Rendering
} }
if (lights != null) if (lights != null)
{ {
var rlights = new RenderableLight[lights.Length]; InitLights(lights);
for (int i = 0; i < lights.Length; i++)
{
var rlight = new RenderableLight();
rlight.Owner = this;
rlight.Init(lights[i]);
rlights[i] = rlight;
}
Lights = rlights;
} }
@ -341,6 +333,19 @@ namespace CodeWalker.Rendering
} }
public void InitLights(LightAttributes[] lights)
{
var rlights = new RenderableLight[lights.Length];
for (int i = 0; i < lights.Length; i++)
{
var rlight = new RenderableLight();
rlight.Owner = this;
rlight.Init(lights[i]);
rlights[i] = rlight;
}
Lights = rlights;
}
private RenderableModel InitModel(DrawableModel dm) private RenderableModel InitModel(DrawableModel dm)
{ {
var rmodel = new RenderableModel(); var rmodel = new RenderableModel();

View File

@ -3304,16 +3304,32 @@ namespace CodeWalker.Rendering
{ {
entity?.EnsureLights(rndbl.Key); entity?.EnsureLights(rndbl.Key);
//reinit lights when added/removed from editor
var dd = rndbl.Key as Drawable;
var fd = rndbl.Key as FragDrawable;
var lights = dd?.LightAttributes?.data_items;
if ((lights == null) && (fd != null) && (fd?.OwnerFragment?.Drawable == fd))
{
lights = fd.OwnerFragment.LightAttributes?.data_items;
}
if ((lights != null) && (lights.Length != rndbl.Lights.Length))
{
rndbl.InitLights(lights);
}
var linst = new RenderableLightInst(); var linst = new RenderableLightInst();
for (int i = 0; i < rndbl.Lights.Length; i++) for (int i = 0; i < rndbl.Lights.Length; i++)
{ {
var rndlight = rndbl.Lights[i]; var rndlight = rndbl.Lights[i];
var light = rndlight.OwnerLight; var light = rndlight.OwnerLight;
if (light.HasChanged == true) if (light.UpdateRenderable == true)
{ {
rndlight.Init(light); rndlight.Init(light);
light.HasChanged = false; light.UpdateRenderable = false;
} }
linst.EntityPosition = position; linst.EntityPosition = position;