コード例 #1
0
    public override SystemModule CopyModule()
    {
        BezierMeshModule mm = BezierMeshModule.CreateInstance <BezierMeshModule>();

        mm.Symbol      = Symbol;
        mm.Age         = Age;
        mm.TerminalAge = TerminalAge;
        mm.Growth      = Growth;
        mm.width       = width;
        mm.height      = height;
        mm.length      = length;
        mm.apposition  = apposition;
        return(mm);
    }
コード例 #2
0
    // Start is called before the first frame update
    void Start()
    {
        //Set the axiom's current age to 1 so that it derives at time 0
        system.Axiom = new ApexModule('1', 1, 1, GrowthList.LOGISTIC, "Prefabs/ModuleObjects/AubrevilleApex", true);
        turtle.apexStack.Push(system.Axiom as ApexModule);
        system.Axiom.InstantiateModule(turtle);
        ApexModule am = (system.Axiom as ApexModule);

        am.Children.RemoveAt(am.Children.Count - 1);

        ObjectModule leaf_module = new ObjectModule('O', 0, 1, GrowthList.LOGISTIC, "Prefabs/ModuleObjects/ManilkaraLeaf");

        leaf_module.scale = Vector3.one * 3f;

        MeshModule       stem_module   = new MeshModule('F', 0, 1, GrowthList.LINEAR);
        BezierMeshModule branch_module = new BezierMeshModule('F', 0, 1, GrowthList.LINEAR);

        branch_module.apposition = true;
        BezierMeshModule flowering_branch = new BezierMeshModule('F', 0, 1, GrowthList.LINEAR);

        flowering_branch.height = 0.25f;

        RotationModule rotation_module             = new RotationModule('+', 0, 1, GrowthList.LINEAR, new Vector3(0, 0, 1), 75f);
        SystemModule   branch_open_module          = new BranchModule('[', 0, 1, GrowthList.NON_DEVELOPMENTAL, true);
        SystemModule   branch_close_module         = new BranchModule(']', 0, 1, GrowthList.NON_DEVELOPMENTAL, false);
        SystemModule   branch_close_module_no_apex = new BranchModule(']', 0, 1, GrowthList.NON_DEVELOPMENTAL, false, false);

        List <SystemModule> main_axis = new List <SystemModule>();

        main_axis.Add(stem_module);
        for (int i = 0; i < BranchWhorls; i++)
        {
            main_axis.Add(branch_open_module);
            main_axis.Add(new RotationModule('+', 0, 1, GrowthList.NON_DEVELOPMENTAL, new Vector3(0, 1, 0), i * 360f / BranchWhorls));
            main_axis.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, new Vector3(1, 0, 0), 90f));
            main_axis.Add(new ApexModule('2', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/AubrevilleApex"));
            main_axis.Add(branch_close_module);
        }
        main_axis.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, Vector3.up, 45f));
        main_axis.Add(branch_open_module.CopyModule());
        main_axis.Add(new ApexModule('1', 0, 1, GrowthList.LOGISTIC, "Prefabs/ModuleObjects/AubrevilleApex", true));
        main_axis.Add(branch_close_module.CopyModule());
        system.Productions.Add('1', main_axis);

        List <SystemModule> whorl_axis = new List <SystemModule>();

        whorl_axis.Add(branch_module.CopyModule());
        whorl_axis.Add(branch_open_module.CopyModule());
        whorl_axis.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, new Vector3(1, 0, 0), -90f));
        whorl_axis.Add(new ApexModule('3', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/AubrevilleApex"));
        whorl_axis.Add(branch_close_module.CopyModule());
        whorl_axis.Add(branch_open_module.CopyModule());
        whorl_axis.Add(new ApexModule('2', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/AubrevilleApex"));
        whorl_axis.Add(branch_close_module.CopyModule());
        system.Productions.Add('2', whorl_axis);

        List <SystemModule> flowering_axis = new List <SystemModule>();

        flowering_axis.Add(flowering_branch.CopyModule());
        flowering_axis.Add(new RotationModule('+', 0, 1, GrowthList.NON_DEVELOPMENTAL, Vector3.up, 90f));
        flowering_axis.Add(branch_open_module.CopyModule());
        flowering_axis.Add(new ApexModule('4', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/AubrevilleApex"));
        flowering_axis.Add(branch_close_module.CopyModule());
        system.Productions.Add('3', flowering_axis);

        List <SystemModule> leaf_whorl = new List <SystemModule>();

        leaf_whorl.Add(new PhysicsMoverModule('M', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/AubrevilleLeafWhorl"));
        for (int i = 0; i < 4; i++)
        {
            leaf_whorl.Add(branch_open_module.CopyModule());
            leaf_whorl.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, Vector3.right, -45f));
            leaf_whorl.Add(leaf_module.CopyModule());
            leaf_whorl.Add(branch_close_module_no_apex.CopyModule());
            leaf_whorl.Add(new RotationModule('+', 0, 1, GrowthList.NON_DEVELOPMENTAL, Vector3.up, 90f));
        }
        system.Productions.Add('4', leaf_whorl);
    }