public static void SaveREA(reaParser parser, string destPath, bool keepBackup) { DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(destPath)); string backup = null; if (keepBackup && File.Exists(destPath)) { backup = Utility.GetDestFile(dir, Path.GetFileNameWithoutExtension(destPath) + ".bak", Path.GetExtension(destPath)); File.Move(destPath, backup); } try { using (BufferedStream bufStr = new BufferedStream(File.OpenWrite(destPath))) { parser.WriteTo(bufStr); } } catch { if (File.Exists(backup)) { if (File.Exists(destPath)) { File.Delete(destPath); } File.Move(backup, destPath); } } }
public FormREA(fpkParser fpkParser, string reaParserVar) { try { InitializeComponent(); this.Controls.Remove(this.menuStrip1); reaParser parser = (reaParser)Gui.Scripting.Variables[reaParserVar]; this.ShowHint = DockState.Document; this.Text = parser.Name; this.ToolTipText = fpkParser.FilePath + @"\" + parser.Name; ParserVar = reaParserVar; EditorVar = Gui.Scripting.GetNextVariable("reaEditor"); Editor = (reaEditor)Gui.Scripting.RunScript(EditorVar + " = reaEditor(parser=" + ParserVar + ")"); Init(); LoadREA(); } catch (Exception ex) { Utility.ReportException(ex); } }
public static void SaveREA(reaParser parser, string destPath, bool keepBackup) { DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(destPath)); string backup = null; if (keepBackup && File.Exists(destPath)) { backup = Utility.GetDestFile(dir, Path.GetFileNameWithoutExtension(destPath) + ".bak", Path.GetExtension(destPath)); File.Move(destPath, backup); } try { using (BufferedStream bufStr = new BufferedStream(File.OpenWrite(destPath))) { parser.WriteTo(bufStr); } } catch { if (File.Exists(backup)) { if (File.Exists(destPath)) File.Delete(destPath); File.Move(backup, destPath); } } }
public static reaAnimationTrack FindTrack(remId trackName, reaParser parser) { foreach (reaAnimationTrack track in parser.ANIC) { if (track.boneFrame == trackName) { return(track); } } return(null); }
void ReopenREA() { string path = this.ToolTipText; string parserCommand = ParserVar + " = OpenREA(path=\"" + path + "\")"; reaParser parser = (reaParser)Gui.Scripting.RunScript(parserCommand); string editorCommand = EditorVar + " = reaEditor(parser=" + ParserVar + ")"; Editor = (reaEditor)Gui.Scripting.RunScript(editorCommand); LoadREA(); }
public static reaAnimationTrack FindTrack(remId trackName, reaParser parser) { foreach (reaAnimationTrack track in parser.ANIC) { if (track.boneFrame == trackName) { return track; } } return null; }
public static void ReplaceAnimation(WorkspaceAnimation wsAnimation, List <ImportedFrame> wsSkeleton, reaParser parser, int resampleCount, bool linear, ReplaceAnimationMethod replaceMethod, int insertPos, bool negateQuaternionFlips) { Report.ReportLog("Replacing animation ..."); List <KeyValuePair <string, ImportedAnimationSampledTrack> > newTrackList = FbxUtility.CopySampledAnimation(wsAnimation, resampleCount, linear); reaANICsection animationNodeList = parser.ANIC; ImportedSampledAnimation iAnim = new ImportedSampledAnimation(); iAnim.TrackList = new List <ImportedAnimationSampledTrack>(animationNodeList.Count); Dictionary <string, ImportedAnimationSampledTrack> animationNodeDic = null; if (replaceMethod != ReplaceAnimationMethod.Replace) { animationNodeDic = new Dictionary <string, ImportedAnimationSampledTrack>(); foreach (reaAnimationTrack animationNode in animationNodeList) { ImportedFrame boneFrame = ImportedHelpers.FindFrame(animationNode.boneFrame, wsSkeleton[0]); bool isTopFrame = boneFrame != null && boneFrame.Parent == wsSkeleton[0]; ImportedAnimationSampledTrack iTrack = Plugins.REMConverter.ConvertTrack(animationNode, isTopFrame); iTrack.Name = animationNode.boneFrame; animationNodeDic.Add(animationNode.boneFrame, iTrack); iAnim.TrackList.Add(iTrack); } } FbxUtility.ReplaceAnimation(replaceMethod, insertPos, newTrackList, iAnim, animationNodeDic, negateQuaternionFlips); animationNodeList.ChildList.Clear(); foreach (var newTrack in iAnim.TrackList) { ImportedFrame boneFrame = ImportedHelpers.FindFrame(newTrack.Name, wsSkeleton[0]); bool isTopFrame = boneFrame != null && boneFrame.Parent == wsSkeleton[0]; reaAnimationTrack animationNode = Plugins.REMConverter.ConvertTrack(newTrack, isTopFrame); animationNodeList.AddChild(animationNode); } }
public void Dispose() { Parser = null; }
public reaEditor(reaParser parser) { Parser = parser; }