示例#1
0
    private bool CheckChanges(bool hasMotor, Transform parent)
    {
        if (this.hadMotor == hasMotor && !(this.otherParent != parent))
        {
            return(false);
        }
        this.hadMotor            = hasMotor;
        this.groundLocalVelocity = new Vector3G();
        this.groundWorldVelocity = new Vector3G();
        this.localVelocity       = new Vector3G();
        this.worldVelocity       = new Vector3G();
        this.impulseForce        = new HeadBob.VectorAccelSampler();
        this.impulseTorque       = new HeadBob.VectorAccelSampler();
        this.lastPosition        = new HeadBob.VectorStamp();
        this.otherParent         = parent;
        this.raw_pos             = new Vector3G();
        this.raw_rot             = new Vector3G();
        BobEffectStack bobEffectStack = this.predicted.stack;

        this.predicted = new HeadBob.Weight()
        {
            stack = bobEffectStack
        };
        bobEffectStack = this.working.stack;
        this.working   = new HeadBob.Weight()
        {
            stack = bobEffectStack
        };
        return(true);
    }
示例#2
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 difference  = new Vector3G();
            double   introduced3 = this.sample0.AddDifference(ref this.sample1, ref difference);
            double   num         = introduced3 + this.sample0.AddDifference(ref this.sample2, ref difference);

            if (num != 0.0)
            {
                num          = 1.0 / num;
                this.accel.x = difference.x * num;
                this.accel.y = difference.y * num;
                this.accel.z = difference.z * num;
            }
        }
示例#3
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);
 }
示例#4
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);
        }
示例#5
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;
            }
        }
示例#6
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);
    }
示例#7
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);
 }
示例#8
0
 private bool CheckChanges(bool hasMotor, Transform parent)
 {
     if (this.hadMotor == hasMotor && !(this.otherParent != parent))
     {
         return false;
     }
     this.hadMotor = hasMotor;
     this.groundLocalVelocity = new Vector3G();
     this.groundWorldVelocity = new Vector3G();
     this.localVelocity = new Vector3G();
     this.worldVelocity = new Vector3G();
     this.impulseForce = new HeadBob.VectorAccelSampler();
     this.impulseTorque = new HeadBob.VectorAccelSampler();
     this.lastPosition = new HeadBob.VectorStamp();
     this.otherParent = parent;
     this.raw_pos = new Vector3G();
     this.raw_rot = new Vector3G();
     BobEffectStack bobEffectStack = this.predicted.stack;
     this.predicted = new HeadBob.Weight()
     {
         stack = bobEffectStack
     };
     bobEffectStack = this.working.stack;
     this.working = new HeadBob.Weight()
     {
         stack = bobEffectStack
     };
     return true;
 }
示例#9
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;
     }
 }