Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 3 additions & 47 deletions DSFBX.Core/DSFBXImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public string ModelIDStr
public double ImportedSkeletonScalePercent = 100.0;
public Vector3 SceneRotation = Vector3.Zero;


public bool ArmorCopyHumanToHollow = true;
public string ArmorExtension = "";
public bool ArmorCopyMaleLegsToFemale = true;
public bool ArmorFixBodyNormals = true;

Expand Down Expand Up @@ -1561,18 +1560,6 @@ private string GetArmorModelName(DSFBXArmorSlot slot)
case DSFBXArmorSlot.LG_A: return $"LG_A_{ModelIDStr}";
case DSFBXArmorSlot.LG_M: return $"LG_M_{ModelIDStr}";
case DSFBXArmorSlot.LG_F: return $"LG_F_{ModelIDStr}";
case DSFBXArmorSlot.HD_A_Hollow: return $"HD_A_{ModelIDStr}_M";
case DSFBXArmorSlot.HD_M_Hollow: return $"HD_M_{ModelIDStr}_M";
case DSFBXArmorSlot.HD_F_Hollow: return $"HD_F_{ModelIDStr}_M";
case DSFBXArmorSlot.BD_A_Hollow: return $"BD_A_{ModelIDStr}_M";
case DSFBXArmorSlot.BD_M_Hollow: return $"BD_M_{ModelIDStr}_M";
case DSFBXArmorSlot.BD_F_Hollow: return $"BD_F_{ModelIDStr}_M";
case DSFBXArmorSlot.AM_A_Hollow: return $"AM_A_{ModelIDStr}_M";
case DSFBXArmorSlot.AM_M_Hollow: return $"AM_M_{ModelIDStr}_M";
case DSFBXArmorSlot.AM_F_Hollow: return $"AM_F_{ModelIDStr}_M";
case DSFBXArmorSlot.LG_A_Hollow: return $"LG_A_{ModelIDStr}_M";
case DSFBXArmorSlot.LG_M_Hollow: return $"LG_M_{ModelIDStr}_M";
case DSFBXArmorSlot.LG_F_Hollow: return $"LG_F_{ModelIDStr}_M";
}
return null;
}
Expand Down Expand Up @@ -1673,7 +1660,7 @@ public bool Import()

foreach (var kvp in armorSubmeshes)
{
var outputBnd = GetModelPath(GetArmorModelName(kvp.Key));
var outputBnd = GetModelPath(GetArmorModelName(kvp.Key) + ArmorExtension);
entityBnd.FilePath = outputBnd;
if (GenerateBackup && (File.Exists(outputBnd) && !File.Exists(outputBnd + ".bak")))
{
Expand Down Expand Up @@ -1701,25 +1688,9 @@ public bool Import()

Print($"Saved armor slot {kvp.Key.ToString()} model to armor model \"{outputBnd}\".");

if (ArmorCopyHumanToHollow && !GetArmorModelName(kvp.Key).EndsWith("_M"))
{
entityBnd.FilePath = outputBnd = GetModelPath(GetArmorModelName(kvp.Key) + "_M");
if (IsRemaster)
{
DataFile.SaveToDcxFile(entityBnd, outputBnd);
}
else
{
DataFile.SaveToFile(entityBnd, outputBnd);
}
OutputtedFiles.Add(outputBnd);

Print($"[Copy Human -> Hollow]\nSaved armor slot {kvp.Key.ToString()} model to armor model \"{outputBnd}\".");
}

if (ArmorCopyMaleLegsToFemale && kvp.Key == DSFBXArmorSlot.LG_M)
{
entityBnd.FilePath = outputBnd = GetModelPath(GetArmorModelName(DSFBXArmorSlot.LG_F));
entityBnd.FilePath = outputBnd = GetModelPath(GetArmorModelName(DSFBXArmorSlot.LG_F) + ArmorExtension);
if (IsRemaster)
{
DataFile.SaveToDcxFile(entityBnd, outputBnd);
Expand All @@ -1732,21 +1703,6 @@ public bool Import()

Print($"[Copy Male Legs -> Female Legs]\nSaved armor slot {kvp.Key.ToString()} model to armor model \"{outputBnd}\".");

if (ArmorCopyHumanToHollow)
{
entityBnd.FilePath = outputBnd = GetModelPath(GetArmorModelName(DSFBXArmorSlot.LG_F_Hollow));
if (IsRemaster)
{
DataFile.SaveToDcxFile(entityBnd, outputBnd);
}
else
{
DataFile.SaveToFile(entityBnd, outputBnd);
}
OutputtedFiles.Add(outputBnd);

Print($"[Copy Male Legs -> Female Legs & Copy Human -> Hollow]\nSaved armor slot {kvp.Key.ToString()} model to armor model \"{outputBnd}\".");
}
}


Expand Down
13 changes: 0 additions & 13 deletions DSFBX.Core/DSFBX_Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,5 @@ public enum DSFBXArmorSlot
LG_A,
LG_M,
LG_F,

HD_A_Hollow,
HD_M_Hollow,
HD_F_Hollow,
BD_A_Hollow,
BD_M_Hollow,
BD_F_Hollow,
AM_A_Hollow,
AM_M_Hollow,
AM_F_Hollow,
LG_A_Hollow,
LG_M_Hollow,
LG_F_Hollow,
}
}
14 changes: 14 additions & 0 deletions DSFBX.ImporterGUI/ArmorExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace DSFBX_GUI
{
class ArmorExtension
{
public static readonly Dictionary<string, string> Dict = new Dictionary<string, string>()
{
{ "System.Windows.Controls.ListBoxItem: Human", "" },
{ "System.Windows.Controls.ListBoxItem: Hollow", "_M" },
{ "System.Windows.Controls.ListBoxItem: Lowpoly", "_L" }
};
}
}
3 changes: 2 additions & 1 deletion DSFBX.ImporterGUI/DSFBX.ImporterGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>

</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
Expand Down Expand Up @@ -77,6 +78,7 @@
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="ArmorExtension.cs" />
<Compile Include="DSFBXConfig.cs" />
<Compile Include="DSFBXContext.cs" />
<Compile Include="MainWindow.xaml.cs">
Expand Down Expand Up @@ -133,7 +135,6 @@
<Name>ModelReloaderDS1R</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>del "$(TargetDir)*.xml" /q /f
Expand Down
12 changes: 1 addition & 11 deletions DSFBX.ImporterGUI/DSFBXConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class DSFBXConfig : INotifyPropertyChanged
{
public string Manual_LastModelTypeDropdownOption = "Weapon";

public string Manual_LastArmorExtensionTypeDropdownOption = "Human";

private bool _forceReloadCHR = true;
public bool ForceReloadCHR
Expand Down Expand Up @@ -59,17 +60,6 @@ public bool ConvertNormalsAxis
}
}

private bool _armorCopyHumanToHollow = true;
public bool ArmorCopyHumanToHollow
{
get => _armorCopyHumanToHollow;
set
{
_armorCopyHumanToHollow = value;
RaisePropertyChanged();
}
}

private bool _armorCopyMaleLegsToFemale = true;
public bool ArmorCopyMaleLegsToFemale
{
Expand Down
22 changes: 8 additions & 14 deletions DSFBX.ImporterGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DSFBX_GUI"
mc:Ignorable="d"
Title="DSFBX Beta v1.1"
Title="DSFBX Beta v1.2"
Width="773"
Height="640"
MinWidth="960"
Expand Down Expand Up @@ -247,19 +247,6 @@
Import Mesh Double-Sided
</CheckBox>

<CheckBox
x:Name="CheckBoxArmorCopyHumanToHollow"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,114,10,0"
Width="215"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Center"
IsChecked="{Binding Config.ArmorCopyHumanToHollow}" Height="29"
>
Copy Human -> Hollow
</CheckBox>

<CheckBox
x:Name="CheckBoxArmorCopyMaleLegsToFemale"
HorizontalAlignment="Right"
Expand Down Expand Up @@ -392,9 +379,16 @@
<ListBoxItem x:Name="ModelTypeDropdown_Weapon" Content="Weapon"/>
</ComboBox>

<ComboBox x:Name="ArmorExtensionTypeDropdown" HorizontalAlignment="Right" Margin="0,120,10,0" VerticalAlignment="Top" Width="103" SelectionChanged="ModelTypeDropdown_SelectionChanged" RenderTransformOrigin="0.503,0.5">
<ListBoxItem x:Name="ArmorExtension_Human" Content="Human"/>
<ListBoxItem x:Name="ArmorExtension_Hollow" Content="Hollow"/>
<ListBoxItem x:Name="ArmorExtension_Lowpoly" Content="Lowpoly"/>
</ComboBox>

<TextBox HorizontalAlignment="Right" Margin="0,95,10,0" VerticalAlignment="Top" Width="103" Text="{Binding Config.EntityModelID}"/>
<Label Content="Model Type:" HorizontalAlignment="Right" Margin="0,64,119,0" VerticalAlignment="Top"/>
<Label Content="Model ID:" HorizontalAlignment="Right" Margin="0,90,119,0" VerticalAlignment="Top"/>
<Label Content="Armor Type:" HorizontalAlignment="Right" Margin="0,115,119,0" VerticalAlignment="Top"/>
<Label
Content="Dark Souls Remastered EXE Path:"
HorizontalAlignment="Left"
Expand Down
51 changes: 49 additions & 2 deletions DSFBX.ImporterGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -152,6 +153,19 @@ void LoadConfig()
{
ModelTypeDropdown.SelectedItem = ModelTypeDropdown_Armor;
}

if (context.Config.Manual_LastArmorExtensionTypeDropdownOption == "Human")
{
ArmorExtensionTypeDropdown.SelectedItem = ArmorExtension_Human;
}
else if (context.Config.Manual_LastArmorExtensionTypeDropdownOption == "Hollow")
{
ArmorExtensionTypeDropdown.SelectedItem = ArmorExtension_Hollow;
}
else if (context.Config.Manual_LastArmorExtensionTypeDropdownOption == "Lowpoly")
{
ArmorExtensionTypeDropdown.SelectedItem = ArmorExtension_Lowpoly;
}
}

void SaveConfig()
Expand All @@ -173,6 +187,19 @@ void SaveConfig()
context.Config.Manual_LastModelTypeDropdownOption = "Armor";
}

if (ArmorExtensionTypeDropdown.SelectedItem == ArmorExtension_Human)
{
context.Config.Manual_LastArmorExtensionTypeDropdownOption = "Human";
}
else if (ArmorExtensionTypeDropdown.SelectedItem == ArmorExtension_Hollow)
{
context.Config.Manual_LastArmorExtensionTypeDropdownOption = "Hollow";
}
else if (ArmorExtensionTypeDropdown.SelectedItem == ArmorExtension_Lowpoly)
{
context.Config.Manual_LastArmorExtensionTypeDropdownOption = "Lowpoly";
}

string json = JsonConvert.SerializeObject(context.Config, Formatting.Indented);
File.WriteAllText("DSFBX_Config.json", json);
}
Expand Down Expand Up @@ -229,7 +256,11 @@ private async void ButtonImport_Click(object sender, RoutedEventArgs e)
Importer.SceneRotation.X = (float)((context.Config.SceneRotationX / 180) * Math.PI);
Importer.SceneRotation.Y = (float)((context.Config.SceneRotationY / 180) * Math.PI);
Importer.SceneRotation.Z = (float)((context.Config.SceneRotationZ / 180) * Math.PI);
Importer.ArmorCopyHumanToHollow = context.Config.ArmorCopyHumanToHollow;
Importer.ArmorExtension = "";
if (Importer.OutputType == DSFBXOutputType.Armor)
{
Importer.ArmorExtension = ArmorExtension.Dict[ArmorExtensionTypeDropdown.SelectedItem.ToString()];
}
Importer.ArmorCopyMaleLegsToFemale = context.Config.ArmorCopyMaleLegsToFemale;
Importer.ArmorFixBodyNormals = context.Config.ArmorFixBodyNormals;
Importer.RotateNormalsBackward = context.Config.RotateNormalsBackward;
Expand Down Expand Up @@ -424,10 +455,26 @@ private void ButtonInputBrowse_Click(object sender, RoutedEventArgs e)
if (dlg.ShowDialog() == true)
{
context.Config.InputFBX = dlg.FileName;
var idNumber = Regex.Match(dlg.FileName, @"\d+").Value;
if (!string.IsNullOrWhiteSpace(idNumber))
context.Config.EntityModelID = int.Parse(idNumber);
var armorExtension = System.IO.Path.GetFileNameWithoutExtension(dlg.FileName);
GetExtension(armorExtension);

SaveConfig();
}
}

private void GetExtension(string armorExtension)
{
if (armorExtension.ToLower().Contains("human"))
ArmorExtensionTypeDropdown.SelectedIndex = 0;
if (armorExtension.ToLower().Contains("hollow"))
ArmorExtensionTypeDropdown.SelectedIndex = 1;
if (armorExtension.ToLower().Contains("lowpoly"))
ArmorExtensionTypeDropdown.SelectedIndex = 2;
}

private void ButtonOutputBrowse_Click(object sender, RoutedEventArgs e)
{
var dlg = new OpenFileDialog()
Expand Down Expand Up @@ -546,7 +593,7 @@ private void ButtonClearOutput_Click(object sender, RoutedEventArgs e)
private void ModelTypeDropdown_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
CheckBoxArmorCopyMaleLegsToFemale.IsEnabled = ModelTypeDropdown.SelectedItem == ModelTypeDropdown_Armor;
CheckBoxArmorCopyHumanToHollow.IsEnabled = ModelTypeDropdown.SelectedItem == ModelTypeDropdown_Armor;
ArmorExtensionTypeDropdown.IsEnabled = ModelTypeDropdown.SelectedItem == ModelTypeDropdown_Armor;
CheckBoxArmorFixBodyNormals.IsEnabled = ModelTypeDropdown.SelectedItem == ModelTypeDropdown_Armor;

checkboxForceReloadPARTS.IsEnabled = ((ModelTypeDropdown.SelectedItem == ModelTypeDropdown_Armor
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Added a few features
* Replaced "Copy Human to Hollow" with dropdown selection for Human, Hollow and Lowpoly
* Auto detect Human Hollow or Lowpoly if included in FBX name
* Auto detect Part ID number, if Part ID number is the only number in the FBX name

# DSFBX
Experimental FBX model importer for Dark Souls 1

Expand Down