/// <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; }
/// <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; }