Skip to content

Commit

Permalink
Merge pull request #1093 from Zurphing/anbmaker-update
Browse files Browse the repository at this point in the history
[ANBMaker] Add a motiontrigger BAR entry to created ANBs alongside outputting an MSET version of the ANB.
  • Loading branch information
Vladabdf authored Aug 8, 2024
2 parents 0fb213c + 11e9ac9 commit 857d5eb
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion OpenKh.Command.AnbMaker/Commands/AnbExCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
Expand All @@ -29,6 +30,7 @@ internal class AnbExCommand : IFbxSourceItemSelector, IMsetInjector

[Argument(1, Description = "anb output")]
public string Output { get; set; }
public string OutputMset { get; set; }

[Option(Description = "specify root armature node name", ShortName = "r")]
public string RootName { get; set; }
Expand Down Expand Up @@ -56,7 +58,7 @@ protected int OnExecute(CommandLineApplication app)
var logger = LogManager.GetLogger("InterpolatedMotionMaker");

Output = Path.GetFullPath(Output ?? Path.GetFileNameWithoutExtension(InputModel) + ".anb");

OutputMset = Path.GetFullPath(OutputMset ?? Path.GetFileNameWithoutExtension(InputModel) + ".mset");
Console.WriteLine($"Writing to: {Output}");

IEnumerable<BasicSourceMotion> parms;
Expand Down Expand Up @@ -117,12 +119,33 @@ protected int OnExecute(CommandLineApplication app)
Type = Bar.EntryType.Motion,
Name = "A999",
Stream = motionStream,
},
new Bar.Entry
{
Type = Bar.EntryType.MotionTriggers,
Name = "A999",
Stream = new MemoryStream() // Replace null with MemoryStream containing "0"
}
}
);

var msetBarStream = new MemoryStream();
Bar.Write(
msetBarStream,
new Bar.Entry[]
{
new Bar.Entry
{
Type = Bar.EntryType.Anb,
Name = "A999",
Stream = anbBarStream
}
}
);

File.WriteAllBytes(Output, anbBarStream.ToArray());
File.WriteAllBytes(Output + ".raw", motionStream.ToArray());
File.WriteAllBytes(OutputMset, msetBarStream.ToArray());

logger.Debug($"Motion data generation successful");

Expand Down

0 comments on commit 857d5eb

Please sign in to comment.