Exemplo n.º 1
0
    private Matrix4x4 Interp(float t, Matrix4x4 a, Matrix4x4 b)
    {
        Matrix4x4 matrixx;

        switch (this.mode)
        {
        case SlerpMode.TransformLerp:
        case SlerpMode.WorldToCameraLerp:
        case SlerpMode.CameraToWorldLerp:
            matrixx = TransitionFunctions.Linear(t, a, b);
            break;

        case SlerpMode.WorldToCameraSlerp2:
            matrixx = TransitionFunctions.SlerpWorldToCamera(t, a, b);
            break;

        default:
            matrixx = TransitionFunctions.Slerp(t, a, b);
            break;
        }
        if (this.inverse0)
        {
            if (this.transpose)
            {
                if (!this.inverse1)
                {
                    return(matrixx.inverse.transpose);
                }
                return(matrixx.inverse.transpose.inverse);
            }
            if (this.inverse1)
            {
                return(matrixx.inverse.inverse);
            }
            return(matrixx.inverse);
        }
        if (this.transpose)
        {
            if (this.inverse1)
            {
                return(matrixx.transpose.inverse);
            }
            return(matrixx.transpose);
        }
        if (this.inverse1)
        {
            return(matrixx.inverse);
        }
        return(matrixx);
    }
Exemplo n.º 2
0
        public int Update(ref Matrix4x4G currentView, ref Matrix4x4G currentProj)
        {
            int num;

            try
            {
                float single = CameraFX.CameraTransitionData.timeSource;
                if (this.end > single)
                {
                    float single1 = Mathf.InverseLerp(this.start, this.end, single);
                    if (single1 < 1f)
                    {
                        single1 = this.func.Evaluate(single1);
                        Matrix4x4G camera     = TransitionFunctions.SlerpWorldToCamera((double)single1, this.view, currentView);
                        Matrix4x4G matrix4x4G = TransitionFunctions.Linear((double)single1, this.proj, currentProj);
                        this.lastTime = single;
                        if (!Matrix4x4G.Equals(ref camera, ref currentView))
                        {
                            currentView = camera;
                            if (Matrix4x4G.Equals(ref matrix4x4G, ref currentProj))
                            {
                                num = 1;
                                return(num);
                            }
                            else
                            {
                                currentProj = matrix4x4G;
                                num         = 3;
                                return(num);
                            }
                        }
                        else if (!Matrix4x4G.Equals(ref matrix4x4G, ref currentProj))
                        {
                            currentProj = matrix4x4G;
                            num         = 2;
                            return(num);
                        }
                    }
                }
                num = 0;
            }
            finally
            {
                this.lastView = currentView;
                this.lastProj = currentProj;
            }
            return(num);
        }
Exemplo n.º 3
0
        public int Update(ref Matrix4x4G currentView, ref Matrix4x4G currentProj)
        {
            int num3;

            try
            {
                float timeSource = CameraFX.CameraTransitionData.timeSource;
                if (this.end > timeSource)
                {
                    float t = Mathf.InverseLerp(this.start, this.end, timeSource);
                    if (t < 1f)
                    {
                        t = this.func.Evaluate(t);
                        Matrix4x4G a         = TransitionFunctions.SlerpWorldToCamera((double)t, this.view, currentView);
                        Matrix4x4G matrixxg2 = TransitionFunctions.Linear((double)t, this.proj, currentProj);
                        this.lastTime = timeSource;
                        if (!Matrix4x4G.Equals(ref a, ref currentView))
                        {
                            currentView = a;
                            if (!Matrix4x4G.Equals(ref matrixxg2, ref currentProj))
                            {
                                currentProj = matrixxg2;
                                return(3);
                            }
                            return(1);
                        }
                        if (!Matrix4x4G.Equals(ref matrixxg2, ref currentProj))
                        {
                            currentProj = matrixxg2;
                            return(2);
                        }
                    }
                }
                num3 = 0;
            }
            finally
            {
                this.lastView = currentView;
                this.lastProj = currentProj;
            }
            return(num3);
        }
Exemplo n.º 4
0
 // Transition을 추가해주는 함수
 public void AddTransition(Tuple <string, string> delta, string chagedState)
 {
     TransitionFunctions.Add(delta, chagedState);
 }
Exemplo n.º 5
0
    private Matrix4x4 Interp(float t, Matrix4x4 a, Matrix4x4 b)
    {
        Matrix4x4 camera;

        switch (this.mode)
        {
        case TransformLerpTest.SlerpMode.TransformSlerp:
        case TransformLerpTest.SlerpMode.WorldToCameraSlerp:
        case TransformLerpTest.SlerpMode.CameraToWorldSlerp:
        {
            camera = TransitionFunctions.Slerp(t, a, b);
            break;
        }

        case TransformLerpTest.SlerpMode.TransformLerp:
        case TransformLerpTest.SlerpMode.WorldToCameraLerp:
        case TransformLerpTest.SlerpMode.CameraToWorldLerp:
        {
            camera = TransitionFunctions.Linear(t, a, b);
            break;
        }

        case TransformLerpTest.SlerpMode.WorldToCameraSlerp2:
        {
            camera = TransitionFunctions.SlerpWorldToCamera(t, a, b);
            break;
        }

        default:
        {
            goto case TransformLerpTest.SlerpMode.CameraToWorldSlerp;
        }
        }
        if (!this.inverse0)
        {
            if (!this.transpose)
            {
                if (!this.inverse1)
                {
                    return(camera);
                }
                return(camera.inverse);
            }
            if (!this.inverse1)
            {
                return(camera.transpose);
            }
            return(camera.transpose.inverse);
        }
        if (!this.transpose)
        {
            if (!this.inverse1)
            {
                return(camera.inverse);
            }
            return(camera.inverse.inverse);
        }
        if (!this.inverse1)
        {
            return(camera.inverse.transpose);
        }
        return(camera.inverse.transpose.inverse);
    }
Exemplo n.º 6
0
    protected sealed override bool Continue()
    {
        Vector4 vector;
        Vector4 vector2;
        float   x;

        if (this.duration <= 0.0)
        {
            return(false);
        }
        double num = HUDIndicator.stepTime - this.damageTime;

        if (num > this.duration)
        {
            return(false);
        }
        this.propBlock.Clear();
        double num2 = num / this.duration;
        double t    = num2 * this.speedModX;
        double num4 = num2 * this.speedModY;
        double num5 = num2 * this.speedModZ;

        if (t > 1.0)
        {
            t = 1.0 - (t - 1.0);
        }
        if (num4 > 1.0)
        {
            num4 = 1.0 - (num4 - 1.0);
        }
        if (num5 > 1.0)
        {
            num5 = 1.0 - (num5 - 1.0);
        }
        double num6 = TransitionFunctions.Spline(t, (double)1.0, (double)0.0);
        double num7 = (num4 >= 0.10000000149011612) ? TransitionFunctions.Spline((double)((num4 - 0.1) / 0.9), (double)1.0, (double)0.0) : TransitionFunctions.Spline((double)(num4 / 0.1), (double)0.0, (double)1.0);
        double num8 = Math.Cos(num5 * 1.5707963267948966);

        vector.x  = (float)num8;
        vector.y  = (float)num6;
        vector.z  = (float)num7;
        vector.w  = (float)num2;
        vector2.x = (float)(num8 / this.speedModX);
        vector2.y = (float)(num6 / this.speedModY);
        vector2.z = (float)(num7 / this.speedModZ);
        vector2.w = (float)(1.0 - num2);
        if (this.inverseX)
        {
            vector2.x = 1f - vector2.x;
        }
        if (this.inverseY)
        {
            vector2.y = 1f - vector2.y;
        }
        if (this.inverseZ)
        {
            vector2.z = 1f - vector2.z;
        }
        if (this.swapX)
        {
            x         = vector2.x;
            vector2.x = vector.x;
            vector.x  = x;
        }
        if (this.swapY)
        {
            x         = vector2.y;
            vector2.y = vector.y;
            vector.y  = x;
        }
        if (this.swapZ)
        {
            x         = vector2.z;
            vector2.z = vector.z;
            vector.z  = x;
        }
        if (vector != this.lastBoundMin)
        {
            this.lastBoundMin = vector;
            this.propBlock.Set("_MinChannels", this.lastBoundMin);
        }
        if (vector2 != this.lastBoundMax)
        {
            this.lastBoundMax = vector2;
            this.propBlock.Set("_MaxChannels", this.lastBoundMax);
        }
        Vector3 vector3 = HUDIndicator.worldToCameraLocalMatrix.MultiplyVector(this.worldDirection);

        vector3.Normalize();
        if ((vector3.y * vector3.y) <= 0.99f)
        {
            base.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Atan2(vector3.z, vector3.x) * 57.29578f);
        }
        this.panel.propertyBlock = this.propBlock;
        return(true);
    }
Exemplo n.º 7
0
    protected sealed override bool Continue()
    {
        Vector4 vector4  = new Vector4();
        Vector4 vector41 = new Vector4();
        float   single;

        if (this.duration <= 0)
        {
            return(false);
        }
        double num = HUDIndicator.stepTime - this.damageTime;

        if (num > this.duration)
        {
            return(false);
        }
        this.propBlock.Clear();
        double num1 = num / this.duration;
        double num2 = num1 * this.speedModX;
        double num3 = num1 * this.speedModY;
        double num4 = num1 * this.speedModZ;

        if (num2 > 1)
        {
            num2 = 1 - (num2 - 1);
        }
        if (num3 > 1)
        {
            num3 = 1 - (num3 - 1);
        }
        if (num4 > 1)
        {
            num4 = 1 - (num4 - 1);
        }
        double num5 = TransitionFunctions.Spline(num2, 1, 0);
        double num6 = (num3 >= 0.100000001490116 ? TransitionFunctions.Spline((num3 - 0.1) / 0.9, 1, 0) : TransitionFunctions.Spline(num3 / 0.1, 0, 1));
        double num7 = Math.Cos(num4 * 1.5707963267949);

        vector4.x  = (float)num7;
        vector4.y  = (float)num5;
        vector4.z  = (float)num6;
        vector4.w  = (float)num1;
        vector41.x = (float)(num7 / this.speedModX);
        vector41.y = (float)(num5 / this.speedModY);
        vector41.z = (float)(num6 / this.speedModZ);
        vector41.w = (float)(1 - num1);
        if (this.inverseX)
        {
            vector41.x = 1f - vector41.x;
        }
        if (this.inverseY)
        {
            vector41.y = 1f - vector41.y;
        }
        if (this.inverseZ)
        {
            vector41.z = 1f - vector41.z;
        }
        if (this.swapX)
        {
            single     = vector41.x;
            vector41.x = vector4.x;
            vector4.x  = single;
        }
        if (this.swapY)
        {
            single     = vector41.y;
            vector41.y = vector4.y;
            vector4.y  = single;
        }
        if (this.swapZ)
        {
            single     = vector41.z;
            vector41.z = vector4.z;
            vector4.z  = single;
        }
        if (vector4 != this.lastBoundMin)
        {
            this.lastBoundMin = vector4;
            this.propBlock.Set("_MinChannels", this.lastBoundMin);
        }
        if (vector41 != this.lastBoundMax)
        {
            this.lastBoundMax = vector41;
            this.propBlock.Set("_MaxChannels", this.lastBoundMax);
        }
        Vector3 vector3 = HUDIndicator.worldToCameraLocalMatrix.MultiplyVector(this.worldDirection);

        vector3.Normalize();
        if (vector3.y * vector3.y <= 0.99f)
        {
            base.transform.localEulerAngles = new Vector3(0f, 0f, Mathf.Atan2(vector3.z, vector3.x) * 57.29578f);
        }
        this.panel.propertyBlock = this.propBlock;
        return(true);
    }
 /// <summary>
 /// 델타 추가
 /// </summary>
 /// <param name="snapShot">델타(현재상태, 현재인풋)</param>
 /// <param name="changedState">바뀔 상태</param>
 private void AddTransition(Tuple <string, string> snapShot, string changedState)
 {
     TransitionFunctions.Add(snapShot, changedState);
 }
Exemplo n.º 9
0
    public Vector3D Evaluate(int frame, bool direction)
    {
        bool         from_found = false, to_found = false;
        TrackingInfo from = new TrackingInfo(), to = new TrackingInfo();
        int          from_frame = 0, to_frame = 0;

        bool         control_lo_found = false, control_hi_found = false;
        TrackingInfo control_lo = new TrackingInfo(), control_hi = new TrackingInfo();
        int          control_lo_frame = 0, control_hi_frame = 0;

        foreach (var pair in keyframes)
        {
            int          keyframe = pair.Key;
            TrackingInfo keyinfo  = pair.Value;
            // MyLog.Default.WriteLine(String.Format("check {0} <> {1}", frame, keyframe));

            if (keyframe <= frame)
            {
                // pass down to lo control slot
                control_lo_frame = from_frame;
                control_lo       = from;
                control_lo_found = from_found;

                from_frame = keyframe;
                from       = keyinfo;
                from_found = true;
            }
            if (keyframe >= frame)
            {
                // fill hi control slot
                if (to_found)
                {
                    control_hi_frame = keyframe;
                    control_hi       = keyinfo;
                    control_hi_found = true;
                    break;
                }
                to_frame = keyframe;
                to       = keyinfo;
                to_found = true;
            }
        }
        if (!from_found && !to_found)
        {
            throw new Exception("timeline empty - cannot evaluate.");
        }
        if (!from_found)
        { // frame before timeline
            return(to.Evaluate(direction: direction));
        }
        if (!to_found)
        { // frame after timeline
            return(from.Evaluate(direction: direction));
        }

        Vector3D from_value = from.Evaluate(direction: direction);
        Vector3D to_value   = to.Evaluate(direction: direction);

        if (from_frame == to_frame)
        { // right on the frame - just use the frame value
            // MyLog.Default.WriteLine(String.Format("keyframe = <{0},{1},{2}>", from_value.X, from_value.Y, from_value.Z));
            return(from_value);
        }

        // MyLog.Default.WriteLine(String.Format("interpol from = <{0},{1},{2}>", from_value.X, from_value.Y, from_value.Z));
        // MyLog.Default.WriteLine(String.Format("interpol to = <{0},{1},{2}>", to_value.X, to_value.Y, to_value.Z));

        float factor = (frame - from_frame) * 1.0f / (to_frame - from_frame);

        // MyLog.Default.WriteLine(String.Format("frame = {0} between {1} and {2} - {3}", frame, from_frame, to_frame, factor));
        // linear and spline transitions are the ones that offer "natural continuity"
        // all others behave like a constant transition, ie. a linear transition from from_value/to to_value
        if (!control_lo_found || control_lo.Transition != TransitionMode.Spline && control_lo.Transition != TransitionMode.Linear)
        {
            if (!control_lo_found)
            {
                control_lo_frame = from_frame - 60;
            }
            // constant
            control_lo.Mode       = TrackMode.Unlocked;
            control_lo.Transition = TransitionMode.Linear;
            control_lo.Value3D    = from_value;
        }
        if (!control_hi_found || control_hi.Transition != TransitionMode.Spline && control_hi.Transition != TransitionMode.Linear)
        {
            if (!control_hi_found)
            {
                control_hi_frame = to_frame + 60;
            }
            control_hi.Mode       = TrackMode.Unlocked;
            control_hi.Transition = TransitionMode.Linear;
            control_hi.Value3D    = to_value;
        }

        switch (to.Transition)
        {
        case TransitionMode.Constant:
            return(TransitionFunctions.constant_transition(from_value, to_value, factor));

        case TransitionMode.Linear:
            return(TransitionFunctions.linear_transition(from_value, to_value, factor));

        case TransitionMode.Cosine:
            return(TransitionFunctions.cosine_transition(from_value, to_value, factor));

        case TransitionMode.Spline:
            return(TransitionFunctions.catmull_rom_transition(
                       control_lo.Evaluate(direction: direction), from_value, to_value, control_hi.Evaluate(direction: direction),
                       control_lo_frame, from_frame, to_frame, control_hi_frame,
                       control_lo.Transition == TransitionMode.Linear, control_hi.Transition == TransitionMode.Linear,
                       frame
                       ));

        default:
            throw new Exception("undefined transition mode");
        }
    }
Exemplo n.º 10
0
 private List <TransitionFunction> GetAllTransitions(State currentState, char c)
 {
     return(TransitionFunctions.FindAll(tf => tf.InputState.Name == currentState.Name && tf.InputSymbol == c));
 }