Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
donkeyProgramming committed Jul 16, 2022
1 parent e63de02 commit 09447fc
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 15 deletions.
20 changes: 15 additions & 5 deletions AssetEditor/ViewModels/MenuBarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class MenuBarViewModel
ToolFactory _toolFactory;
ApplicationSettingsService _settingsService;
SkeletonAnimationLookUpHelper _skeletonAnimationLookUpHelper;
public IEditorCreator EditorCreator { get; set; }

public ICommand OpenSettingsWindowCommand { get; set; }
public ICommand CreateNewPackFileCommand { get; set; }
Expand All @@ -59,6 +60,7 @@ public class MenuBarViewModel
public ICommand OpenAnimMetaDecocderCommand { get; set; }
public ICommand OpenMountCreatorCommand { get; set; }
public ICommand OpenAnimationBatchExporterCommand { get; set; }
public ICommand OpenWh2AnimpackUpdaterCommand { get; set; }
public ICommand OpenAnimationBuilderCommand { get; set; }

public ICommand SearchCommand { get; set; }
Expand All @@ -72,20 +74,23 @@ public class MenuBarViewModel
public ICommand OpenHelpCommand { get; set; }
public ICommand OpenPatreonCommand { get; set; }
public ICommand OpenDiscordCommand { get; set; }
public ICommand DownloadRmeCommand { get; set; }

public ICommand OpenKitbashEditorCommand { get; set; }
public ICommand OpenCampaignAnimCreatorCommand { get; set; }
public ICommand OpenPropCreatorCommand { get; set; }
public ICommand OpenAnimationTransferToolCommand { get; set; }
public ICommand OpenSuperViewToolCommand { get; set; }
public ICommand OpenTechSkeletonEditorCommand { get; set; }
public IEditorCreator EditorCreator { get; set; }

public ICommand GenerateRmv2ReportCommand { get; set; }
public ICommand GenerateMetaDataReportCommand { get; set; }
public ICommand GenerateFileListReportCommand { get; set; }
public ICommand GenerateMetaDataJsonsReportCommand { get; set; }
public ICommand CreateAnimPackWarhammer3Command { get; set; }
public ICommand CreateAnimPack3kCommand { get; set; }

// Tutorials
public ICommand OpenAnimatedPropTutorialCommand { get; set; }
public ICommand OpenAssetEdBasicTutorialCommand { get; set; }
public ICommand OpenSkragTutorialCommand { get; set; }
Expand Down Expand Up @@ -117,6 +122,7 @@ public MenuBarViewModel(IServiceProvider provider, PackFileService packfileServi
OpenSuperViewToolCommand = new RelayCommand(OpenSuperViewTool);
OpenTechSkeletonEditorCommand = new RelayCommand(OpenTechSkeletonEditor);
OpenAnimationBatchExporterCommand = new RelayCommand(OpenAnimationBatchExporter);
OpenWh2AnimpackUpdaterCommand = new RelayCommand(OpenWh2AnimpackUpdater);
OpenAnimationBuilderCommand = new RelayCommand(OpenOpenAnimationBuilder);

GenerateRmv2ReportCommand = new RelayCommand(GenerateRmv2Report);
Expand All @@ -142,6 +148,7 @@ public MenuBarViewModel(IServiceProvider provider, PackFileService packfileServi
OpenHelpCommand = new RelayCommand(() => Process.Start(new ProcessStartInfo("cmd", $"/c start https://tw-modding.com/index.php/Tutorial:AssetEditor") { CreateNoWindow = true }));
OpenPatreonCommand = new RelayCommand(() => Process.Start(new ProcessStartInfo("cmd", $"/c start https://www.patreon.com/TheAssetEditor") { CreateNoWindow = true }));
OpenDiscordCommand = new RelayCommand(() => Process.Start(new ProcessStartInfo("cmd", $"/c start https://discord.gg/6Djf2sCczC") { CreateNoWindow = true }));
DownloadRmeCommand = new RelayCommand(() => Process.Start(new ProcessStartInfo("cmd", $"/c start https://github.com/mr-phazer/RME_Release/releases/latest") { CreateNoWindow = true }));

var settings = settingsService.CurrentSettings;
settings.RecentPackFilePaths.CollectionChanged += (sender, args) => CreateRecentPackFilesItems();
Expand Down Expand Up @@ -279,12 +286,15 @@ void OpenTechSkeletonEditor()

void OpenAnimationBatchExporter() => AnimationBatchExportViewModel.ShowWindow(_packfileService, _skeletonAnimationLookUpHelper);

void OpenWh2AnimpackUpdater()
{
}


void OpenOpenAnimationBuilder()
{
{
var editorView = _toolFactory.CreateEditorViewModel<AnimationBuilderViewModel>();
EditorCreator.CreateEmptyEditor(editorView);
}
var editorView = _toolFactory.CreateEditorViewModel<AnimationBuilderViewModel>();
EditorCreator.CreateEmptyEditor(editorView);
}

void GenerateRmv2Report()
Expand Down
10 changes: 7 additions & 3 deletions AssetEditor/Views/MenuBarView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@
<MenuItem Header="Animation Transfer Tool" Command="{Binding MenuBar.OpenAnimationTransferToolCommand}" />
<MenuItem Header="Super view" Command="{Binding MenuBar.OpenSuperViewToolCommand}" />
<MenuItem Header="Skeleton Editor" Command="{Binding MenuBar.OpenTechSkeletonEditorCommand}" />
<MenuItem Header="Animation batch converter" Command="{Binding MenuBar.OpenAnimationBatchExporterCommand}" />

<Separator/>
<MenuItem Header="Animation File Batch converter" Command="{Binding MenuBar.OpenAnimationBatchExporterCommand}" />
<MenuItem Header="Warhammer 2 Animpack Updater" Command="{Binding MenuBar.OpenWh2AnimpackUpdaterCommand}" />
<Separator/>
<MenuItem Header="Import/Export to FBX (RME download)" Command="{Binding MenuBar.DownloadRmeCommand}" />

<MenuItem Header="Animation builder" Command="{Binding MenuBar.OpenAnimationBuilderCommand}" Visibility="Collapsed" />
<MenuItem Header="AnimMeta Decoder" Command="{Binding MenuBar.OpenAnimMetaDecocderCommand}" IsEnabled="False" Visibility="Collapsed"/>
Expand All @@ -92,8 +97,7 @@
<MenuItem Header="[YT]Example: Kostaltyn Reskin" Command="{Binding MenuBar.OpenKostalynTutorialCommand}"/>
<MenuItem Header="[YT]Animated Prop and custom Animation Packs" Command="{Binding MenuBar.OpenAnimatedPropTutorialCommand}"/>
<Separator/>
<MenuItem Header="Ask questions:" Command="{Binding MenuBar.OpenDiscordCommand}"/>
<Separator/>
<MenuItem Header="Ask questions - Discord community" Command="{Binding MenuBar.OpenDiscordCommand}"/>
<MenuItem Header="Manual" Command="{Binding MenuBar.OpenHelpCommand}"/>
</MenuItem>

Expand Down
32 changes: 28 additions & 4 deletions AudioResearch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class Program
static void Main(string[] args)
{
string[] allBnkFiles = GetAllBnkFiles();
var datDb = CreateDatDb();

Console.WriteLine($"Found {allBnkFiles.Length} bnk files");
allBnkFiles = FilterUnvantedFiles(allBnkFiles, out var removedFiles);
allBnkFiles = FilterUnvantedFiles(allBnkFiles, new[] { "media", "init.bnk", "animation_blood_data.bnk" }, out var removedFiles);
Console.WriteLine($"Found {allBnkFiles.Length} bnk files after filtering");

var globalSoundDatabase = new Dictionary<string, SoundDataBase>();
Expand Down Expand Up @@ -109,17 +110,16 @@ static void PrintHircData(IEnumerable<HircItem> hircItems)
}
}

static string[] FilterUnvantedFiles(string[] files, out string[] removedFiles)
static string[] FilterUnvantedFiles(string[] files, string[] removeFilters, out string[] removedFiles)
{
var tempRemoveFiles = new List<string>();
var fileList = files.ToList();

// Files that contains multiple items not decoded.
var removeFilter = new[]{ "media", "init.bnk", "animation_blood_data.bnk" };

foreach (var file in fileList)
{
foreach (var removeName in removeFilter)
foreach (var removeName in removeFilters)
{
if (file.Contains(removeName))
{
Expand Down Expand Up @@ -155,6 +155,30 @@ private static string[] GetAllBnkFiles()
throw new Exception("The export folder should contain 611 bnk files. (Core files + English Folder)");
return allBnkFiles;
}

private static string[] GetAllDatFiles()
{
var allDatFiles = Directory.GetFiles(GetExportedWWiseFolder(), "*.dat", SearchOption.AllDirectories);
if (allDatFiles.Length != 15)
throw new Exception("The export folder should contain 15 dat files.");
return allDatFiles;
}

private static SoundDatFile CreateDatDb()
{
var datFiles = GetAllDatFiles();
datFiles = FilterUnvantedFiles(datFiles, new[] { "bank_splits.dat" }, out var removedFiles);

var masterDat = new SoundDatFile();
foreach (var datFile in datFiles)
{
var pf = new PackFile(datFile, new FileSystemSource(datFile));
var parsedFile = DatParser.Parse(pf, false);
masterDat.Merge(parsedFile);
}

return masterDat;
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ public static PackFile CreateAnimationDbWarhammer3(PackFileService pfs)
return null;
}

public static PackFile CreateAnimationDbWarhammer3(PackFileService pfs, string name)
public static string GenerateWh3AnimPackName(string name)
{

var fileName = SaveHelper.EnsureEnding(name, ".animpack");
var filePath = @"animations/database/battle/bin/" + fileName;
return filePath;
}

public static PackFile CreateAnimationDbWarhammer3(PackFileService pfs, string name)
{
var filePath = GenerateWh3AnimPackName(name);

if (!SaveHelper.IsFilenameUnique(pfs, filePath))
{
Expand Down
83 changes: 83 additions & 0 deletions CommonControls/Services/AnimPackUpdaterService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
using CommonControls.Common;
using CommonControls.Editors.AnimationPack;
using CommonControls.FileTypes.AnimationPack;
using CommonControls.FileTypes.AnimationPack.AnimPackFileTypes;
using CommonControls.FileTypes.AnimationPack.AnimPackFileTypes.Wh3;
using CommonControls.FileTypes.PackFiles.Models;
using Serilog;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace CommonControls.Services
{
public class AnimPackUpdaterService
{
private readonly PackFileService _pfs;
private readonly ILogger _logger = Logging.Create<AnimPackUpdaterService>();

public AnimPackUpdaterService(PackFileService pfs)
{
_pfs = pfs;
}

public void Process(PackFileContainer packFileContainer, GameTypeEnum existingPackVersion = GameTypeEnum.Warhammer2, GameTypeEnum outputFormat = GameTypeEnum.Warhammer3)
{
if (outputFormat != GameTypeEnum.Warhammer3)
throw new Exception($"{outputFormat} selected as output, only Warhammer 3 is currently supported");

if (existingPackVersion != GameTypeEnum.Warhammer2)
throw new Exception($"{outputFormat} selected as input, only Warhammer 2 is currently supported");

var animPackFiles = _pfs.FindAllWithExtention(".animpack", packFileContainer);
var animPacks = animPackFiles.Select(x => AnimationPackSerializer.Load(x, _pfs, GameTypeEnum.Warhammer2)).ToArray();

if (animPacks.Length == 0)
throw new Exception("No animation packs found in the packfile");

foreach (var animPack in animPacks)
{
var outputWh3AnimPack = new AnimationPackFile();

var unkownFilesCount = animPack.Files.Count(x => x is IMatchedCombatBin || x is UnknownAnimFile);
if (unkownFilesCount != 0)
throw new Exception($"AnimPack {animPack.FileName} contains {unkownFilesCount} unkown files");

var animFrags = animPack.Files.Where(x => x is AnimationFragmentFile).Cast<AnimationFragmentFile>();
var animBins = animPack.Files.Where(x => x is AnimationBin).Cast<AnimationBin>();
var animationBinEntries = animBins.SelectMany(x => x.AnimationTableEntries).ToArray();

var processedFragments = 0;
var processedBinEntries = 0;

foreach (var binEntry in animationBinEntries)
{

var wh3Bin = new AnimationBinWh3(binEntry.Name);
wh3Bin.SkeletonName = binEntry.SkeletonName;
wh3Bin.MountBin = binEntry.MountName;
wh3Bin.LocomotionGraph = "animations/locomotion_graphs/entity_locomotion_graph.xml";

var fragment = animFrags.First(x => string.Equals(x.FileName, binEntry.Name, StringComparison.InvariantCultureIgnoreCase));
foreach (var animationSetEntry in fragment.Fragments)
{

processedFragments++;
}

processedBinEntries++;
outputWh3AnimPack.AddFile(wh3Bin);
}

var animPackPathWithoutExtentions = Path.GetFileNameWithoutExtension(animPack.FileName);
var outputAnimPackName = AnimationPackSampleDataCreator.GenerateWh3AnimPackName(animPackPathWithoutExtentions + "_wh3");
SaveHelper.Save(_pfs, outputAnimPackName, null, AnimationPackSerializer.ConvertToBytes(outputWh3AnimPack), false);
}

}


}
}
18 changes: 17 additions & 1 deletion ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,16 @@ make time in superview copyable

V0.39
----------------------------
animtranfer tool filter for batch processing
Clean up render list items - One dispsable large list and one on the go. All types of line items made in a factory and works for both
Convert wh2 animpack to wh3 format
Phazer link
Fix datParser so it does not break wh2


OpenWh2AnimpackUpdaterCommand
DownloadRmeCommand

TL;DR - Fixed some huge bugs, auto upgrade Wh2 animpacks to Wh3, added tutorials and quality of life fixes

Features:
* Animation report (Thanks to Klissian)
Expand All @@ -219,6 +227,7 @@ Features:
* Added more tutorials under the tutorials dropdown (thanks to Masked Mustachio)
* Ctrl + double click expands all child nodes in the packfile tree view
* Collapse all added to packfile tree view context menu
* Lot of code related to audio modding (Work in progres)

BugFixes:
* Static meshes now load/save correctly. Should no longer get incorrect shading in game when using static meshes. (Thanks to Phazer)
Expand All @@ -227,6 +236,13 @@ BugFixes:
* Fixed error when creating LODs
* Fixed crash when using prop meta tags

New tutorials:
https://www.youtube.com/watch?v=b68hSHZ5raY
https://www.youtube.com/watch?v=7HN4oA2LsFM
https://www.youtube.com/watch?v=MhvbZfNp8Qw
https://www.youtube.com/watch?v=ONRAKJUmuiM
https://www.youtube.com/watch?v=AXw99yc74CY



V0.38
Expand Down

0 comments on commit 09447fc

Please sign in to comment.