Exemplo n.º 1
0
    public float GetBonesValue(StoreType id, KneadType type)
    {
        switch (type)
        {
        case KneadType.PosX:
            return(mPosition[(int)id].x);

        case KneadType.PosY:
            return(mPosition[(int)id].y);

        case KneadType.PosZ:
            return(mPosition[(int)id].z);

        case KneadType.ScaleX:
            return(mScale[(int)id].x);

        case KneadType.ScaleY:
            return(mScale[(int)id].y);

        case KneadType.ScaleZ:
            return(mScale[(int)id].z);

        default:
            return(0.0f);
        }
    }
Exemplo n.º 2
0
    public void SaveBonesValue(StoreType id, KneadType type)
    {
        switch (type)
        {
        case KneadType.PosX:
            mPosition[(int)id].x = transform.localPosition.x;
            break;

        case KneadType.PosY:
            mPosition[(int)id].y = transform.localPosition.y;
            break;

        case KneadType.PosZ:
            mPosition[(int)id].z = transform.localPosition.z;
            break;

        case KneadType.Rotation:
            mRotation[(int)id] = transform.localRotation;
            break;

        case KneadType.ScaleX:
            mScale[(int)id].x = transform.localScale.x;
            break;

        case KneadType.ScaleY:
            mScale[(int)id].y = transform.localScale.y;
            break;

        case KneadType.ScaleZ:
            mScale[(int)id].z = transform.localScale.z;
            break;
        }
    }
Exemplo n.º 3
0
    void DrawBoneControlRot(BonesControl target, KneadType type)
    {
        EditorGUILayout.Space();
        using (var scope1 = new EditorGUI.ChangeCheckScope())
        {
            foldout[(int)type] = EditorGUILayout.Foldout(foldout[(int)type], BonesControl.GetLabel(type));
            if (foldout[(int)type])
            {
                target.UnlockTransformElement(type);
                float   angle;
                Vector3 axis;
                GUILayout.Label("Min Value");
                target.MRotation[0].ToAngleAxis(out angle, out axis);
                EditorGUILayout.Vector3Field("Axis", axis);
                EditorGUILayout.FloatField("Angle", angle);

                GUILayout.Label("Max Value");
                target.MRotation[1].ToAngleAxis(out angle, out axis);
                EditorGUILayout.Vector3Field("Axis", axis);
                EditorGUILayout.FloatField("Angle", angle);

                using (var scope = new EditorGUILayout.HorizontalScope())
                {
                    if (GUILayout.Button("SaveMin"))
                    {
                        target.SaveBonesValue(BonesControl.StoreType.StoreMinValue, type);
                        MakeSceneDirty();
                    }
                    using (var ccs = new EditorGUI.ChangeCheckScope())
                    {
                        target.progress[(int)type] = EditorGUILayout.Slider(target.progress[(int)type], -1, 1);
                        if (ccs.changed)
                        {
                            target.UpdateProgress(type);
                        }
                    }
                    if (GUILayout.Button("SaveMax"))
                    {
                        target.SaveBonesValue(BonesControl.StoreType.StoreMaxValue, type);
                        MakeSceneDirty();
                    }
                }
            }
            GUILayout.Space(2);
            if (scope1.changed)
            {
                MakeSceneDirty();
            }
        }
    }
Exemplo n.º 4
0
    static public string GetLabel(KneadType type)
    {
        switch (type)
        {
        case KneadType.PosX:
        case KneadType.PosY:
        case KneadType.PosZ:
        case KneadType.Rotation:
        case KneadType.ScaleX:
        case KneadType.ScaleY:
        case KneadType.ScaleZ:
            return(type.ToString());

        default:
            return("");
        }
    }
Exemplo n.º 5
0
    void DrawBoneControl(BonesControl target, KneadType type)
    {
        EditorGUILayout.Space();
        using (var scope1 = new EditorGUI.ChangeCheckScope())
        {
            foldout[(int)type] = EditorGUILayout.Foldout(foldout[(int)type], BonesControl.GetLabel(type));
            if (foldout[(int)type])
            {
                target.UnlockTransformElement(type);

                using (var scope = new EditorGUILayout.HorizontalScope())
                {
                    string minValue = target.GetBonesValue(BonesControl.StoreType.StoreMinValue, type).ToString();
                    if (GUILayout.Button(minValue))
                    {
                        target.SaveBonesValue(BonesControl.StoreType.StoreMinValue, type);
                        MakeSceneDirty();
                    }
                    using (var ccs = new EditorGUI.ChangeCheckScope())
                    {
                        target.progress[(int)type] = EditorGUILayout.Slider(target.progress[(int)type], -1, 1);
                        if (ccs.changed)
                        {
                            target.UpdateProgress(type);
                        }
                    }
                    minValue = target.GetBonesValue(BonesControl.StoreType.StoreMaxValue, type).ToString();
                    if (GUILayout.Button(minValue))
                    {
                        target.SaveBonesValue(BonesControl.StoreType.StoreMaxValue, type);
                        MakeSceneDirty();
                    }
                }
            }
            GUILayout.Space(2);
            if (scope1.changed)
            {
                MakeSceneDirty();
            }
        }
    }
Exemplo n.º 6
0
    public void UpdateProgress(KneadType type, float d)
    {
        int id = d < 0 ? 0 : 1;

        switch (type)
        {
        case KneadType.PosX:
            curPosition.x = Mathf.Lerp(defaultPosition.x, mPosition[(int)id].x, Mathf.Abs(d));
            break;

        case KneadType.PosY:
            curPosition.y = Mathf.Lerp(defaultPosition.y, mPosition[(int)id].y, Mathf.Abs(d));
            break;

        case KneadType.PosZ:
            curPosition.z = Mathf.Lerp(defaultPosition.z, mPosition[(int)id].z, Mathf.Abs(d));
            break;

        case KneadType.Rotation:
            curRotation = Quaternion.Lerp(defaultRotation, mRotation[(int)id], Mathf.Abs(d));
            break;

        case KneadType.ScaleX:
            curScale.x = Mathf.Lerp(defaultScale.x, mScale[(int)id].x, Mathf.Abs(d));
            break;

        case KneadType.ScaleY:
            curScale.y = Mathf.Lerp(defaultScale.y, mScale[(int)id].y, Mathf.Abs(d));
            break;

        case KneadType.ScaleZ:
            curScale.z = Mathf.Lerp(defaultScale.z, mScale[(int)id].z, Mathf.Abs(d));
            break;
        }
        RefreshTransform();
    }
Exemplo n.º 7
0
    public void UpdateProgress(KneadType type)
    {
        float d = progress[(int)type];

        UpdateProgress(type, d);
    }
Exemplo n.º 8
0
 public void UnlockTransformElement(KneadType type)
 {
     unlockBoneState |= (1 << (int)type);
 }