예제 #1
0
        public void SaveDefault( Object rootObject )
        {
            if ( eyeControl == EyeControl.MecanimEyeBones )
            {
                Animator animator = (rootObject as MonoBehaviour).GetComponent<Animator>();
                Transform leftEyeBoneTransform = animator.GetBoneTransform(HumanBodyBones.LeftEye);
                Transform rightEyeBoneTransform = animator.GetBoneTransform(HumanBodyBones.RightEye);

                leftBoneEyeRotationLimiter.SaveDefault( leftEyeBoneTransform );
                rightBoneEyeRotationLimiter.SaveDefault( rightEyeBoneTransform );

                isEyeBoneDefaultSet = true;
            }
            else if ( eyeControl == EyeControl.SelectedObjects )
            {
                leftEyeballEyeRotationLimiter.SaveDefault( leftEye );
                rightEyeballEyeRotationLimiter.SaveDefault( rightEye );

                isEyeBallDefaultSet = true;
            }

            if ( eyelidControl == EyelidControl.Bones )
            {
                upperLeftLimiter.SaveDefault(upperEyeLidLeft);
                upperRightLimiter.SaveDefault(upperEyeLidRight);
                if ( lowerEyeLidLeft != null )
                    lowerLeftLimiter.SaveDefault(lowerEyeLidLeft);
                if ( lowerEyeLidRight != null )
                    lowerRightLimiter.SaveDefault(lowerEyeLidRight);

                isEyelidBonesDefaultSet = true;
            }
            else if ( eyelidControl == EyelidControl.Blendshapes )
            {
                SkinnedMeshRenderer[] skinnedMeshRenderers = (rootObject as MonoBehaviour).GetComponentsInChildren<SkinnedMeshRenderer>();
                blendshapesConfigs = new BlendshapesConfig[ skinnedMeshRenderers.Length ];
                for ( int i=0;  i<skinnedMeshRenderers.Length;  i++ )
                {
                    BlendshapesConfig blendshapesConfig = new BlendshapesConfig {skinnedMeshRenderer = skinnedMeshRenderers[i]};
                    blendshapesConfig.blendShapeCount = blendshapesConfig.skinnedMeshRenderer.sharedMesh.blendShapeCount;
                    blendshapesConfig.blendshapeWeights = new float[blendshapesConfig.blendShapeCount ];
                    for ( int j=0;  j<blendshapesConfig.blendShapeCount;  j++ )
                        blendshapesConfig.blendshapeWeights[j] = blendshapesConfig.skinnedMeshRenderer.GetBlendShapeWeight(j);
                    blendshapesConfigs[i] = blendshapesConfig;
                }

                isEyelidBlendshapeDefaultSet = true;
            }
        }
예제 #2
0
        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;
        }