mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-17 04:22:54 +08:00
PR #235 also enable light culling plane by flag
This commit is contained in:
parent
29530a05f6
commit
d049e3ad1c
@ -4505,11 +4505,8 @@ namespace CodeWalker.GameFiles
|
||||
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);
|
||||
tx = Vector3.Normalize(Tangent);
|
||||
ty = Vector3.Normalize(Vector3.Cross(Direction, Tangent));
|
||||
break;
|
||||
}
|
||||
|
@ -27,26 +27,26 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
@ -38,6 +38,10 @@ cbuffer PSLightInstVars : register(b2)
|
||||
uint InstType;
|
||||
float3 InstCullingPlaneNormal;
|
||||
float InstCullingPlaneOffset;
|
||||
uint InstCullingPlaneEnable;
|
||||
uint InstUnused1;
|
||||
uint InstUnused2;
|
||||
uint InstUnused3;
|
||||
}
|
||||
|
||||
|
||||
@ -170,19 +174,20 @@ float4 DeferredLight(float3 camRel, float3 norm, float4 diffuse, float4 specular
|
||||
{
|
||||
float3 srpos = InstPosition - camRel; //light position relative to surface position
|
||||
float ldist = length(srpos);
|
||||
if (InstCullingPlaneEnable == 1)
|
||||
{
|
||||
float d = dot(srpos, InstCullingPlaneNormal) - InstCullingPlaneOffset;
|
||||
if (d > 0) return 0;
|
||||
}
|
||||
if (InstType == 4)//capsule
|
||||
{
|
||||
float3 ext = InstDirection.xyz * (InstCapsuleExtent.y * 0.5);
|
||||
float3 ext = InstDirection.xyz * (InstCapsuleExtent.x * 0.5);
|
||||
float4 lsn = GetLineSegmentNearestPoint(srpos, ext, -ext);
|
||||
ldist = lsn.w;
|
||||
srpos.xyz = lsn.xyz;
|
||||
}
|
||||
if (ldist > InstFalloff) return 0;
|
||||
if (ldist <= 0) return 0;
|
||||
|
||||
float d = dot(srpos, InstCullingPlaneNormal) - InstCullingPlaneOffset;
|
||||
if (d > 0) return 0;
|
||||
|
||||
float4 rgbi = float4(InstColour, InstIntensity);
|
||||
float3 lcol = rgbi.rgb;// * rgbi.a; // * 5.0f;
|
||||
float3 ldir = srpos / ldist;
|
||||
|
@ -56,7 +56,7 @@ VS_Output main(float4 ipos : POSITION, uint iid : SV_InstanceID)
|
||||
else if (InstType == 4)//capsule
|
||||
{
|
||||
float3 cpos = ipos.xyz * extent;
|
||||
cpos.y += abs(InstCapsuleExtent.y) * (ipos.w - 0.5);
|
||||
cpos.y += abs(InstCapsuleExtent.x) * (ipos.w - 0.5);
|
||||
opos = (cpos.x * InstTangentX.xyz) + (cpos.y * InstDirection.xyz) + (cpos.z * InstTangentY.xyz);
|
||||
}
|
||||
|
||||
|
67
CodeWalker/Forms/ModelForm.Designer.cs
generated
67
CodeWalker/Forms/ModelForm.Designer.cs
generated
@ -100,6 +100,10 @@
|
||||
this.ControlLightDirCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.SkydomeCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.TimeOfDayLabel = new System.Windows.Forms.Label();
|
||||
this.OptionsHelperTabPage = new System.Windows.Forms.TabPage();
|
||||
this.OptionsShowOutlinesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.SnapAngleUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.label33 = new System.Windows.Forms.Label();
|
||||
this.ToolsPanelHideButton = new System.Windows.Forms.Button();
|
||||
this.ToolsDragPanel = new System.Windows.Forms.Panel();
|
||||
this.ToolsPanelShowButton = new System.Windows.Forms.Button();
|
||||
@ -119,6 +123,8 @@
|
||||
this.OptionsRenderTabPage.SuspendLayout();
|
||||
this.OptionsLightingTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).BeginInit();
|
||||
this.OptionsHelperTabPage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SnapAngleUpDown)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// StatsUpdateTimer
|
||||
@ -544,6 +550,7 @@
|
||||
//
|
||||
this.OptionsTabControl.Controls.Add(this.OptionsRenderTabPage);
|
||||
this.OptionsTabControl.Controls.Add(this.OptionsLightingTabPage);
|
||||
this.OptionsTabControl.Controls.Add(this.OptionsHelperTabPage);
|
||||
this.OptionsTabControl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.OptionsTabControl.Location = new System.Drawing.Point(0, 0);
|
||||
this.OptionsTabControl.Name = "OptionsTabControl";
|
||||
@ -932,6 +939,59 @@
|
||||
this.TimeOfDayLabel.TabIndex = 5;
|
||||
this.TimeOfDayLabel.Text = "12:00";
|
||||
//
|
||||
// OptionsHelperTabPage
|
||||
//
|
||||
this.OptionsHelperTabPage.Controls.Add(this.OptionsShowOutlinesCheckBox);
|
||||
this.OptionsHelperTabPage.Controls.Add(this.SnapAngleUpDown);
|
||||
this.OptionsHelperTabPage.Controls.Add(this.label33);
|
||||
this.OptionsHelperTabPage.Location = new System.Drawing.Point(4, 22);
|
||||
this.OptionsHelperTabPage.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.OptionsHelperTabPage.Name = "OptionsHelperTabPage";
|
||||
this.OptionsHelperTabPage.Padding = new System.Windows.Forms.Padding(4);
|
||||
this.OptionsHelperTabPage.Size = new System.Drawing.Size(233, 474);
|
||||
this.OptionsHelperTabPage.TabIndex = 2;
|
||||
this.OptionsHelperTabPage.Text = "Helpers";
|
||||
this.OptionsHelperTabPage.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// OptionsShowOutlinesCheckBox
|
||||
//
|
||||
this.OptionsShowOutlinesCheckBox.AutoSize = true;
|
||||
this.OptionsShowOutlinesCheckBox.Checked = true;
|
||||
this.OptionsShowOutlinesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.OptionsShowOutlinesCheckBox.Location = new System.Drawing.Point(9, 7);
|
||||
this.OptionsShowOutlinesCheckBox.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.OptionsShowOutlinesCheckBox.Name = "OptionsShowOutlinesCheckBox";
|
||||
this.OptionsShowOutlinesCheckBox.Size = new System.Drawing.Size(120, 17);
|
||||
this.OptionsShowOutlinesCheckBox.TabIndex = 37;
|
||||
this.OptionsShowOutlinesCheckBox.Text = "Show Light Outlines";
|
||||
this.OptionsShowOutlinesCheckBox.UseVisualStyleBackColor = true;
|
||||
this.OptionsShowOutlinesCheckBox.CheckedChanged += new System.EventHandler(this.OptionsShowOutlinesCheckBox_CheckedChanged);
|
||||
//
|
||||
// SnapAngleUpDown
|
||||
//
|
||||
this.SnapAngleUpDown.DecimalPlaces = 1;
|
||||
this.SnapAngleUpDown.Location = new System.Drawing.Point(130, 52);
|
||||
this.SnapAngleUpDown.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.SnapAngleUpDown.Maximum = new decimal(new int[] {
|
||||
180,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.SnapAngleUpDown.Name = "SnapAngleUpDown";
|
||||
this.SnapAngleUpDown.Size = new System.Drawing.Size(95, 20);
|
||||
this.SnapAngleUpDown.TabIndex = 34;
|
||||
this.SnapAngleUpDown.ValueChanged += new System.EventHandler(this.SnapAngleUpDown_ValueChanged);
|
||||
//
|
||||
// label33
|
||||
//
|
||||
this.label33.AutoSize = true;
|
||||
this.label33.Location = new System.Drawing.Point(8, 54);
|
||||
this.label33.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.label33.Name = "label33";
|
||||
this.label33.Size = new System.Drawing.Size(91, 13);
|
||||
this.label33.TabIndex = 33;
|
||||
this.label33.Text = "Snap angle (deg):";
|
||||
//
|
||||
// ToolsPanelHideButton
|
||||
//
|
||||
this.ToolsPanelHideButton.Location = new System.Drawing.Point(3, 3);
|
||||
@ -1011,6 +1071,9 @@
|
||||
this.OptionsLightingTabPage.ResumeLayout(false);
|
||||
this.OptionsLightingTabPage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TimeOfDayTrackBar)).EndInit();
|
||||
this.OptionsHelperTabPage.ResumeLayout(false);
|
||||
this.OptionsHelperTabPage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.SnapAngleUpDown)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -1093,5 +1156,9 @@
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveAllTexturesMenuButton;
|
||||
private System.Windows.Forms.ToolStripMenuItem SaveSharedTexturesMenuButton;
|
||||
private System.Windows.Forms.FolderBrowserDialog FolderBrowserDialog;
|
||||
private System.Windows.Forms.TabPage OptionsHelperTabPage;
|
||||
private System.Windows.Forms.NumericUpDown SnapAngleUpDown;
|
||||
private System.Windows.Forms.Label label33;
|
||||
private System.Windows.Forms.CheckBox OptionsShowOutlinesCheckBox;
|
||||
}
|
||||
}
|
@ -623,10 +623,34 @@ namespace CodeWalker.Forms
|
||||
//called during UpdateWidgets()
|
||||
if (newscale == oldscale) return;
|
||||
if (selectedLight == null || lightForm == null || !editingLights) return;
|
||||
selectedLight.Falloff = newscale.Z;
|
||||
if (selectedLight.Type == LightType.Capsule)
|
||||
{
|
||||
selectedLight.Falloff = newscale.X;
|
||||
selectedLight.Extent = new Vector3(newscale.Z, newscale.Z, newscale.Z);
|
||||
}
|
||||
else if (selectedLight.Type == LightType.Spot)
|
||||
{
|
||||
selectedLight.Falloff = newscale.Z;
|
||||
selectedLight.ConeInnerAngle = newscale.Y;
|
||||
selectedLight.ConeOuterAngle = newscale.X;
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedLight.Falloff = newscale.Z;
|
||||
}
|
||||
selectedLight.UpdateRenderable = true;
|
||||
}
|
||||
|
||||
private void SetRotationSnapping(float degrees)
|
||||
{
|
||||
Widget.SnapAngleDegrees = degrees;
|
||||
var cval = (float)SnapAngleUpDown.Value;
|
||||
if (cval != degrees)
|
||||
{
|
||||
SnapAngleUpDown.Value = (decimal)degrees;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RenderSingleItem()
|
||||
{
|
||||
@ -2030,6 +2054,10 @@ namespace CodeWalker.Forms
|
||||
|
||||
private void ModelForm_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (ActiveControl is NumericUpDown)
|
||||
{
|
||||
ActiveControl = null;
|
||||
}
|
||||
switch (e.Button)
|
||||
{
|
||||
case MouseButtons.Left: MouseLButtonDown = true; break;
|
||||
@ -2642,5 +2670,18 @@ namespace CodeWalker.Forms
|
||||
{
|
||||
SetWidgetMode(ToolbarScaleButton.Checked ? WidgetMode.Default : WidgetMode.Scale);
|
||||
}
|
||||
|
||||
private void OptionsShowOutlinesCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
showLightGizmos = OptionsShowOutlinesCheckBox.Checked;
|
||||
}
|
||||
|
||||
private void SnapAngleUpDown_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Widget != null)
|
||||
{
|
||||
SetRotationSnapping((float)SnapAngleUpDown.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -130,8 +130,8 @@
|
||||
<data name="ToolbarMaterialEditorButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKwSURBVDhPbVPbTlpREOUL+jn+gIn3xHiPEW8YNHIIKiJq
|
||||
rKAiQUtVij2aoqA0Ira1SSWRi1a8Ja0Wqla08aHVhtL4YH0wRh/64OqZAXuzk+xkZ+9Za9as2Vv2b1xd
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAKwSURBVDhPbVNtL5thFO4v2M/xByTeE/EeUW+VEn2aoqqI
|
||||
aVFNWYeu9pCVli6qtlkyTfSFqbdkY+0wZfFhY+m6+GASifBhH1x7zmntzU5yJ3fu+1zXuc517lv2b1xd
|
||||
XaVdX187Li8vTy4uLn7Qoj2d0V0q7W7c3NzckxI859/PEYlEsLjox5x3DlNT03BPuxEIBHF6egrKodwU
|
||||
LBl0IFXYPjo6YuDr5RWsrIQR8AcxP/8STqcLw8Mj6Ovrw+bGJij3LxJiPTz8CN+CDxvrm9jd2cOHvX1s
|
||||
bW0jFAzBKykZGxtHf78ZOp0O4XCYldyC087OzlhuMBBCNBLFyfEXJBLfEIsdYG1tnVU4njgwYBmAXq+H
|
||||
@ -141,8 +141,8 @@
|
||||
MJvNMBgMbJJtxAbxsciSR+2jsFofSuMzob29A4IgoKqqCoWFhaipqUm2QEZQj83Nzejs6ITRYORqtHp7
|
||||
etHVdZ9Hp1KpGFRSUoLc3FzY7fakiTQKGglJa2xsRJOmCS0tWmi1WiYVBDWUSiVXJnBeXh6ys7MRj8eT
|
||||
Y0y9BU8oFEJFRQUbVFurgEKh4IqV8kqUlZWhoKAAOTk5SE9Ph8/n+/2QKG6fst/vR2lpKYqKinhRr2QW
|
||||
Sc7IyEBWVhaDKfe//4FYSZooilydAJmZmZDL5dxzSvbdz/RnUF9kDjlMY6JFezqju1RaKmSyn++nhCv9
|
||||
J3dAAAAAAElFTkSuQmCC
|
||||
Sc7IyEBWVhaDKfe//4FYSZooilydAJmZmZDL5dxzSvbdz/RnUF9kDjlMY6JFezqju1RaKmSyn77bhBMB
|
||||
OQGrAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarTextureEditorButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
@ -157,12 +157,12 @@
|
||||
<data name="ToolbarLightEditorButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEeSURBVDhPnZJNboQwDIU5whyhR+gRepQepQv2XbPqUXqE
|
||||
bvgRsKgQQggEZMHfMpOPJhmUMozaJ1lRbL9nx47nQghxmef5bVkWMQyD7LpOcqq7xK/TjgFZJX61bSuT
|
||||
JJFhGFqLokjWdY3Ih07/DSpA3hNd0yLHndC2W9k1OiFPU26YpumZt5rEvu+lepI17pCJMZd1XV809Qc4
|
||||
9gKQyrKUWZbJoigeCwAmbZLiON5E0jTdTu74iY/jiO+iaTcogXeGtO/CCBjf6SZQVcHPqqpsMgJN02x3
|
||||
/Kz5sLoBQdXid57ntirGdpj+KdlADejV/Q+n+3dBFQbq2uHk7wGC7/vW/iXg2l8FRBAEW3VOLfCkw4/B
|
||||
11brE/xENZM71T3vCpBKAD1CW/uhAAAAAElFTkSuQmCC
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAEeSURBVDhPnZJJboQwEEU5Qh8hR8gRcpQcJQv2WbPKUXKE
|
||||
bBgELCKEEIMAL5iWbj9i08ihaSVfKlk1/F/lsh0bQojLNE1v8zyLvu9l27aSU/mSuC47BmRV+NU0jYyi
|
||||
SPq+v1kQBLIsS0Q+dPlv0AHynmibFjmehLHtzrYxCXWacsM4js/c1RR2XSfVlTbDh0yOvSzL8qKpPyCw
|
||||
F4CU57lMkkRmWfZYALBpUxSG4SoSx/F64hMnPwwDsYum3aAE3lnSfgojYGKnL4GqSn4WRbEVI1DX9eoT
|
||||
55kPuxuQVCN+p2m6dcV4HbZ/SjZQC3q1/8Pp+9ugCwu17XDz9wDBdd3N/iVg218FhOd5a3dOLfCk04/B
|
||||
166qSvAT1U7udHecK4/hADrwkPT0AAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
<data name="ToolbarMoveButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
|
2129
CodeWalker/Forms/ModelLightForm.Designer.cs
generated
2129
CodeWalker/Forms/ModelLightForm.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -122,7 +122,8 @@ namespace CodeWalker.Forms
|
||||
ColourBUpDown.Value = 0;
|
||||
IntensityTextBox.Text = "";
|
||||
FlagsTextBox.Text = "";
|
||||
FlashinessUpDown.Value = 0;
|
||||
FlashinessComboBox.SelectedIndex = 0;
|
||||
LightHashUpDown.Value = 0;
|
||||
BoneIDUpDown.Value = 0;
|
||||
GroupIDUpDown.Value = 0;
|
||||
FalloffTextBox.Text = "";
|
||||
@ -167,7 +168,9 @@ namespace CodeWalker.Forms
|
||||
ColourLabel.BackColor = System.Drawing.Color.FromArgb(light.ColorR, light.ColorG, light.ColorB);
|
||||
IntensityTextBox.Text = FloatUtil.ToString(light.Intensity);
|
||||
FlagsTextBox.Text = light.Flags.ToString();
|
||||
FlashinessUpDown.Value = light.Flashiness;
|
||||
UpdateFlagsCheckBoxes();
|
||||
FlashinessComboBox.SelectedIndex = light.Flashiness;
|
||||
LightHashUpDown.Value = light.LightHash;
|
||||
BoneIDUpDown.Value = light.BoneId;
|
||||
GroupIDUpDown.Value = light.GroupId;
|
||||
FalloffTextBox.Text = FloatUtil.ToString(light.Falloff);
|
||||
@ -195,7 +198,7 @@ namespace CodeWalker.Forms
|
||||
CullingPlaneNormalTextBox.Text = FloatUtil.GetVector3String(light.CullingPlaneNormal);
|
||||
CullingPlaneOffsetTextBox.Text = FloatUtil.ToString(light.CullingPlaneOffset);
|
||||
TimeFlagsTextBox.Text = light.TimeFlags.ToString();
|
||||
UpdateFlagsCheckBoxes();
|
||||
UpdateTimeFlagsCheckBoxes();
|
||||
populatingui = false;
|
||||
}
|
||||
}
|
||||
@ -206,12 +209,37 @@ namespace CodeWalker.Forms
|
||||
selectedLight.UpdateRenderable = true;
|
||||
}
|
||||
|
||||
public void UpdateWidgetTransform()
|
||||
{
|
||||
var sl = selectedLight;
|
||||
var pos = sl.Position;
|
||||
Bone bone = null;
|
||||
ModelForm.Skeleton?.BonesMap?.TryGetValue(sl.BoneId, out bone);
|
||||
if (bone != null)
|
||||
{
|
||||
var xform = bone.AbsTransform;
|
||||
pos = xform.Multiply(pos);
|
||||
}
|
||||
if (sl == null) return;
|
||||
if (sl.Type == LightType.Capsule)
|
||||
{
|
||||
ModelForm.SetWidgetTransform(pos, sl.Orientation, new Vector3(sl.Falloff, sl.Falloff, sl.Extent.X));
|
||||
}
|
||||
else if (sl.Type == LightType.Spot)
|
||||
{
|
||||
ModelForm.SetWidgetTransform(pos, sl.Orientation, new Vector3(sl.ConeOuterAngle, sl.ConeInnerAngle, sl.Falloff));
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelForm.SetWidgetTransform(pos, sl.Orientation, new Vector3(sl.Falloff));
|
||||
}
|
||||
}
|
||||
|
||||
private LightAttributes NewLightAttribute()
|
||||
{
|
||||
LightAttributes light = new LightAttributes();
|
||||
light.Direction = Vector3.BackwardLH;
|
||||
light.Tangent = Vector3.Right;
|
||||
light.Tangent = Vector3.Left;
|
||||
light.Intensity = 5;
|
||||
light.ConeInnerAngle = 5;
|
||||
light.ConeOuterAngle = 35;
|
||||
@ -221,7 +249,7 @@ namespace CodeWalker.Forms
|
||||
light.ColorR = 255;
|
||||
light.ColorG = 255;
|
||||
light.ColorB = 255;
|
||||
light.TimeFlags = 14680191;
|
||||
light.TimeFlags = 16777215;
|
||||
return light;
|
||||
}
|
||||
private LightAttributes DuplicateLightAttribute()
|
||||
@ -288,18 +316,7 @@ namespace CodeWalker.Forms
|
||||
selectedLight = light;
|
||||
ModelForm.selectedLight = light;
|
||||
UpdateUI();
|
||||
|
||||
var pos = light.Position;
|
||||
Bone bone = null;
|
||||
ModelForm.Skeleton?.BonesMap?.TryGetValue(light.BoneId, out bone);
|
||||
if (bone != null)
|
||||
{
|
||||
var xform = bone.AbsTransform;
|
||||
pos = xform.Multiply(pos);
|
||||
//TODO:? handle bone's rotation correctly for widget??
|
||||
}
|
||||
|
||||
ModelForm.SetWidgetTransform(pos, light.Orientation, new Vector3(light.Falloff));
|
||||
UpdateWidgetTransform();
|
||||
}
|
||||
}
|
||||
private void SelectLightTreeNode(LightAttributes light)
|
||||
@ -445,7 +462,7 @@ namespace CodeWalker.Forms
|
||||
SelectLightTreeNode(selectedLight);
|
||||
}
|
||||
|
||||
private void UpdateFlagsCheckBoxes()
|
||||
private void UpdateTimeFlagsCheckBoxes()
|
||||
{
|
||||
var l = selectedLight;
|
||||
var tfam = (l.TimeFlags >> 0) & 0xFFF;
|
||||
@ -460,6 +477,16 @@ namespace CodeWalker.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateFlagsCheckBoxes()
|
||||
{
|
||||
var l = selectedLight;
|
||||
var f = l.Flags;
|
||||
for (int i = 0; i < FlagsCheckedListBox.Items.Count; i++)
|
||||
{
|
||||
FlagsCheckedListBox.SetItemCheckState(i, ((f & (1u << i)) > 0) ? CheckState.Checked : CheckState.Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
private uint GetFlagsFromItemCheck(CheckedListBox clb, ItemCheckEventArgs e)
|
||||
{
|
||||
uint flags = 0;
|
||||
@ -533,6 +560,15 @@ namespace CodeWalker.Forms
|
||||
}
|
||||
|
||||
|
||||
private void UpdateLightTreeNodeText()
|
||||
{
|
||||
if (LightsTreeView.Nodes.Count == 0 || LightsTreeView.SelectedNode == null) return;
|
||||
var lnode = LightsTreeView.SelectedNode;
|
||||
if (lnode.Index >= 0)
|
||||
{
|
||||
lnode.Text = "Light" + (lnode.Index + 1).ToString() + " : " + selectedLight.Type.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LightsTreeView_AfterSelect(object sender, TreeViewEventArgs e)
|
||||
@ -558,6 +594,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.Position != v)
|
||||
{
|
||||
selectedLight.Position = v;
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -579,6 +616,8 @@ namespace CodeWalker.Forms
|
||||
selectedLight.Type = LightType.Spot;
|
||||
break;
|
||||
}
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightTreeNodeText();
|
||||
UpdateLightParams();
|
||||
}
|
||||
|
||||
@ -629,6 +668,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.Falloff != v)
|
||||
{
|
||||
selectedLight.Falloff = v;
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -653,6 +693,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.ConeInnerAngle != v)
|
||||
{
|
||||
selectedLight.ConeInnerAngle = v;
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -665,6 +706,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.ConeOuterAngle != v)
|
||||
{
|
||||
selectedLight.ConeOuterAngle = v;
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -701,6 +743,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.Direction != v)
|
||||
{
|
||||
selectedLight.Direction = v;
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -711,6 +754,14 @@ namespace CodeWalker.Forms
|
||||
DirectionTextBox.Text = FloatUtil.GetVector3String(d);
|
||||
}
|
||||
|
||||
private void ResetDirectionButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Vector3 d = Vector3.ForwardRH;
|
||||
Vector3 t = Vector3.Left;
|
||||
DirectionTextBox.Text = FloatUtil.GetVector3String(d);
|
||||
TangentTextBox.Text = FloatUtil.GetVector3String(t);
|
||||
}
|
||||
|
||||
private void TangentTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (populatingui) return;
|
||||
@ -719,6 +770,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.Tangent != v)
|
||||
{
|
||||
selectedLight.Tangent = v;
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -729,27 +781,40 @@ namespace CodeWalker.Forms
|
||||
TangentTextBox.Text = FloatUtil.GetVector3String(t);
|
||||
}
|
||||
|
||||
private void FlagsTextBox_TextChanged(object sender, EventArgs e)
|
||||
private void CalculateTangentButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Vector3 d = Vector3.Normalize(FloatUtil.ParseVector3String(DirectionTextBox.Text));
|
||||
Vector3 v = Vector3.Down;
|
||||
Vector3 t = Vector3.Normalize(Vector3.Cross(d, v));
|
||||
if (t == Vector3.Zero)
|
||||
{
|
||||
v = Vector3.Left;
|
||||
t = Vector3.Normalize(Vector3.Cross(d, v));
|
||||
}
|
||||
TangentTextBox.Text = FloatUtil.GetVector3String(t);
|
||||
}
|
||||
|
||||
private void FlashinessComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (populatingui) return;
|
||||
if (selectedLight == null) return;
|
||||
uint.TryParse(FlagsTextBox.Text, out uint v);
|
||||
if (selectedLight.Flags != v)
|
||||
var v = (byte)FlashinessComboBox.SelectedIndex;
|
||||
if (selectedLight.Flashiness != v)
|
||||
{
|
||||
selectedLight.Flags = v;
|
||||
selectedLight.Flashiness = v;
|
||||
UpdateLightParams();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void FlashinessUpDown_ValueChanged(object sender, EventArgs e)
|
||||
private void LightHash_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (populatingui) return;
|
||||
if (selectedLight == null) return;
|
||||
var v = (byte)FlashinessUpDown.Value;
|
||||
if (selectedLight.Flashiness != v)
|
||||
var v = (byte)LightHashUpDown.Value;
|
||||
if (selectedLight.LightHash != v)
|
||||
{
|
||||
selectedLight.Flashiness = v;
|
||||
selectedLight.LightHash = v;
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -762,6 +827,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.BoneId != v)
|
||||
{
|
||||
selectedLight.BoneId = v;
|
||||
UpdateWidgetTransform();
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
@ -947,7 +1013,7 @@ namespace CodeWalker.Forms
|
||||
selectedLight.TimeFlags = v;
|
||||
}
|
||||
populatingui = true;
|
||||
UpdateFlagsCheckBoxes();
|
||||
UpdateTimeFlagsCheckBoxes();
|
||||
populatingui = false;
|
||||
}
|
||||
|
||||
@ -983,6 +1049,34 @@ namespace CodeWalker.Forms
|
||||
populatingui = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
populatingui = true;
|
||||
UpdateFlagsCheckBoxes();
|
||||
populatingui = false;
|
||||
}
|
||||
|
||||
private void FlagsCheckedListBox_ItemCheck(object sender, ItemCheckEventArgs e)
|
||||
{
|
||||
if (populatingui) return;
|
||||
if (selectedLight == null) return;
|
||||
var v = GetFlagsFromItemCheck(FlagsCheckedListBox, e);
|
||||
if (selectedLight.Flags != v)
|
||||
{
|
||||
selectedLight.Flags = v;
|
||||
}
|
||||
populatingui = true;
|
||||
FlagsTextBox.Text = selectedLight.Flags.ToString();
|
||||
populatingui = false;
|
||||
}
|
||||
|
||||
private void TextureHashTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (populatingui) return;
|
||||
@ -1005,6 +1099,7 @@ namespace CodeWalker.Forms
|
||||
if (selectedLight.CullingPlaneNormal != v)
|
||||
{
|
||||
selectedLight.CullingPlaneNormal = v;
|
||||
UpdateLightParams();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1077,11 +1172,6 @@ namespace CodeWalker.Forms
|
||||
DuplicateLight();
|
||||
}
|
||||
|
||||
private void MainSplitContainer_Panel2_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void newLightToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateLight();
|
||||
|
@ -148,7 +148,7 @@
|
||||
<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
|
||||
wgAADsIBFShKgAAAAHhJREFUOE/dkLsNwCAMRBkpMzAc69IgWuJLsGUQH4cyJz1Alu8VOEtSSlfOORKl
|
||||
p67Mw+UQQvHeN2wFq7IIcFjpRZg9Aj3coSWNAPeMvoQbM3rHRsBLI1jCQpTxR2aB3pMyciKQMnIiqNU3
|
||||
PxPsWAqsDAVfqVWKczdonTmVYM9FFwAAAABJRU5ErkJggg==
|
||||
</value>
|
||||
|
@ -1384,6 +1384,7 @@ namespace CodeWalker.Rendering
|
||||
public Vector3 CullingPlaneNormal;
|
||||
public float CullingPlaneOffset;
|
||||
public uint TimeFlags;
|
||||
public uint Flags;
|
||||
public MetaHash TextureHash;
|
||||
|
||||
public void Init(LightAttributes l)
|
||||
@ -1409,6 +1410,7 @@ namespace CodeWalker.Rendering
|
||||
CullingPlaneNormal = l.CullingPlaneNormal;
|
||||
CullingPlaneOffset = l.CullingPlaneOffset;
|
||||
TimeFlags = l.TimeFlags;
|
||||
Flags = l.Flags;
|
||||
TextureHash = l.ProjectedTextureHash;
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,10 @@ namespace CodeWalker.Rendering
|
||||
public uint InstType;
|
||||
public Vector3 InstCullingPlaneNormal;
|
||||
public float InstCullingPlaneOffset;
|
||||
public uint InstCullingPlaneEnable;
|
||||
public uint InstUnused1;
|
||||
public uint InstUnused2;
|
||||
public uint InstUnused3;
|
||||
}
|
||||
|
||||
public struct DeferredSSAAPSVars
|
||||
@ -573,6 +577,7 @@ namespace CodeWalker.Rendering
|
||||
LightInstVars.Vars.InstConeOuterAngle = rl.ConeOuterAngle;
|
||||
LightInstVars.Vars.InstType = (uint)rl.Type;
|
||||
LightInstVars.Vars.InstCullingPlaneOffset = rl.CullingPlaneOffset;
|
||||
LightInstVars.Vars.InstCullingPlaneEnable = ((rl.Flags & 0x40000) != 0) ? 1u : 0u;
|
||||
LightInstVars.Update(context);
|
||||
LightInstVars.SetVSCBuffer(context, 1);
|
||||
LightInstVars.SetPSCBuffer(context, 2);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user