Example #1
0
        /// <summary>
        /// InterBlockMesh の頂点情報とエフェクト情報をもとに BlockMesh を生成します。
        /// </summary>
        /// <param name="interMesh">頂点情報とエフェクト情報を提供する InterBlockMesh。</param>
        /// <returns>生成された BlockMesh。</returns>
        public BlockMesh Create(InterBlockMesh interMesh)
        {
            var lodCount = interMesh.MeshLods.Length;

            var mesh = new BlockMesh();
            mesh.SetMeshMaterials(interMesh.MeshMaterials);

            mesh.AllocateMeshLods(lodCount);

            for (int lod = 0; lod < lodCount; lod++)
            {
                var interMeshLod = interMesh.MeshLods[lod];
                var meshLod = mesh.MeshLods[lod];

                var meshPartCount = interMeshLod.MeshParts.Length;
                meshLod.AllocateMeshParts(GraphicsDevice, meshPartCount);

                for (int i = 0; i < meshPartCount; i++)
                {
                    var interMeshPart = interMeshLod.MeshParts[i];
                    var meshPart = meshLod.MeshParts[i];

                    meshPart.MeshMaterial = mesh.MeshMaterials[interMeshPart.MeshMaterialIndex];
                    meshPart.PopulateVertices(interMeshPart.Vertices);
                    meshPart.PopulateIndices(interMeshPart.Indices);
                }
            }

            return mesh;
        }
Example #2
0
 /// <summary>
 /// BlockMesh をアンロードします。
 /// </summary>
 /// <param name="mesh">アンロードする BlockMesh。</param>
 public void Unload(BlockMesh mesh)
 {
     if (!meshes.Remove(mesh))
         throw new InvalidOperationException("The specified BlockMesh is not managed.");
     mesh.Dispose();
 }
Example #3
0
 public void Cancel(BlockMesh blockMesh)
 {
     queue.RemoveAll((i) => i.BlockMesh == blockMesh);
 }
Example #4
0
        /// <summary>
        /// 指定の BlockMeshPart のロード要求をキューへ追加します。
        /// </summary>
        /// <param name="interBlockMesh">BlockMesh のロード元となる InterBlockMesh。</param>
        /// <param name="blockMesh">分割ロード対応の BlockMesh。</param>
        /// <param name="levelOfDetail">対象とする LOD。</param>
        /// <param name="meshPartIndex">対象とする BlockMeshPart のインデックス。</param>
        void Enqueue(InterBlockMesh interBlockMesh, BlockMesh blockMesh, int levelOfDetail, int meshPartIndex)
        {
            lock (this)
            {
                if (queue.Count == MaxCapacity)
                    throw new InvalidOperationException("This queue is full.");

                var item = new Item
                {
                    InterBlockMesh = interBlockMesh,
                    BlockMesh = blockMesh,
                    LevelOfDetail = levelOfDetail,
                    MeshPartIndex = meshPartIndex
                };

                queue.Add(item);
            }
        }
Example #5
0
 /// <summary>
 /// 指定の LOD についての分割ロード要求をキューへ追加します。
 /// </summary>
 /// <param name="interBlockMesh">BlockMesh のロード元となる InterBlockMesh。</param>
 /// <param name="blockMesh">分割ロード対応の BlockMesh。</param>
 /// <param name="levelOfDetail">対象とする LOD。</param>
 void Enqueue(InterBlockMesh interBlockMesh, BlockMesh blockMesh, int levelOfDetail)
 {
     for (int i = 0; i < blockMesh.MeshLods[levelOfDetail].MeshParts.Count; i++)
     {
         Enqueue(interBlockMesh, blockMesh, levelOfDetail, i);
     }
 }
Example #6
0
        /// <summary>
        /// 分割ロード対応の BlockMesh を生成します。
        /// </summary>
        /// <param name="graphicsDevice">GraphicsDevice。</param>
        /// <param name="interBlockMesh">BlockMesh のロード元となる InterBlockMesh。</param>
        /// <returns>分割ロード対応の BlockMesh。</returns>
        BlockMesh CreatePhasedBlockMesh(GraphicsDevice graphicsDevice, InterBlockMesh interBlockMesh)
        {
            var lodCount = interBlockMesh.MeshLods.Length;

            var blockMesh = new BlockMesh();
            blockMesh.SetMeshMaterials(interBlockMesh.MeshMaterials);
            blockMesh.AllocateMeshLods(lodCount);

            for (int lod = 0; lod < lodCount; lod++)
            {
                var interMeshLod = interBlockMesh.MeshLods[lod];
                var meshPartCount = interMeshLod.MeshParts.Length;
                var meshLod = blockMesh.MeshLods[lod];

                meshLod.AllocateMeshParts(graphicsDevice, meshPartCount);

                for (int i = 0; i < meshPartCount; i++)
                {
                    var interMeshPart = interMeshLod.MeshParts[i];
                    var meshPart = meshLod.MeshParts[i];

                    meshPart.MeshMaterial = blockMesh.MeshMaterials[interMeshPart.MeshMaterialIndex];
                }
            }

            return blockMesh;
        }
Example #7
0
 void InterBlockMeshLoadTaskCallback(string name, InterBlockMesh result)
 {
     if (meshName == name) mesh = workspace.LoadBlockMesh(result);
 }
Example #8
0
 public void CancelLoadBlockMesh(BlockMesh blockMesh)
 {
     blockMeshLoadQueue.Cancel(blockMesh);
 }