Пример #1
0
    private void CalculateVelocity()
    {
        Vector3G  vector3G  = new Vector3G();
        double    num       = (double)Time.time - (double)this.lastVelocityCalc;
        Character character = base.idMain;
        Vector3   vector3   = (!character ? base.transform.position : character.origin);
        Vector3G  vector3G1 = new Vector3G(ref vector3);
        double    num1      = 1 / num;

        vector3G.x = num1 * (vector3G1.x - this.lastPosPrecise.x);
        vector3G.y = num1 * (vector3G1.y - this.lastPosPrecise.y);
        vector3G.z = num1 * (vector3G1.z - this.lastPosPrecise.z);
        Matrix4x4G matrix4x4G = new Matrix4x4G(base.transform.worldToLocalMatrix);

        Matrix4x4G.Mult3x3(ref vector3G, ref matrix4x4G, 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 >= (double)this.movement.configuration.minMoveSpeed)
        {
            double num2 = 1 / this.speedPrecise;
            this.movementNormalPrecise.x = (double)this.localVelocity.x * num2;
            this.movementNormalPrecise.y = (double)this.localVelocity.z * num2;
            double num3 = this.anglePrecise;
            this.anglePrecise = Math.Atan2(this.movementNormalPrecise.x, this.movementNormalPrecise.y) / 3.14159265358979 * 180;
            float single = this.movement.configuration.maxTurnSpeed;
            if (single > 0f && this.anglePrecise != num3 && this.lastAngleSpeedPrecise >= 0.05)
            {
                double num4 = (double)Time.deltaTime * (double)single;
                if (Precise.MoveTowardsAngle(ref num3, ref this.anglePrecise, ref num4, out this.anglePrecise))
                {
                    double num5 = this.anglePrecise / 180 * 3.14159265358979;
                    this.movementNormalPrecise.x = Math.Sin(num5);
                    this.movementNormalPrecise.y = Math.Cos(num5);
                }
            }
            this.lastAngleSpeedPrecise = this.speedPrecise;
        }
        else
        {
            this.speedPrecise            = 0;
            this.movementNormalPrecise.x = 0;
            this.movementNormalPrecise.y = 0;
            if (this.lastAngleSpeedPrecise > 0)
            {
                float single1 = this.movement.configuration.maxTimeBetweenTurns;
                float single2 = single1;
                if (single1 > 0f)
                {
                    PlayerAnimation playerAnimation = this;
                    playerAnimation.lastAngleSpeedPrecise = playerAnimation.lastAngleSpeedPrecise - (double)(Time.deltaTime / single2);
                }
            }
        }
        this.lastPosPrecise = vector3G1;
        this.lastPos        = vector3;
        this.movementNormal = this.movementNormalPrecise.f;
        this.speed          = (float)this.speedPrecise;
        this.angle          = (float)this.anglePrecise;
        this.localVelocity  = this.localVelocityPrecise.f;
    }
Пример #2
0
 // Token: 0x06002BC8 RID: 11208 RVA: 0x000A375C File Offset: 0x000A195C
 internal static void ApplyTransitionAlterations(Camera camera, global::CameraFX fx, bool useFX)
 {
     if (useFX)
     {
         int num = global::CameraFX.g_trans.Update(ref fx.worldToCameraMatrix, ref fx.projectionMatrix);
         if ((num & 1) == 1)
         {
             camera.worldToCameraMatrix = fx.worldToCameraMatrix.f;
             Matrix4x4G.Inverse(ref fx.worldToCameraMatrix, ref fx.cameraToWorldMatrix);
         }
         if ((num & 2) == 2)
         {
             camera.projectionMatrix = fx.projectionMatrix.f;
         }
     }
     else
     {
         Matrix4x4G matrix4x4G;
         Precise.ExtractCameraMatrixWorldToCamera(camera, ref matrix4x4G);
         Matrix4x4G matrix4x4G2;
         Precise.ExtractCameraMatrixProjection(camera, ref matrix4x4G2);
         int num2 = global::CameraFX.g_trans.Update(ref matrix4x4G, ref matrix4x4G2);
         if ((num2 & 1) == 1)
         {
             camera.ResetWorldToCameraMatrix();
             camera.worldToCameraMatrix = matrix4x4G.f;
         }
         if ((num2 & 2) == 2)
         {
             camera.ResetProjectionMatrix();
             camera.projectionMatrix = matrix4x4G2.f;
         }
     }
 }
    // Token: 0x06000420 RID: 1056 RVA: 0x00014844 File Offset: 0x00012A44
    private void CalculateVelocity()
    {
        double            num    = (double)Time.time - (double)this.lastVelocityCalc;
        global::Character idMain = base.idMain;
        Vector3           vector = (!idMain) ? base.transform.position : idMain.origin;
        Vector3G          vector3G;

        vector3G..ctor(ref vector);
        double   num2 = 1.0 / num;
        Vector3G vector3G2;

        vector3G2.x = num2 * (vector3G.x - this.lastPosPrecise.x);
        vector3G2.y = num2 * (vector3G.y - this.lastPosPrecise.y);
        vector3G2.z = num2 * (vector3G.z - this.lastPosPrecise.z);
        Matrix4x4G matrix4x4G;

        matrix4x4G..ctor(base.transform.worldToLocalMatrix);
        Matrix4x4G.Mult3x3(ref vector3G2, ref matrix4x4G, ref 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 < (double)this.movement.configuration.minMoveSpeed)
        {
            this.speedPrecise            = 0.0;
            this.movementNormalPrecise.x = 0.0;
            this.movementNormalPrecise.y = 0.0;
            float maxTimeBetweenTurns;
            if (this.lastAngleSpeedPrecise > 0.0 && (maxTimeBetweenTurns = this.movement.configuration.maxTimeBetweenTurns) > 0f)
            {
                this.lastAngleSpeedPrecise -= (double)(Time.deltaTime / maxTimeBetweenTurns);
            }
        }
        else
        {
            double num3 = 1.0 / this.speedPrecise;
            this.movementNormalPrecise.x = (double)this.localVelocity.x * num3;
            this.movementNormalPrecise.y = (double)this.localVelocity.z * num3;
            double num4 = 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 != num4 && this.lastAngleSpeedPrecise >= 0.05)
            {
                double num5 = (double)Time.deltaTime * (double)maxTurnSpeed;
                if (Precise.MoveTowardsAngle(ref num4, ref this.anglePrecise, ref num5, ref this.anglePrecise))
                {
                    double num6 = this.anglePrecise / 180.0 * 3.1415926535897931;
                    this.movementNormalPrecise.x = Math.Sin(num6);
                    this.movementNormalPrecise.y = Math.Cos(num6);
                }
            }
            this.lastAngleSpeedPrecise = this.speedPrecise;
        }
        this.lastPosPrecise = vector3G;
        this.lastPos        = vector;
        this.movementNormal = this.movementNormalPrecise.f;
        this.speed          = (float)this.speedPrecise;
        this.angle          = (float)this.anglePrecise;
        this.localVelocity  = this.localVelocityPrecise.f;
    }
Пример #4
0
    private void PushPosition()
    {
        VectorStamp stamp;
        VectorStamp stamp2;
        Vector3     eyesOrigin;
        Vector3     eulerAngles;
        Character   character;

        this.worldToLocal.f = this.otherParent.worldToLocalMatrix;
        this.localToWorld.f = this.otherParent.localToWorldMatrix;
        stamp.timeStamp     = Time.time;
        stamp.valid         = true;
        if ((this._motor != null) && ((character = this._motor.idMain as Character) != null))
        {
            eulerAngles = character.eyesAngles.eulerAngles;
            eyesOrigin  = character.eyesOrigin;
        }
        else
        {
            eulerAngles = this.otherParent.eulerAngles;
            eyesOrigin  = this.otherParent.position;
        }
        stamp.vector.x   = eyesOrigin.x;
        stamp.vector.y   = eyesOrigin.y;
        stamp.vector.z   = eyesOrigin.z;
        stamp2.vector.x  = eulerAngles.x;
        stamp2.vector.y  = eulerAngles.y;
        stamp2.vector.z  = eulerAngles.z;
        stamp2.timeStamp = Time.time;
        stamp2.valid     = true;
        if (this.lastPosition.valid && (this.lastPosition.timeStamp != stamp.timeStamp))
        {
            double num = 1.0 / ((double)(stamp.timeStamp - this.lastPosition.timeStamp));
            this.worldVelocity.x = (stamp.vector.x - this.lastPosition.vector.x) * num;
            this.worldVelocity.y = (stamp.vector.y - this.lastPosition.vector.y) * num;
            this.worldVelocity.z = (stamp.vector.z - this.lastPosition.vector.z) * num;
            Matrix4x4G.Mult3x3(ref this.worldVelocity, ref this.worldToLocal, out this.localVelocity);
        }
        this.impulseForce.Sample(ref this.localVelocity, stamp.timeStamp);
        this.lastPosition = stamp;
        if (this.lastRotation.valid && (this.lastRotation.timeStamp != stamp2.timeStamp))
        {
            double num2 = 1.0 / ((double)(stamp2.timeStamp - this.lastRotation.timeStamp));
            Precise.DeltaAngle(ref this.lastRotation.vector.x, ref stamp2.vector.x, out this.localAngularVelocity.x);
            Precise.DeltaAngle(ref this.lastRotation.vector.y, ref stamp2.vector.y, out this.localAngularVelocity.y);
            Precise.DeltaAngle(ref this.lastRotation.vector.z, ref stamp2.vector.z, out this.localAngularVelocity.z);
            this.localAngularVelocity.x *= num2;
            this.localAngularVelocity.y *= num2;
            this.localAngularVelocity.z *= num2;
        }
        this.impulseTorque.Sample(ref this.localAngularVelocity, stamp2.timeStamp);
        this.lastRotation            = stamp2;
        this.localVelocityMag        = Math.Sqrt(((this.localVelocity.x * this.localVelocity.x) + (this.localVelocity.y * this.localVelocity.y)) + (this.localVelocity.z * this.localVelocity.z));
        this.worldVelocityMag        = Math.Sqrt(((this.worldVelocity.x * this.worldVelocity.x) + (this.worldVelocity.y * this.worldVelocity.y)) + (this.worldVelocity.z * this.worldVelocity.z));
        this.localAngularVelocityMag = Math.Sqrt(((this.localAngularVelocity.x * this.localAngularVelocity.x) + (this.localAngularVelocity.y * this.localAngularVelocity.y)) + (this.localAngularVelocity.z * this.localAngularVelocity.z));
    }
Пример #5
0
    // Token: 0x06002E35 RID: 11829 RVA: 0x000B02B8 File Offset: 0x000AE4B8
    private void PushPosition()
    {
        this.worldToLocal.f = this.otherParent.worldToLocalMatrix;
        this.localToWorld.f = this.otherParent.localToWorldMatrix;
        global::HeadBob.VectorStamp vectorStamp;
        vectorStamp.timeStamp = Time.time;
        vectorStamp.valid     = true;
        global::Character character;
        Vector3           eulerAngles;
        Vector3           vector;

        if (this._motor && (character = (this._motor.idMain as global::Character)))
        {
            eulerAngles = character.eyesAngles.eulerAngles;
            vector      = character.eyesOrigin;
        }
        else
        {
            eulerAngles = this.otherParent.eulerAngles;
            vector      = this.otherParent.position;
        }
        vectorStamp.vector.x = (double)vector.x;
        vectorStamp.vector.y = (double)vector.y;
        vectorStamp.vector.z = (double)vector.z;
        global::HeadBob.VectorStamp vectorStamp2;
        vectorStamp2.vector.x  = (double)eulerAngles.x;
        vectorStamp2.vector.y  = (double)eulerAngles.y;
        vectorStamp2.vector.z  = (double)eulerAngles.z;
        vectorStamp2.timeStamp = Time.time;
        vectorStamp2.valid     = true;
        if (this.lastPosition.valid && this.lastPosition.timeStamp != vectorStamp.timeStamp)
        {
            double num = 1.0 / (double)(vectorStamp.timeStamp - this.lastPosition.timeStamp);
            this.worldVelocity.x = (vectorStamp.vector.x - this.lastPosition.vector.x) * num;
            this.worldVelocity.y = (vectorStamp.vector.y - this.lastPosition.vector.y) * num;
            this.worldVelocity.z = (vectorStamp.vector.z - this.lastPosition.vector.z) * num;
            Matrix4x4G.Mult3x3(ref this.worldVelocity, ref this.worldToLocal, ref this.localVelocity);
        }
        this.impulseForce.Sample(ref this.localVelocity, vectorStamp.timeStamp);
        this.lastPosition = vectorStamp;
        if (this.lastRotation.valid && this.lastRotation.timeStamp != vectorStamp2.timeStamp)
        {
            double num2 = 1.0 / (double)(vectorStamp2.timeStamp - this.lastRotation.timeStamp);
            Precise.DeltaAngle(ref this.lastRotation.vector.x, ref vectorStamp2.vector.x, ref this.localAngularVelocity.x);
            Precise.DeltaAngle(ref this.lastRotation.vector.y, ref vectorStamp2.vector.y, ref this.localAngularVelocity.y);
            Precise.DeltaAngle(ref this.lastRotation.vector.z, ref vectorStamp2.vector.z, ref this.localAngularVelocity.z);
            this.localAngularVelocity.x = this.localAngularVelocity.x * num2;
            this.localAngularVelocity.y = this.localAngularVelocity.y * num2;
            this.localAngularVelocity.z = this.localAngularVelocity.z * num2;
        }
        this.impulseTorque.Sample(ref this.localAngularVelocity, vectorStamp2.timeStamp);
        this.lastRotation            = vectorStamp2;
        this.localVelocityMag        = Math.Sqrt(this.localVelocity.x * this.localVelocity.x + this.localVelocity.y * this.localVelocity.y + this.localVelocity.z * this.localVelocity.z);
        this.worldVelocityMag        = Math.Sqrt(this.worldVelocity.x * this.worldVelocity.x + this.worldVelocity.y * this.worldVelocity.y + this.worldVelocity.z * this.worldVelocity.z);
        this.localAngularVelocityMag = Math.Sqrt(this.localAngularVelocity.x * this.localAngularVelocity.x + this.localAngularVelocity.y * this.localAngularVelocity.y + this.localAngularVelocity.z * this.localAngularVelocity.z);
    }
Пример #6
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;
    }
Пример #7
0
    // Token: 0x06003DFB RID: 15867 RVA: 0x000E059C File Offset: 0x000DE79C
    private void OnDrawGizmos()
    {
        Matrix4x4G matrix4x4G;

        Precise.ExtractLocalToWorld(base.transform, ref matrix4x4G);
        Matrix4x4 localToWorldMatrix = base.transform.localToWorldMatrix;
        Vector3   vector             = localToWorldMatrix.MultiplyPoint(Vector3.zero);
        Vector3   vector2            = localToWorldMatrix.MultiplyPoint(Vector3.forward);
        Vector3   vector3            = localToWorldMatrix.MultiplyPoint(Vector3.up);
        Vector3   vector4            = localToWorldMatrix.MultiplyPoint(Vector3.right);
        Vector3G  vector3G;

        vector3G.x = 1.0;
        vector3G.y = 0.0;
        vector3G.z = 0.0;
        Vector3G vector3G2;

        Matrix4x4G.Mult(ref vector3G, ref matrix4x4G, ref vector3G2);
        vector3G.x = 0.0;
        vector3G.y = 1.0;
        vector3G.z = 0.0;
        Vector3G vector3G3;

        Matrix4x4G.Mult(ref vector3G, ref matrix4x4G, ref vector3G3);
        vector3G.x = 0.0;
        vector3G.y = 0.0;
        vector3G.z = 1.0;
        Vector3G vector3G4;

        Matrix4x4G.Mult(ref vector3G, ref matrix4x4G, ref vector3G4);
        vector3G.x = 0.0;
        vector3G.y = 0.0;
        vector3G.z = 0.0;
        Vector3G vector3G5;

        Matrix4x4G.Mult(ref vector3G, ref matrix4x4G, ref vector3G5);
        Gizmos.color = Color.red * new Color(1f, 1f, 1f, 0.5f);
        Gizmos.DrawLine(vector, vector4);
        Gizmos.color = Color.green * new Color(1f, 1f, 1f, 0.5f);
        Gizmos.DrawLine(vector, vector3);
        Gizmos.color = Color.blue * new Color(1f, 1f, 1f, 0.5f);
        Gizmos.DrawLine(vector, vector2);
        Gizmos.color = Color.red * new Color(1f, 1f, 1f, 1f);
        Gizmos.DrawLine(vector3G5.f, vector3G2.f);
        Gizmos.color = Color.green * new Color(1f, 1f, 1f, 1f);
        Gizmos.DrawLine(vector3G5.f, vector3G3.f);
        Gizmos.color = Color.blue * new Color(1f, 1f, 1f, 1f);
        Gizmos.DrawLine(vector3G5.f, vector3G4.f);
    }
Пример #8
0
                public Monitor(ushort min, ushort max, List <PreciseEditorData> peaks, ushort startDelay, ushort stepDelay, ushort exposition, ushort forwardDelay, ushort backwardDelay, Action <ushort, PreciseEditorData> graphUpdater, Action <long[][], List <PreciseEditorData>, short?> successfulExit, int iterations, int timeLimit, PreciseEditorData checkerPeak, short?initialShift, ushort allowedShift)
                    : base((s, e) => {
                    var ee = (SuccessfulExitEventArgs)e;
                    successfulExit(ee.Counts, ee.Points, ee.Shift);
                }) {
                    // TODO: checker peak received by index, after sort found by equality again
                    cycle = new Precise(min, max, peaks, startDelay, stepDelay, exposition, forwardDelay, backwardDelay, graphUpdater, (ps, peds, shift) => OnSuccessfulExit(new SuccessfulExitEventArgs(ps, peds, shift)), initialShift, CheckShift);
                    cycle.VoltageStepChangeRequested += Cycle_VoltageStepRequested;
                    cycle.Finalize += Cycle_Finalize;
                    cycle.Disable  += cycle_Disable;

                    this.allowedShift = allowedShift;
                    stopper           = new MeasureStopper(iterations, timeLimit);
                    // redundant data
                    if (initialShift.HasValue && checkerPeak != null)
                    {
                        // TODO: move up to Commander. only index here
                        peak         = checkerPeak;
                        checkerIndex = peaks.FindIndex(peak.Equals);
                    }
                }
Пример #9
0
    private void PushPosition()
    {
        HeadBob.VectorStamp vectorStamp  = new HeadBob.VectorStamp();
        HeadBob.VectorStamp vectorStamp1 = new HeadBob.VectorStamp();
        Vector3             vector3;
        Vector3             vector31;

        this.worldToLocal.f   = this.otherParent.worldToLocalMatrix;
        this.localToWorld.f   = this.otherParent.localToWorldMatrix;
        vectorStamp.timeStamp = Time.time;
        vectorStamp.valid     = true;
        if (this._motor)
        {
            Character character  = this._motor.idMain as Character;
            Character character1 = character;
            if (!character)
            {
                goto Label1;
            }
            vector31 = character1.eyesAngles.eulerAngles;
            vector3  = character1.eyesOrigin;
            goto Label0;
        }
Label1:
        vector31 = this.otherParent.eulerAngles;
        vector3  = this.otherParent.position;
Label0:
        vectorStamp.vector.x   = (double)vector3.x;
        vectorStamp.vector.y   = (double)vector3.y;
        vectorStamp.vector.z   = (double)vector3.z;
        vectorStamp1.vector.x  = (double)vector31.x;
        vectorStamp1.vector.y  = (double)vector31.y;
        vectorStamp1.vector.z  = (double)vector31.z;
        vectorStamp1.timeStamp = Time.time;
        vectorStamp1.valid     = true;
        if (this.lastPosition.valid && this.lastPosition.timeStamp != vectorStamp.timeStamp)
        {
            double num = 1 / (double)(vectorStamp.timeStamp - this.lastPosition.timeStamp);
            this.worldVelocity.x = (vectorStamp.vector.x - this.lastPosition.vector.x) * num;
            this.worldVelocity.y = (vectorStamp.vector.y - this.lastPosition.vector.y) * num;
            this.worldVelocity.z = (vectorStamp.vector.z - this.lastPosition.vector.z) * num;
            Matrix4x4G.Mult3x3(ref this.worldVelocity, ref this.worldToLocal, out this.localVelocity);
        }
        this.impulseForce.Sample(ref this.localVelocity, vectorStamp.timeStamp);
        this.lastPosition = vectorStamp;
        if (this.lastRotation.valid && this.lastRotation.timeStamp != vectorStamp1.timeStamp)
        {
            double num1 = 1 / (double)(vectorStamp1.timeStamp - this.lastRotation.timeStamp);
            Precise.DeltaAngle(ref this.lastRotation.vector.x, ref vectorStamp1.vector.x, out this.localAngularVelocity.x);
            Precise.DeltaAngle(ref this.lastRotation.vector.y, ref vectorStamp1.vector.y, out this.localAngularVelocity.y);
            Precise.DeltaAngle(ref this.lastRotation.vector.z, ref vectorStamp1.vector.z, out this.localAngularVelocity.z);
            this.localAngularVelocity.x = this.localAngularVelocity.x * num1;
            this.localAngularVelocity.y = this.localAngularVelocity.y * num1;
            this.localAngularVelocity.z = this.localAngularVelocity.z * num1;
        }
        this.impulseTorque.Sample(ref this.localAngularVelocity, vectorStamp1.timeStamp);
        this.lastRotation            = vectorStamp1;
        this.localVelocityMag        = Math.Sqrt(this.localVelocity.x * this.localVelocity.x + this.localVelocity.y * this.localVelocity.y + this.localVelocity.z * this.localVelocity.z);
        this.worldVelocityMag        = Math.Sqrt(this.worldVelocity.x * this.worldVelocity.x + this.worldVelocity.y * this.worldVelocity.y + this.worldVelocity.z * this.worldVelocity.z);
        this.localAngularVelocityMag = Math.Sqrt(this.localAngularVelocity.x * this.localAngularVelocity.x + this.localAngularVelocity.y * this.localAngularVelocity.y + this.localAngularVelocity.z * this.localAngularVelocity.z);
    }
Пример #10
0
                public Monitor(ushort min, ushort max, List<PreciseEditorData> peaks, ushort startDelay, ushort stepDelay, ushort exposition, ushort forwardDelay, ushort backwardDelay, Action<ushort, PreciseEditorData> graphUpdater, Action<long[][], List<PreciseEditorData>, short?> successfulExit, int iterations, int timeLimit, PreciseEditorData checkerPeak, short? initialShift, ushort allowedShift)
                    : base((s, e) => {
                        var ee = (SuccessfulExitEventArgs)e;
                        successfulExit(ee.Counts, ee.Points, ee.Shift);
                    })
                {
                    // TODO: checker peak received by index, after sort found by equality again
                    cycle = new Precise(min, max, peaks, startDelay, stepDelay, exposition, forwardDelay, backwardDelay, graphUpdater, (ps, peds, shift) => OnSuccessfulExit(new SuccessfulExitEventArgs(ps, peds, shift)), initialShift, CheckShift);
                    cycle.VoltageStepChangeRequested += Cycle_VoltageStepRequested;
                    cycle.Finalize += Cycle_Finalize;
                    cycle.Disable += cycle_Disable;

                    this.allowedShift = allowedShift;
                    stopper = new MeasureStopper(iterations, timeLimit);
                    // redundant data
                    if (initialShift.HasValue && checkerPeak != null) {
                        // TODO: move up to Commander. only index here
                        peak = checkerPeak;
                        checkerIndex = peaks.FindIndex(peak.Equals);
                    }
                }
Пример #11
0
    // Token: 0x06002BC7 RID: 11207 RVA: 0x000A2E68 File Offset: 0x000A1068
    public void PostPreCull()
    {
        if (global::CameraFX.viewModelRootTransform)
        {
            Quaternion localRotation = base.transform.localRotation;
            Vector3    localPosition = base.transform.localPosition;
            if (this.viewModel)
            {
                this.viewModel.ModifyAiming(new Ray(base.transform.parent.position, base.transform.parent.forward), ref localPosition, ref localRotation);
            }
            global::CameraFX.viewModelRootTransform.localRotation = Quaternion.Inverse(localRotation);
            global::CameraFX.viewModelRootTransform.localPosition = -localPosition;
        }
        Precise.ExtractLocalToWorldToLocal(this.camera.transform, ref this.localToWorldMatrix, ref this.worldToLocalMatrix);
        if (this.adaptiveNearPlane)
        {
            int      num      = (this.camera.cullingMask & ~this.adaptiveNearPlane.ignoreLayers.value) | this.adaptiveNearPlane.forceLayers.value;
            Vector3G vector3G = default(Vector3G);
            Vector3G vector3G2;
            this.localToWorldMatrix.MultiplyPoint(ref vector3G, ref vector3G2);
            Collider[] array   = Physics.OverlapSphere(vector3G2.f, this.adaptiveNearPlane.minNear + this.adaptiveNearPlane.maxNear, num);
            float      num2    = float.PositiveInfinity;
            double     num3    = (double)this.camera.fieldOfView;
            double     num4    = (double)this.camera.aspect;
            double     num5    = (double)this.adaptiveNearPlane.minNear;
            double     num6    = (double)(this.adaptiveNearPlane.maxNear + this.adaptiveNearPlane.threshold);
            float      minNear = this.adaptiveNearPlane.minNear;
            float      num7    = this.adaptiveNearPlane.maxNear + this.adaptiveNearPlane.threshold - minNear;
            Matrix4x4G matrix4x4G;
            Matrix4x4G.Perspective(ref num3, ref num4, ref num5, ref num6, ref matrix4x4G);
            Matrix4x4G matrix4x4G2;
            Matrix4x4G.Inverse(ref matrix4x4G, ref matrix4x4G2);
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    Vector3G vector3G3;
                    vector3G3.x = ((double)i - 3.5) / 3.5;
                    vector3G3.y = ((double)j - 3.5) / 3.5;
                    vector3G3.z = 0.0;
                    Vector3G vector3G4;
                    matrix4x4G2.MultiplyPoint(ref vector3G3, ref vector3G4);
                    vector3G3.z = 1.0;
                    Vector3G vector3G5;
                    matrix4x4G2.MultiplyPoint(ref vector3G3, ref vector3G5);
                    vector3G4.x = -vector3G4.x;
                    vector3G4.y = -vector3G4.y;
                    vector3G4.z = -vector3G4.z;
                    vector3G5.x = -vector3G5.x;
                    vector3G5.y = -vector3G5.y;
                    vector3G5.z = -vector3G5.z;
                    Vector3G vector3G6;
                    this.localToWorldMatrix.MultiplyPoint(ref vector3G4, ref vector3G6);
                    Vector3G vector3G7;
                    this.localToWorldMatrix.MultiplyPoint(ref vector3G5, ref vector3G7);
                    Vector3G vector3G8;
                    vector3G8.x = vector3G7.x - vector3G6.x;
                    vector3G8.y = vector3G7.y - vector3G6.y;
                    vector3G8.z = vector3G7.z - vector3G6.z;
                    float num8 = (float)Math.Sqrt(vector3G8.x * vector3G8.x + vector3G8.y * vector3G8.y + vector3G8.z * vector3G8.z);
                    float num9 = num8;
                    Ray   ray;
                    ray..ctor(vector3G6.f, vector3G8.f);
                    foreach (Collider collider in array)
                    {
                        RaycastHit raycastHit;
                        if (collider.Raycast(ray, ref raycastHit, num9))
                        {
                            float distance = raycastHit.distance;
                            if (distance < num9)
                            {
                                num9 = distance;
                                float num10 = minNear + distance / num8 * num7;
                                if (num2 > num10)
                                {
                                    num2 = num10;
                                }
                            }
                        }
                    }
                }
            }
            if (float.IsInfinity(num2))
            {
                this.camera.nearClipPlane = this.adaptiveNearPlane.maxNear;
            }
            else
            {
                num2 -= this.adaptiveNearPlane.threshold;
                if (num2 >= this.adaptiveNearPlane.maxNear)
                {
                    this.camera.nearClipPlane = this.adaptiveNearPlane.maxNear;
                }
                else if (num2 <= this.adaptiveNearPlane.minNear)
                {
                    this.camera.nearClipPlane = this.adaptiveNearPlane.minNear;
                }
                else
                {
                    this.camera.nearClipPlane = num2;
                }
            }
        }
        global::PerspectiveMatrixBuilder perspectiveMatrixBuilder;

        perspectiveMatrixBuilder.fieldOfView = (double)this.camera.fieldOfView;
        perspectiveMatrixBuilder.aspectRatio = (double)this.camera.aspect;
        perspectiveMatrixBuilder.nearPlane   = (double)this.camera.nearClipPlane;
        perspectiveMatrixBuilder.farPlane    = (double)this.camera.farClipPlane;
        global::PerspectiveMatrixBuilder perspectiveMatrixBuilder2 = perspectiveMatrixBuilder;
        Matrix4x4G matrix4x4G3;

        if (this.camera.isOrthoGraphic)
        {
            this.projectionMatrix.f = this.camera.projectionMatrix;
            matrix4x4G3             = this.projectionMatrix;
        }
        else
        {
            if (this.viewModel)
            {
                this.viewModel.ModifyPerspective(ref perspectiveMatrixBuilder2);
            }
            if (global::CameraFX.vm_projuse)
            {
                perspectiveMatrixBuilder2.ToProjectionMatrix(out this.projectionMatrix);
            }
            else
            {
                perspectiveMatrixBuilder.ToProjectionMatrix(out this.projectionMatrix);
            }
            this.camera.projectionMatrix = this.projectionMatrix.f;
            perspectiveMatrixBuilder2.ToProjectionMatrix(out matrix4x4G3);
        }
        Vector4 vector;

        vector.y = (float)perspectiveMatrixBuilder2.nearPlane;
        vector.z = (float)perspectiveMatrixBuilder2.farPlane;
        vector.w = (float)(1.0 / perspectiveMatrixBuilder2.farPlane);
        if (global::CameraFX.vm_flip == global::CameraFX.PLATFORM_POLL.flipRequired)
        {
            vector.x = 1f;
            Shader.SetGlobalMatrix("V_MUNITY_MATRIX_P", matrix4x4G3.f);
        }
        else
        {
            vector.x = -1f;
            global::PerspectiveMatrixBuilder perspectiveMatrixBuilder3;
            perspectiveMatrixBuilder3.nearPlane   = perspectiveMatrixBuilder2.nearPlane;
            perspectiveMatrixBuilder3.farPlane    = perspectiveMatrixBuilder2.farPlane;
            perspectiveMatrixBuilder3.fieldOfView = -perspectiveMatrixBuilder2.fieldOfView;
            perspectiveMatrixBuilder3.aspectRatio = -perspectiveMatrixBuilder2.aspectRatio;
            Matrix4x4G matrix4x4G4;
            perspectiveMatrixBuilder3.ToProjectionMatrix(out matrix4x4G4);
            Shader.SetGlobalMatrix("V_MUNITY_MATRIX_P", matrix4x4G4.f);
        }
        Shader.SetGlobalVector("V_M_ProjectionParams", vector);
        if (this.recalcViewMatrix)
        {
            Vector3G    vector3G9;
            QuaternionG quaternionG;
            Vector3G    vector3G10;
            Precise.ExtractWorldCoordinates(this.camera.transform, ref vector3G9, ref quaternionG, ref vector3G10);
            vector3G10.x = 1.0;
            vector3G10.y = 1.0;
            vector3G10.z = -1.0;
            Matrix4x4G.TRS(ref vector3G9, ref quaternionG, ref vector3G10, ref this.cameraToWorldMatrix);
            if (Matrix4x4G.Inverse(ref this.cameraToWorldMatrix, ref this.worldToCameraMatrix))
            {
                this.camera.worldToCameraMatrix = this.worldToCameraMatrix.f;
            }
        }
        else
        {
            this.cameraToWorldMatrix.f = this.camera.cameraToWorldMatrix;
            this.worldToCameraMatrix.f = this.camera.worldToCameraMatrix;
        }
        this.worldToCameraMatrixUnAltered = this.worldToCameraMatrix;
        this.cameraToWorldMatrixUnAltered = this.cameraToWorldMatrix;
        this.projectionMatrixUnAltered    = this.projectionMatrix;
        global::CameraFX.ApplyTransitionAlterations(this.camera, this, true);
        this.projectScreen.modelview  = (this.projectViewport.modelview = this.worldToCameraMatrix);
        this.projectScreen.projection = (this.projectViewport.projection = this.projectionMatrix);
        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 matrix4x4G5;

        Matrix4x4G.Mult(ref this.localToWorldMatrix, ref this.worldToCameraMatrix, ref matrix4x4G5);
        Matrix4x4G matrix4x4G6;

        Matrix4x4G.Mult(ref matrix4x4G5, ref this.projectionMatrix, ref matrix4x4G6);
        Matrix4x4G matrix4x4G7;

        Matrix4x4G.Inverse(ref matrix4x4G5, ref matrix4x4G7);
        Matrix4x4G matrix4x4G8;

        Matrix4x4G.Inverse(ref matrix4x4G6, ref matrix4x4G8);
        Matrix4x4G matrix4x4G9;

        Matrix4x4G.Inverse(ref this.localToWorldMatrix, ref matrix4x4G9);
        Matrix4x4G matrix4x4G10;

        Matrix4x4G.Transpose(ref matrix4x4G8, ref matrix4x4G10);
        Matrix4x4G matrix4x4G11;

        Matrix4x4G.Transpose(ref matrix4x4G7, ref matrix4x4G11);
        Matrix4x4G matrix4x4G12;

        Matrix4x4G.Transpose(ref matrix4x4G9, ref matrix4x4G12);
        if (this.viewModel)
        {
            this.viewModel.UpdateProxies();
        }
        global::BoundHack.Achieve(base.transform.position);
        global::ContextSprite.UpdateSpriteFading(this.camera);
        global::PlayerClient localPlayerClient = global::PlayerClient.localPlayerClient;

        if (localPlayerClient)
        {
            localPlayerClient.ProcessLocalPlayerPreRender();
        }
        global::RPOS.BeforeSceneRender_Internal(this.camera);
    }