Ejemplo 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)));
            }
        }
Ejemplo 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();
        }