private static void WriteMetaFile(string path, Vector3 offset, bool toRightHanded) { BlockGroup blockGroup = EditManager.Instance.Layers[0].GetBlockGroup(); ModelGroup modelGroup = EditManager.Instance.Layers[0].GetModelGroup(); Mesh mesh = blockGroup.GetRouteMesh(); Block[] blocks = blockGroup.GetEnterableBlocks(); // モデルを見て移動可能かどうかをチェックする blocks = blocks.Where(block => { var model = modelGroup.GetModel(block.position); return(model == null || model.shape.enterable); }).ToArray(); var fieldPanels = new FieldPanelGroup(mesh, blocks, offset); fieldPanels.ApplyRoutePath(blockGroup, EditManager.Instance.RoutePath); // バウンディングボックス Vector3 minpos = mesh.bounds.min + offset; Vector3 maxpos = mesh.bounds.max + offset; // 座標系反転処理 if (toRightHanded) { fieldPanels.ApplyRightHanded(); minpos = FileUtil.ApplyRightHanded(minpos); maxpos = FileUtil.ApplyRightHanded(maxpos); float z = minpos.z; minpos.z = maxpos.z; maxpos.z = z; } var mem = new MemoryStream(); var writer = new BinaryWriter(mem); writer.Write("E3MT".ToArray()); // Identifier writer.Write(2); // Version // バウンディングボックス writer.Write(minpos); writer.Write(maxpos); // 移動パネル fieldPanels.Write(writer); // 当たり判定ブロック Block[] colliderBlocks = blockGroup.GetAllBlocks(); writer.Write(colliderBlocks.Length); Vector3 colliderOffset = new Vector3(0.5f, 0.25f, 0.5f); foreach (var block in colliderBlocks) { Vector3 position = block.position; if (toRightHanded) { position = FileUtil.ApplyRightHanded(position); } position += colliderOffset; writer.Write(position); } // 3Dモデル配置 Model[] models = modelGroup.GetAllModels(); writer.Write(models.Length); foreach (var model in models) { Vector3 position = model.position; if (toRightHanded) { position = FileUtil.ApplyRightHanded(position); } writer.Write(model.shape.id); writer.Write(position); writer.Write(model.offset); writer.Write((float)model.rotation); writer.Write(model.shape.scale * model.scale); } File.WriteAllBytes(path, mem.ToArray()); }