//-- Apply character offsets for current animation, if they can be found --// public static void ApplyCharacterOffsets() { var currentAnimation = AI_BetterHScenes.hFlagCtrl.nowAnimationInfo.nameAnimation; var bValidOffsetsFound = false; if (currentAnimation == null) { return; } if (AI_BetterHScenes.currentMotion == null) { AI_BetterHScenes.currentMotion = "default"; } string characterPairName = null; foreach (var character in AI_BetterHScenes.characters.Where(character => character != null && character.visibleAll)) { if (characterPairName == null) { characterPairName = character.fileParam.fullname; } else { characterPairName += "_" + character.fileParam.fullname; } } var animationList = animationOffsets.Animations.Find(x => x.AnimationName == currentAnimation); if (animationList != null && characterPairName != null) { MotionList motionList; if (AI_BetterHScenes.useOneOffsetForAllMotions.Value) { motionList = animationList.MotionList.Find(x => x.MotionName == "default"); } else { motionList = animationList.MotionList.Find(x => x.MotionName == AI_BetterHScenes.currentMotion); if (motionList == null) { motionList = animationList.MotionList.Find(x => x.MotionName == "default"); } else if (motionList.MotionName != AI_BetterHScenes.currentMotion) { motionList = animationList.MotionList.Find(x => x.MotionName == "default"); } } var characterPair = motionList?.CharacterPairList.Find(x => x.CharacterPairName == characterPairName); if (characterPair != null) { for (var charIndex = 0; charIndex < AI_BetterHScenes.characters.Count; charIndex++) { var characterOffsetParameters = characterPair.CharacterOffsets.Find(x => x.CharacterName == AI_BetterHScenes.characters[charIndex].fileParam.fullname); if (characterOffsetParameters == null) { continue; } OffsetVectors[] loadOffsets = new OffsetVectors[(int)BodyPart.BodyPartsCount]; loadOffsets[(int)BodyPart.WholeBody] = new OffsetVectors(new Vector3(characterOffsetParameters.PositionOffsetX, characterOffsetParameters.PositionOffsetY, characterOffsetParameters.PositionOffsetZ), new Vector3(characterOffsetParameters.RotationOffsetP, characterOffsetParameters.RotationOffsetY, characterOffsetParameters.RotationOffsetR), new Vector3(0, 0, 0)); loadOffsets[(int)BodyPart.LeftHand] = new OffsetVectors(new Vector3(characterOffsetParameters.LeftHandPositionOffsetX, characterOffsetParameters.LeftHandPositionOffsetY, characterOffsetParameters.LeftHandPositionOffsetZ), new Vector3(characterOffsetParameters.LeftHandRotationOffsetP, characterOffsetParameters.LeftHandRotationOffsetY, characterOffsetParameters.LeftHandRotationOffsetR), new Vector3(characterOffsetParameters.LeftHandHintPositionOffsetX, characterOffsetParameters.LeftHandHintPositionOffsetY, characterOffsetParameters.LeftHandHintPositionOffsetZ)); loadOffsets[(int)BodyPart.RightHand] = new OffsetVectors(new Vector3(characterOffsetParameters.RightHandPositionOffsetX, characterOffsetParameters.RightHandPositionOffsetY, characterOffsetParameters.RightHandPositionOffsetZ), new Vector3(characterOffsetParameters.RightHandRotationOffsetP, characterOffsetParameters.RightHandRotationOffsetY, characterOffsetParameters.RightHandRotationOffsetR), new Vector3(characterOffsetParameters.RightHandHintPositionOffsetX, characterOffsetParameters.RightHandHintPositionOffsetY, characterOffsetParameters.RightHandHintPositionOffsetZ)); loadOffsets[(int)BodyPart.LeftFoot] = new OffsetVectors(new Vector3(characterOffsetParameters.LeftFootPositionOffsetX, characterOffsetParameters.LeftFootPositionOffsetY, characterOffsetParameters.LeftFootPositionOffsetZ), new Vector3(characterOffsetParameters.LeftFootRotationOffsetP, characterOffsetParameters.LeftFootRotationOffsetY, characterOffsetParameters.LeftFootRotationOffsetR), new Vector3(characterOffsetParameters.LeftFootHintPositionOffsetX, characterOffsetParameters.LeftFootHintPositionOffsetY, characterOffsetParameters.LeftFootHintPositionOffsetZ)); loadOffsets[(int)BodyPart.RightFoot] = new OffsetVectors(new Vector3(characterOffsetParameters.RightFootPositionOffsetX, characterOffsetParameters.RightFootPositionOffsetY, characterOffsetParameters.RightFootPositionOffsetZ), new Vector3(characterOffsetParameters.RightFootRotationOffsetP, characterOffsetParameters.RightFootRotationOffsetY, characterOffsetParameters.RightFootRotationOffsetR), new Vector3(characterOffsetParameters.RightFootHintPositionOffsetX, characterOffsetParameters.RightFootHintPositionOffsetY, characterOffsetParameters.RightFootHintPositionOffsetZ)); SliderUI.LoadOffsets(charIndex, loadOffsets); bValidOffsetsFound = true; } SliderUI.ApplyPositions(); } } // if we didn't find offsets to apply, move the characters to their 0 position, in case they were moved out of it from another offset. if (!bValidOffsetsFound) { SliderUI.ResetPositions(); } SliderUI.UpdateUIPositions(); }
//-- Apply character offsets for current animation, if they can be found --// public static void ApplyCharacterOffsets() { var currentAnimation = AI_BetterHScenes.hFlagCtrl.nowAnimationInfo.nameAnimation; var bValidOffsetsFound = false; if (currentAnimation == null) { return; } if (AI_BetterHScenes.currentMotion == null) { AI_BetterHScenes.currentMotion = "default"; } string characterGroupName = null; foreach (var character in AI_BetterHScenes.characters.Where(character => character != null && character.visibleAll)) { if (characterGroupName == null) { characterGroupName = character.fileParam.fullname; } else { characterGroupName += "_" + character.fileParam.fullname; } } if (characterGroupName != null) { var characterGroup = hSceneOffsets.CharacterGroupList.Find(x => x.CharacterGroupName == characterGroupName); if (characterGroup != null) { for (var charIndex = 0; charIndex < AI_BetterHScenes.characters.Count; charIndex++) { var character = characterGroup.CharacterList.Find(x => x.CharacterName == AI_BetterHScenes.characters[charIndex].fileParam.fullname); if (character == null) { continue; } var animation = character.AnimationList.Find(x => x.AnimationName == currentAnimation); if (animation == null) { continue; } var motion = animation.MotionOffsetList.Find(x => x.MotionName == AI_BetterHScenes.currentMotion); if (AI_BetterHScenes.useOneOffsetForAllMotions.Value || motion == null || motion.MotionName != AI_BetterHScenes.currentMotion) { if (AI_BetterHScenes.useUniqueOffsetForWeak.Value && AI_BetterHScenes.currentMotion.StartsWith("D_")) { motion = animation.MotionOffsetList.Find(x => x.MotionName == "defaultWeak"); } else { motion = animation.MotionOffsetList.Find(x => x.MotionName == "default"); } } if (motion == null) { continue; } OffsetVectors[] loadOffsets = new OffsetVectors[(int)BodyPart.BodyPartsCount]; loadOffsets[(int)BodyPart.WholeBody] = new OffsetVectors(new Vector3(motion.PositionOffsetX, motion.PositionOffsetY, motion.PositionOffsetZ), new Vector3(motion.RotationOffsetP, motion.RotationOffsetY, motion.RotationOffsetR), new Vector3(motion.HeadRotationOffsetP, motion.HeadRotationOffsetY, motion.HeadRotationOffsetR), 0f); loadOffsets[(int)BodyPart.LeftHand] = new OffsetVectors(new Vector3(motion.LeftHandPositionOffsetX, motion.LeftHandPositionOffsetY, motion.LeftHandPositionOffsetZ), new Vector3(motion.LeftHandRotationOffsetP, motion.LeftHandRotationOffsetY, motion.LeftHandRotationOffsetR), new Vector3(motion.LeftHandHintPositionOffsetX, motion.LeftHandHintPositionOffsetY, motion.LeftHandHintPositionOffsetZ), motion.LeftHandDigitRotationOffsetZ); loadOffsets[(int)BodyPart.RightHand] = new OffsetVectors(new Vector3(motion.RightHandPositionOffsetX, motion.RightHandPositionOffsetY, motion.RightHandPositionOffsetZ), new Vector3(motion.RightHandRotationOffsetP, motion.RightHandRotationOffsetY, motion.RightHandRotationOffsetR), new Vector3(motion.RightHandHintPositionOffsetX, motion.RightHandHintPositionOffsetY, motion.RightHandHintPositionOffsetZ), motion.RightHandDigitRotationOffsetZ); loadOffsets[(int)BodyPart.LeftFoot] = new OffsetVectors(new Vector3(motion.LeftFootPositionOffsetX, motion.LeftFootPositionOffsetY, motion.LeftFootPositionOffsetZ), new Vector3(motion.LeftFootRotationOffsetP, motion.LeftFootRotationOffsetY, motion.LeftFootRotationOffsetR), new Vector3(motion.LeftFootHintPositionOffsetX, motion.LeftFootHintPositionOffsetY, motion.LeftFootHintPositionOffsetZ), motion.LeftFootDigitRotationOffsetZ); loadOffsets[(int)BodyPart.RightFoot] = new OffsetVectors(new Vector3(motion.RightFootPositionOffsetX, motion.RightFootPositionOffsetY, motion.RightFootPositionOffsetZ), new Vector3(motion.RightFootRotationOffsetP, motion.RightFootRotationOffsetY, motion.RightFootRotationOffsetR), new Vector3(motion.RightFootHintPositionOffsetX, motion.RightFootHintPositionOffsetY, motion.RightFootHintPositionOffsetZ), motion.RightFootDigitRotationOffsetZ); bool[] jointCorrections = new bool[(int)BodyPart.BodyPartsCount]; jointCorrections[(int)BodyPart.LeftHand] = motion.LeftHandJointCorrection; jointCorrections[(int)BodyPart.RightHand] = motion.RightHandJointCorrection; jointCorrections[(int)BodyPart.LeftFoot] = motion.LeftFootJointCorrection; jointCorrections[(int)BodyPart.RightFoot] = motion.RightFootJointCorrection; SliderUI.LoadOffsets(charIndex, loadOffsets, jointCorrections, character.ShoeOffset, character.MouthOffset); bValidOffsetsFound = true; } SliderUI.ApplyPositionsAndCorrections(); } } // if we didn't find offsets to apply, move the characters to their 0 position, in case they were moved out of it from another offset. if (!bValidOffsetsFound) { SliderUI.ResetPositions(); } SliderUI.UpdateUIPositions(); }