public bool Parse(BinaryReader br, string id)
    {
        switch (id)
        {
        case "Num":
            int num = br.ReadInt32();
            Keys  = new MegaBezFloatKey[num];
            Times = new float[num];
            break;

        case "Keys":
            for (int i = 0; i < Keys.Length; i++)
            {
                Keys[i]        = new MegaBezFloatKey();
                Keys[i].val    = br.ReadSingle();
                Keys[i].intan  = br.ReadSingle();
                Keys[i].outtan = br.ReadSingle();
                Times[i]       = br.ReadSingle();
            }
            InitKeys();
            break;

        case "BKeys":                   // Blender keys
            Vector2 co    = Vector2.zero;
            Vector2 left  = Vector2.zero;
            Vector3 right = Vector2.zero;

            Vector2 pco    = Vector2.zero;
            Vector2 pleft  = Vector2.zero;
            Vector3 pright = Vector2.zero;

            for (int i = 0; i < Keys.Length; i++)
            {
                Keys[i] = new MegaBezFloatKey();

                co.x = br.ReadSingle();
                co.y = br.ReadSingle();

                left.x = br.ReadSingle();
                left.y = br.ReadSingle();

                right.x = br.ReadSingle();
                right.y = br.ReadSingle();

                if (i > 0)
                {
                    MakeKey(Keys[i - 1], pco, pleft, pright, co, left, right);
                }

                pco      = co;
                pleft    = left;
                pright   = right;
                Times[i] = co.x / 30.0f;
            }
            break;
        }

        return(true);
    }
    public void MakeKey(MegaBezFloatKey key, Vector2 pco, Vector2 pleft, Vector2 pright, Vector2 co, Vector2 left, Vector2 right)
    {
        float f1 = pco.y * 100.0f;
        float f2 = pright.y * 100.0f;
        float f3 = left.y * 100.0f;
        float f4 = co.y * 100.0f;

        key.val   = f1;
        key.coef3 = 3.0f * (f2 - f1);
        key.coef2 = 3.0f * (f1 - 2.0f * f2 + f3);
        key.coef1 = f4 - f1 + 3.0f * (f2 - f3);
    }
	public void MakeKey(MegaBezFloatKey key, Vector2 pco, Vector2 pleft, Vector2 pright, Vector2 co, Vector2 left, Vector2 right)
	{
		float f1 = pco.y * 100.0f;
		float f2 = pright.y * 100.0f;
		float f3 = left.y * 100.0f;
		float f4 = co.y * 100.0f;

		key.val = f1;
		key.coef3 = 3.0f * (f2 - f1);
		key.coef2 = 3.0f * (f1 - 2.0f * f2 + f3);
		key.coef1 = f4 - f1 + 3.0f * (f2 - f3);
	}
	public bool Parse(BinaryReader br, string id)
	{
		switch ( id )
		{
			case "Num":
				int num = br.ReadInt32();
				Keys = new MegaBezFloatKey[num];
				Times = new float[num];
				break;

			case "Keys":
				for ( int i = 0; i < Keys.Length; i++ )
				{
					Keys[i] = new MegaBezFloatKey();
					Keys[i].val = br.ReadSingle();
					Keys[i].intan = br.ReadSingle();
					Keys[i].outtan = br.ReadSingle();
					Times[i] = br.ReadSingle();
				}
				InitKeys();
				break;

			case "BKeys":	// Blender keys
				Vector2 co = Vector2.zero;
				Vector2 left = Vector2.zero;
				Vector3 right = Vector2.zero;

				Vector2 pco = Vector2.zero;
				Vector2 pleft = Vector2.zero;
				Vector3 pright = Vector2.zero;

				for ( int i = 0; i < Keys.Length; i++ )
				{
					Keys[i] = new MegaBezFloatKey();

					co.x = br.ReadSingle();
					co.y = br.ReadSingle();

					left.x = br.ReadSingle();
					left.y = br.ReadSingle();

					right.x = br.ReadSingle();
					right.y = br.ReadSingle();

					if ( i > 0 )
						MakeKey(Keys[i - 1], pco, pleft, pright, co, left, right);

					pco = co;
					pleft = left;
					pright = right;
					Times[i] = co.x / 30.0f;
				}
				break;
		}

		return true;
	}