예제 #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 VectorAccelSampler();
        this.impulseTorque       = new VectorAccelSampler();
        this.lastPosition        = new VectorStamp();
        this.otherParent         = parent;
        this.raw_pos             = new Vector3G();
        this.raw_rot             = new Vector3G();
        BobEffectStack stack = this.predicted.stack;

        this.predicted       = new Weight();
        this.predicted.stack = stack;
        stack              = this.working.stack;
        this.working       = new Weight();
        this.working.stack = stack;
        return(true);
    }
예제 #2
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));
    }