Пример #1
0
 public override ExpressionComponent Process(Stack <ExpressionComponent> args)
 {
     if (args.Count == 1)
     {
         if (args.Peek().ComponentType == ExpressionComponentType.String)
         {
             return(args.Pop());
         }
         else if (args.Peek().ComponentType == ExpressionComponentType.Number)
         {
             return(new Number(0 + (double)(args.Pop().Value)));
         }
     }
     else if (args.Count == 2)
     {
         ExpressionComponent arg1 = args.Pop();
         ExpressionComponent arg2 = args.Pop();
         if (arg1.ComponentType == ExpressionComponentType.String && arg2.ComponentType == ExpressionComponentType.String)
         {
             return(new Operands.String(arg1.Value.ToString() + arg2.Value.ToString()));
         }
         else if (arg1.ComponentType == ExpressionComponentType.Number && arg2.ComponentType == ExpressionComponentType.Number)
         {
             return(new Operands.Number((double)(arg1.Value) + (double)(arg2.Value)));
         }
     }
     return(new Null());
 }
Пример #2
0
 private static void ApplyCommonSettingsToComponent(ExpressionComponent component,
                                                    OneClickComponent oneClickComponent,
                                                    int componentNumber)
 {
     component.durationOn   = oneClickComponent.durOn;
     component.durationOff  = oneClickComponent.durOff;
     component.durationHold = oneClickComponent.durHold;
     component.easing       = easingType;
     component.inspFoldout  = false;
     component.name         = String.IsNullOrEmpty(oneClickComponent.componentName)
                                     ? "component " + componentNumber.ToString()
                                     : oneClickComponent.componentName;
 }
        public override ExpressionComponent Process(Stack <ExpressionComponent> args)
        {
            if (args.Count == 2)
            {
                ExpressionComponent arg1 = args.Pop();
                ExpressionComponent arg2 = args.Pop();
                if (arg1.ComponentType == ExpressionComponentType.Number && arg2.ComponentType == ExpressionComponentType.Number)
                {
                    return(new Operands.Number((double)(arg1.Value) / (double)(arg2.Value)));
                }
            }

            return(new Operands.Null());
        }
Пример #4
0
 public override ExpressionComponent Process(Stack <ExpressionComponent> args)
 {
     if (args.Count == 2)
     {
         ExpressionComponent arg1 = args.Pop();
         ExpressionComponent arg2 = args.Pop();
         if (arg1.ComponentType == arg2.ComponentType && arg1.ComponentType == ExpressionComponentType.Boolean)
         {
             if ((bool)arg1.Value == false || (bool)arg2.Value == false)
             {
                 return(new Operands.False());
             }
             else
             {
                 return(new Operands.True());
             }
         }
     }
     return(new Operands.Null());
 }
Пример #5
0
 public override ExpressionComponent Process(Stack <ExpressionComponent> args)
 {
     if (args.Count == 2)
     {
         ExpressionComponent arg1 = args.Pop();
         ExpressionComponent arg2 = args.Pop();
         if (arg1.ComponentType == arg2.ComponentType && arg1.ComponentType == ExpressionComponentType.Number)
         {
             if (arg1.Value.Equals(arg2.Value))
             {
                 return(new Operands.True());
             }
             else
             {
                 return(new Operands.False());
             }
         }
     }
     return(new Operands.Null());
 }
Пример #6
0
        private static void ConfigureModuleExpressions(OneClickConfiguration configuration)
        {
            for (int exp = 0; exp < configuration.oneClickExpressions.Count; exp++)
            {
                Expression expression = InitializeExpressionType(configuration, exp);

                var componentCount = 0;              // keeps track of good component creation to prevent creating components when criteria are not met (i.e. search blendshape name not found).
                var currCmpntID    = 0;              // holds the index of the current component being configured.
                InspectorControllerHelperData controlHelper;
                ExpressionComponent           component = new ExpressionComponent();

                for (int j = 0; j < configuration.oneClickExpressions[exp].components.Count; j++)
                {
                    var oneClickComponent = configuration.oneClickExpressions[exp].components[j];

                    switch (oneClickComponent.type)
                    {
                    case OneClickComponent.ComponentType.Shape:
                        // create a component for each valid, required SMR.
                        for (int i = 0; i < requiredSmrs.Count; i++)
                        {
                            // cast the OneClickComponent...
                            var oneClickShapeComponent = (OneClickShapeComponent)oneClickComponent;

                            int blendshapeIndex = -1;
                            // we need to confirm proposed blendshape names are viable...
                            foreach (var blendshapeName in oneClickShapeComponent.blendshapeNames)
                            {
                                if (oneClickShapeComponent.useRegex)
                                {
                                    blendshapeIndex = RegexFindBlendshapeName(requiredSmrs[i], blendshapeName);
                                }
                                else
                                {
                                    blendshapeIndex = requiredSmrs[i].sharedMesh.GetBlendShapeIndex(blendshapeName);
                                }

                                if (blendshapeIndex > -1)                                         // we found one!
                                {
                                    break;
                                }
                            }
                            if (blendshapeIndex == -1)                                     // we didn't find our blendshape...
                            {
                                continue;
                            }

                            // Create a new component if applicable.
                            currCmpntID = CreateNewComponent(componentCount, expression);

                            controlHelper            = expression.controllerVars[currCmpntID];
                            controlHelper.smr        = requiredSmrs[i];
                            controlHelper.blendIndex = blendshapeIndex;
                            controlHelper.minShape   = 0f;
                            controlHelper.maxShape   = oneClickShapeComponent.maxAmount;

                            component             = expression.components[currCmpntID];
                            component.controlType = ExpressionComponent.ControlType.Shape;

                            ApplyCommonSettingsToComponent(component, oneClickComponent, currCmpntID);
                            componentCount++;                                     // good component created, update component count.
                        }

                        break;

                    case OneClickComponent.ComponentType.UMA:
                        var oneClickUepComponent = (OneClickUepComponent)oneClickComponent;

                        // Create a new component if applicable.
                        currCmpntID = CreateNewComponent(componentCount, expression);

                        controlHelper             = expression.controllerVars[currCmpntID];
                        controlHelper.umaUepProxy = uepProxy;
                        controlHelper.blendIndex  = uepProxy.GetPoseIndex(oneClickUepComponent.poseName);
                        controlHelper.minShape    = 0f;
                        controlHelper.uepAmount   = oneClickUepComponent.maxAmount;

                        component             = expression.components[currCmpntID];
                        component.controlType = ExpressionComponent.ControlType.UMA;

                        ApplyCommonSettingsToComponent(component, oneClickComponent, currCmpntID);
                        componentCount++;                                 // good component created, update component count.

                        break;

                    case OneClickComponent.ComponentType.Bone:
                        var oneClickBoneComponent = (OneClickBoneComponent)oneClickComponent;

                        // confirm bone is viable...
                        var bone = FindBone(oneClickBoneComponent.componentSearchName);
                        if (bone == null)
                        {
                            Debug.LogWarning("Could not find bone: " + oneClickBoneComponent.componentSearchName);
                            continue;
                        }

                        // Create a new component if applicable.
                        currCmpntID = CreateNewComponent(componentCount, expression);

                        controlHelper                = expression.controllerVars[currCmpntID];
                        controlHelper.bone           = bone;
                        controlHelper.startTform     = ConvertBoneToTform(bone);
                        controlHelper.endTform       = oneClickBoneComponent.max;
                        controlHelper.fracRot        = oneClickBoneComponent.useRot;
                        controlHelper.fracPos        = oneClickBoneComponent.usePos;
                        controlHelper.fracScl        = oneClickBoneComponent.useScl;
                        controlHelper.inspIsSetStart = true;
                        controlHelper.inspIsSetEnd   = true;

                        component             = expression.components[currCmpntID];
                        component.controlType = ExpressionComponent.ControlType.Bone;

                        controlHelper.StoreBoneBase();
                        controlHelper.StoreStartTform();

                        ApplyCommonSettingsToComponent(component, oneClickComponent, currCmpntID);
                        componentCount++;                                 // good component created, update component count.

                        break;

                    case OneClickComponent.ComponentType.Animator:
                        var oneClickAnimatorComponent = (OneClickAnimatorComponent)oneClickComponent;

                        var animator = FindAnimator(oneClickAnimatorComponent.componentSearchName);
                        if (animator == null)
                        {
                            Debug.LogWarning("Could not find Animator: " + oneClickAnimatorComponent.componentSearchName);
                            continue;
                        }

                        // Create a new component if applicable.
                        currCmpntID = CreateNewComponent(componentCount, expression);

                        controlHelper          = expression.controllerVars[currCmpntID];
                        controlHelper.animator = animator;
                        controlHelper.isTriggerParameterBiDirectional = oneClickAnimatorComponent.isTriggerParmBiDirectional;
                        controlHelper.blendIndex = oneClickAnimatorComponent.animationParmIndex;

                        component             = expression.components[currCmpntID];
                        component.controlType = ExpressionComponent.ControlType.Animator;

                        ApplyCommonSettingsToComponent(component, oneClickComponent, currCmpntID);
                        componentCount++;                                 // good component created, update component count.

                        break;
                    }
                }

                // if no component was created for this expression, remove it.
                if (componentCount == 0)
                {
                    Debug.Log("Removed expression " + expression.name + " This may be OK, but may indicate a change in the model generator. If this is a supported model, contact Crazy Minnow Studio via [email protected].");
                    switch (configuration.type)
                    {
                    case OneClickConfiguration.ConfigType.Salsa:
                        salsa.visemes.RemoveAt(salsa.visemes.Count - 1);
                        break;

                    case OneClickConfiguration.ConfigType.Emoter:
                        emoter.emotes.RemoveAt(emoter.emotes.Count - 1);
                        break;
                    }
                }

                // module-specific wrap-up
                switch (configuration.type)
                {
                case OneClickConfiguration.ConfigType.Salsa:
                    salsa.DistributeTriggers(LerpEasings.EasingType.SquaredIn);
                    break;
                }
            }
        }