Inheritance: UnityEngine.MonoBehaviour
Ejemplo n.º 1
0
        public void Grow()
        {
            if (axiomObject == null)
            {
                Debug.LogError("The axiom object is not set.");
                return;
            }

            if (axiomObject.GetComponent <AxiomObject>() == null)
            {
                Debug.LogError("The axiom object does not have the AxiomObject component.");
                return;
            }

            if (ruleCollectionObject == null)
            {
                Debug.LogError("The rule collection object is not set.");
                return;
            }

            if (ruleCollectionObject.GetComponent <RuleCollectionObject>() == null)
            {
                Debug.LogError("The rule collection object does not have the RuleCollectionObject component.");
                return;
            }

            List <Variable> axiom = axiomObject.GetComponent <AxiomObject>().Axiom;

            RuleCollection ruleCollection = ruleCollectionObject.GetComponent <RuleCollectionObject>().RuleCollection;

            variables = LSystem.Grow(axiom, ruleCollection, numberOfIterations);

            if (printResultInConsole)
            {
                string result = "";

                foreach (Variable variable in variables)
                {
                    result += variable.ToString();
                }

                Debug.Log("Result:");
                Debug.Log("Number of variables: " + variables.Count);
                Debug.Log(result);
            }
        }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        this.lsys = new LSystem.LSystem();

        lsys.Rules = new Dictionary <string, string> {
            { "1", "FF-[1]++F+F" }
        };
//		lsys.Rules = new Dictionary<string, string> { { "1", "FF-[1]++F+F+1" } };
//		lsys.Rules = new Dictionary<string, string> { { "1", "F+F-F([1]" } };

//		lsys.Rules = new Dictionary<string, string> {
//			{ "1", "FFF+[2]F+(>[---1]" },
//			{ "2", "FFF[1]+[1]+[1]+[1]" }
//		};

        lsys.Angle         = this.angle;
        lsys.SegmentLength = this.segmentLength;

        var cmd = new CommonCommands();

        cmd.Angle         = this.angle;
        cmd.AngleAxis     = this.angleAxis;
        cmd.SegmentAxis   = this.segmentAxis;
        cmd.SegmentLength = this.segmentLength;
        lsys.AddCommand(cmd);

        this.segmentDrawer = new VectorLineSegmentDrawer();
        var segCmd = new SegmentCommand();

        segCmd.Segment     = this.segmentDrawer;
        segCmd.SegmentAxis = this.segmentAxis;

        lsys.AddCommand(segCmd);

        this.totalTime = lsys.Duration(this.generations);
        Debug.Log(string.Format("totalTime = {0}", this.totalTime));

//		lsys.Draw(Vector3.zero, this.generations);
    }
Ejemplo n.º 3
0
 void OnEnable()
 {
     sys = (LSystem)target;
 }
Ejemplo n.º 4
0
 void OnEnable()
 {
     sys = (LSystem)target;
 }