AnimationClip LoadAnimation(string path) { var file = _pfs.FindFile(path); var animation = AnimationFile.Create(file); return(new AnimationClip(animation)); }
private void SkeletonChanged(string selectedSkeletonPath) { HeaderText = ""; _skeletonPackFile = null; Skeleton = null; AnimationsForCurrentSkeleton = new ObservableCollection <AnimationReference>(); if (!string.IsNullOrWhiteSpace(selectedSkeletonPath)) { _skeletonPackFile = _packFileService.FindFile(selectedSkeletonPath) as PackFile; if (_skeletonPackFile == null) { HeaderText = "No skeleton"; } else { HeaderText = _skeletonPackFile.Name + " - No Animation"; AnimationsForCurrentSkeleton = _skeletonAnimationLookUpHelper.GetAnimationsForSkeleton(Path.GetFileNameWithoutExtension(_skeletonPackFile.Name)); var skeletonAnimationFile = AnimationFile.Create(_skeletonPackFile); Skeleton = new GameSkeleton(skeletonAnimationFile, Player); } } SelectedAnimation = null; }
public void Load(string path, ISceneNode parent, AnimationPlayer player, ref string skeletonName) { var file = _packFileService.FindFile(path); if (file == null) { _logger.Here().Error($"File {path} not found"); return; } Load(file as PackFile, parent, player, ref skeletonName); }
private void MountTagSeleted(FragmentStatusSlotItem value) { if (value != null) { var file = _pfs.FindFile(value.Entry.Value.AnimationFile); var animationRef = _skeletonAnimationLookUpHelper.FindAnimationRefFromPackFile(file, _pfs); _mount.SetAnimation(animationRef); var lookUp = "RIDER_" + value.Entry.Value.Slot.Value; SelectedRiderTag.Filter = ""; SelectedRiderTag.SelectedItem = SelectedRiderTag.Values.FirstOrDefault(x => x.Entry.Value.Slot.Value == lookUp); } _validateAction(); }
public void GenerateWsModel() { try { var isAllVisible = _editableMeshNode.AreAllNodesVisible(); bool onlySaveVisible = false; if (isAllVisible == false) { if (MessageBox.Show("Only generate for visible nodes?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { onlySaveVisible = true; } } var modelFile = _kitbasherViewModel.MainFile as PackFile; var modelFilePath = _packFileService.GetFullPath(modelFile); var wsModelPath = Path.ChangeExtension(modelFilePath, ".wsmodel"); var existingWsModelFile = _packFileService.FindFile(wsModelPath, _packFileService.GetEditablePack()); var wsModelData = GenerateWsModel(modelFilePath, onlySaveVisible, out var wsModelGeneratedPerfectly); if (wsModelGeneratedPerfectly == false) { MessageBox.Show("Unable to correclty generate WS model, this file needs manual work before its can be used by the game!"); } SaveHelper.Save(_packFileService, wsModelPath, existingWsModelFile as PackFile, Encoding.UTF8.GetBytes(wsModelData)); } catch (Exception e) { _logger.Here().Error("Error generating ws model - " + e.ToString()); MessageBox.Show("Generation failed!"); } }
public static void CreateLionAndHu01b(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var editorView = toolFactory.CreateEditorViewModel <MountAnimationCreatorViewModel>(); editorView.MainInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\hef_princess_campaign_01.variantmeshdefinition") }; editorView.RefInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\hef_war_lion.variantmeshdefinition") }; creator.CreateEmptyEditor(editorView); }
public static void CreateBroodHorrorEditor(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var editorView = toolFactory.CreateEditorViewModel <MountAnimationCreatorViewModel>(); editorView.MainInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\skv_plague_priest.variantmeshdefinition") }; editorView.RefInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\skv_brood_horror.variantmeshdefinition") }; creator.CreateEmptyEditor(editorView); }
public static void CreateKarlAndSquigEditor(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var editorView = toolFactory.CreateEditorViewModel <MountAnimationCreatorViewModel>(); editorView.MainInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\emp_ch_karl.variantmeshdefinition") }; editorView.RefInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\grn_great_cave_squig.variantmeshdefinition") }; creator.CreateEmptyEditor(editorView); }
public static void CreateDamselAndGrymgoreEditor(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var editorView = toolFactory.CreateEditorViewModel <MountAnimationCreatorViewModel>(); editorView.MainInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\brt_damsel_campaign_01.variantmeshdefinition") }; editorView.RefInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\lzd_carnosaur_grymloq.variantmeshdefinition") }; creator.CreateEmptyEditor(editorView); }
public static void CreateRaptorAndHu02(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var editorView = toolFactory.CreateEditorViewModel <MountAnimationCreatorViewModel>(); editorView.MainInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\grn_savage_orc_base.variantmeshdefinition") as PackFile, }; editorView.RefInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\def_cold_one.variantmeshdefinition") as PackFile, }; creator.CreateEmptyEditor(editorView); }
IImage LoadTextureAsTexture2d(string fileName) { var file = _packFileService.FindFile(fileName); if (file == null) { return(null); } var content = (file as PackFile).DataSource.ReadData(); using (MemoryStream stream = new MemoryStream(content)) { var image = Pfim.Dds.Create(stream, new Pfim.PfimConfig(32768, Pfim.TargetFormat.Native, true)); if (image as Pfim.Dxt1Dds != null) { } else if (image as Pfim.Dxt5Dds != null) { } else { throw new Exception("Unknow texture format: " + image.ToString()); } return(image); } }
public static void CreateDamselAndSkavenEditor(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var editorView = toolFactory.CreateEditorViewModel <PropCreatorViewModel>(); editorView.MainInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\skv_assassin.variantmeshdefinition") as PackFile, Animation = packfileService.FindFile(@"animations\battle\humanoid17\halberd\stand\hu17_hb_stand_01.anim") as PackFile, }; editorView.RefInput = new AnimationToolInput() { Mesh = packfileService.FindFile(@"variantmeshes\variantmeshdefinitions\brt_damsel_campaign_01.variantmeshdefinition") as PackFile, Animation = packfileService.FindFile(@"animations\battle\humanoid01b\staff_and_sword\celebrate\hu1b_sfsw_celebrate_01.anim") as PackFile, }; creator.CreateEmptyEditor(editorView); }
PackFile GetWarLionModel() { PackFileService packFileService = new PackFileService(new PackFileDataBase()); var loadedPackFile = packFileService.Load(@"Data\variants_wp_.pack"); var file = packFileService.FindFile(@"variantmeshes\wh_variantmodels\bc4\hef\hef_war_lion\hef_war_lion_02.rigid_model_v2"); Assert.NotNull(file); return(file as PackFile); }
PackFile GetWeaponModel() { PackFileService packFileService = new PackFileService(new PackFileDataBase()); var loadedPackFile = packFileService.Load(@"Data\variants_wp_.pack"); var file = packFileService.FindFile(@"variantmeshes\wh_variantmodels\hu1d\hef\hef_props\hef_ranger_sword_1h_03.rigid_model_v2"); Assert.NotNull(file); return(file as PackFile); }
public void DeleteFile() { PackFileService packFileService = new PackFileService(new PackFileDataBase(), null); var loadedPackFile = packFileService.Load(@"Data\CaPackFile_01.pack"); var file = packFileService.FindFile(@"warmachines\tex\dwf_gyrocopter_obisidan_01_diffuse.dds"); packFileService.DeleteFile(loadedPackFile, file); var fileCount = loadedPackFile.FileList.Count; Assert.AreEqual(3, fileCount); }
public void LoadBootPack() { PackFileService packFileService = new PackFileService(new PackFileDataBase(), null); var pack0 = packFileService.Load(@"Data\boot.pack"); var file = packFileService.FindFile(@"fx\cardcaps.txt"); PackFile concretFile = file as PackFile; var s = Encoding.UTF8.GetString(concretFile.DataSource.ReadData()); Assert.NotNull(pack0); }
public void LoadReference(string path) { _logger.Here().Information($"Loading reference model from path - {path}"); var refereneceMesh = _packFileService.FindFile(path); if (refereneceMesh == null) { _logger.Here().Error("Unable to find file"); return; } LoadReference(refereneceMesh as PackFile); }
public void AddFolderToChild() { PackFileService packFileService = new PackFileService(new PackFileDataBase()); var loadedPackFile = packFileService.Load(@"Data\CaPackFile_01.pack"); packFileService.AddFolderContent(loadedPackFile, @"warmachines\materials", @"Data\FolderData"); var newFileCount = loadedPackFile.FileList.Count; Assert.AreEqual(9, newFileCount); var file = packFileService.FindFile(@"warmachines\materials\subFolder1\Subfolder_1_file1.txt"); Assert.NotNull(file); }
public void AddFileToFolder() { PackFileService packFileService = new PackFileService(new PackFileDataBase()); var loadedPackFile = packFileService.Load(@"Data\CaPackFile_01.pack"); packFileService.AddFileToPack(loadedPackFile, @"warmachines\materials", TestPackFileHelper.CreatePackFile("TestFile.txt")); var newFileCount = loadedPackFile.FileList.Count; Assert.AreEqual(5, newFileCount); var file = packFileService.FindFile(@"warmachines\materials\TestFile.txt"); Assert.NotNull(file); }
void OnItemDoubleClicked(DataTableRow row) { if (row == null) { return; } var file = _pf.FindFile(row.FileName); var nameSize = row.TagName.Length + 2; using (var stream = new MemoryStream((file as PackFile).DataSource.ReadData())) { var editor = new WpfHexaEditor.HexEditor { Stream = stream, ReadOnlyMode = true, ByteGrouping = WpfHexaEditor.Core.ByteSpacerGroup.FourByte, ByteSpacerPositioning = WpfHexaEditor.Core.ByteSpacerPosition.HexBytePanel, ByteSpacerVisualStyle = WpfHexaEditor.Core.ByteSpacerVisual.Dash, ByteSpacerWidthTickness = WpfHexaEditor.Core.ByteSpacerWidth.Normal, DataStringVisual = WpfHexaEditor.Core.DataVisualType.Decimal, OffSetStringVisual = WpfHexaEditor.Core.DataVisualType.Decimal, CustomBackgroundBlockItems = new List <WpfHexaEditor.Core.CustomBackgroundBlock>() { new WpfHexaEditor.Core.CustomBackgroundBlock() { Color = new SolidColorBrush(Colors.LightGreen), StartOffset = row.DataItem.Start, Length = row.DataItem.Size }, new WpfHexaEditor.Core.CustomBackgroundBlock() { Color = new SolidColorBrush(Colors.LightBlue), StartOffset = row.DataItem.Start - nameSize, Length = nameSize } } }; var form = new Window { Title = _pf.GetFullPath(file as PackFile), Content = editor }; form.ShowDialog(); } }
Texture2D LoadTextureAsTexture2d(string fileName, GraphicsDevice device) { try { //r content = File.ReadAllBytes(@"C:\Users\ole_k\Desktop\New folder\rad_rustig.dds"); var file = _pf.FindFile(fileName) as PackFile; if (file == null) { _logger.Here().Error($"Unable to find texture: {fileName}"); return(null); } var content = file.DataSource.ReadData(); using (MemoryStream stream = new MemoryStream(content)) { var image = Pfim.Dds.Create(stream, new Pfim.PfimConfig(32768, Pfim.TargetFormat.Native, false)); if (image as Pfim.Dxt1Dds != null) { var texture = new Texture2D(device, image.Width, image.Height, false, SurfaceFormat.Dxt1); texture.SetData(image.Data, 0, (int)image.Header.PitchOrLinearSize); return(texture); } else if (image as Pfim.Dxt5Dds != null) { var texture = new Texture2D(device, image.Width, image.Height, false, SurfaceFormat.Dxt5); texture.SetData(image.Data, 0, (int)image.Header.PitchOrLinearSize); return(texture); } else if (image as Pfim.Dxt3Dds != null) { var texture = new Texture2D(device, image.Width, image.Height, false, SurfaceFormat.Dxt3); texture.SetData(image.Data, 0, (int)image.Header.PitchOrLinearSize); return(texture); } else { throw new Exception("Unknow texture format: " + image.ToString() + " Path = " + fileName); } } } catch (Exception e) { _logger.Here().Error($"Error loading texture ({fileName}): {e}"); } return(null); }
static string GenerateNewAnimationName(PackFileService pfs, string fullPath, string prefix, int numberId = 0) { string numberPostFix = ""; if (numberId != 0) { numberPostFix = "_" + numberId; } var potentialName = Path.GetDirectoryName(fullPath) + "\\" + prefix + numberPostFix + Path.GetFileName(fullPath); var fileRef = pfs.FindFile(potentialName); if (fileRef == null) { return(potentialName); } else { return(GenerateNewAnimationName(pfs, fullPath, prefix, numberId + 1)); } }
public static void CreateLoremasterHead(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var packFile = packfileService.FindFile(@"variantmeshes\wh_variantmodels\hu1d\hef\hef_loremaster_of_hoeth\hef_loremaster_of_hoeth_head_01.rigid_model_v2"); creator.OpenFile(packFile); }
public static void Load(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var packFile = packfileService.FindFile(@"animations\animation_tables\animation_tables.animpack"); creator.OpenFile(packFile); }
public static PackFile Save(PackFileService packFileService, string filename, PackFile packFile, byte[] updatedData = null, bool promptSaveOverride = true) { filename = filename.ToLower(); var selectedEditabelPackFile = packFileService.GetEditablePack(); if (selectedEditabelPackFile == null) { MessageBox.Show("No editable pack selected!"); return(null); } var existingFile = packFileService.FindFile(filename, selectedEditabelPackFile); if (existingFile != null && promptSaveOverride) { var fullPath = packFileService.GetFullPath(existingFile as PackFile, selectedEditabelPackFile); if (MessageBox.Show($"Replace existing file?\n{fullPath} \nin packfile:{selectedEditabelPackFile.Name}", "", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) { var extention = Path.GetExtension(fullPath); using (var browser = new SavePackFileWindow(packFileService)) { browser.ViewModel.Filter.SetExtentions(new List <string>() { extention }); if (browser.ShowDialog() == true) { var path = browser.FilePath; if (path.Contains(extention) == false) { path += extention; } filename = path; existingFile = null; } else { return(null); } } } } if (existingFile == null) { var directoryPath = Path.GetDirectoryName(filename); var justFileName = Path.GetFileName(filename); var data = updatedData; if (data == null) { data = packFile.DataSource.ReadData(); } var newPackFile = new PackFile(justFileName, new MemorySource(data)); packFileService.AddFileToPack(selectedEditabelPackFile, directoryPath, newPackFile); return(newPackFile); } else { if (updatedData == null) { throw new Exception("Trying to update an existing file, but no data is provided"); } packFileService.SaveFile(existingFile as PackFile, updatedData); return(existingFile as PackFile); } }
public static void CreateSlayerBody(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var packFile = packfileService.FindFile(@"variantmeshes\wh_variantmodels\hu3\dwf\dwf_slayers\body\dwf_slayers_body_01.rigid_model_v2"); creator.OpenFile(packFile); }
public static void CreateSkavenSlaveHead(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var packFile = packfileService.FindFile(@"variantmeshes\wh_variantmodels\hu17\skv\skv_clan_rats\head\skv_clan_rats_head_04.rigid_model_v2"); creator.OpenFile(packFile); }
public static void CreatePrincessBody(IEditorCreator creator, IToolFactory toolFactory, PackFileService packfileService) { var packFile = packfileService.FindFile(@"variantmeshes/wh_variantmodels/hu1b/hef/hef_princess/hef_princess_body_01.rigid_model_v2"); creator.OpenFile(packFile); }