public CharacterOffsetLocations() { offsetVectors = new OffsetVectors[offsetTransformNames.Length]; offsetTransforms = new Transform[offsetTransformNames.Length]; hintTransforms = new Transform[hintTransformNames.Length]; headTransforms = new Transform[headTransformNames.Length]; digitTransforms = new Transform[digitTransformNames.Length][]; baseData = new Correct.BaseData[offsetTransformNames.Length]; lastBasePosition = new Vector3[offsetTransformNames.Length]; lastBaseRotation = new Vector3[offsetTransformNames.Length]; baseReplaceTransforms = new Transform[offsetTransformNames.Length]; jointCorrection = new bool[(int)BodyPart.BodyPartsCount]; for (var offset = 0; offset < offsetVectors.Length; offset++) { offsetVectors[offset] = new OffsetVectors(); } for (var joint = 0; joint < jointCorrection.Length; joint++) { jointCorrection[joint] = AI_BetterHScenes.defaultJointCorrection.Value; } for (var offset = (int)BodyPart.LeftHand; offset < digitTransforms.Length; offset++) { digitTransforms[offset] = new Transform[digitTransformNames[offset].Length]; } allLimbsFound = false; }
private static void CopyPositions() { for (var charIndex = 0; charIndex < copyOffsetVectors.Length; charIndex++) { for (var bodyPart = 0; bodyPart < copyOffsetVectors[charIndex].Length; bodyPart++) { copyOffsetVectors[charIndex][bodyPart] = new OffsetVectors(characterOffsets[charIndex].offsetVectors[bodyPart].position, characterOffsets[charIndex].offsetVectors[bodyPart].rotation, characterOffsets[charIndex].offsetVectors[bodyPart].hintPosition); } } }
public static void InitDraggersUI() { characterOffsets = new CharacterOffsetLocations[AI_BetterHScenes.characters.Count]; copyOffsetVectors = new OffsetVectors[AI_BetterHScenes.characters.Count][]; for (var charIndex = 0; charIndex < AI_BetterHScenes.characters.Count; charIndex++) { characterOffsets[charIndex] = new CharacterOffsetLocations(); copyOffsetVectors[charIndex] = new OffsetVectors[(int)BodyPart.BodyPartsCount]; characterOffsets[charIndex].LoadCharacterTransforms(AI_BetterHScenes.characters[charIndex]); } UpdateUIPositions(); }
public CharacterOffsetLocations() { offsetVectors = new OffsetVectors[offsetTransformNames.Length]; offsetTransforms = new Transform[offsetTransformNames.Length]; hintTransforms = new Transform[hintTransformNames.Length]; baseData = new Correct.BaseData[offsetTransformNames.Length]; lastBasePosition = new Vector3[offsetTransformNames.Length]; lastBaseRotation = new Vector3[offsetTransformNames.Length]; baseReplaceTransforms = new Transform[offsetTransformNames.Length]; for (var offset = 0; offset < offsetVectors.Length; offset++) { offsetVectors[offset] = new OffsetVectors(); } allLimbsFound = false; }
//-- 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(); }
private static void ConvertLegacyFile() { hSceneOffsets = new BetterHScenesOffsetsXML(); Stream OffsetFile; try { // Read in the data string fileName = AI_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, 0f); 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), 0f); 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), 0f); 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), 0f); 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), 0f); 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; } }
//-- 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(); }