예제 #1
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);
        }
예제 #2
0
        public object Load(IResource resource)
        {
            var definition = (ChunkSettingsDefinition) serializer.Deserialize(resource);

            var settings = new ChunkSettings
            {
                ChunkSize = definition.ChunkSize,
                VertexBuildConcurrencyLevel = definition.VertexBuildConcurrencyLevel,
                UpdateBufferCountPerFrame = definition.UpdateBufferCountPerFrame,
                MinActiveVolume = definition.MinActiveRange,
                MaxActiveVolume = definition.MaxActiveRange,
                ChunkStoreType = definition.ChunkStoreType
            };

            settings.PartitionManager.ClusterSize = definition.ClusterSize;
            settings.PartitionManager.ActivationCapacity = definition.ActivationCapacity;
            settings.PartitionManager.PassivationCapacity = definition.PassivationCapacity;
            settings.PartitionManager.PassivationSearchCapacity = definition.PassivationSearchCapacity;
            settings.PartitionManager.PriorActiveDistance = definition.PriorActiveDistance;

            settings.PartitionManager.PartitionSize = definition.ChunkSize.ToVector3();
            settings.PartitionManager.MinActiveVolume = new DefaultActiveVolume(settings.MinActiveVolume);
            settings.PartitionManager.MaxActiveVolume = new DefaultActiveVolume(settings.MaxActiveVolume);

            return settings;
        }
예제 #3
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);
        }