Exemplo n.º 1
0
        public Vector3 Push(IKSolverFullBody solver)
        {
            Vector3 vector = Vector3.zero;

            for (int i = 0; i < this.children.Length; i++)
            {
                vector += solver.chain[this.children[i]].Push(solver) * solver.chain[this.children[i]].pushParent;
            }
            this.nodes[this.nodes.Length - 1].solverPosition += vector;
            if (this.nodes.Length < 2)
            {
                return(Vector3.zero);
            }
            if (this.push <= 0f)
            {
                return(Vector3.zero);
            }
            Vector3 a         = this.nodes[2].solverPosition - this.nodes[0].solverPosition;
            float   magnitude = a.magnitude;

            if (magnitude == 0f)
            {
                return(Vector3.zero);
            }
            float num = 1f - magnitude / this.distance;

            if (num <= 0f)
            {
                return(Vector3.zero);
            }
            FBIKChain.Smoothing smoothing = this.pushSmoothing;
            if (smoothing != FBIKChain.Smoothing.Exponential)
            {
                if (smoothing == FBIKChain.Smoothing.Cubic)
                {
                    num *= num * num;
                }
            }
            else
            {
                num *= num;
            }
            Vector3 vector2 = -a * num * this.push;

            this.nodes[0].solverPosition += vector2;
            return(vector2);
        }
Exemplo n.º 2
0
        public void Reach(IKSolverFullBody solver)
        {
            if (!this.initiated)
            {
                return;
            }
            for (int i = 0; i < this.children.Length; i++)
            {
                solver.chain[this.children[i]].Reach(solver);
            }
            if (this.reachForce <= 0f)
            {
                return;
            }
            Vector3 vector = this.nodes[2].solverPosition - this.nodes[0].solverPosition;

            if (vector == Vector3.zero)
            {
                return;
            }
            float   magnitude = vector.magnitude;
            Vector3 a         = vector / magnitude * this.length;
            float   num       = Mathf.Clamp(magnitude / this.length, 1f - this.reachForce, 1f + this.reachForce) - 1f;

            num = Mathf.Clamp(num + this.reachForce, -1f, 1f);
            FBIKChain.Smoothing smoothing = this.reachSmoothing;
            if (smoothing != FBIKChain.Smoothing.Exponential)
            {
                if (smoothing == FBIKChain.Smoothing.Cubic)
                {
                    num *= num * num;
                }
            }
            else
            {
                num *= num;
            }
            Vector3 vector2 = a * Mathf.Clamp(num, 0f, magnitude);

            this.nodes[0].solverPosition += vector2 * (1f - this.nodes[0].effectorPositionWeight);
            this.nodes[2].solverPosition += vector2;
        }
Exemplo n.º 3
0
        protected override void ResetAction()
        {
            limb = FullBodyBipedChain.LeftArm;
            pull = new FsmFloat { UseVariable = true };
            reach = new FsmFloat { UseVariable = true };
            push = new FsmFloat { UseVariable = true };
            pushParent = new FsmFloat { UseVariable = true };
            bendGoal = new FsmGameObject { UseVariable = true };
            bendGoalWeight = new FsmFloat { UseVariable = true };

            target = new FsmGameObject { UseVariable = true };
            position = new FsmVector3 { UseVariable = true };
            positionWeight = new FsmFloat { UseVariable = true };
            rotation = new FsmQuaternion { UseVariable = true };
            rotationWeight = new FsmFloat { UseVariable = true };
            positionOffset = new FsmVector3 { UseVariable = true };
            maintainRelativePositionWeight = new FsmFloat { UseVariable = true };

            startEffectorTarget = new FsmGameObject { UseVariable = true };
            startEffectorPosition = new FsmVector3 { UseVariable = true };
            startEffectorPositionWeight = new FsmFloat { UseVariable = true };
            startEffectorPositionOffset = new FsmVector3 { UseVariable = true };

            maintainRotationWeight = new FsmFloat { UseVariable = true };
            mappingWeight = new FsmFloat { UseVariable = true};
            reachSmoothing = FBIKChain.Smoothing.Exponential;
            pushSmoothing = FBIKChain.Smoothing.Exponential;

            rotation = Quaternion.identity;
            mappingWeight = 1f;
            pull = 1f;
            reach = 0.05f;
            push = 0f;
            pushParent = 0f;
            bendGoalWeight = 0f;
        }
Exemplo n.º 4
0
            public static void Execute(FullBodyBipedIK ik, List <List <string> > dataList)
            {
                Transform[]           componentsInChildren = (Transform[])((Component)ik).GetComponentsInChildren <Transform>(true);
                int                   num1           = 0;
                List <List <string> > stringListList = dataList;
                int                   index1         = num1;
                int                   count1         = index1 + 1;
                List <string>         stringList1    = stringListList[index1];
                int                   num2           = 0;
                // ISSUE: variable of the null type
                __Null        solver1     = ik.solver;
                List <string> stringList2 = stringList1;
                int           index2      = num2;
                int           num3        = index2 + 1;
                double        num4        = (double)float.Parse(stringList2[index2]);

                ((IKSolver)solver1).IKPositionWeight = (__Null)num4;
                // ISSUE: variable of the null type
                __Null        solver2     = ik.solver;
                List <string> stringList3 = stringList1;
                int           index3      = num3;
                int           num5        = index3 + 1;
                int           num6        = int.Parse(stringList3[index3]);

                ((IKSolverFullBody)solver2).iterations = (__Null)num6;
                int num7 = 0;

                foreach (List <string> stringList4 in dataList.Skip <List <string> >(count1))
                {
                    if (((IKSolverFullBody)ik.solver).effectors.Length > num7)
                    {
                        ++num7;
                        int num8 = 0;
                        // ISSUE: variable of the null type
                        __Null                solver3           = ik.solver;
                        List <string>         stringList5       = stringList4;
                        int                   index4            = num8;
                        int                   num9              = index4 + 1;
                        FullBodyBipedEffector bodyBipedEffector = Illusion.Utils.Enum <FullBodyBipedEffector> .Cast(stringList5[index4]);

                        IKEffector eff = ((IKSolverFullBodyBiped)solver3).GetEffector(bodyBipedEffector);
                        if (eff != null)
                        {
                            IKEffector    ikEffector1 = eff;
                            List <string> stringList6 = stringList4;
                            int           index5      = num9;
                            int           num10       = index5 + 1;
                            double        num11       = (double)float.Parse(stringList6[index5]);
                            ikEffector1.positionWeight = (__Null)num11;
                            IKEffector    ikEffector2 = eff;
                            List <string> stringList7 = stringList4;
                            int           index6      = num10;
                            int           num12       = index6 + 1;
                            double        num13       = (double)float.Parse(stringList7[index6]);
                            ikEffector2.rotationWeight = (__Null)num13;
                            List <string> stringList8 = stringList4;
                            int           index7      = num12;
                            int           num14       = index7 + 1;
                            string        findFrame   = stringList8[index7];
                            if (findFrame == "null")
                            {
                                eff.target = null;
                            }
                            else
                            {
                                ((IEnumerable <Transform>)componentsInChildren).FirstOrDefault <Transform>((Func <Transform, bool>)(p => ((Object)p).get_name() == findFrame)).SafeProc <Transform>((Action <Transform>)(frame => eff.target = (__Null)frame));
                            }
                            if (Object.op_Inequality((Object)eff.target, (Object)null))
                            {
                                // ISSUE: variable of the null type
                                __Null        target1     = eff.target;
                                List <string> stringList9 = stringList4;
                                int           index8      = num14;
                                int           num15       = index8 + 1;
                                Vector3       vector3_1   = stringList9[index8].GetVector3();
                                ((Transform)target1).set_localPosition(vector3_1);
                                // ISSUE: variable of the null type
                                __Null        target2      = eff.target;
                                List <string> stringList10 = stringList4;
                                int           index9       = num15;
                                int           num16        = index9 + 1;
                                Vector3       vector3_2    = stringList10[index9].GetVector3();
                                ((Transform)target2).set_localEulerAngles(vector3_2);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                int count2 = count1 + num7;
                int num17  = 0;

                foreach (List <string> stringList4 in dataList.Skip <List <string> >(count2))
                {
                    if (((IKSolverFullBody)ik.solver).chain.Length <= num17)
                    {
                        break;
                    }
                    FBIKChain     fbikChain1  = (FBIKChain)((IKSolverFullBody)ik.solver).chain[num17++];
                    int           num8        = 0;
                    FBIKChain     fbikChain2  = fbikChain1;
                    List <string> stringList5 = stringList4;
                    int           index4      = num8;
                    int           num9        = index4 + 1;
                    double        num10       = (double)float.Parse(stringList5[index4]);
                    fbikChain2.pull = (__Null)num10;
                    FBIKChain     fbikChain3  = fbikChain1;
                    List <string> stringList6 = stringList4;
                    int           index5      = num9;
                    int           num11       = index5 + 1;
                    double        num12       = (double)float.Parse(stringList6[index5]);
                    fbikChain3.reach = (__Null)num12;
                    FBIKChain     fbikChain4  = fbikChain1;
                    List <string> stringList7 = stringList4;
                    int           index6      = num11;
                    int           num13       = index6 + 1;
                    double        num14       = (double)float.Parse(stringList7[index6]);
                    fbikChain4.push = (__Null)num14;
                    FBIKChain     fbikChain5  = fbikChain1;
                    List <string> stringList8 = stringList4;
                    int           index7      = num13;
                    int           num15       = index7 + 1;
                    double        num16       = (double)float.Parse(stringList8[index7]);
                    fbikChain5.pushParent = (__Null)num16;
                    FBIKChain           fbikChain6  = fbikChain1;
                    List <string>       stringList9 = stringList4;
                    int                 index8      = num15;
                    int                 num18       = index8 + 1;
                    FBIKChain.Smoothing smoothing1  = Illusion.Utils.Enum <FBIKChain.Smoothing> .Cast(stringList9[index8]);

                    fbikChain6.reachSmoothing = (__Null)smoothing1;
                    FBIKChain           fbikChain7   = fbikChain1;
                    List <string>       stringList10 = stringList4;
                    int                 index9       = num18;
                    int                 num19        = index9 + 1;
                    FBIKChain.Smoothing smoothing2   = Illusion.Utils.Enum <FBIKChain.Smoothing> .Cast(stringList10[index9]);

                    fbikChain7.pushSmoothing = (__Null)smoothing2;
                    // ISSUE: variable of the null type
                    __Null        bendConstraint = fbikChain1.bendConstraint;
                    List <string> stringList11   = stringList4;
                    int           index10        = num19;
                    int           num20          = index10 + 1;
                    double        num21          = (double)float.Parse(stringList11[index10]);
                    ((IKConstraintBend)bendConstraint).weight = (__Null)num21;
                    List <string> stringList12 = stringList4;
                    int           index11      = num20;
                    int           num22        = index11 + 1;
                    string        findFrame    = stringList12[index11];
                    if (findFrame == "null")
                    {
                        ((IKConstraintBend)fbikChain1.bendConstraint).bendGoal = null;
                    }
                    else
                    {
                        ((IKConstraintBend)fbikChain1.bendConstraint).bendGoal = (__Null)((IEnumerable <Transform>)componentsInChildren).FirstOrDefault <Transform>((Func <Transform, bool>)(p => ((Object)p).get_name() == findFrame));
                    }
                    if (Object.op_Inequality((Object)((IKConstraintBend)fbikChain1.bendConstraint).bendGoal, (Object)null))
                    {
                        // ISSUE: variable of the null type
                        __Null        bendGoal1    = ((IKConstraintBend)fbikChain1.bendConstraint).bendGoal;
                        List <string> stringList13 = stringList4;
                        int           index12      = num22;
                        int           num23        = index12 + 1;
                        Vector3       vector3_1    = stringList13[index12].GetVector3();
                        ((Transform)bendGoal1).set_localPosition(vector3_1);
                        // ISSUE: variable of the null type
                        __Null        bendGoal2    = ((IKConstraintBend)fbikChain1.bendConstraint).bendGoal;
                        List <string> stringList14 = stringList4;
                        int           index13      = num23;
                        int           num24        = index13 + 1;
                        Vector3       vector3_2    = stringList14[index13].GetVector3();
                        ((Transform)bendGoal2).set_localEulerAngles(vector3_2);
                    }
                }
            }