void CreateBoneOverview(GameSkeleton skeleton)
        {
            var boneIndexsUsed = _meshNode.Geometry.GetUniqeBlendIndices();

            Bones.Clear();

            if (skeleton == null)
            {
                return;
            }

            for (int i = 0; i < skeleton.BoneCount; i++)
            {
                var parentBoneId = skeleton.GetParentBone(i);
                if (parentBoneId == -1)
                {
                    Bones.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i], boneIndexsUsed));
                }
                else
                {
                    var treeParent = GetParent(Bones, parentBoneId);

                    if (treeParent != null)
                    {
                        treeParent.Children.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i], boneIndexsUsed));
                    }
                }
            }

            Bones = FilterHelper.FilterBoneList("", true, Bones);
        }
        void CreateBoneOverview(GameSkeleton skeleton)
        {
            SelectedBone = null;
            Bones.Clear();
            BoneCount = 0;

            if (skeleton == null)
            {
                return;
            }

            BoneCount = skeleton.BoneCount;
            for (int i = 0; i < skeleton.BoneCount; i++)
            {
                var parentBoneId = skeleton.GetParentBone(i);
                if (parentBoneId == -1)
                {
                    Bones.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i]));
                }
                else
                {
                    var treeParent = GetParent(Bones, parentBoneId);

                    if (treeParent != null)
                    {
                        treeParent.Children.Add(CreateNode(i, parentBoneId, skeleton.BoneNames[i]));
                    }
                }
            }
        }
 public BmiViewModel(GameSkeleton skeleton, Rmv2MeshNode meshNode, IComponentManager componentManager)
 {
     _componentManager = componentManager;
     _meshNode         = meshNode;
     _skeleton         = skeleton;
     CreateBoneOverview(_skeleton);
 }
        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;
        }
示例#5
0
 public GrowMeshCommand(GameSkeleton skeleton, Rmv2MeshNode node, float factor, List <int> bonesAffectedScale)
 {
     _node               = node;
     _factor             = factor;
     _gameSkeleton       = skeleton;
     _bonesAffectedScale = bonesAffectedScale;
 }
 public RemapBoneIndexesCommand(Rmv2MeshNode meshOwner, List <IndexRemapping> mapping, string newSkeletonName, bool moveMeshToFit, GameSkeleton currentSkeleton, GameSkeleton targetSkeleton)
 {
     _meshOwner       = meshOwner;
     _mapping         = mapping;
     _newSkeletonName = newSkeletonName;
     _moveMeshToFit   = moveMeshToFit;
     _currentSkeleton = currentSkeleton;
     _targetSkeleton  = targetSkeleton;
 }
示例#7
0
 void Awake()
 {
     gridSystem      = GetComponent <GridSystem> ();
     selectorManager = GetComponent <SelectorManager> ();
     stats           = GetComponent <Stats> ();
     inputManager    = GetComponent <IInputManager> ();
     UImanager       = GetComponent <UIManager> ();
     particleManager = GetComponent <IParticleManager> ();
     audoisource     = GetComponent <AudioSource>();
     Instance        = this;
 }
示例#8
0
        public MountAnimationGeneratorService(AnimationSettingsViewModel animationSettings, Rmv2MeshNode mountMesh, int mountVertexId, int riderBoneIndex, AssetViewModel rider, AssetViewModel mount)
        {
            _animationSettings = animationSettings;
            _mountVertexId     = mountVertexId;

            _riderBoneIndex = riderBoneIndex;
            _riderSkeleton  = rider.Skeleton;
            _mountSkeleton  = mount.Skeleton;

            float mountScale = (float)_animationSettings.Scale.Value;

            mount.SetTransform(Matrix.CreateScale(mountScale));
            _mountVertexPositionResolver = new MeshAnimationHelper(mountMesh, Matrix.CreateScale(mountScale));
        }
        private void RiderSkeletonChanges(GameSkeleton newValue)
        {
            if (newValue == null)
            {
                ActiveOutputFragment.UpdatePossibleValues(null);
                SelectedRiderBone.UpdatePossibleValues(null);
            }
            else
            {
                ActiveOutputFragment.UpdatePossibleValues(MountLinkController.LoadFragmentsForSkeleton(newValue.SkeletonName, true));
                SelectedRiderBone.UpdatePossibleValues(SkeletonHelper.CreateFlatSkeletonList(newValue));
            }

            SelectedRiderBone.SelectedItem = SelectedRiderBone.PossibleValues.FirstOrDefault(x => string.Equals("root", x.BoneName, StringComparison.OrdinalIgnoreCase));
            MountLinkController.ReloadFragments(true, false);
            UpdateCanSaveAndPreviewStates();
        }
示例#10
0
        public MeshFitterViewModel(RemappedAnimatedBoneConfiguration configuration, List <Rmv2MeshNode> meshNodes, GameSkeleton targetSkeleton, AnimationFile currentSkeletonFile, IComponentManager componentManager) : base(configuration)
        {
            _meshNodes        = meshNodes;
            _dwarfSkeleton    = targetSkeleton;
            _componentManager = componentManager;

            _animationPlayer    = _componentManager.GetComponent <AnimationsContainerComponent>().RegisterAnimationPlayer(new AnimationPlayer(), "Temp animation rerig");
            _humanoid01Skeleton = new GameSkeleton(currentSkeletonFile, _animationPlayer);


            // Build empty animation
            _animationClip = new AnimationClip();
            _animationClip.DynamicFrames.Add(new AnimationClip.KeyFrame());

            for (int i = 0; i < _humanoid01Skeleton.BoneCount; i++)
            {
                _animationClip.DynamicFrames[0].Rotation.Add(_humanoid01Skeleton.Rotation[i]);
                _animationClip.DynamicFrames[0].Position.Add(_humanoid01Skeleton.Translation[i]);
                _animationClip.DynamicFrames[0].Scale.Add(Vector3.One);

                _animationClip.RotationMappings.Add(new AnimationFile.AnimationBoneMapping(i));
                _animationClip.TranslationMappings.Add(new AnimationFile.AnimationBoneMapping(i));
            }


            _animationPlayer.SetAnimation(_animationClip, _humanoid01Skeleton);
            _animationPlayer.Play();


            var resourceLib = _componentManager.GetComponent <ResourceLibary>();

            _currentSkeletonNode = new SkeletonNode(resourceLib.Content, new SimpleSkeletonProvider(_humanoid01Skeleton));
            _componentManager.GetComponent <SceneManager>().RootNode.AddObject(_currentSkeletonNode);


            _oldAnimationPlayer = _meshNodes.First().AnimationPlayer;
            foreach (var mesh in _meshNodes)
            {
                mesh.AnimationPlayer = _animationPlayer;
            }
        }
 public SkeletonBoneAnimationResolver(GameSkeleton gameSkeleton, int boneIndex)
 {
     _gameSkeleton = gameSkeleton;
     _boneIndex    = boneIndex;
 }
示例#12
0
        static public PackFile SaveAnimation(PackFileService pfs, string riderAnimationName, string savePrefix, bool ensureUniqeName, AnimationClip clip, GameSkeleton skeleton)
        {
            var animFile = clip.ConvertToFileFormat(skeleton);
            var bytes    = AnimationFile.GetBytes(animFile);

            string savePath = "";

            if (string.IsNullOrWhiteSpace(savePrefix) == false)
            {
                if (ensureUniqeName)
                {
                    savePath = GenerateNewAnimationName(pfs, riderAnimationName, savePrefix);
                }
                else
                {
                    savePath = Path.GetDirectoryName(riderAnimationName) + "\\" + savePrefix + Path.GetFileName(riderAnimationName);
                }
            }

            return(SaveHelper.Save(pfs, savePath, null, bytes));
        }
示例#13
0
 public SimpleSkeletonProvider(GameSkeleton skeleton)
 {
     Skeleton = skeleton;
 }
 private void MountSkeletonChanged(GameSkeleton newValue)
 {
     UpdateCanSaveAndPreviewStates();
     MountLinkController.ReloadFragments(false, true);
 }