public static ISceneNodeViewModel Create(ISceneNode node, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, PackFileService pf, AnimationControllerViewModel animationControllerViewModel, IComponentManager componentManager)
        {
            switch (node)
            {
            case MainEditableNode mainNode:
                return(new MainEditableNodeViewModel(mainNode, skeletonAnimationLookUpHelper, animationControllerViewModel, pf));

            case Rmv2ModelNode m:
                return(new ModelSceneNodeViewModel(m));

            case Rmv2LodNode l:
                return(new LodSceneNodeViewModel(l));

            case Rmv2MeshNode m:
                return(new MeshSceneNodeViewModel(m, pf, skeletonAnimationLookUpHelper, componentManager));

            case SkeletonNode s:
                return(new SkeletonSceneNodeViewModel(s, pf, skeletonAnimationLookUpHelper));

            case GroupNode n:
            {
                if (n.IsEditable && n.Parent != null)
                {
                    return(new GroupNodeViewModel(n));
                }

                return(null);
            }


            default:
                return(null);
            }
        }
Exemplo n.º 2
0
 public MeshSceneNodeViewModel(Rmv2MeshNode node, PackFileService pfs, SkeletonAnimationLookUpHelper animLookUp, IComponentManager componentManager)
 {
     _meshNode = node;
     General   = new MeshSceneNodeViewModel_General(_meshNode);
     Animation = new MeshSceneNodeViewModel_Animation(pfs, _meshNode, animLookUp, componentManager);
     Graphics  = new MeshSceneNodeViewModel_Graphics(_meshNode, pfs);
 }
Exemplo n.º 3
0
        public Editor(PackFileService pfs, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, AssetViewModel rider, AssetViewModel mount, AssetViewModel newAnimation, IComponentManager componentManager)
        {
            _pfs              = pfs;
            _newAnimation     = newAnimation;
            _mount            = mount;
            _rider            = rider;
            _selectionManager = componentManager.GetComponent <SelectionManager>();

            DisplayGeneratedSkeleton = new NotifyAttr <bool>(true, (value) => _newAnimation.IsSkeletonVisible = value);
            DisplayGeneratedMesh     = new NotifyAttr <bool>(true, (value) => { if (_newAnimation.MainNode != null)
                                                                                {
                                                                                    _newAnimation.MainNode.IsVisible = value;
                                                                                }
                                                             });

            SelectedRiderBone   = new FilterCollection <SkeletonBoneNode>(null, (x) => UpdateCanSaveAndPreviewStates());
            MountLinkController = new MountLinkController(pfs, skeletonAnimationLookUpHelper, rider, mount, UpdateCanSaveAndPreviewStates);

            ActiveOutputFragment = new FilterCollection <AnimationFragment>(null, OutputFragmentSelected);
            ActiveOutputFragment.SearchFilter = (value, rx) => { return(rx.Match(value.FileName).Success); };

            ActiveFragmentSlot = new FilterCollection <FragmentStatusSlotItem>(null, (x) => UpdateCanSaveAndPreviewStates());
            ActiveFragmentSlot.SearchFilter = (value, rx) => { return(rx.Match(value.Entry.Value.Slot.Value).Success); };

            _mount.SkeletonChanged  += MountSkeletonChanged;
            _rider.SkeletonChanged  += RiderSkeletonChanges;
            _rider.AnimationChanged += RiderAnimationChanged;

            MountSkeletonChanged(_mount.Skeleton);
            RiderSkeletonChanges(_rider.Skeleton);
        }
        public MainEditableNodeViewModel(MainEditableNode mainNode, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, AnimationControllerViewModel animationControllerViewModel, PackFileService pf)
        {
            _mainNode = mainNode;
            _skeletonAnimationLookUpHelper = skeletonAnimationLookUpHelper;
            _animationControllerViewModel  = animationControllerViewModel;
            _pf = pf;

            SkeletonNameList = _skeletonAnimationLookUpHelper.SkeletonFileNames;
            if (_mainNode.Model != null)
            {
                SkeletonName = SkeletonNameList.FirstOrDefault(x => x.Contains(_mainNode.Model.Header.SkeletonName));
                UpdateSkeletonName();
            }
        }
        public MountLinkController(PackFileService pfs, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, AssetViewModel rider, AssetViewModel mount, Action validate)
        {
            _pfs = pfs;
            _skeletonAnimationLookUpHelper = skeletonAnimationLookUpHelper;
            _rider          = rider;
            _mount          = mount;
            _validateAction = validate;

            SelectedMountTag = new FilterCollection <FragmentStatusSlotItem>(null, MountTagSeleted);
            SelectedRiderTag = new FilterCollection <FragmentStatusSlotItem>(null, RiderTagSelected);
            SelectedMount    = new FilterCollection <AnimationFragment>(null, (value) => MuntSelected(value, SelectedMountTag, _mount.SkeletonName));
            SelectedRider    = new FilterCollection <AnimationFragment>(null, (value) => MuntSelected(value, SelectedRiderTag, _rider.SkeletonName));

            SelectedMountTag.SearchFilter = (value, rx) => { return(rx.Match(value.Entry.Value.Slot.Value).Success); };
            SelectedRiderTag.SearchFilter = (value, rx) => { return(rx.Match(value.Entry.Value.Slot.Value).Success); };
            SelectedMount.SearchFilter    = (value, rx) => { return(rx.Match(value.FileName).Success); };
            SelectedRider.SearchFilter    = (value, rx) => { return(rx.Match(value.FileName).Success); };

            ReloadFragments();
        }
Exemplo n.º 6
0
        public MeshSceneNodeViewModel_Animation(PackFileService pfs, Rmv2MeshNode meshNode, SkeletonAnimationLookUpHelper animLookUp, IComponentManager componentManager)
        {
            _pfs              = pfs;
            _meshNode         = meshNode;
            _animLookUp       = animLookUp;
            _componentManager = componentManager;

            SkeletonName            = _meshNode.MeshModel.ParentSkeletonName;
            LinkDirectlyToBoneIndex = _meshNode.MeshModel.Header.LinkDirectlyToBoneIndex;
            AttachmentPoints        = _meshNode.MeshModel.AttachmentPoints.OrderBy(x => x.BoneIndex).ToList();

            var skeletonFile = _animLookUp.GetSkeletonFileFromName(_pfs, SkeletonName);
            var bones        = _meshNode.Geometry.GetUniqeBlendIndices();

            AnimatedBones = bones.Select(x => new AnimatedBone()
            {
                BoneIndex = x, Name = skeletonFile.Bones[x].Name
            }).OrderBy(x => x.BoneIndex).ToList();
            OpenBoneRemappingToolCommand = new RelayCommand(OpenBoneRemappingTool);
        }
        public AnimationControllerViewModel(IComponentManager componentManager, PackFileService pf, SkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper)
        {
            _componentManager = componentManager;
            _packFileService  = pf;
            _skeletonAnimationLookUpHelper = skeletonAnimationLookUpHelper;
            SkeletonList = _skeletonAnimationLookUpHelper.SkeletonFileNames;

            var animCollection = _componentManager.GetComponent <AnimationsContainerComponent>();

            Player = animCollection.RegisterAnimationPlayer(new AnimationPlayer(), "MainPlayer");
            Player.OnFrameChanged += OnAnimationFrameChanged;

            PausePlayCommand = new RelayCommand(OnPlayPause);
            NextFrameCommand = new RelayCommand(OnNextFrame);
            PrivFrameCommand = new RelayCommand(OnPrivFrame);

            FirstFrameCommand = new RelayCommand(OnFirstFrame);
            LastFrameCommand  = new RelayCommand(OnLastFrame);

            IsEnabled = false;
        }
        public MenuBarViewModel(IComponentManager componentManager, PackFileService packFileService, SkeletonAnimationLookUpHelper skeletonHelper)
        {
            _packFileService = packFileService;

            TransformTool = new TransformToolViewModel(componentManager);
            Gizmo         = new GizmoModeMenuBarViewModel(TransformTool, componentManager, _commandFactory);
            General       = new GeneralMenuBarViewModel(componentManager, _commandFactory);
            Tools         = new ToolsMenuBarViewModel(componentManager, _commandFactory, _packFileService, skeletonHelper);

            ImportReferenceCommand            = new RelayCommand(ImportReference);
            ImportReferenceCommand_PaladinVMD = new RelayCommand(ImportReference_PaladinVMD);
        }
 public PropCreatorViewModel(PackFileService pfs, SkeletonAnimationLookUpHelper skeletonHelper) : base(pfs, skeletonHelper, "Main", "Reference")
 {
     DisplayName = "Anim.Prop Creator";
 }
Exemplo n.º 10
0
        public static void ShowView(List <ISelectable> meshesToFit, IComponentManager componentManager, SkeletonAnimationLookUpHelper skeletonHelper, PackFileService pfs)
        {
            var sceneManager   = componentManager.GetComponent <SceneManager>();
            var resourceLib    = componentManager.GetComponent <ResourceLibary>();
            var animCollection = componentManager.GetComponent <AnimationsContainerComponent>();

            var meshNodes = meshesToFit
                            .Where(x => x is Rmv2MeshNode)
                            .Select(x => x as Rmv2MeshNode)
                            .ToList();

            var allSkeltonNames = meshNodes
                                  .Select(x => x.MeshModel.ParentSkeletonName)
                                  .Distinct();

            if (allSkeltonNames.Count() != 1)
            {
                throw new Exception("Unexpected number of skeletons. This tool only works for one skeleton");
            }

            var currentSkeletonName = allSkeltonNames.First();
            var currentSkeletonFile = skeletonHelper.GetSkeletonFileFromName(pfs, currentSkeletonName);

            var usedBoneIndexes = meshNodes
                                  .SelectMany(x => x.Geometry.GetUniqeBlendIndices())
                                  .Distinct()
                                  .Select(x => (int)x)
                                  .ToList();

            var targetSkeleton     = componentManager.GetComponent <IEditableMeshResolver>().GeEditableMeshRootNode().Skeleton;
            var targetSkeletonFile = skeletonHelper.GetSkeletonFileFromName(pfs, targetSkeleton.Name);

            RemappedAnimatedBoneConfiguration config = new RemappedAnimatedBoneConfiguration();

            config.ParnetModelSkeletonName = targetSkeleton.Name;
            config.ParentModelBones        = AnimatedBone.CreateFromSkeleton(targetSkeletonFile);

            config.MeshSkeletonName = currentSkeletonName;
            config.MeshBones        = AnimatedBone.CreateFromSkeleton(currentSkeletonFile, usedBoneIndexes);


            var containingWindow = new Window();

            containingWindow.Title       = "Texture Preview Window";
            containingWindow.DataContext = new MeshFitterViewModel(config, meshNodes, targetSkeleton.AnimationProvider.Skeleton, currentSkeletonFile, componentManager);
            containingWindow.Content     = new MeshFitterView();
            containingWindow.Closed     += ContainingWindow_Closed;
            containingWindow.Show();
        }
 public MountAnimationCreatorViewModel(PackFileService pfs, SkeletonAnimationLookUpHelper skeletonHelper) : base(pfs, skeletonHelper, "Rider", "Mount")
 {
     DisplayName = "MountAnimCreator";
 }
Exemplo n.º 12
0
 public SkeletonSceneNodeViewModel(SkeletonNode node, PackFileService pf, SkeletonAnimationLookUpHelper animLookUp)
 {
     _meshNode = node;
 }
 public void Dispose()
 {
     _skeletonAnimationLookUpHelper = null;
     _mainNode = null;
 }