Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        //Isn't this what we wanted to avoid via the L_System Laboratory?
        //Soon we will find ourselves re-compiling and twisting these parameters endlessly, rather than an interactive editor...
        ObjectModule leaf_module = new ObjectModule('O', 0, 1, GrowthList.LOGISTIC, "Prefabs/ModuleObjects/ManilkaraLeaf");

        leaf_module.scale = Vector3.one * 5f;

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

        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);

        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(0, 0, 1), 90f));
            main_axis.Add(new ApexModule('2', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/Apex"));
            main_axis.Add(branch_close_module);
        }
        main_axis.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, Vector3.up, 45f));
        main_axis.Add(new ApexModule('1', 0, 1, GrowthList.LOGISTIC, "Prefabs/ModuleObjects/Apex"));
        system.Productions.Add('1', main_axis);

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

        whorl_axis.Add(stem_module.CopyModule());
        whorl_axis.Add(branch_open_module.CopyModule());
        whorl_axis.Add(new ApexModule('3', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/Apex"));
        whorl_axis.Add(branch_close_module.CopyModule());
        whorl_axis.Add(new ApexModule('2', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/Apex"));
        system.Productions.Add('2', whorl_axis);

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

        flowering_axis.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, new Vector3(0, 0, 1), -90f));
        flowering_axis.Add(stem_module.CopyModule());
        flowering_axis.Add(new RotationModule('+', 0, 1, GrowthList.NON_DEVELOPMENTAL, Vector3.up, 90f));
        system.Productions.Add('3', flowering_axis);

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

        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.CopyModule());
            leaf_whorl.Add(new RotationModule('+', 0, 1, GrowthList.NON_DEVELOPMENTAL, Vector3.up, 90f));
        }
        leaf_whorl.Add(stem_module.CopyModule());
        system.Productions.Add('M', leaf_whorl);
    }
 public SegmentItem(LogicalSegment segment, ObjectModule module)
 {
     this.segment = segment;
     this.symbols = new List <SymbolItem>(
         from symbol in module.DefinedNames
         where symbol.BaseSegment == segment
         orderby symbol.Offset, symbol.Name
         select new SymbolItem(symbol));
 }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        LineModule stem_module = new LineModule('F', 0, 1, GrowthList.LINEAR);

        stem_module.LineWidth  = 0.5f;
        stem_module.LineLength = 5.0f;
        //MeshModule stem_module = new MeshModule('M', 0, 1, GrowthList.LINEAR);
        //stem_module.x = 0.1f;
        //stem_module.y = 1f;
        //stem_module.z = 0.1f;

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

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

        leaf_module.scale = Vector3.one * 2.5f;

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

        //main_axis.Add(branch_open_module);
        main_axis.Add(rotation_module);
        main_axis.Add(stem_module);
        main_axis.Add(new ApexModule('2', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/PlatformApex"));
        //main_axis.Add(branch_close_module);
        main_axis.Add(new ApexModule('1', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/Apex"));
        system.Productions.Add('1', main_axis);

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

        platform_axis.Add(branch_open_module);
        platform_axis.Add(rotation_module);
        platform_axis.Add(stem_module);
        platform_axis.Add(new PhysicsMoverModule('3', 0, 1, GrowthList.LINEAR, "Prefabs/ModuleObjects/LeafWhorlMover"));
        platform_axis.Add(branch_close_module);
        system.Productions.Add('2', platform_axis);

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

        leaf_whorl.Add(branch_open_module);
        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, false));
            leaf_whorl.Add(leaf_module.CopyModule());
            leaf_whorl.Add(branch_close_module.CopyModule());
            leaf_whorl.Add(new RotationModule('+', 0, 1, GrowthList.NON_DEVELOPMENTAL, Vector3.up, 90f, false));
        }
        leaf_whorl.Add(branch_close_module);
        system.Productions.Add('3', leaf_whorl);

        ApexModule axiom_apex = system.Axiom as ApexModule;

        turtle.TurtleAnalysis(0f);
        axiom_apex.Apex.ActivateApex();
    }
 public void SetUI(ObjectModule om)
 {
     currentModule        = om;
     objectDropdown.value = pathDictionary[om.ObjectPath];
     Trigger.isOn         = om.trigger;
     Jointed.isOn         = om.jointed;
     ObjectEuler.Vector   = om.rotation;
     ObjectScale.Vector   = om.scale;
 }
 public void Init(ObjectModule om)
 {
     currentModule = om;
     SetPath();
     SetToggle();
     SetJointed();
     SetScale();
     SetEuler();
 }
 public void RegisterModule()
 {
     var mod = new ObjectModule();
     var target = new ContainerBuilder();
     target.RegisterModule(mod);
     Assert.False(mod.ConfigureCalled);
     var container = target.Build();
     Assert.True(mod.ConfigureCalled);
     Assert.True(container.IsRegistered<object>());
 }
Пример #7
0
    public override SystemModule CopyModule()
    {
        ObjectModule om = new ObjectModule(Symbol, Age, TerminalAge, Growth, ObjectPath);

        om.rotation = rotation;
        om.scale    = scale;
        om.trigger  = trigger;
        om.jointed  = jointed;

        return(om);
    }
        public void RegisterModule()
        {
            var mod    = new ObjectModule();
            var target = new ContainerBuilder();

            target.RegisterModule(mod);
            Assert.False(mod.ConfigureCalled);
            var container = target.Build();

            Assert.True(mod.ConfigureCalled);
            Assert.True(container.IsRegistered <object>());
        }
            public ConstantSegmentItem(ObjectModule module)
            {
                this.module = module;

                // Find all defined names with absolute segment. These
                // symbols are most likely constants.
                this.constants = new List <SymbolItem>(
                    from symbol in module.DefinedNames
                    where symbol.BaseSegment == null
                    orderby symbol.Name
                    select new SymbolItem(symbol));
            }
Пример #10
0
        private void DoOpenLibFile(string fileName)
        {
            ObjectLibrary library = OmfLoader.LoadLibrary(fileName);

            library.ResolveAllSymbols();

            LibraryDisassembler dasm = new LibraryDisassembler(library);

            dasm.Analyze();

            this.program = library;
            this.procedureList.Program = program;
            this.errorList.Program     = program;
            this.segmentList.Program   = program;

            // Display all unresolved symbols.
            foreach (string key in library.GetUnresolvedSymbols())
            {
                System.Diagnostics.Debug.WriteLine(string.Format(
                                                       "Symbol {0} is unresolved.", key));
            }

            this.libraryBrowser.Library = library;

#if false
            string symbolToFind = "FISRQQ";
            foreach (var mod in library.Symbols[symbolToFind])
            {
                System.Diagnostics.Debug.WriteLine(string.Format(
                                                       "Symbol {0} is defined in module {1}",
                                                       symbolToFind, mod.Name));
            }
            //library.DuplicateSymbols

            ObjectModule  module     = library.FindModule("_ctype");
            DefinedSymbol symbol     = module.DefinedNames.Find(x => x.Name == "_isupper");
            Address       entryPoint = new Address(
                symbol.BaseSegment.Id, (int)symbol.Offset);

            Disassembler16New dasm = new Disassembler16New(library);
            dasm.Analyze(entryPoint);

            this.disassemblyList.SetView(library, symbol.BaseSegment);
#endif
        }
Пример #11
0
        private static string FormatSymbolicOperand(
            X86Codec.Instruction instruction,
            X86Codec.Operand operand,
            FixupDefinition fixup,
            ObjectModule module)
        {
            if (fixup.Target.Method == FixupTargetMethod.ExternalPlusDisplacement ||
                fixup.Target.Method == FixupTargetMethod.ExternalWithoutDisplacement)
            {
                var extIndex = fixup.Target.IndexOrFrame;
                var extName  = module.ExternalNames[extIndex - 1];
                var disp     = fixup.Target.Displacement;

                //System.Diagnostics.Debug.WriteLine(string.Format(
                //    "{0} : operand {4} refers to {1}+{2} : {3}",
                //    instruction, extName, disp, fixup.Location, operand));
                return(extName.Name);
            }
            return(null);
        }
            public ModuleItem(ObjectModule module)
            {
                if (module == null)
                {
                    throw new ArgumentNullException("module");
                }

                this.Module  = module;
                this.Symbols = new List <ITreeNode>();

                ConstantSegmentItem constantGroup = new ConstantSegmentItem(module);

                if (constantGroup.HasChildren)
                {
                    this.Symbols.Add(constantGroup);
                }

                // Hide zero-length segments.
                this.Symbols.AddRange(
                    from segment in module.Segments
                    where segment.Length > 0
                    orderby segment.Class, segment.Name
                    select new SegmentItem(segment, module));

                this.Symbols.AddRange(
                    from alias in module.Aliases
                    select(ITreeNode) new SymbolAliasItem(alias));

#if false
                this.Symbols.AddRange(
                    from symbol in module.DefinedNames
                    where symbol.BaseSegment != null
                    orderby symbol.BaseSegment.Name, symbol.Offset, symbol.Name
                    select new SymbolItem(symbol));
#endif
            }
Пример #13
0
        private void UpdateImage(ObjectModule module)
        {
#if false
            // For each segment, construct a list of LEDATA/LIDATA records.
            // These records fill data into the segment.
            // It is required that the data do not overlap, and do not
            // exceed segment boundary (here we only support 16-bit segments,
            // whose maximum size is 64KB).

            // Find the first CODE segment.
            LogicalSegment codeSegment = null;
            foreach (var seg in module.Segments)
            {
                if (seg.Class == "CODE")
                {
                    codeSegment = seg;
                    break;
                }
            }
            if (codeSegment == null)
            {
                return;
            }

            // Create a BinaryImage with the code.
            BinaryImage image = new BinaryImage(codeSegment.Image.Data, new Pointer(0, 0));

            // Disassemble the instructions literally. Note that this should
            // be improved, but we don't do that yet.
            var addr = image.BaseAddress;
            for (var i = image.StartAddress; i < image.EndAddress;)
            {
                var instruction = image.DecodeInstruction(addr);

                // An operand may have zero or one component that may be
                // fixed up. Check this.
#if false
                for (int k = 0; k < instruction.Operands.Length; k++)
                {
                    var operand = instruction.Operands[k];
                    if (operand is RelativeOperand)
                    {
                        var opr        = (RelativeOperand)operand;
                        var loc        = opr.Offset.Location;
                        int j          = i - image.StartAddress + loc.StartOffset;
                        int fixupIndex = codeSegment.DataFixups[j];
                        if (fixupIndex != 0)
                        {
                            FixupDefinition fixup = codeSegment.Fixups[fixupIndex - 1];
                            if (fixup.DataOffset != j)
                            {
                                continue;
                            }

                            var target = new SymbolicTarget(fixup, module);
                            instruction.Operands[k] = new SymbolicRelativeOperand(target);
                            System.Diagnostics.Debug.WriteLine(instruction.ToString());
                        }
                    }
                }
#endif

                image.CreatePiece(addr, addr + instruction.EncodedLength, ByteType.Code);
                image[addr].Instruction = instruction;
                addr = addr.Increment(instruction.EncodedLength);

                // TODO: we need to check more accurately.

#if false
                // Check if any bytes covered by this instruction has a fixup
                // record associated with it. Note that an instruction might
                // have multiple fixup records associated with it, such as
                // in a far call.
                for (int j = 0; j < instruction.EncodedLength; j++)
                {
                    int fixupIndex = codeSegment.DataFixups[i - image.StartAddress + j];
                    if (fixupIndex != 0)
                    {
                        FixupDefinition fixup = codeSegment.Fixups[fixupIndex - 1];
                        if (fixup.DataOffset != i - image.StartAddress + j)
                        {
                            continue;
                        }

                        if (fixup.Target.Method == FixupTargetSpecFormat.ExternalPlusDisplacement ||
                            fixup.Target.Method == FixupTargetSpecFormat.ExternalWithoutDisplacement)
                        {
                            var extIndex = fixup.Target.IndexOrFrame;
                            var extName  = module.ExternalNames[extIndex - 1];
                            var disp     = fixup.Target.Displacement;

                            System.Diagnostics.Debug.WriteLine(string.Format(
                                                                   "{0} refers to {1}+{2} : {3}",
                                                                   instruction, extName, disp, fixup.Location));
                        }
                    }
                }
#endif

                i += instruction.EncodedLength;
            }
            // ...

            // Display the code in our disassmbly window.
            if (this.ListingWindow != null)
            {
                Document doc = new Document();
                doc.Image = image;
                this.ListingWindow.Document = doc;
            }
#endif
        }
    // 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);
    }
    public void BuildDefaultSystem()
    {
        ObjectModule om = new ObjectModule('O', 0, 1, GrowthList.LINEAR, ObjectBuilder.OBJECT_PATH + ObjectList.SIMPLE_LEAF);

        om.scale    = Vector3.one * 0.1f;
        om.rotation = new Vector3(90, 0, 0);

        ObjectModule om_right = new ObjectModule('O', 0, 1, GrowthList.LINEAR, ObjectBuilder.OBJECT_PATH + ObjectList.SIMPLE_LEAF);

        om_right.scale    = Vector3.one * 0.1f;
        om_right.rotation = new Vector3(90, 180, 0);
        om_right.jointed  = true;

        JointModule jm = new JointModule('{', 0, 1, GrowthList.LINEAR, JointBuilder.JOINT_PATH + JointModule.HINGE_JOINT);

        jm.jointSpringSpring = 10f;
        jm.jointSpringDamper = 99f;

        jm.jointLimitMin = -10;
        jm.jointLimitMax = 10;

        ObjectModule om_right_z = new ObjectModule('O', 0, 1, GrowthList.LOGISTIC, ObjectBuilder.OBJECT_PATH + ObjectList.SIMPLE_LEAF);

        om_right_z.scale    = Vector3.one * 0.1f;
        om_right_z.rotation = new Vector3(90, 90, 0);

        JointModule jmc = new JointModule('{', 0, 1, GrowthList.LINEAR, JointBuilder.JOINT_PATH + JointModule.CHARACTER_JOINT);

        jmc.mass = 1;

        jmc.jointSpringSpring = 10f;
        jmc.jointSpringDamper = 99f;

        jmc.jointLimitMin = -10;
        jmc.jointLimitMax = 10;

        jmc.twistLimit1 = -10;
        jmc.twistLimit2 = 10;

        jmc.twistSpringSpring = 10f;
        jmc.twistSpringDamper = 99f;

        LineModule ln = new LineModule('F', 0, 1, GrowthList.EXPONENTIAL);

        ln.LineWidth  = 0.1f;
        ln.LineLength = 0.1f;
        ln.jointed    = true;

        ObjectModule om_z = new ObjectModule('O', 0, 1, GrowthList.LINEAR, ObjectBuilder.OBJECT_PATH + ObjectList.SIMPLE_LEAF);

        om_z.scale    = Vector3.one * 0.1f;
        om_z.rotation = new Vector3(90, -90, 0);

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

        lm.Add(jmc.CopyModule());
        lm.Add(ln.CopyModule());
        lm.Add(new SystemModule('[', 0, 1, GrowthList.NON_DEVELOPMENTAL));
        lm.Add(jm.CopyModule());
        lm.Add(new RotationModule('+', 0, 1, GrowthList.LINEAR, new Vector3(1, 0, 0), 45f));
        lm.Add(om_right.CopyModule());
        lm.Add(new SystemModule('}', 0, 1, GrowthList.NON_DEVELOPMENTAL));
        lm.Add(new SystemModule(']', 0, 1, GrowthList.NON_DEVELOPMENTAL));
        lm.Add(new SystemModule('1', 0, 1, GrowthList.NON_DEVELOPMENTAL));
        lm.Add(new SystemModule('}', 0, 1, GrowthList.NON_DEVELOPMENTAL));

        Productions.Add('1', lm);
    }