Ejemplo n.º 1
0
        public static Node CreateRoot(Context.Constants constants, Context.Depth depth, Context.Branch branch)
        {
            GameObject gameObject = new GameObject("Chunk");

            gameObject.transform.SetParent(branch.gameObject.transform, false);
            MeshFilter   meshFilter   = gameObject.AddComponent <MeshFilter>();
            MeshRenderer meshRenderer = gameObject.AddComponent <MeshRenderer>();

            meshRenderer.enabled        = false;
            meshRenderer.sharedMaterial = constants.material;

            int[]   path = new int[0];
            int[]   neighborBranches;
            int[][] neighborPaths;
            GetNeighborPaths(path, branch.index, out neighborBranches, out neighborPaths);

            return(new Node
            {
                parent = null,
                children = null,
                path = path,
                neighborBranches = neighborBranches,
                neighborPaths = neighborPaths,
                branch = branch,
                depth = depth,
                offset = Vector2.zero,
                gameObject = gameObject,
                mesh = null,
                meshFilter = meshFilter,
                meshRenderer = meshRenderer,
                meshRequest = null,
                meshRequestCancellation = null
            });
        }
Ejemplo n.º 2
0
        void DoUpdate()
        {
            plugins = GetComponents <Core.Plugin>();

            Core.Context.Constants constants = new Core.Context.Constants
            {
                desiredScreenSpaceLength = desiredScreenSpaceLength,
                gameObject = gameObject,
                material   = material,
                maxDepth   = maxDepth,
                resolution = resolution * 2 - 1, // We can only use odd resolutions.
                plugins    = new Core.Plugin.PluginChain(plugins)
            };

            Core.Context.Branch[]    branches  = Core.Context.Branch.GetFromConstants(constants);
            Core.Context.Depth[]     depths    = Core.Context.Depth.GetFromConstants(constants);
            Core.Context.Triangles[] triangles = Core.Context.Triangles.GetFromConstants(constants);
            Core.Node[] roots = new Core.Node[6];
            for (int i = 0; i < 6; i++)
            {
                roots[i] = Core.Node.CreateRoot(constants, depths[0], branches[i]);
            }

            context = new Core.Context
            {
                constants = constants,
                branches  = branches,
                depths    = depths,
                triangles = triangles,
                roots     = roots
            };

            foreach (Core.Plugin plugin in plugins)
            {
                plugin.OnChange += HandleChange;
                plugin.OnPluginStart();
            }

            constants.plugins.ModifyMaterial(context, constants.material);

            Core.Reconciler.Initialize(context);
        }