Exemplo n.º 1
0
    public bool ViewportToWorldPoint(ref Vector3 v, out Vector3 p)
    {
        Vector3G vectorg2;
        Vector3G win  = new Vector3G((Vector3)v);
        bool     flag = this.projectViewport.UnProject(ref win, out vectorg2);

        p = vectorg2.f;
        return(flag);
    }
Exemplo n.º 2
0
    public bool ScreenToWorldPoint(ref Vector3 v)
    {
        Vector3G vectorg2;
        Vector3G win  = new Vector3G((Vector3)v);
        bool     flag = this.projectScreen.UnProject(ref win, out vectorg2);

        v = vectorg2.f;
        return(flag);
    }
Exemplo n.º 3
0
    private void RunSim(ref int i, ref Vector3G force, ref Vector3G torque)
    {
        while (i < this.dataCount)
        {
            this.ctx.data = this.data[i];
            switch (this.ctx.data.effect.Simulate(ref this.ctx))
            {
            case BOBRES.CONTINUE:
            {
                force.x  = force.x + this.ctx.data.force.x;
                force.y  = force.y + this.ctx.data.force.y;
                force.z  = force.z + this.ctx.data.force.z;
                torque.x = torque.x + this.ctx.data.torque.x;
                torque.y = torque.y + this.ctx.data.torque.y;
                torque.z = torque.z + this.ctx.data.torque.z;
                break;
            }

            case BOBRES.EXIT:
            {
                if (!this.isFork)
                {
                    int num  = i;
                    int num1 = num;
                    i = num + 1;
                    int num2 = num1;
                    this.RunSim(ref i, ref force, ref torque);
                    if (this.ctx.data == null)
                    {
                        this.data.RemoveAt(num2);
                    }
                    else
                    {
                        if (this.ctx.data.effect != null)
                        {
                            this.ctx.data.effect.Destroy(ref this.ctx.data);
                        }
                        this.data.RemoveAt(num2);
                        foreach (BobEffectStack fork in this.forks)
                        {
                            fork.data.RemoveAt(num2);
                        }
                    }
                }
                return;
            }

            case BOBRES.ERROR:
            {
                Debug.LogError("Error with effect", this.ctx.data.effect);
                break;
            }
            }
            i = i + 1;
        }
    }
Exemplo n.º 4
0
 public void Simulate(ref double dt, ref Vector3G force, ref Vector3G torque)
 {
     this.dataCount = this.data.Count;
     if (this.dataCount > 0)
     {
         int i = 0;
         this.ctx.dt = dt;
         this.RunSim(ref i, ref force, ref torque);
     }
 }
Exemplo n.º 5
0
    private void CalculateVelocity()
    {
        Vector3G  vectorg2;
        double    num     = Time.time - this.lastVelocityCalc;
        Character idMain  = base.idMain;
        Vector3   v       = (idMain == null) ? base.transform.position : idMain.origin;
        Vector3G  vectorg = new Vector3G(ref v);
        double    num2    = 1.0 / num;

        vectorg2.x = num2 * (vectorg.x - this.lastPosPrecise.x);
        vectorg2.y = num2 * (vectorg.y - this.lastPosPrecise.y);
        vectorg2.z = num2 * (vectorg.z - this.lastPosPrecise.z);
        Matrix4x4G b = new Matrix4x4G(base.transform.worldToLocalMatrix);

        Matrix4x4G.Mult3x3(ref vectorg2, ref b, out this.localVelocityPrecise);
        this.lastVelocityCalc = Time.time;
        this.speedPrecise     = Math.Sqrt((this.localVelocityPrecise.x * this.localVelocityPrecise.x) + (this.localVelocityPrecise.z * this.localVelocityPrecise.z));
        if (this.speedPrecise < this.movement.configuration.minMoveSpeed)
        {
            float num3;
            this.speedPrecise            = 0.0;
            this.movementNormalPrecise.x = 0.0;
            this.movementNormalPrecise.y = 0.0;
            if ((this.lastAngleSpeedPrecise > 0.0) && ((num3 = this.movement.configuration.maxTimeBetweenTurns) > 0f))
            {
                this.lastAngleSpeedPrecise -= Time.deltaTime / num3;
            }
        }
        else
        {
            double num4 = 1.0 / this.speedPrecise;
            this.movementNormalPrecise.x = this.localVelocity.x * num4;
            this.movementNormalPrecise.y = this.localVelocity.z * num4;
            double anglePrecise = this.anglePrecise;
            this.anglePrecise = (Math.Atan2(this.movementNormalPrecise.x, this.movementNormalPrecise.y) / 3.1415926535897931) * 180.0;
            float maxTurnSpeed = this.movement.configuration.maxTurnSpeed;
            if (((maxTurnSpeed > 0f) && (this.anglePrecise != anglePrecise)) && (this.lastAngleSpeedPrecise >= 0.05))
            {
                double maxDelta = Time.deltaTime * maxTurnSpeed;
                if (Precise.MoveTowardsAngle(ref anglePrecise, ref this.anglePrecise, ref maxDelta, out this.anglePrecise))
                {
                    double a = (this.anglePrecise / 180.0) * 3.1415926535897931;
                    this.movementNormalPrecise.x = Math.Sin(a);
                    this.movementNormalPrecise.y = Math.Cos(a);
                }
            }
            this.lastAngleSpeedPrecise = this.speedPrecise;
        }
        this.lastPosPrecise = vectorg;
        this.lastPos        = v;
        this.movementNormal = this.movementNormalPrecise.f;
        this.speed          = (float)this.speedPrecise;
        this.angle          = (float)this.anglePrecise;
        this.localVelocity  = this.localVelocityPrecise.f;
    }
Exemplo n.º 6
0
    public Ray ViewportPointToRay(Vector3 v)
    {
        Vector3G vector3G;
        Vector3G vector3G1;
        Vector3G vector3G2 = new Vector3G(v);

        this.projectViewport.UnProject(ref vector3G2, out vector3G);
        vector3G2.z = vector3G2.z + 1;
        this.projectViewport.UnProject(ref vector3G2, out vector3G1);
        return(new Ray(vector3G.f, new Vector3((float)(vector3G1.x - vector3G.x), (float)(vector3G1.y - vector3G.y), (float)(vector3G1.z - vector3G.z))));
    }
Exemplo n.º 7
0
    public Ray ViewportPointToRay(Vector3 v)
    {
        Vector3G vectorg2;
        Vector3G vectorg3;
        Vector3G win = new Vector3G(v);

        this.projectViewport.UnProject(ref win, out vectorg2);
        win.z++;
        this.projectViewport.UnProject(ref win, out vectorg3);
        return(new Ray(vectorg2.f, new Vector3((float)(vectorg3.x - vectorg2.x), (float)(vectorg3.y - vectorg2.y), (float)(vectorg3.z - vectorg2.z))));
    }
Exemplo n.º 8
0
 public double AddDifference(ref HeadBob.VectorStamp previous, ref Vector3G difference)
 {
     if (previous.valid && (previous.timeStamp != this.timeStamp))
     {
         double num = 1.0 / ((double)(this.timeStamp - previous.timeStamp));
         difference.x += num * (this.vector.x - previous.vector.x);
         difference.y += num * (this.vector.y - previous.vector.y);
         difference.z += num * (this.vector.z - previous.vector.z);
         return(1.0);
     }
     return(0.0);
 }
Exemplo n.º 9
0
    private void RunSim(ref int i, ref Vector3G force, ref Vector3G torque)
    {
        while (i < this.dataCount)
        {
            int num;
            this.ctx.data = this.data[i];
            switch (this.ctx.data.effect.Simulate(ref this.ctx))
            {
            case BOBRES.CONTINUE:
                force.x  += this.ctx.data.force.x;
                force.y  += this.ctx.data.force.y;
                force.z  += this.ctx.data.force.z;
                torque.x += this.ctx.data.torque.x;
                torque.y += this.ctx.data.torque.y;
                torque.z += this.ctx.data.torque.z;
                goto Label_0210;

            case BOBRES.EXIT:
                if (!this.isFork)
                {
                    num = i++;
                    this.RunSim(ref i, ref force, ref torque);
                    if (this.ctx.data == null)
                    {
                        break;
                    }
                    if (this.ctx.data.effect != null)
                    {
                        this.ctx.data.effect.Destroy(ref this.ctx.data);
                    }
                    this.data.RemoveAt(num);
                    foreach (BobEffectStack stack in this.forks)
                    {
                        stack.data.RemoveAt(num);
                    }
                }
                return;

            case BOBRES.ERROR:
                Debug.LogError("Error with effect", this.ctx.data.effect);
                goto Label_0210;

            default:
                goto Label_0210;
            }
            this.data.RemoveAt(num);
            return;

Label_0210:
            i++;
        }
    }
Exemplo n.º 10
0
        public double AddDifference(ref HeadBob.VectorStamp previous, ref Vector3G difference)
        {
            if (!previous.valid || previous.timeStamp == this.timeStamp)
            {
                return(0);
            }
            double num = 1 / (double)(this.timeStamp - previous.timeStamp);

            difference.x = difference.x + num * (this.vector.x - previous.vector.x);
            difference.y = difference.y + num * (this.vector.y - previous.vector.y);
            difference.z = difference.z + num * (this.vector.z - previous.vector.z);
            return(1);
        }
Exemplo n.º 11
0
    public static Vector3G Slerp(double t, Vector3G a, Vector3G b)
    {
        double num2;
        double v = AngleRadians(a, b);

        if ((v == 0.0) || ((num2 = Sin(v)) == 0.0))
        {
            return(Linear(t, a, b));
        }
        double num3 = Sin((double)((1.0 - t) * v)) / num2;
        double num4 = Sin((double)(t * v)) / num2;

        return(Sum(Mul(a, num3), Mul(b, num4)));
    }
Exemplo n.º 12
0
    // Token: 0x0600176C RID: 5996 RVA: 0x00057580 File Offset: 0x00055780
    private void RunSim(ref int i, ref Vector3G force, ref Vector3G torque)
    {
        while (i < this.dataCount)
        {
            this.ctx.data = this.data[i];
            switch (this.ctx.data.effect.Simulate(ref this.ctx))
            {
            case global::BOBRES.CONTINUE:
                force.x  += this.ctx.data.force.x;
                force.y  += this.ctx.data.force.y;
                force.z  += this.ctx.data.force.z;
                torque.x += this.ctx.data.torque.x;
                torque.y += this.ctx.data.torque.y;
                torque.z += this.ctx.data.torque.z;
                break;

            case global::BOBRES.EXIT:
                if (!this.isFork)
                {
                    int index = i++;
                    this.RunSim(ref i, ref force, ref torque);
                    if (this.ctx.data != null)
                    {
                        if (this.ctx.data.effect != null)
                        {
                            this.ctx.data.effect.Destroy(ref this.ctx.data);
                        }
                        this.data.RemoveAt(index);
                        foreach (global::BobEffectStack bobEffectStack in this.forks)
                        {
                            bobEffectStack.data.RemoveAt(index);
                        }
                    }
                    else
                    {
                        this.data.RemoveAt(index);
                    }
                }
                return;

            case global::BOBRES.ERROR:
                Debug.LogError("Error with effect", this.ctx.data.effect);
                break;
            }
            i++;
        }
    }
Exemplo n.º 13
0
 public static double AngleDegrees(Vector3G a, Vector3G b)
 {
     double num = TransitionFunctions.DotNormal(a, b);
     if (num >= 1)
     {
         return 0;
     }
     if (num <= -1)
     {
         return 180;
     }
     if (num == 0)
     {
         return 90;
     }
     return TransitionFunctions.RadiansToDegrees(TransitionFunctions.Acos(num));
 }
Exemplo n.º 14
0
 public static double AngleRadians(Vector3G a, Vector3G b)
 {
     double num = TransitionFunctions.DotNormal(a, b);
     if (num >= 1)
     {
         return 0;
     }
     if (num <= -1)
     {
         return 3.14159265358979;
     }
     if (num == 0)
     {
         return 1.5707963267949;
     }
     return TransitionFunctions.Acos(num);
 }
Exemplo n.º 15
0
    public static Vector3G Normalize(Vector3G v)
    {
        Vector3G vectorg;
        double   num = ((v.x * v.x) + (v.y * v.y)) + (v.z * v.z);

        switch (num)
        {
        case 0.0:
        case 1.0:
            return(v);
        }
        num       = Sqrt(num);
        vectorg.x = v.x / num;
        vectorg.y = v.y / num;
        vectorg.z = v.z / num;
        return(vectorg);
    }
Exemplo n.º 16
0
    private void OnDrawGizmos()
    {
        Matrix4x4G matrix4x4G;
        Vector3G   vector3G;
        Vector3G   vector3G1;
        Vector3G   vector3G2;
        Vector3G   vector3G3;
        Vector3G   vector3G4 = new Vector3G();

        base.transform.ExtractLocalToWorld(out matrix4x4G);
        Matrix4x4 matrix4x4 = base.transform.localToWorldMatrix;
        Vector3   vector3   = matrix4x4.MultiplyPoint(Vector3.zero);
        Vector3   vector31  = matrix4x4.MultiplyPoint(Vector3.forward);
        Vector3   vector32  = matrix4x4.MultiplyPoint(Vector3.up);
        Vector3   vector33  = matrix4x4.MultiplyPoint(Vector3.right);

        vector3G4.x = 1;
        vector3G4.y = 0;
        vector3G4.z = 0;
        Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G);
        vector3G4.x = 0;
        vector3G4.y = 1;
        vector3G4.z = 0;
        Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G1);
        vector3G4.x = 0;
        vector3G4.y = 0;
        vector3G4.z = 1;
        Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G2);
        vector3G4.x = 0;
        vector3G4.y = 0;
        vector3G4.z = 0;
        Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G3);
        Gizmos.color = Color.red * new Color(1f, 1f, 1f, 0.5f);
        Gizmos.DrawLine(vector3, vector33);
        Gizmos.color = Color.green * new Color(1f, 1f, 1f, 0.5f);
        Gizmos.DrawLine(vector3, vector32);
        Gizmos.color = Color.blue * new Color(1f, 1f, 1f, 0.5f);
        Gizmos.DrawLine(vector3, vector31);
        Gizmos.color = Color.red * new Color(1f, 1f, 1f, 1f);
        Gizmos.DrawLine(vector3G3.f, vector3G.f);
        Gizmos.color = Color.green * new Color(1f, 1f, 1f, 1f);
        Gizmos.DrawLine(vector3G3.f, vector3G1.f);
        Gizmos.color = Color.blue * new Color(1f, 1f, 1f, 1f);
        Gizmos.DrawLine(vector3G3.f, vector3G2.f);
    }
Exemplo n.º 17
0
    public static double AngleDegrees(Vector3G a, Vector3G b)
    {
        double v = DotNormal(a, b);

        if (v >= 1.0)
        {
            return(0.0);
        }
        if (v <= -1.0)
        {
            return(180.0);
        }
        if (v == 0.0)
        {
            return(90.0);
        }
        return(RadiansToDegrees(Acos(v)));
    }
Exemplo n.º 18
0
    public static double AngleRadians(Vector3G a, Vector3G b)
    {
        double v = DotNormal(a, b);

        if (v >= 1.0)
        {
            return(0.0);
        }
        if (v <= -1.0)
        {
            return(3.1415926535897931);
        }
        if (v == 0.0)
        {
            return(1.5707963267948966);
        }
        return(Acos(v));
    }
Exemplo n.º 19
0
 private void OnDrawGizmos()
 {
     Matrix4x4G matrix4x4G;
     Vector3G vector3G;
     Vector3G vector3G1;
     Vector3G vector3G2;
     Vector3G vector3G3;
     Vector3G vector3G4 = new Vector3G();
     base.transform.ExtractLocalToWorld(out matrix4x4G);
     Matrix4x4 matrix4x4 = base.transform.localToWorldMatrix;
     Vector3 vector3 = matrix4x4.MultiplyPoint(Vector3.zero);
     Vector3 vector31 = matrix4x4.MultiplyPoint(Vector3.forward);
     Vector3 vector32 = matrix4x4.MultiplyPoint(Vector3.up);
     Vector3 vector33 = matrix4x4.MultiplyPoint(Vector3.right);
     vector3G4.x = 1;
     vector3G4.y = 0;
     vector3G4.z = 0;
     Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G);
     vector3G4.x = 0;
     vector3G4.y = 1;
     vector3G4.z = 0;
     Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G1);
     vector3G4.x = 0;
     vector3G4.y = 0;
     vector3G4.z = 1;
     Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G2);
     vector3G4.x = 0;
     vector3G4.y = 0;
     vector3G4.z = 0;
     Matrix4x4G.Mult(ref vector3G4, ref matrix4x4G, out vector3G3);
     Gizmos.color = Color.red * new Color(1f, 1f, 1f, 0.5f);
     Gizmos.DrawLine(vector3, vector33);
     Gizmos.color = Color.green * new Color(1f, 1f, 1f, 0.5f);
     Gizmos.DrawLine(vector3, vector32);
     Gizmos.color = Color.blue * new Color(1f, 1f, 1f, 0.5f);
     Gizmos.DrawLine(vector3, vector31);
     Gizmos.color = Color.red * new Color(1f, 1f, 1f, 1f);
     Gizmos.DrawLine(vector3G3.f, vector3G.f);
     Gizmos.color = Color.green * new Color(1f, 1f, 1f, 1f);
     Gizmos.DrawLine(vector3G3.f, vector3G1.f);
     Gizmos.color = Color.blue * new Color(1f, 1f, 1f, 1f);
     Gizmos.DrawLine(vector3G3.f, vector3G2.f);
 }
Exemplo n.º 20
0
 private void Update()
 {
     if ((this.R == null) || (this.R.Length == 0))
     {
         this.unity = Quaternion.identity;
         this.facep = QuaternionG.identity;
     }
     else if (this.revMul)
     {
         int index = this.R.Length - 1;
         this.unity = Quaternion.Euler(this.R[index]);
         Vector3G deg = new Vector3G(this.R[index]);
         QuaternionG.Euler(ref deg, out this.facep);
         index--;
         while (index >= 0)
         {
             QuaternionG ng;
             this.unity = Quaternion.Euler(this.R[index]) * this.unity;
             deg.f      = this.R[index];
             QuaternionG.Euler(ref deg, out ng);
             QuaternionG.Mult(ref ng, ref this.facep, out this.facep);
             index--;
         }
     }
     else
     {
         int num2 = 0;
         this.unity = Quaternion.Euler(this.R[num2]);
         Vector3G vectorg2 = new Vector3G(this.R[num2]);
         QuaternionG.Euler(ref vectorg2, out this.facep);
         num2++;
         while (num2 < this.R.Length)
         {
             QuaternionG ng2;
             this.unity *= Quaternion.Euler(this.R[num2]);
             vectorg2.f  = this.R[num2];
             QuaternionG.Euler(ref vectorg2, out ng2);
             QuaternionG.Mult(ref this.facep, ref ng2, out this.facep);
             num2++;
         }
     }
 }
Exemplo n.º 21
0
    private void Update()
    {
        QuaternionG quaternionG;
        QuaternionG quaternionG1;

        if (this.R == null || (int)this.R.Length == 0)
        {
            this.unity = Quaternion.identity;
            this.facep = QuaternionG.identity;
        }
        else if (!this.revMul)
        {
            int i = 0;
            this.unity = Quaternion.Euler(this.R[i]);
            Vector3G vector3G = new Vector3G(this.R[i]);
            QuaternionG.Euler(ref vector3G, out this.facep);
            for (i++; i < (int)this.R.Length; i++)
            {
                QuaternionTest quaternionTest = this;
                quaternionTest.unity = quaternionTest.unity * Quaternion.Euler(this.R[i]);
                vector3G.f           = this.R[i];
                QuaternionG.Euler(ref vector3G, out quaternionG1);
                QuaternionG quaternionG2 = this.facep;
                QuaternionG.Mult(ref quaternionG2, ref quaternionG1, out this.facep);
            }
        }
        else
        {
            int length = (int)this.R.Length - 1;
            this.unity = Quaternion.Euler(this.R[length]);
            Vector3G r = new Vector3G(this.R[length]);
            QuaternionG.Euler(ref r, out this.facep);
            for (length--; length >= 0; length--)
            {
                this.unity = Quaternion.Euler(this.R[length]) * this.unity;
                r.f        = this.R[length];
                QuaternionG.Euler(ref r, out quaternionG);
                QuaternionG.Mult(ref quaternionG, ref this.facep, out this.facep);
            }
        }
    }
Exemplo n.º 22
0
    public static Vector3G Evaluate(this TransitionFunction f, double t, Vector3G a, Vector3G b)
    {
        switch (f)
        {
        case TransitionFunction.Linear:
            return(Linear(t, a, b));

        case TransitionFunction.Round:
            return(Round(t, a, b));

        case TransitionFunction.Floor:
            return(Floor(t, a, b));

        case TransitionFunction.Ceil:
            return(Ceil(t, a, b));

        case TransitionFunction.Spline:
            return(Spline(t, a, b));
        }
        throw new ArgumentOutOfRangeException("v", "Attempted use of unrecognized TransitionFunction enum value");
    }
Exemplo n.º 23
0
        public void Sample(ref Vector3G v, float timeStamp)
        {
            if (this.sample1.timeStamp < timeStamp)
            {
                this.sample2 = this.sample1;
            }
            if (this.sample0.timeStamp < timeStamp)
            {
                this.sample1 = this.sample0;
            }
            this.sample0.vector    = v;
            this.sample0.timeStamp = timeStamp;
            this.sample0.valid     = true;
            Vector3G vector3G = new Vector3G();
            double   num      = this.sample0.AddDifference(ref this.sample1, ref vector3G) + this.sample0.AddDifference(ref this.sample2, ref vector3G);

            if (num != 0)
            {
                num          = 1 / num;
                this.accel.x = vector3G.x * num;
                this.accel.y = vector3G.y * num;
                this.accel.z = vector3G.z * num;
            }
        }
Exemplo n.º 24
0
 public static QuaternionG LookRotation(Vector3G forward, Vector3G up)
 {
     QuaternionG quaternionG;
     QuaternionG.LookRotation(ref forward, ref up, out quaternionG);
     return quaternionG;
 }
Exemplo n.º 25
0
    private void Solve(ref Weight weight, ref double dt)
    {
        Vector3G vectorg;

        vectorg.x = (dt * this.groundLocalVelocity.x) * this.cfg.forceSpeedMultiplier.x;
        vectorg.y = (dt * this.groundLocalVelocity.y) * this.cfg.forceSpeedMultiplier.y;
        vectorg.z = (dt * this.groundLocalVelocity.z) * this.cfg.forceSpeedMultiplier.z;
        Vector3G fE       = weight.position.fE;
        Vector3G vectorg3 = weight.rotation.fE;

        weight.position.fE = new Vector3G();
        weight.rotation.fE = new Vector3G();
        if (this.anyAdditionalCurves)
        {
            for (int i = 0; i < this.additionalCurveCount; i++)
            {
                double        groundLocalVelocityMag;
                BobForceCurve curve = this.cfg.additionalCurves[i];
                switch (curve.source)
                {
                case BobForceCurveSource.LocalMovementMagnitude:
                    groundLocalVelocityMag = this.groundLocalVelocityMag;
                    break;

                case BobForceCurveSource.LocalMovementX:
                    groundLocalVelocityMag = this.groundLocalVelocity.x;
                    break;

                case BobForceCurveSource.LocalMovementY:
                    groundLocalVelocityMag = this.groundLocalVelocity.y;
                    break;

                case BobForceCurveSource.LocalMovementZ:
                    groundLocalVelocityMag = this.groundLocalVelocity.z;
                    break;

                case BobForceCurveSource.WorldMovementMagnitude:
                    groundLocalVelocityMag = this.groundWorldVelocityMag;
                    break;

                case BobForceCurveSource.WorldMovementX:
                    groundLocalVelocityMag = this.groundWorldVelocity.x;
                    break;

                case BobForceCurveSource.WorldMovementY:
                    groundLocalVelocityMag = this.groundWorldVelocity.y;
                    break;

                case BobForceCurveSource.WorldMovementZ:
                    groundLocalVelocityMag = this.groundWorldVelocity.z;
                    break;

                case BobForceCurveSource.LocalVelocityMagnitude:
                    groundLocalVelocityMag = this.localVelocityMag;
                    break;

                case BobForceCurveSource.LocalVelocityX:
                    groundLocalVelocityMag = this.localVelocity.x;
                    break;

                case BobForceCurveSource.LocalVelocityY:
                    groundLocalVelocityMag = this.localVelocity.y;
                    break;

                case BobForceCurveSource.WorldVelocityMagnitude:
                    groundLocalVelocityMag = this.worldVelocityMag;
                    break;

                case BobForceCurveSource.WorldVelocityX:
                    groundLocalVelocityMag = this.worldVelocity.x;
                    break;

                case BobForceCurveSource.WorldVelocityY:
                    groundLocalVelocityMag = this.worldVelocity.y;
                    break;

                case BobForceCurveSource.WorldVelocityZ:
                    groundLocalVelocityMag = this.worldVelocity.z;
                    break;

                case BobForceCurveSource.RotationMagnitude:
                    groundLocalVelocityMag = this.localAngularVelocityMag;
                    break;

                case BobForceCurveSource.RotationPitch:
                    groundLocalVelocityMag = this.localAngularVelocity.x;
                    break;

                case BobForceCurveSource.RotationYaw:
                    groundLocalVelocityMag = this.localAngularVelocity.y;
                    break;

                case BobForceCurveSource.RotationRoll:
                    groundLocalVelocityMag = this.localAngularVelocity.z;
                    break;

                case BobForceCurveSource.TurnMagnitude:
                    groundLocalVelocityMag = this.groundLocalAngularVelocityMag;
                    break;

                case BobForceCurveSource.TurnPitch:
                    groundLocalVelocityMag = this.groundLocalAngularVelocity.x;
                    break;

                case BobForceCurveSource.TurnYaw:
                    groundLocalVelocityMag = this.groundLocalAngularVelocity.y;
                    break;

                case BobForceCurveSource.TurnRoll:
                    groundLocalVelocityMag = this.groundLocalAngularVelocity.z;
                    break;

                default:
                    groundLocalVelocityMag = this.localVelocity.z;
                    break;
                }
                BobForceCurveTarget target = curve.target;
                if ((target == BobForceCurveTarget.Position) || (target != BobForceCurveTarget.Rotation))
                {
                    curve.Calculate(ref weight.additionalPositions[i], ref groundLocalVelocityMag, ref dt, ref weight.position.fE);
                }
                else
                {
                    curve.Calculate(ref weight.additionalPositions[i], ref groundLocalVelocityMag, ref dt, ref weight.rotation.fE);
                }
            }
        }
        if (this.cfg.impulseForceSmooth > 0f)
        {
            Vector3G.SmoothDamp(ref weight.position.fI, ref this.impulseForce.accel, ref weight.position.fIV, this.cfg.impulseForceSmooth, this.cfg.impulseForceMaxChangeAcceleration, ref dt);
        }
        else
        {
            weight.position.fI = this.impulseForce.accel;
        }
        if (this.cfg.angleImpulseForceSmooth > 0f)
        {
            Vector3G.SmoothDamp(ref weight.rotation.fI, ref this.impulseTorque.accel, ref weight.rotation.fIV, this.cfg.angleImpulseForceSmooth, this.cfg.angleImpulseForceMaxChangeAcceleration, ref dt);
        }
        else
        {
            weight.rotation.fI = this.impulseTorque.accel;
        }
        weight.position.fE.x += this.inputForce.x + (weight.position.fI.x * this.cfg.impulseForceScale.x);
        weight.position.fE.y += this.inputForce.y + (weight.position.fI.y * this.cfg.impulseForceScale.y);
        weight.position.fE.z += this.inputForce.z + (weight.position.fI.z * this.cfg.impulseForceScale.z);
        weight.rotation.fE.x += weight.rotation.fI.x * this.cfg.angularImpulseForceScale.x;
        weight.rotation.fE.y += weight.rotation.fI.y * this.cfg.angularImpulseForceScale.y;
        weight.rotation.fE.z += weight.rotation.fI.z * this.cfg.angularImpulseForceScale.z;
        Vector3G vectorg4 = weight.position.value;

        vectorg4.x /= (double)this.cfg.elipsoidRadii.x;
        vectorg4.y /= (double)this.cfg.elipsoidRadii.y;
        vectorg4.z /= (double)this.cfg.elipsoidRadii.z;
        double d = ((vectorg4.x * vectorg4.x) + (vectorg4.y * vectorg4.y)) + (vectorg4.z * vectorg4.z);

        if (d > 1.0)
        {
            d           = 1.0 / Math.Sqrt(d);
            vectorg4.x *= d;
            vectorg4.y *= d;
            vectorg4.z *= d;
        }
        vectorg4.x *= this.cfg.elipsoidRadii.x;
        vectorg4.y *= this.cfg.elipsoidRadii.y;
        vectorg4.z *= this.cfg.elipsoidRadii.z;
        weight.stack.Simulate(ref dt, ref weight.position.fE, ref weight.rotation.fE);
        weight.position.acceleration.x = (weight.position.fE.x - fE.x) + (((vectorg4.x * -this.cfg.springConstant.x) - (weight.position.velocity.x * this.cfg.springDampen.x)) * this.cfg.weightMass);
        weight.position.acceleration.y = (weight.position.fE.y - fE.y) + (((vectorg4.y * -this.cfg.springConstant.y) - (weight.position.velocity.y * this.cfg.springDampen.y)) * this.cfg.weightMass);
        weight.position.acceleration.z = (weight.position.fE.z - fE.z) + (((vectorg4.z * -this.cfg.springConstant.z) - (weight.position.velocity.z * this.cfg.springDampen.z)) * this.cfg.weightMass);
        weight.position.velocity.x    += weight.position.acceleration.x * dt;
        weight.position.velocity.y    += weight.position.acceleration.y * dt;
        weight.position.velocity.z    += weight.position.acceleration.z * dt;
        if (!float.IsInfinity(this.cfg.maxVelocity.x))
        {
            if (weight.position.velocity.x < -this.cfg.maxVelocity.x)
            {
                weight.position.value.x -= this.cfg.maxVelocity.x * dt;
            }
            else if (weight.position.velocity.x > this.cfg.maxVelocity.x)
            {
                weight.position.value.x += this.cfg.maxVelocity.x * dt;
            }
            else
            {
                weight.position.value.x += weight.position.velocity.x * dt;
            }
        }
        else
        {
            weight.position.value.x += weight.position.velocity.x * dt;
        }
        if (!float.IsInfinity(this.cfg.maxVelocity.y))
        {
            if (weight.position.velocity.y < -this.cfg.maxVelocity.y)
            {
                weight.position.value.y -= this.cfg.maxVelocity.y * dt;
            }
            else if (weight.position.velocity.y > this.cfg.maxVelocity.y)
            {
                weight.position.value.y += this.cfg.maxVelocity.y * dt;
            }
            else
            {
                weight.position.value.y += weight.position.velocity.y * dt;
            }
        }
        else
        {
            weight.position.value.y += weight.position.velocity.y * dt;
        }
        if (!float.IsInfinity(this.cfg.maxVelocity.z))
        {
            if (weight.position.velocity.z < -this.cfg.maxVelocity.z)
            {
                weight.position.value.z -= this.cfg.maxVelocity.z * dt;
            }
            else if (weight.position.velocity.z > this.cfg.maxVelocity.z)
            {
                weight.position.value.z += this.cfg.maxVelocity.z * dt;
            }
            else
            {
                weight.position.value.z += weight.position.velocity.z * dt;
            }
        }
        else
        {
            weight.position.value.z += weight.position.velocity.z * dt;
        }
        weight.rotation.acceleration.x = (weight.rotation.fE.x - vectorg3.x) + (((weight.rotation.value.x * -this.cfg.angularSpringConstant.x) - (weight.rotation.velocity.x * this.cfg.angularSpringDampen.x)) * this.cfg.angularWeightMass);
        weight.rotation.acceleration.y = (weight.rotation.fE.y - vectorg3.y) + (((weight.rotation.value.y * -this.cfg.angularSpringConstant.y) - (weight.rotation.velocity.y * this.cfg.angularSpringDampen.y)) * this.cfg.angularWeightMass);
        weight.rotation.acceleration.z = (weight.rotation.fE.z - vectorg3.z) + (((weight.rotation.value.z * -this.cfg.angularSpringConstant.z) - (weight.rotation.velocity.z * this.cfg.angularSpringDampen.z)) * this.cfg.angularWeightMass);
        weight.rotation.velocity.x    += weight.rotation.acceleration.x * dt;
        weight.rotation.velocity.y    += weight.rotation.acceleration.y * dt;
        weight.rotation.velocity.z    += weight.rotation.acceleration.z * dt;
        weight.rotation.value.x       += weight.rotation.velocity.x * dt;
        weight.rotation.value.y       += weight.rotation.velocity.y * dt;
        weight.rotation.value.z       += weight.rotation.velocity.z * dt;
    }
Exemplo n.º 26
0
 public static Vector3G Floor(double t, Vector3G a, Vector3G b)
 {
     return (t >= 1 ? b : a);
 }
Exemplo n.º 27
0
    private int Step(float dt)
    {
        double  num;
        int     num1    = 0;
        int     num2    = 0;
        HeadBob headBob = this;

        headBob.timeSolve = headBob.timeSolve + (double)dt;
        double num3 = ((double)this.cfg.solveRate >= 0 ? 1 / (double)this.cfg.solveRate : 1 / -(double)this.cfg.solveRate);

        if ((double)this.cfg.intermitRate != 0)
        {
            num = ((double)this.cfg.intermitRate >= 0 ? 1 / (double)this.cfg.intermitRate : 1 / -(double)this.cfg.intermitRate);
        }
        else
        {
            num = 0;
        }
        double num4 = num;

        if (double.IsInfinity(num3) || num3 == 0)
        {
            num3 = this.timeSolve;
        }
        bool   flag = num4 > num3;
        double num5 = num3 * (double)this.cfg.timeScale;

        if (this.timeSolve >= num3)
        {
            do
            {
                HeadBob headBob1 = this;
                headBob1.timeSolve = headBob1.timeSolve - num3;
                if (flag)
                {
                    HeadBob headBob2 = this;
                    headBob2.timeIntermit = headBob2.timeIntermit - num3;
                    if (this.timeIntermit < 0)
                    {
                        this.intermitStart = this.working;
                    }
                }
                this.Solve(ref this.working, ref num5);
                if (flag && this.timeIntermit < 0)
                {
                    this.intermitNext     = this.working;
                    this.intermitFraction = (this.timeIntermit + num3) / num3;
                    HeadBob headBob3 = this;
                    headBob3.timeIntermit = headBob3.timeIntermit + num4;
                    num2++;
                }
                num1++;
            }while (this.timeSolve >= num3);
        }
        if (flag)
        {
            if (num2 > 0)
            {
                if (!this.simStep)
                {
                    this.raw_pos = this.intermitNext.position.@value;
                    this.raw_rot = this.intermitNext.rotation.@value;
                    this.CheckDeadZone();
                }
                else
                {
                    Vector3G.Lerp(ref this.intermitStart.position.@value, ref this.intermitNext.position.@value, ref this.intermitFraction, out this.raw_pos);
                    Vector3G.Lerp(ref this.intermitStart.rotation.@value, ref this.intermitNext.rotation.@value, ref this.intermitFraction, out this.raw_rot);
                    this.CheckDeadZone();
                }
            }
            return(num2);
        }
        if (!this.simStep)
        {
            this.raw_pos = this.working.position.@value;
            this.raw_rot = this.working.rotation.@value;
            this.CheckDeadZone();
        }
        else
        {
            this.working.CopyTo(ref this.predicted);
            this.Solve(ref this.predicted, ref num5);
            num1 = -(num1 + 1);
            double num6 = this.timeSolve / num3;
            Vector3G.Lerp(ref this.working.position.@value, ref this.predicted.position.@value, ref num6, out this.raw_pos);
            Vector3G.Lerp(ref this.working.rotation.@value, ref this.predicted.rotation.@value, ref num6, out this.raw_rot);
            this.CheckDeadZone();
        }
        return(num1);
    }
Exemplo n.º 28
0
 public static double Dot(Vector3G a, Vector3G b)
 {
     return a.x * b.x + a.y * b.y + a.z * b.z;
 }
Exemplo n.º 29
0
    // Token: 0x06002E47 RID: 11847 RVA: 0x000B1304 File Offset: 0x000AF504
    public void Calculate(ref Vector3G v, ref double pow, ref double dt, ref Vector3G sum)
    {
        if (!this.once)
        {
            this.Gasp();
        }
        if (!this.calc)
        {
            return;
        }
        float    num   = (!this.mask) ? 1f : this.sourceMask.Evaluate((float)pow);
        bool     flag  = num == 0f || num == -0f;
        float    num2  = (!this.scaleFixed) ? ((!this.scale) ? 1f : this.sourceScale.Evaluate((float)pow)) : 0f;
        bool     flag2 = !this.scaleFixed && num2 != 0f && num2 != -0f;
        Vector3G vector3G;

        if (this.infoX.calc)
        {
            if (flag2 && !this.infoX.constant)
            {
                v.x += pow * dt * (double)num2 * (double)this.positionScale.x;
                if (v.x > (double)this.infoX.duration)
                {
                    v.x -= (double)this.infoX.duration;
                }
                else if (v.x < (double)(-(double)this.infoX.duration))
                {
                    v.x += (double)this.infoX.duration;
                }
            }
            vector3G.x = (double)((!flag) ? (this.forceX.Evaluate((float)v.x) * this.outputScale.x) : 0f);
        }
        else
        {
            vector3G.x = 0.0;
        }
        if (this.infoY.calc)
        {
            if (flag2 && !this.infoY.constant)
            {
                v.y += pow * dt * (double)num2 * (double)this.positionScale.y;
                if (v.y > (double)this.infoY.duration)
                {
                    v.y -= (double)this.infoY.duration;
                }
                else if (v.y < (double)(-(double)this.infoY.duration))
                {
                    v.y += (double)this.infoY.duration;
                }
            }
            vector3G.y = (double)((!flag) ? (this.forceY.Evaluate((float)v.y) * this.outputScale.y) : 0f);
        }
        else
        {
            vector3G.y = 0.0;
        }
        if (this.infoZ.calc)
        {
            if (flag2 && !this.infoZ.constant)
            {
                v.z += pow * dt * (double)num2 * (double)this.positionScale.z;
                if (v.z > (double)this.infoZ.duration)
                {
                    v.z -= (double)this.infoZ.duration;
                }
                else if (v.z < (double)(-(double)this.infoZ.duration))
                {
                    v.z += (double)this.infoZ.duration;
                }
            }
            vector3G.z = (double)((!flag) ? (this.forceZ.Evaluate((float)v.z) * this.outputScale.z) : 0f);
        }
        else
        {
            vector3G.z = 0.0;
        }
        if (!flag)
        {
            sum.x += vector3G.x * (double)num;
            sum.y += vector3G.y * (double)num;
            sum.z += vector3G.z * (double)num;
        }
    }
Exemplo n.º 30
0
 private static void SET_X3(ref Matrix4x4G m, Vector3G v)
 {
     m.m03 = v.x;
     m.m13 = v.y;
     m.m23 = v.z;
 }
Exemplo n.º 31
0
 private static void TRANS(ref Matrix4x4G a, Vector3G v)
 {
     TransitionFunctions.SET_X3(ref a, v);
 }
Exemplo n.º 32
0
 private static void SET_X0(ref Matrix4x4G m, Vector3G v)
 {
     m.m00 = v.x;
     m.m10 = v.y;
     m.m20 = v.z;
 }
Exemplo n.º 33
0
 private static void SET_X1(ref Matrix4x4G m, Vector3G v)
 {
     m.m01 = v.x;
     m.m11 = v.y;
     m.m21 = v.z;
 }
Exemplo n.º 34
0
 private static void SET_2X(ref Matrix4x4G m, Vector3G v)
 {
     m.m20 = v.x;
     m.m21 = v.y;
     m.m22 = v.z;
 }
Exemplo n.º 35
0
 public static Vector3G Linear(double t, Vector3G a, Vector3G b)
 {
     return(Sum(Mul(a, 1.0 - t), Mul(b, t)));
 }
Exemplo n.º 36
0
    public void PostPreCull()
    {
        Vector3G   vector3G;
        Matrix4x4G matrix4x4G;
        Matrix4x4G matrix4x4G1;
        Vector3G   vector3G1 = new Vector3G();
        Vector3G   vector3G2;
        Vector3G   vector3G3;
        Vector3G   vector3G4;
        Vector3G   vector3G5;
        Vector3G   vector3G6 = new Vector3G();
        RaycastHit raycastHit;
        Matrix4x4G matrix4x4G2;
        PerspectiveMatrixBuilder perspectiveMatrixBuilder = new PerspectiveMatrixBuilder();
        Vector4 vector4 = new Vector4();
        PerspectiveMatrixBuilder perspectiveMatrixBuilder1 = new PerspectiveMatrixBuilder();
        Matrix4x4G  matrix4x4G3;
        Vector3G    vector3G7;
        QuaternionG quaternionG;
        Vector3G    vector3G8;
        Matrix4x4G  matrix4x4G4;
        Matrix4x4G  matrix4x4G5;
        Matrix4x4G  matrix4x4G6;
        Matrix4x4G  matrix4x4G7;
        Matrix4x4G  matrix4x4G8;
        Matrix4x4G  matrix4x4G9;
        Matrix4x4G  matrix4x4G10;
        Matrix4x4G  matrix4x4G11;

        if (CameraFX.viewModelRootTransform)
        {
            Quaternion quaternion = base.transform.localRotation;
            Vector3    vector3    = base.transform.localPosition;
            if (this.viewModel)
            {
                this.viewModel.ModifyAiming(new Ray(base.transform.parent.position, base.transform.parent.forward), ref vector3, ref quaternion);
            }
            CameraFX.viewModelRootTransform.localRotation = Quaternion.Inverse(quaternion);
            CameraFX.viewModelRootTransform.localPosition = -vector3;
        }
        this.camera.transform.ExtractLocalToWorldToLocal(out this.localToWorldMatrix, out this.worldToLocalMatrix);
        if (this.adaptiveNearPlane)
        {
            int      num       = this.camera.cullingMask & ~this.adaptiveNearPlane.ignoreLayers.@value | this.adaptiveNearPlane.forceLayers.@value;
            Vector3G vector3G9 = new Vector3G();
            this.localToWorldMatrix.MultiplyPoint(ref vector3G9, out vector3G);
            Collider[] colliderArray = Physics.OverlapSphere(vector3G.f, this.adaptiveNearPlane.minNear + this.adaptiveNearPlane.maxNear, num);
            int        num1          = -1;
            float      single        = Single.PositiveInfinity;
            double     num2          = (double)this.camera.fieldOfView;
            double     num3          = (double)this.camera.aspect;
            double     num4          = (double)this.adaptiveNearPlane.minNear;
            double     num5          = (double)(this.adaptiveNearPlane.maxNear + this.adaptiveNearPlane.threshold);
            float      single1       = this.adaptiveNearPlane.minNear;
            float      single2       = this.adaptiveNearPlane.maxNear + this.adaptiveNearPlane.threshold - single1;
            Matrix4x4G.Perspective(ref num2, ref num3, ref num4, ref num5, out matrix4x4G);
            Matrix4x4G.Inverse(ref matrix4x4G, out matrix4x4G1);
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    vector3G1.x = ((double)i - 3.5) / 3.5;
                    vector3G1.y = ((double)j - 3.5) / 3.5;
                    vector3G1.z = 0;
                    matrix4x4G1.MultiplyPoint(ref vector3G1, out vector3G2);
                    vector3G1.z = 1;
                    matrix4x4G1.MultiplyPoint(ref vector3G1, out vector3G3);
                    vector3G2.x = -vector3G2.x;
                    vector3G2.y = -vector3G2.y;
                    vector3G2.z = -vector3G2.z;
                    vector3G3.x = -vector3G3.x;
                    vector3G3.y = -vector3G3.y;
                    vector3G3.z = -vector3G3.z;
                    this.localToWorldMatrix.MultiplyPoint(ref vector3G2, out vector3G4);
                    this.localToWorldMatrix.MultiplyPoint(ref vector3G3, out vector3G5);
                    vector3G6.x = vector3G5.x - vector3G4.x;
                    vector3G6.y = vector3G5.y - vector3G4.y;
                    vector3G6.z = vector3G5.z - vector3G4.z;
                    float single3 = (float)Math.Sqrt(vector3G6.x * vector3G6.x + vector3G6.y * vector3G6.y + vector3G6.z * vector3G6.z);
                    float single4 = single3;
                    Ray   ray     = new Ray(vector3G4.f, vector3G6.f);
                    for (int k = 0; k < (int)colliderArray.Length; k++)
                    {
                        if (colliderArray[k].Raycast(ray, out raycastHit, single4))
                        {
                            float single5 = raycastHit.distance;
                            if (single5 < single4)
                            {
                                single4 = single5;
                                float single6 = single1 + single5 / single3 * single2;
                                if (single > single6)
                                {
                                    single = single6;
                                    num1   = k;
                                }
                            }
                        }
                    }
                }
            }
            if (!float.IsInfinity(single))
            {
                single = single - this.adaptiveNearPlane.threshold;
                if (single >= this.adaptiveNearPlane.maxNear)
                {
                    this.camera.nearClipPlane = this.adaptiveNearPlane.maxNear;
                }
                else if (single > this.adaptiveNearPlane.minNear)
                {
                    this.camera.nearClipPlane = single;
                }
                else
                {
                    this.camera.nearClipPlane = this.adaptiveNearPlane.minNear;
                }
            }
            else
            {
                this.camera.nearClipPlane = this.adaptiveNearPlane.maxNear;
            }
        }
        perspectiveMatrixBuilder.fieldOfView = (double)this.camera.fieldOfView;
        perspectiveMatrixBuilder.aspectRatio = (double)this.camera.aspect;
        perspectiveMatrixBuilder.nearPlane   = (double)this.camera.nearClipPlane;
        perspectiveMatrixBuilder.farPlane    = (double)this.camera.farClipPlane;
        PerspectiveMatrixBuilder perspectiveMatrixBuilder2 = perspectiveMatrixBuilder;

        if (!this.camera.isOrthoGraphic)
        {
            if (this.viewModel)
            {
                this.viewModel.ModifyPerspective(ref perspectiveMatrixBuilder2);
            }
            if (!CameraFX.vm_projuse)
            {
                perspectiveMatrixBuilder.ToProjectionMatrix(out this.projectionMatrix);
            }
            else
            {
                perspectiveMatrixBuilder2.ToProjectionMatrix(out this.projectionMatrix);
            }
            this.camera.projectionMatrix = this.projectionMatrix.f;
            perspectiveMatrixBuilder2.ToProjectionMatrix(out matrix4x4G2);
        }
        else
        {
            this.projectionMatrix.f = this.camera.projectionMatrix;
            matrix4x4G2             = this.projectionMatrix;
        }
        vector4.y = (float)perspectiveMatrixBuilder2.nearPlane;
        vector4.z = (float)perspectiveMatrixBuilder2.farPlane;
        vector4.w = (float)(1 / perspectiveMatrixBuilder2.farPlane);
        if (CameraFX.vm_flip != CameraFX.PLATFORM_POLL.flipRequired)
        {
            vector4.x = -1f;
            perspectiveMatrixBuilder1.nearPlane   = perspectiveMatrixBuilder2.nearPlane;
            perspectiveMatrixBuilder1.farPlane    = perspectiveMatrixBuilder2.farPlane;
            perspectiveMatrixBuilder1.fieldOfView = -perspectiveMatrixBuilder2.fieldOfView;
            perspectiveMatrixBuilder1.aspectRatio = -perspectiveMatrixBuilder2.aspectRatio;
            perspectiveMatrixBuilder1.ToProjectionMatrix(out matrix4x4G3);
            Shader.SetGlobalMatrix("V_MUNITY_MATRIX_P", matrix4x4G3.f);
        }
        else
        {
            vector4.x = 1f;
            Shader.SetGlobalMatrix("V_MUNITY_MATRIX_P", matrix4x4G2.f);
        }
        Shader.SetGlobalVector("V_M_ProjectionParams", vector4);
        if (!this.recalcViewMatrix)
        {
            this.cameraToWorldMatrix.f = this.camera.cameraToWorldMatrix;
            this.worldToCameraMatrix.f = this.camera.worldToCameraMatrix;
        }
        else
        {
            this.camera.transform.ExtractWorldCoordinates(out vector3G7, out quaternionG, out vector3G8);
            vector3G8.x = 1;
            vector3G8.y = 1;
            vector3G8.z = -1;
            Matrix4x4G.TRS(ref vector3G7, ref quaternionG, ref vector3G8, out this.cameraToWorldMatrix);
            if (Matrix4x4G.Inverse(ref this.cameraToWorldMatrix, out this.worldToCameraMatrix))
            {
                this.camera.worldToCameraMatrix = this.worldToCameraMatrix.f;
            }
        }
        this.worldToCameraMatrixUnAltered = this.worldToCameraMatrix;
        this.cameraToWorldMatrixUnAltered = this.cameraToWorldMatrix;
        this.projectionMatrixUnAltered    = this.projectionMatrix;
        CameraFX.ApplyTransitionAlterations(this.camera, this, true);
        Matrix4x4G matrix4x4G12 = this.worldToCameraMatrix;
        Matrix4x4G matrix4x4G13 = matrix4x4G12;

        this.projectViewport.modelview = matrix4x4G12;
        this.projectScreen.modelview   = matrix4x4G13;
        Matrix4x4G matrix4x4G14 = this.projectionMatrix;

        matrix4x4G13 = matrix4x4G14;
        this.projectViewport.projection = matrix4x4G14;
        this.projectScreen.projection   = matrix4x4G13;
        Rect rect = this.camera.pixelRect;

        this.projectScreen.offset.x = (double)rect.x;
        this.projectScreen.offset.y = (double)rect.y;
        this.projectScreen.size.x   = (double)rect.width;
        this.projectScreen.size.y   = (double)rect.height;
        rect = this.camera.rect;
        this.projectViewport.offset.x = (double)rect.x;
        this.projectViewport.offset.y = (double)rect.y;
        this.projectViewport.size.x   = (double)rect.width;
        this.projectViewport.size.y   = (double)rect.height;
        Matrix4x4G.Mult(ref this.localToWorldMatrix, ref this.worldToCameraMatrix, out matrix4x4G7);
        Matrix4x4G.Mult(ref matrix4x4G7, ref this.projectionMatrix, out matrix4x4G4);
        Matrix4x4G.Inverse(ref matrix4x4G7, out matrix4x4G8);
        Matrix4x4G.Inverse(ref matrix4x4G4, out matrix4x4G5);
        Matrix4x4G.Inverse(ref this.localToWorldMatrix, out matrix4x4G10);
        Matrix4x4G.Transpose(ref matrix4x4G5, out matrix4x4G6);
        Matrix4x4G.Transpose(ref matrix4x4G8, out matrix4x4G9);
        Matrix4x4G.Transpose(ref matrix4x4G10, out matrix4x4G11);
        if (this.viewModel)
        {
            this.viewModel.UpdateProxies();
        }
        BoundHack.Achieve(base.transform.position);
        ContextSprite.UpdateSpriteFading(this.camera);
        PlayerClient playerClient = PlayerClient.localPlayerClient;

        if (playerClient)
        {
            playerClient.ProcessLocalPlayerPreRender();
        }
        RPOS.BeforeSceneRender_Internal(this.camera);
    }
Exemplo n.º 37
0
 private static Vector3G LLERP(double t, Vector3G a, Vector3G b)
 {
     return(Linear(t, a, b));
 }
Exemplo n.º 38
0
    public void Calculate(ref Vector3G v, ref double pow, ref double dt, ref Vector3G sum)
    {
        Vector3G vector3G = new Vector3G();
        float    single;
        bool     flag;

        if (!this.once)
        {
            this.Gasp();
        }
        if (!this.calc)
        {
            return;
        }
        float single1 = (!this.mask ? 1f : this.sourceMask.Evaluate((float)pow));
        bool  flag1   = (single1 == 0f ? true : single1 == 0f);

        if (!this.scaleFixed)
        {
            single = (!this.scale ? 1f : this.sourceScale.Evaluate((float)pow));
        }
        else
        {
            single = 0f;
        }
        float single2 = single;

        if (this.scaleFixed)
        {
            flag = false;
        }
        else
        {
            flag = (single2 == 0f ? false : single2 != 0f);
        }
        bool flag2 = flag;

        if (!this.infoX.calc)
        {
            vector3G.x = 0;
        }
        else
        {
            if (flag2 && !this.infoX.constant)
            {
                v.x = v.x + pow * dt * (double)single2 * (double)this.positionScale.x;
                if (v.x > (double)this.infoX.duration)
                {
                    v.x = v.x - (double)this.infoX.duration;
                }
                else if (v.x < (double)(-this.infoX.duration))
                {
                    v.x = v.x + (double)this.infoX.duration;
                }
            }
            vector3G.x = (double)((!flag1 ? this.forceX.Evaluate((float)v.x) * this.outputScale.x : 0f));
        }
        if (!this.infoY.calc)
        {
            vector3G.y = 0;
        }
        else
        {
            if (flag2 && !this.infoY.constant)
            {
                v.y = v.y + pow * dt * (double)single2 * (double)this.positionScale.y;
                if (v.y > (double)this.infoY.duration)
                {
                    v.y = v.y - (double)this.infoY.duration;
                }
                else if (v.y < (double)(-this.infoY.duration))
                {
                    v.y = v.y + (double)this.infoY.duration;
                }
            }
            vector3G.y = (double)((!flag1 ? this.forceY.Evaluate((float)v.y) * this.outputScale.y : 0f));
        }
        if (!this.infoZ.calc)
        {
            vector3G.z = 0;
        }
        else
        {
            if (flag2 && !this.infoZ.constant)
            {
                v.z = v.z + pow * dt * (double)single2 * (double)this.positionScale.z;
                if (v.z > (double)this.infoZ.duration)
                {
                    v.z = v.z - (double)this.infoZ.duration;
                }
                else if (v.z < (double)(-this.infoZ.duration))
                {
                    v.z = v.z + (double)this.infoZ.duration;
                }
            }
            vector3G.z = (double)((!flag1 ? this.forceZ.Evaluate((float)v.z) * this.outputScale.z : 0f));
        }
        if (!flag1)
        {
            sum.x = sum.x + vector3G.x * (double)single1;
            sum.y = sum.y + vector3G.y * (double)single1;
            sum.z = sum.z + vector3G.z * (double)single1;
        }
    }
Exemplo n.º 39
0
 private static void SET_3X(ref Matrix4x4G m, Vector3G v)
 {
     m.m30 = v.x;
     m.m31 = v.y;
     m.m32 = v.z;
 }
Exemplo n.º 40
0
    private int Step(float dt)
    {
        int num  = 0;
        int num2 = 0;

        this.timeSolve += dt;
        double d    = (this.cfg.solveRate >= 0.0) ? (1.0 / ((double)this.cfg.solveRate)) : (1.0 / -((double)this.cfg.solveRate));
        double num4 = (this.cfg.intermitRate != 0.0) ? ((this.cfg.intermitRate >= 0.0) ? (1.0 / ((double)this.cfg.intermitRate)) : (1.0 / -((double)this.cfg.intermitRate))) : 0.0;

        if (double.IsInfinity(d) || (d == 0.0))
        {
            d = this.timeSolve;
        }
        bool   flag = num4 > d;
        double num5 = d * this.cfg.timeScale;

        if (this.timeSolve >= d)
        {
            do
            {
                this.timeSolve -= d;
                if (flag)
                {
                    this.timeIntermit -= d;
                    if (this.timeIntermit < 0.0)
                    {
                        this.intermitStart = this.working;
                    }
                }
                this.Solve(ref this.working, ref num5);
                if (flag && (this.timeIntermit < 0.0))
                {
                    this.intermitNext     = this.working;
                    this.intermitFraction = (this.timeIntermit + d) / d;
                    this.timeIntermit    += num4;
                    num2++;
                }
                num++;
            }while (this.timeSolve >= d);
        }
        if (flag)
        {
            if (num2 > 0)
            {
                if (this.simStep)
                {
                    Vector3G.Lerp(ref this.intermitStart.position.value, ref this.intermitNext.position.value, ref this.intermitFraction, out this.raw_pos);
                    Vector3G.Lerp(ref this.intermitStart.rotation.value, ref this.intermitNext.rotation.value, ref this.intermitFraction, out this.raw_rot);
                    this.CheckDeadZone();
                    return(num2);
                }
                this.raw_pos = this.intermitNext.position.value;
                this.raw_rot = this.intermitNext.rotation.value;
                this.CheckDeadZone();
            }
            return(num2);
        }
        if (this.simStep)
        {
            this.working.CopyTo(ref this.predicted);
            this.Solve(ref this.predicted, ref num5);
            num = -(num + 1);
            double t = this.timeSolve / d;
            Vector3G.Lerp(ref this.working.position.value, ref this.predicted.position.value, ref t, out this.raw_pos);
            Vector3G.Lerp(ref this.working.rotation.value, ref this.predicted.rotation.value, ref t, out this.raw_rot);
            this.CheckDeadZone();
            return(num);
        }
        this.raw_pos = this.working.position.value;
        this.raw_rot = this.working.rotation.value;
        this.CheckDeadZone();
        return(num);
    }
Exemplo n.º 41
0
 public static double CrossDot(Vector3G a, Vector3G b, Vector3G dotB)
 {
     return (a.y * b.z - a.z * b.y) * dotB.x + (a.z * b.x - a.x * b.z) * dotB.y + (a.x * b.y - a.y * b.x) * dotB.z;
 }
Exemplo n.º 42
0
 public static Vector3G Normalize(Vector3G v)
 {
     Vector3G vector3G = new Vector3G();
     double num = v.x * v.x + v.y * v.y + v.z * v.z;
     if (num == 0 || num == 1)
     {
         return v;
     }
     num = TransitionFunctions.Sqrt(num);
     vector3G.x = v.x / num;
     vector3G.y = v.y / num;
     vector3G.z = v.z / num;
     return vector3G;
 }
Exemplo n.º 43
0
 private static void SET_X2(ref Matrix4x4G m, Vector3G v)
 {
     m.m02 = v.x;
     m.m12 = v.y;
     m.m22 = v.z;
 }
Exemplo n.º 44
0
 public static Vector3G Z3(double z)
 {
     Vector3G vector3G = new Vector3G();
     double num = 0;
     double num1 = num;
     vector3G.y = num;
     vector3G.x = num1;
     vector3G.z = z;
     return vector3G;
 }
Exemplo n.º 45
0
 private static Vector3G SLERP(double t, Vector3G a, Vector3G b)
 {
     return TransitionFunctions.Slerp(t, a, b);
 }
Exemplo n.º 46
0
 private static void DIR_Z(ref Matrix4x4G a, Vector3G v)
 {
     TransitionFunctions.SET_X2(ref a, v);
 }
Exemplo n.º 47
0
 private static Vector3G VECT3F(double x, double y, double z)
 {
     Vector3G vector3G = new Vector3G();
     vector3G.x = x;
     vector3G.y = y;
     vector3G.z = z;
     return vector3G;
 }
Exemplo n.º 48
0
 public static Vector3G Cross(Vector3G a, Vector3G b)
 {
     Vector3G vector3G = new Vector3G();
     vector3G.x = a.y * b.z - a.z * b.y;
     vector3G.y = a.z * b.x - a.x * b.z;
     vector3G.z = a.x * b.y - a.y * b.x;
     return vector3G;
 }
Exemplo n.º 49
0
 public static double DotNormal(Vector3G a, Vector3G b)
 {
     return TransitionFunctions.Dot(TransitionFunctions.Normalize(a), TransitionFunctions.Normalize(b));
 }
Exemplo n.º 50
0
 private static Vector3G LLERP(double t, Vector3G a, Vector3G b)
 {
     return TransitionFunctions.Linear(t, a, b);
 }
Exemplo n.º 51
0
 public static Vector3G Evaluate(this TransitionFunction f, double t, Vector3G a, Vector3G b)
 {
     switch (f)
     {
         case TransitionFunction.Linear:
         {
             return TransitionFunctions.Linear(t, a, b);
         }
         case TransitionFunction.Round:
         {
             return TransitionFunctions.Round(t, a, b);
         }
         case TransitionFunction.Floor:
         {
             return TransitionFunctions.Floor(t, a, b);
         }
         case TransitionFunction.Ceil:
         {
             return TransitionFunctions.Ceil(t, a, b);
         }
         case TransitionFunction.Spline:
         {
             return TransitionFunctions.Spline(t, a, b);
         }
     }
     throw new ArgumentOutOfRangeException("v", "Attempted use of unrecognized TransitionFunction enum value");
 }
Exemplo n.º 52
0
 private static void SCALE(ref Matrix4x4G a, Vector3G v)
 {
     TransitionFunctions.SET_3X(ref a, v);
 }
Exemplo n.º 53
0
 public static double Length(Vector3G a)
 {
     return TransitionFunctions.Sqrt(a.x * a.x + a.y * a.y + a.z * a.z);
 }
Exemplo n.º 54
0
 private static void SET_0X(ref Matrix4x4G m, Vector3G v)
 {
     m.m00 = v.x;
     m.m01 = v.y;
     m.m02 = v.z;
 }
Exemplo n.º 55
0
 public static Vector3G Linear(double t, Vector3G a, Vector3G b)
 {
     return TransitionFunctions.Sum(TransitionFunctions.Mul(a, 1 - t), TransitionFunctions.Mul(b, t));
 }
Exemplo n.º 56
0
 private static void SET_1X(ref Matrix4x4G m, Vector3G v)
 {
     m.m10 = v.x;
     m.m11 = v.y;
     m.m12 = v.z;
 }
Exemplo n.º 57
0
 public static Vector3G Mul(Vector3G a, double b)
 {
     Vector3G vector3G = new Vector3G();
     vector3G.x = a.x * b;
     vector3G.y = a.y * b;
     vector3G.z = a.z * b;
     return vector3G;
 }
Exemplo n.º 58
0
    private void Solve(ref HeadBob.Weight weight, ref double dt)
    {
        Vector3G vector3G = new Vector3G();
        double   num;

        vector3G.x = dt * this.groundLocalVelocity.x * (double)this.cfg.forceSpeedMultiplier.x;
        vector3G.y = dt * this.groundLocalVelocity.y * (double)this.cfg.forceSpeedMultiplier.y;
        vector3G.z = dt * this.groundLocalVelocity.z * (double)this.cfg.forceSpeedMultiplier.z;
        Vector3G vector3G1 = weight.position.fE;
        Vector3G vector3G2 = weight.rotation.fE;
        Vector3G vector3G3 = new Vector3G();

        weight.position.fE = vector3G3;
        Vector3G vector3G4 = new Vector3G();

        weight.rotation.fE = vector3G4;
        if (this.anyAdditionalCurves)
        {
            for (int i = 0; i < this.additionalCurveCount; i++)
            {
                BobForceCurve bobForceCurve = this.cfg.additionalCurves[i];
                switch (bobForceCurve.source)
                {
                case BobForceCurveSource.LocalMovementMagnitude:
                {
                    num = this.groundLocalVelocityMag;
                    break;
                }

                case BobForceCurveSource.LocalMovementX:
                {
                    num = this.groundLocalVelocity.x;
                    break;
                }

                case BobForceCurveSource.LocalMovementY:
                {
                    num = this.groundLocalVelocity.y;
                    break;
                }

                case BobForceCurveSource.LocalMovementZ:
                {
                    num = this.groundLocalVelocity.z;
                    break;
                }

                case BobForceCurveSource.WorldMovementMagnitude:
                {
                    num = this.groundWorldVelocityMag;
                    break;
                }

                case BobForceCurveSource.WorldMovementX:
                {
                    num = this.groundWorldVelocity.x;
                    break;
                }

                case BobForceCurveSource.WorldMovementY:
                {
                    num = this.groundWorldVelocity.y;
                    break;
                }

                case BobForceCurveSource.WorldMovementZ:
                {
                    num = this.groundWorldVelocity.z;
                    break;
                }

                case BobForceCurveSource.LocalVelocityMagnitude:
                {
                    num = this.localVelocityMag;
                    break;
                }

                case BobForceCurveSource.LocalVelocityX:
                {
                    num = this.localVelocity.x;
                    break;
                }

                case BobForceCurveSource.LocalVelocityY:
                {
                    num = this.localVelocity.y;
                    break;
                }

                case BobForceCurveSource.LocalVelocityZ:
                {
                    num = this.localVelocity.z;
                    break;
                }

                case BobForceCurveSource.WorldVelocityMagnitude:
                {
                    num = this.worldVelocityMag;
                    break;
                }

                case BobForceCurveSource.WorldVelocityX:
                {
                    num = this.worldVelocity.x;
                    break;
                }

                case BobForceCurveSource.WorldVelocityY:
                {
                    num = this.worldVelocity.y;
                    break;
                }

                case BobForceCurveSource.WorldVelocityZ:
                {
                    num = this.worldVelocity.z;
                    break;
                }

                case BobForceCurveSource.RotationMagnitude:
                {
                    num = this.localAngularVelocityMag;
                    break;
                }

                case BobForceCurveSource.RotationPitch:
                {
                    num = this.localAngularVelocity.x;
                    break;
                }

                case BobForceCurveSource.RotationYaw:
                {
                    num = this.localAngularVelocity.y;
                    break;
                }

                case BobForceCurveSource.RotationRoll:
                {
                    num = this.localAngularVelocity.z;
                    break;
                }

                case BobForceCurveSource.TurnMagnitude:
                {
                    num = this.groundLocalAngularVelocityMag;
                    break;
                }

                case BobForceCurveSource.TurnPitch:
                {
                    num = this.groundLocalAngularVelocity.x;
                    break;
                }

                case BobForceCurveSource.TurnYaw:
                {
                    num = this.groundLocalAngularVelocity.y;
                    break;
                }

                case BobForceCurveSource.TurnRoll:
                {
                    num = this.groundLocalAngularVelocity.z;
                    break;
                }

                default:
                {
                    goto case BobForceCurveSource.LocalVelocityZ;
                }
                }
                BobForceCurveTarget bobForceCurveTarget = bobForceCurve.target;
                if (bobForceCurveTarget != BobForceCurveTarget.Position)
                {
                    if (bobForceCurveTarget != BobForceCurveTarget.Rotation)
                    {
                        goto Label3;
                    }
                    bobForceCurve.Calculate(ref weight.additionalPositions[i], ref num, ref dt, ref weight.rotation.fE);
                    goto Label1;
                }
Label3:
                bobForceCurve.Calculate(ref weight.additionalPositions[i], ref num, ref dt, ref weight.position.fE);
Label1:
            }
        }
        if (this.cfg.impulseForceSmooth <= 0f)
        {
            weight.position.fI = this.impulseForce.accel;
        }
        else
        {
            Vector3G.SmoothDamp(ref weight.position.fI, ref this.impulseForce.accel, ref weight.position.fIV, this.cfg.impulseForceSmooth, this.cfg.impulseForceMaxChangeAcceleration, ref dt);
        }
        if (this.cfg.angleImpulseForceSmooth <= 0f)
        {
            weight.rotation.fI = this.impulseTorque.accel;
        }
        else
        {
            Vector3G.SmoothDamp(ref weight.rotation.fI, ref this.impulseTorque.accel, ref weight.rotation.fIV, this.cfg.angleImpulseForceSmooth, this.cfg.angleImpulseForceMaxChangeAcceleration, ref dt);
        }
        weight.position.fE.x = weight.position.fE.x + (this.inputForce.x + weight.position.fI.x * (double)this.cfg.impulseForceScale.x);
        weight.position.fE.y = weight.position.fE.y + (this.inputForce.y + weight.position.fI.y * (double)this.cfg.impulseForceScale.y);
        weight.position.fE.z = weight.position.fE.z + (this.inputForce.z + weight.position.fI.z * (double)this.cfg.impulseForceScale.z);
        weight.rotation.fE.x = weight.rotation.fE.x + weight.rotation.fI.x * (double)this.cfg.angularImpulseForceScale.x;
        weight.rotation.fE.y = weight.rotation.fE.y + weight.rotation.fI.y * (double)this.cfg.angularImpulseForceScale.y;
        weight.rotation.fE.z = weight.rotation.fE.z + weight.rotation.fI.z * (double)this.cfg.angularImpulseForceScale.z;
        Vector3G vector3G5 = weight.position.@value;

        vector3G5.x = vector3G5.x / (double)this.cfg.elipsoidRadii.x;
        vector3G5.y = vector3G5.y / (double)this.cfg.elipsoidRadii.y;
        vector3G5.z = vector3G5.z / (double)this.cfg.elipsoidRadii.z;
        double num1 = vector3G5.x * vector3G5.x + vector3G5.y * vector3G5.y + vector3G5.z * vector3G5.z;

        if (num1 > 1)
        {
            num1        = 1 / Math.Sqrt(num1);
            vector3G5.x = vector3G5.x * num1;
            vector3G5.y = vector3G5.y * num1;
            vector3G5.z = vector3G5.z * num1;
        }
        vector3G5.x = vector3G5.x * (double)this.cfg.elipsoidRadii.x;
        vector3G5.y = vector3G5.y * (double)this.cfg.elipsoidRadii.y;
        vector3G5.z = vector3G5.z * (double)this.cfg.elipsoidRadii.z;
        weight.stack.Simulate(ref dt, ref weight.position.fE, ref weight.rotation.fE);
        weight.position.acceleration.x = weight.position.fE.x - vector3G1.x + (vector3G5.x * (double)(-this.cfg.springConstant.x) - weight.position.velocity.x * (double)this.cfg.springDampen.x) * (double)this.cfg.weightMass;
        weight.position.acceleration.y = weight.position.fE.y - vector3G1.y + (vector3G5.y * (double)(-this.cfg.springConstant.y) - weight.position.velocity.y * (double)this.cfg.springDampen.y) * (double)this.cfg.weightMass;
        weight.position.acceleration.z = weight.position.fE.z - vector3G1.z + (vector3G5.z * (double)(-this.cfg.springConstant.z) - weight.position.velocity.z * (double)this.cfg.springDampen.z) * (double)this.cfg.weightMass;
        weight.position.velocity.x     = weight.position.velocity.x + weight.position.acceleration.x * dt;
        weight.position.velocity.y     = weight.position.velocity.y + weight.position.acceleration.y * dt;
        weight.position.velocity.z     = weight.position.velocity.z + weight.position.acceleration.z * dt;
        if (float.IsInfinity(this.cfg.maxVelocity.x))
        {
            [email protected] = [email protected] + weight.position.velocity.x * dt;
        }
        else if (weight.position.velocity.x < (double)(-this.cfg.maxVelocity.x))
        {
            [email protected] = [email protected] - (double)this.cfg.maxVelocity.x * dt;
        }
        else if (weight.position.velocity.x <= (double)this.cfg.maxVelocity.x)
        {
            [email protected] = [email protected] + weight.position.velocity.x * dt;
        }
        else
        {
            [email protected] = [email protected] + (double)this.cfg.maxVelocity.x * dt;
        }
        if (float.IsInfinity(this.cfg.maxVelocity.y))
        {
            [email protected] = [email protected] + weight.position.velocity.y * dt;
        }
        else if (weight.position.velocity.y < (double)(-this.cfg.maxVelocity.y))
        {
            [email protected] = [email protected] - (double)this.cfg.maxVelocity.y * dt;
        }
        else if (weight.position.velocity.y <= (double)this.cfg.maxVelocity.y)
        {
            [email protected] = [email protected] + weight.position.velocity.y * dt;
        }
        else
        {
            [email protected] = [email protected] + (double)this.cfg.maxVelocity.y * dt;
        }
        if (float.IsInfinity(this.cfg.maxVelocity.z))
        {
            [email protected] = [email protected] + weight.position.velocity.z * dt;
        }
        else if (weight.position.velocity.z < (double)(-this.cfg.maxVelocity.z))
        {
            [email protected] = [email protected] - (double)this.cfg.maxVelocity.z * dt;
        }
        else if (weight.position.velocity.z <= (double)this.cfg.maxVelocity.z)
        {
            [email protected] = [email protected] + weight.position.velocity.z * dt;
        }
        else
        {
            [email protected] = [email protected] + (double)this.cfg.maxVelocity.z * dt;
        }
        weight.rotation.acceleration.x = weight.rotation.fE.x - vector3G2.x + ([email protected] * (double)(-this.cfg.angularSpringConstant.x) - weight.rotation.velocity.x * (double)this.cfg.angularSpringDampen.x) * (double)this.cfg.angularWeightMass;
        weight.rotation.acceleration.y = weight.rotation.fE.y - vector3G2.y + ([email protected] * (double)(-this.cfg.angularSpringConstant.y) - weight.rotation.velocity.y * (double)this.cfg.angularSpringDampen.y) * (double)this.cfg.angularWeightMass;
        weight.rotation.acceleration.z = weight.rotation.fE.z - vector3G2.z + ([email protected] * (double)(-this.cfg.angularSpringConstant.z) - weight.rotation.velocity.z * (double)this.cfg.angularSpringDampen.z) * (double)this.cfg.angularWeightMass;
        weight.rotation.velocity.x     = weight.rotation.velocity.x + weight.rotation.acceleration.x * dt;
        weight.rotation.velocity.y     = weight.rotation.velocity.y + weight.rotation.acceleration.y * dt;
        weight.rotation.velocity.z     = weight.rotation.velocity.z + weight.rotation.acceleration.z * dt;
        [email protected]       = [email protected] + weight.rotation.velocity.x * dt;
        [email protected]       = [email protected] + weight.rotation.velocity.y * dt;
        [email protected]       = [email protected] + weight.rotation.velocity.z * dt;
    }
Exemplo n.º 59
0
 public static Vector3G Rotate(QuaternionG rotation, Vector3G vector)
 {
     Vector3G vector3G;
     QuaternionG.Mult(ref rotation, ref vector, out vector3G);
     return vector3G;
 }
Exemplo n.º 60
0
 public void Calculate(ref Vector3G v, ref double pow, ref double dt, ref Vector3G sum)
 {
     if (!this.once)
     {
         this.Gasp();
     }
     if (this.calc)
     {
         Vector3G vectorg;
         float    num   = !this.mask ? 1f : this.sourceMask.Evaluate((float)pow);
         bool     flag  = (num == 0f) || (num == 0f);
         float    num2  = !this.scaleFixed ? (!this.scale ? 1f : this.sourceScale.Evaluate((float)pow)) : 0f;
         bool     flag2 = !this.scaleFixed && ((num2 != 0f) && (num2 != 0f));
         if (this.infoX.calc)
         {
             if (flag2 && !this.infoX.constant)
             {
                 v.x += ((pow * dt) * num2) * this.positionScale.x;
                 if (v.x > this.infoX.duration)
                 {
                     v.x -= this.infoX.duration;
                 }
                 else if (v.x < -this.infoX.duration)
                 {
                     v.x += this.infoX.duration;
                 }
             }
             vectorg.x = !flag ? ((double)(this.forceX.Evaluate((float)v.x) * this.outputScale.x)) : ((double)0f);
         }
         else
         {
             vectorg.x = 0.0;
         }
         if (this.infoY.calc)
         {
             if (flag2 && !this.infoY.constant)
             {
                 v.y += ((pow * dt) * num2) * this.positionScale.y;
                 if (v.y > this.infoY.duration)
                 {
                     v.y -= this.infoY.duration;
                 }
                 else if (v.y < -this.infoY.duration)
                 {
                     v.y += this.infoY.duration;
                 }
             }
             vectorg.y = !flag ? ((double)(this.forceY.Evaluate((float)v.y) * this.outputScale.y)) : ((double)0f);
         }
         else
         {
             vectorg.y = 0.0;
         }
         if (this.infoZ.calc)
         {
             if (flag2 && !this.infoZ.constant)
             {
                 v.z += ((pow * dt) * num2) * this.positionScale.z;
                 if (v.z > this.infoZ.duration)
                 {
                     v.z -= this.infoZ.duration;
                 }
                 else if (v.z < -this.infoZ.duration)
                 {
                     v.z += this.infoZ.duration;
                 }
             }
             vectorg.z = !flag ? ((double)(this.forceZ.Evaluate((float)v.z) * this.outputScale.z)) : ((double)0f);
         }
         else
         {
             vectorg.z = 0.0;
         }
         if (!flag)
         {
             sum.x += vectorg.x * num;
             sum.y += vectorg.y * num;
             sum.z += vectorg.z * num;
         }
     }
 }