public ControlDataForExport GetExport(Transform startXform) { ControlDataForExport export = new ControlDataForExport { eyeControl = eyeControl, eyelidBoneMode = eyelidBoneMode, leftEyePath = Utils.GetPathForTransform(startXform, leftEye), rightEyePath = Utils.GetPathForTransform(startXform, rightEye), maxEyeUpBoneAngle = maxEyeUpBoneAngle, maxEyeDownBoneAngle = maxEyeDownBoneAngle, maxEyeUpEyeballAngle = maxEyeUpEyeballAngle, maxEyeDownEyeballAngle = maxEyeDownEyeballAngle, isEyeBallDefaultSet = isEyeBallDefaultSet, isEyeBoneDefaultSet = isEyeBoneDefaultSet, isEyeBallLookUpSet = isEyeBallLookUpSet, isEyeBoneLookUpSet = isEyeBoneLookUpSet, isEyeBallLookDownSet = isEyeBallLookDownSet, isEyeBoneLookDownSet = isEyeBoneLookDownSet, leftBoneEyeRotationLimiter = leftBoneEyeRotationLimiter.GetExport(startXform), rightBoneEyeRotationLimiter = rightBoneEyeRotationLimiter.GetExport(startXform), leftEyeballEyeRotationLimiter = leftEyeballEyeRotationLimiter.GetExport(startXform), rightEyeballEyeRotationLimiter = rightEyeballEyeRotationLimiter.GetExport(startXform), eyelidControl = eyelidControl, eyelidsFollowEyesVertically = eyelidsFollowEyesVertically, upperEyeLidLeftPath = Utils.GetPathForTransform(startXform, upperEyeLidLeft), upperEyeLidRightPath = Utils.GetPathForTransform(startXform, upperEyeLidRight), lowerEyeLidLeftPath = Utils.GetPathForTransform(startXform, lowerEyeLidLeft), lowerEyeLidRightPath = Utils.GetPathForTransform(startXform, lowerEyeLidRight), isEyelidBonesDefaultSet = isEyelidBonesDefaultSet, isEyelidBonesClosedSet = isEyelidBonesClosedSet, isEyelidBonesLookUpSet = isEyelidBonesLookUpSet, isEyelidBonesLookDownSet = isEyelidBonesLookDownSet, upperLeftLimiter = upperLeftLimiter.GetExport(startXform), upperRightLimiter = upperRightLimiter.GetExport(startXform), lowerLeftLimiter = lowerLeftLimiter.GetExport(startXform), lowerRightLimiter = lowerRightLimiter.GetExport(startXform), eyeWidenOrSquint = eyeWidenOrSquint, isEyelidBlendshapeDefaultSet = isEyelidBlendshapeDefaultSet, isEyelidBlendshapeClosedSet = isEyelidBlendshapeClosedSet, isEyelidBlendshapeLookUpSet = isEyelidBlendshapeLookUpSet, isEyelidBlendshapeLookDownSet = isEyelidBlendshapeLookDownSet }; export.blendshapesForBlinking = new EyelidPositionBlendshapeForExport[blendshapesForBlinking.Length]; for ( int i=0; i<blendshapesForBlinking.Length; i++ ) export.blendshapesForBlinking[i] = blendshapesForBlinking[i].GetExport(startXform); export.blendshapesForLookingUp = new EyelidPositionBlendshapeForExport[blendshapesForLookingUp.Length]; for ( int i=0; i<blendshapesForLookingUp.Length; i++ ) export.blendshapesForLookingUp[i] = blendshapesForLookingUp[i].GetExport(startXform); export.blendshapesForLookingDown = new EyelidPositionBlendshapeForExport[blendshapesForLookingDown.Length]; for ( int i=0; i<blendshapesForLookingDown.Length; i++ ) export.blendshapesForLookingDown[i] = blendshapesForLookingDown[i].GetExport(startXform); export.blendshapesConfigs = new BlendshapesConfigForExport[blendshapesConfigs.Length]; for ( int i=0; i<blendshapesConfigs.Length; i++ ) export.blendshapesConfigs[i] = blendshapesConfigs[i].GetExport(startXform); return export; }
public void Import(ControlDataForExport import, Transform startXform) { eyeControl = import.eyeControl; eyelidBoneMode = import.eyelidBoneMode; leftEye = Utils.GetTransformFromPath(startXform, import.leftEyePath); rightEye = Utils.GetTransformFromPath(startXform, import.rightEyePath); maxEyeUpBoneAngle = import.maxEyeUpBoneAngle; maxEyeDownBoneAngle = import.maxEyeDownBoneAngle; maxEyeUpEyeballAngle = import.maxEyeUpEyeballAngle; maxEyeDownEyeballAngle = import.maxEyeDownEyeballAngle; isEyeBallDefaultSet = import.isEyeBallDefaultSet; isEyeBoneDefaultSet = import.isEyeBoneDefaultSet; isEyeBallLookUpSet = import.isEyeBallLookUpSet; isEyeBoneLookUpSet = import.isEyeBoneLookUpSet; isEyeBallLookDownSet = import.isEyeBallLookDownSet; isEyeBoneLookDownSet = import.isEyeBoneLookDownSet; eyelidControl = import.eyelidControl; eyelidsFollowEyesVertically = import.eyelidsFollowEyesVertically; upperEyeLidLeft = Utils.GetTransformFromPath(startXform, import.upperEyeLidLeftPath); upperEyeLidRight = Utils.GetTransformFromPath(startXform, import.upperEyeLidRightPath); lowerEyeLidLeft = Utils.GetTransformFromPath(startXform, import.lowerEyeLidLeftPath); lowerEyeLidRight = Utils.GetTransformFromPath(startXform, import.lowerEyeLidRightPath); isEyelidBonesDefaultSet = import.isEyelidBonesDefaultSet; isEyelidBonesClosedSet = import.isEyelidBonesClosedSet; isEyelidBonesLookUpSet = import.isEyelidBonesLookUpSet; isEyelidBonesLookDownSet = import.isEyelidBonesLookDownSet; eyeWidenOrSquint = import.eyeWidenOrSquint; isEyelidBlendshapeDefaultSet = import.isEyelidBlendshapeDefaultSet; isEyelidBlendshapeClosedSet = import.isEyelidBlendshapeClosedSet; isEyelidBlendshapeLookUpSet = import.isEyelidBlendshapeLookUpSet; isEyelidBlendshapeLookDownSet = import.isEyelidBlendshapeLookDownSet; leftBoneEyeRotationLimiter.Import(import.leftBoneEyeRotationLimiter, startXform); rightBoneEyeRotationLimiter.Import(import.rightBoneEyeRotationLimiter, startXform); leftEyeballEyeRotationLimiter.Import(import.leftEyeballEyeRotationLimiter, startXform); rightEyeballEyeRotationLimiter.Import(import.rightEyeballEyeRotationLimiter, startXform); upperLeftLimiter.Import(import.upperLeftLimiter, startXform); upperRightLimiter.Import(import.upperRightLimiter, startXform); lowerLeftLimiter.Import(import.lowerLeftLimiter, startXform); lowerRightLimiter.Import(import.lowerRightLimiter, startXform); if ( import.blendshapesForBlinking != null ) { blendshapesForBlinking = new EyelidPositionBlendshape[import.blendshapesForBlinking.Length]; for ( int i=0; i<import.blendshapesForBlinking.Length; i++ ) { EyelidPositionBlendshape eyelidPositionBlendshape = new EyelidPositionBlendshape(); eyelidPositionBlendshape.Import(import.blendshapesForBlinking[i], startXform); blendshapesForBlinking[i] = eyelidPositionBlendshape; } } if ( import.blendshapesForLookingUp != null ) { blendshapesForLookingUp = new EyelidPositionBlendshape[import.blendshapesForLookingUp.Length]; for ( int i=0; i<import.blendshapesForLookingUp.Length; i++ ) { EyelidPositionBlendshape eyelidPositionBlendshape = new EyelidPositionBlendshape(); eyelidPositionBlendshape.Import(import.blendshapesForLookingUp[i], startXform); blendshapesForLookingUp[i] = eyelidPositionBlendshape; } } if ( import.blendshapesForLookingDown != null ) { blendshapesForLookingDown = new EyelidPositionBlendshape[import.blendshapesForLookingDown.Length]; for ( int i=0; i<import.blendshapesForLookingDown.Length; i++ ) { EyelidPositionBlendshape eyelidPositionBlendshape = new EyelidPositionBlendshape(); eyelidPositionBlendshape.Import(import.blendshapesForLookingDown[i], startXform); blendshapesForLookingDown[i] = eyelidPositionBlendshape; } } bool canImportBlendshapeConfigs = false; SkinnedMeshRenderer[] skinnedMeshRenderers = startXform.GetComponentsInChildren<SkinnedMeshRenderer>(); if (import.blendshapesConfigs != null) if ( skinnedMeshRenderers.Length == import.blendshapesConfigs.Length ) { canImportBlendshapeConfigs = true; foreach (BlendshapesConfigForExport blendshapeConfigImport in import.blendshapesConfigs) if (false == BlendshapesConfig.CanImport(blendshapeConfigImport, startXform)) { canImportBlendshapeConfigs = false; break; } } if ( canImportBlendshapeConfigs ) { blendshapesConfigs = new BlendshapesConfig[import.blendshapesConfigs.Length]; for ( int i=0; i<import.blendshapesConfigs.Length; i++ ) { BlendshapesConfig blendshapesConfig = new BlendshapesConfig(); blendshapesConfig.Import(startXform, import.blendshapesConfigs[i]); blendshapesConfigs[i] = blendshapesConfig; } } else blendshapesConfigs = null; }
public bool CanImport(ControlDataForExport import, Transform startXform) { bool canImport = Utils.CanGetTransformFromPath(startXform, import.leftEyePath) && Utils.CanGetTransformFromPath(startXform, import.rightEyePath) && Utils.CanGetTransformFromPath(startXform, import.upperEyeLidLeftPath) && Utils.CanGetTransformFromPath(startXform, import.upperEyeLidRightPath) && Utils.CanGetTransformFromPath(startXform, import.lowerEyeLidLeftPath) && Utils.CanGetTransformFromPath(startXform, import.lowerEyeLidRightPath) && leftBoneEyeRotationLimiter.CanImport(import.leftBoneEyeRotationLimiter, startXform) && rightBoneEyeRotationLimiter.CanImport(import.rightBoneEyeRotationLimiter, startXform) && leftEyeballEyeRotationLimiter.CanImport(import.leftEyeballEyeRotationLimiter, startXform) && rightEyeballEyeRotationLimiter.CanImport(import.rightEyeballEyeRotationLimiter, startXform) && upperLeftLimiter.CanImport(import.upperLeftLimiter, startXform) && upperRightLimiter.CanImport(import.upperRightLimiter, startXform) && lowerLeftLimiter.CanImport(import.lowerLeftLimiter, startXform) && lowerRightLimiter.CanImport(import.lowerRightLimiter, startXform); if ( false == canImport ) return false; if ( import.blendshapesForBlinking != null ) foreach ( EyelidPositionBlendshapeForExport blendShapeImport in import.blendshapesForBlinking ) if ( false == EyelidPositionBlendshape.CanImport(blendShapeImport, startXform) ) return false; if ( import.blendshapesForLookingUp != null ) foreach ( EyelidPositionBlendshapeForExport blendShapeImport in import.blendshapesForLookingUp) if ( false == EyelidPositionBlendshape.CanImport(blendShapeImport, startXform) ) return false; if ( import.blendshapesForLookingDown != null ) foreach ( EyelidPositionBlendshapeForExport blendShapeImport in import.blendshapesForLookingDown) if ( false == EyelidPositionBlendshape.CanImport(blendShapeImport, startXform) ) return false; //if ( import.blendshapesConfigs != null ) // foreach ( BlendshapesConfigForExport blendshapeConfigImport in import.blendshapesConfigs) // if ( false == BlendshapesConfig.CanImport(blendshapeConfigImport, startXform) ) // return false; return true; }