Exemplo n.º 1
0
            internal BuildVertexTask(ChunkMeshManager manager, Callback callback)
            {
                this.manager  = manager;
                this.callback = callback;

                WaitCallbackMethod = new WaitCallback(Execute);
            }
Exemplo n.º 2
0
        public ChunkVertexBuilder(ChunkMeshManager meshManager)
        {
            if (meshManager == null)
            {
                throw new ArgumentNullException("meshManager");
            }

            this.meshManager = meshManager;

            var segmentCount = meshManager.MeshSegments.X * meshManager.MeshSegments.Y * meshManager.MeshSegments.Z;

            opaques       = new ChunkVertices[meshManager.MeshSegments.X, meshManager.MeshSegments.Y, meshManager.MeshSegments.Z];
            translucences = new ChunkVertices[meshManager.MeshSegments.X, meshManager.MeshSegments.Y, meshManager.MeshSegments.Z];

            for (int z = 0; z < meshManager.MeshSegments.Z; z++)
            {
                for (int y = 0; y < meshManager.MeshSegments.Y; y++)
                {
                    for (int x = 0; x < meshManager.MeshSegments.X; x++)
                    {
                        var segmentPosition = new IntVector3(x, y, z);
                        opaques[x, y, z]       = new ChunkVertices();
                        translucences[x, y, z] = new ChunkVertices();
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <param name="chunkManager">チャンク マネージャ。</param>
        /// <param name="position">チャンクの位置。</param>
        /// <param name="region">リージョン。</param>
        public Chunk(ChunkManager chunkManager, ChunkMeshManager meshManager, Region region, IntVector3 position)
        {
            if (chunkManager == null)
            {
                throw new ArgumentNullException("manager");
            }
            if (region == null)
            {
                throw new ArgumentNullException("region");
            }

            this.chunkManager = chunkManager;
            this.meshManager  = meshManager;
            this.region       = region;
            Position          = position;

            opaqueMeshes      = new ChunkMesh[meshManager.MeshSegments.X, meshManager.MeshSegments.Y, meshManager.MeshSegments.Z];
            translucentMeshes = new ChunkMesh[meshManager.MeshSegments.X, meshManager.MeshSegments.Y, meshManager.MeshSegments.Z];

            Node = chunkManager.CreateNode();
        }
Exemplo n.º 4
0
        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <param name="settings">チャンク設定。</param>
        /// <param name="graphicsDevice">グラフィックス デバイス。</param>
        /// <param name="regionManager">リージョン マネージャ。</param>
        /// <param name="sceneManager">シーン マネージャ。</param>
        public ChunkManager(
            ChunkSettings settings,
            GraphicsDevice graphicsDevice,
            RegionManager regionManager,
            SceneManager sceneManager)
            : base(settings.PartitionManager)
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }
            if (regionManager == null)
            {
                throw new ArgumentNullException("regionManager");
            }

            ChunkSize           = settings.ChunkSize;
            this.graphicsDevice = graphicsDevice;
            this.regionManager  = regionManager;
            SceneManager        = sceneManager;

            switch (settings.ChunkStoreType)
            {
            case ChunkStoreType.Storage:
                ChunkStore = StorageChunkStore.Instance;
                break;

            default:
                ChunkStore = NullChunkStore.Instance;
                break;
            }

            EmptyData = new ChunkData(this);

            BaseNode = sceneManager.CreateSceneNode("ChunkRoot");
            sceneManager.RootNode.Children.Add(BaseNode);

            meshManager = new ChunkMeshManager(this, settings.VertexBuildConcurrencyLevel, settings.UpdateBufferCountPerFrame);
        }