private void visualize(GameObject gameObject, Vector3[] groundVertices, Vector3 offset, float height = 10)
    {
        Stack <StateOld> StateStack   = new Stack <StateOld>();
        StateOld         currentState = new StateOld(gameObject, groundVertices);

        for (int i = 0; i < axiom.Length; i++)
        {
            char symbol = axiom[i];
            if (symbol != '[' && symbol != ']')
            {
                if (symbol == 'E')
                {
                    VisualizerOld.extrude(currentState, height);
                }
                else if (symbol == 'x')
                {
                    VisualizerOld.scale(currentState, 0.6f, 1, 1);
                }
                else if (symbol == 'y')
                {
                    VisualizerOld.scale(currentState, 1, 0.4f, 1);
                }
                else if (symbol == 'z')
                {
                    VisualizerOld.scale(currentState, 1, 1, 0.9f);
                }
                else if (symbol == 'X')
                {
                    VisualizerOld.translate(currentState, 0.2f, 0, 0);
                }
                else if (symbol == 'Y')
                {
                    VisualizerOld.translate(currentState, 0, -1, 0);
                }
                else if (symbol == 'Z')
                {
                    VisualizerOld.translate(currentState, 0, 0, 0.2f);
                }
            }
            else if (axiom[i] == '[')
            {
                StateStack.Push(currentState.clone());
            }
            else if (axiom[i] == ']')
            {
                currentState = StateStack.Pop();
            }
        }

        if (offset != null)
        {
            gameObject.transform.Translate(offset);
        }
    }
Beispiel #2
0
 public void visualize(GameObject gameObject, Vector3[] groundVertices, Vector3 offset, float height = 10)
 {
     if (!useOldVisualizerAndState)
     {
         Stack <State> StateStack   = new Stack <State>();
         State         currentState = new State(gameObject, groundVertices);
         for (int i = 0; i < axiom.Length; i++)
         {
             char symbol = axiom[i];
             if (symbol != '[' && symbol != ']')
             {
                 if (symbol == 'E')
                 {
                     //  Debug.Log("Y PRE EXTRUDE: " + currentState.getTop()[0].y);
                     Visualizer.extrude(currentState, height);
                     //  Debug.Log("Y POST EXTRUDE: " + currentState.getTop()[0].y);
                 }
                 else if (symbol == 'x')
                 {
                     Visualizer.scale(currentState, new Vector3(0.6f, 1, 1));
                 }
                 else if (symbol == 'y')
                 {
                     // Debug.Log("Y PRE SCALE: " + currentState.getTop()[0].y);
                     Visualizer.scale(currentState, new Vector3(1, 0.4f, 1));
                     // Debug.Log("Y POST SCALE: " + currentState.getTop()[0].y);
                 }
                 else if (symbol == 'z')
                 {
                     Visualizer.scale(currentState, new Vector3(1, 1, 0.9f));
                 }
                 else if (symbol == 'X')
                 {
                     Visualizer.translate(currentState, new Vector3(1, 0, 0));
                 }
                 else if (symbol == 'Y')
                 {
                     //  Debug.Log("Y PRE TRANSLATE: " + currentState.getTop()[0].y);
                     Visualizer.translate(currentState, new Vector3(0, -3, 0));
                     //  Debug.Log("Y POST TRANSLATE: " + currentState.getTop()[0].y);
                 }
                 else if (symbol == 'Z')
                 {
                     Visualizer.translate(currentState, new Vector3(0, 0, 0.2f));
                 }
             }
             else if (axiom[i] == '[')
             {
                 StateStack.Push(currentState.clone());
             }
             else if (axiom[i] == ']')
             {
                 currentState = StateStack.Pop();
             }
         }
     }
     else
     {
         Stack <StateOld> StateStack   = new Stack <StateOld>();
         StateOld         currentState = new StateOld(gameObject, groundVertices);
         for (int i = 0; i < axiom.Length; i++)
         {
             char symbol = axiom[i];
             if (symbol != '[' && symbol != ']')
             {
                 if (symbol == 'E')
                 {
                     VisualizerOld.extrude(currentState, height);
                 }
                 else if (symbol == 'x')
                 {
                     VisualizerOld.scale(currentState, 0.6f, 1, 1);
                 }
                 else if (symbol == 'y')
                 {
                     VisualizerOld.scale(currentState, 1, 0.4f, 1);
                 }
                 else if (symbol == 'z')
                 {
                     VisualizerOld.scale(currentState, 1, 1, 0.9f);
                 }
                 else if (symbol == 'X')
                 {
                     VisualizerOld.translate(currentState, 0.2f, 0, 0);
                 }
                 else if (symbol == 'Y')
                 {
                     VisualizerOld.translate(currentState, 0, -1, 0);
                 }
                 else if (symbol == 'Z')
                 {
                     VisualizerOld.translate(currentState, 0, 0, 0.2f);
                 }
             }
             else if (axiom[i] == '[')
             {
                 StateStack.Push(currentState.clone());
             }
             else if (axiom[i] == ']')
             {
                 currentState = StateStack.Pop();
             }
         }
     }
     if (offset != null)
     {
         gameObject.transform.Translate(offset);
     }
 }