예제 #1
0
        public Turtle(float breath)
        {
            this.breath = breath;
            //twistVector *= ((1-breath) + 0.35f); "straghtens out"
            twistVector  *= 1 + breath;
            meshGenerator = new MeshBuilder();
            state         = new TurtleState(new Vector3(0, 0, 0),
                                            Quaternion.identity,
                                            baseRadius, 0);
            previousStates = new List <TurtleState>();

            this.grammar       = new Dictionary <string, Action>();
            this.grammar["["]  = () => SavePosition();
            this.grammar["]"]  = () => ResumePosition();
            this.grammar["+"]  = () => Rotate(0, 0, angle);
            this.grammar["-"]  = () => Rotate(0, 0, -angle);
            this.grammar["|"]  = () => Rotate(0, 0, 180);
            this.grammar["\\"] = () => Rotate(angle, 0, 0);
            this.grammar["/"]  = () => Rotate(-angle, 0, 0);
            this.grammar["^"]  = () => Rotate(0, angle, 0);
            this.grammar["&"]  = () => Rotate(0, -angle, 0);
            this.grammar["#"]  = () => RandomRotate();
            this.grammar["L"]  = () => Leaf();
            this.grammar["A"]  = () => Branch();
        }
예제 #2
0
 private void ResumePosition()
 {
     state = previousStates[previousStates.Count - 1];
     previousStates.RemoveAt(previousStates.Count - 1);
 }