Exemplo n.º 1
0
        void OpenBoneRemappingTool()
        {
            var targetSkeletonName = _meshNode.MeshModel.ParentSkeletonName;

            var existingSkeletonMeshNode = _meshNode.GetParentModel();
            var existingSkeltonName      = existingSkeletonMeshNode.Model.Header.SkeletonName;

            RemappedAnimatedBoneConfiguration config = new RemappedAnimatedBoneConfiguration();

            var existingSkeletonFile = _animLookUp.GetSkeletonFileFromName(_pfs, targetSkeletonName);

            config.MeshSkeletonName = targetSkeletonName;
            config.MeshBones        = AnimatedBone.CreateFromSkeleton(existingSkeletonFile, AnimatedBones.Select(x => x.BoneIndex).ToList());


            var newSkeletonFile = _animLookUp.GetSkeletonFileFromName(_pfs, existingSkeltonName);

            config.ParnetModelSkeletonName = existingSkeltonName;
            config.ParentModelBones        = AnimatedBone.CreateFromSkeleton(newSkeletonFile);



            AnimatedBlendIndexRemappingWindow window = new AnimatedBlendIndexRemappingWindow()
            {
                DataContext = new AnimatedBlendIndexRemappingViewModel(config)
            };

            if (window.ShowDialog() == true)
            {
                var remapping = config.MeshBones.First().BuildRemappingList();
                _componentManager.GetComponent <CommandExecutor>().ExecuteCommand(new RemapBoneIndexesCommand(_meshNode, remapping, config.ParnetModelSkeletonName, config.MoveMeshToFit, new GameSkeleton(existingSkeletonFile, null), new GameSkeleton(newSkeletonFile, null)));
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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);
        }