public void DeleteCharacterAnimation(CharacterXML character, AnimationXML animation)
        {
            var existingCharacter = CharacterList.Find(x => x.CharacterName == character.CharacterName);

            if (existingCharacter != null)
            {
                existingCharacter.DeleteAnimation(animation);
            }
        }
Exemple #2
0
        //-- Save the character pair of offsets to the xml file, overwriting if necessary --//
        public static void SaveCharacterGroupOffsets(List <string> characterNames, List <OffsetVectors[]> offsetVectorList, List <bool[]> jointCorrectionList, List <float> shoeOffsets, bool isDefault = false)
        {
            if (characterNames.IsNullOrEmpty() || offsetVectorList.IsNullOrEmpty() || shoeOffsets.IsNullOrEmpty())
            {
                return;
            }

            var currentAnimation = HS2_BetterHScenes.hFlagCtrl.nowAnimationInfo.nameAnimation;

            if (currentAnimation == null || HS2_BetterHScenes.currentMotion == null)
            {
                return;
            }

            var currentMotion = HS2_BetterHScenes.currentMotion;

            if (isDefault)
            {
                currentMotion = "default";
            }

            string characterGroupName = null;

            foreach (var name in characterNames)
            {
                if (characterGroupName == null)
                {
                    characterGroupName = name;
                }
                else
                {
                    characterGroupName += "_" + name;
                }
            }

            HS2_BetterHScenes.Logger.LogMessage("Saving Offsets for " + currentAnimation + " Motion " + currentMotion + " for characters " + characterGroupName);

            var characterGroup = new CharacterGroupXML(characterGroupName);

            for (var charIndex = 0; charIndex < characterNames.Count; charIndex++)
            {
                var motionOffsets = new MotionOffsetsXML(currentMotion, offsetVectorList[charIndex], jointCorrectionList[charIndex]);
                var animation     = new AnimationXML(currentAnimation);
                animation.AddMotionOffsets(motionOffsets);

                var character = new CharacterXML(characterNames[charIndex], shoeOffsets[charIndex]);
                character.AddAnimation(animation);

                characterGroup.AddCharacter(character);
            }

            hSceneOffsets.AddCharacterGroup(characterGroup);
            SaveOffsetsToFile();
        }
        public void AddCharacter(CharacterXML character)
        {
            var existingCharacter = CharacterList.Find(x => x.CharacterName == character.CharacterName);

            if (existingCharacter != null)
            {
                existingCharacter.ShoeOffset = character.ShoeOffset;

                foreach (var animation in character.AnimationList)
                {
                    existingCharacter.AddAnimation(animation);
                }
            }
            else
            {
                CharacterList.Add(character);
            }
        }
Exemple #4
0
        private static void ConvertLegacyFile()
        {
            hSceneOffsets = new BetterHScenesOffsetsXML();

            Stream OffsetFile;

            try
            {
                // Read in the data
                string fileName = HS2_BetterHScenes.offsetFile.Value;

                OffsetFile = new FileStream(fileName, FileMode.Open);
                var serializer       = new XmlSerializer(typeof(AnimationOffsets));
                var animationOffsets = (AnimationOffsets)serializer.Deserialize(OffsetFile);

                foreach (var animation in animationOffsets.Animations)
                {
                    foreach (var motion in animation.MotionList)
                    {
                        foreach (var characterPair in motion.CharacterPairList)
                        {
                            CharacterGroupXML characterGroupXML = new CharacterGroupXML(characterPair.CharacterPairName);
                            foreach (var character in characterPair.CharacterOffsets)
                            {
                                OffsetVectors[] offsetVectors = new OffsetVectors[(int)BodyPart.BodyPartsCount];
                                offsetVectors[(int)BodyPart.WholeBody] = new OffsetVectors(new Vector3(character.PositionOffsetX, character.PositionOffsetY, character.PositionOffsetZ),
                                                                                           new Vector3(character.RotationOffsetP, character.RotationOffsetY, character.RotationOffsetR),
                                                                                           Vector3.zero);
                                offsetVectors[(int)BodyPart.LeftHand] = new OffsetVectors(new Vector3(character.LeftHandPositionOffsetX, character.LeftHandPositionOffsetY, character.LeftHandPositionOffsetZ),
                                                                                          new Vector3(character.LeftHandRotationOffsetP, character.LeftHandRotationOffsetY, character.LeftHandRotationOffsetR),
                                                                                          new Vector3(character.LeftHandHintPositionOffsetX, character.LeftHandHintPositionOffsetY, character.LeftHandHintPositionOffsetZ));
                                offsetVectors[(int)BodyPart.RightHand] = new OffsetVectors(new Vector3(character.RightHandPositionOffsetX, character.RightHandPositionOffsetY, character.RightHandPositionOffsetZ),
                                                                                           new Vector3(character.RightHandRotationOffsetP, character.RightHandRotationOffsetY, character.RightHandRotationOffsetR),
                                                                                           new Vector3(character.RightHandHintPositionOffsetX, character.RightHandHintPositionOffsetY, character.RightHandHintPositionOffsetZ));
                                offsetVectors[(int)BodyPart.LeftFoot] = new OffsetVectors(new Vector3(character.LeftFootPositionOffsetX, character.LeftFootPositionOffsetY, character.LeftFootPositionOffsetZ),
                                                                                          new Vector3(character.LeftFootRotationOffsetP, character.LeftFootRotationOffsetY, character.LeftFootRotationOffsetR),
                                                                                          new Vector3(character.LeftFootHintPositionOffsetX, character.LeftFootHintPositionOffsetY, character.LeftFootHintPositionOffsetZ));
                                offsetVectors[(int)BodyPart.RightFoot] = new OffsetVectors(new Vector3(character.RightFootPositionOffsetX, character.RightFootPositionOffsetY, character.RightFootPositionOffsetZ),
                                                                                           new Vector3(character.RightFootRotationOffsetP, character.RightFootRotationOffsetY, character.RightFootRotationOffsetR),
                                                                                           new Vector3(character.RightFootHintPositionOffsetX, character.RightFootHintPositionOffsetY, character.RightFootHintPositionOffsetZ));

                                bool[] jointCorrections = new bool[(int)BodyPart.BodyPartsCount];

                                MotionOffsetsXML motionOffsetsXML = new MotionOffsetsXML(motion.MotionName, offsetVectors, jointCorrections);
                                AnimationXML     animationXML     = new AnimationXML(animation.AnimationName);
                                CharacterXML     characterXML     = new CharacterXML(character.CharacterName, 0);

                                animationXML.AddMotionOffsets(motionOffsetsXML);
                                characterXML.AddAnimation(animationXML);
                                characterGroupXML.AddCharacter(characterXML);
                            }

                            hSceneOffsets.AddCharacterGroup(characterGroupXML);
                        }
                    }
                }

                SaveOffsetsToFile();

                // Close the file
                OffsetFile.Close();
                File.Delete(fileName);
            }
            catch
            {
                //HS2_BetterHScenes.Logger.LogMessage("read error!");
                return;
            }
        }