Beispiel #1
0
    //generates a mesh from a l system ruleset
    public Mesh MeshFromRuleset(int idx)
    {
        //create L system
        LSystem ls            = new LSystem(_rulesets[idx]._axiom, _iterationCount, _rulesets[idx]);
        string  lSystemOutput = ls.Generate();

        //use turtle to create mesh of L system
        Turtle turtle = new Turtle(_rulesets[idx]._angle);

        turtle.Decode(lSystemOutput);
        turtle.CreateMesh();

        Mesh mesh = turtle._finalMesh;

        return(mesh);
    }
Beispiel #2
0
    //animates the step by step drawing of the mesh
    public IEnumerator AnimateMesh(int objNum, View view)
    {
        var     ruleSet       = _rulesets[objNum];
        LSystem ls            = new LSystem(ruleSet._axiom, _iterationCount, ruleSet);
        string  lSystemOutput = ls.Generate();

        //use turtle to create mesh of L system
        Turtle turtle = new Turtle(ruleSet._angle);

        turtle.Decode(lSystemOutput);

        for (int i = 0; i < turtle._meshes.Count; i++)
        {
            turtle.PartialMesh(i);

            //view.InstructionsRewrite(turtle._partialInstructions); //writes the turtle instructions to screen (used in video)
            view.MeshRedraw(turtle._partialMesh); //redraws the partial mesh
            yield return(new WaitForSeconds(0.01f));
        }
    }