我需要從MDLMeshBufferData實例創建一個MTKMeshBuffer實例。這裏是一個代碼片段:如何從MDLMeshBufferData中提取數據以填充MTKMeshBuffer?
let mdlm = MDLMesh(scnGeometry:sceneGeometry, bufferAllocator:nil)
let mdlSubmesh:MDLSubmesh = mdlm.submeshes?[ 0 ] as! MDLSubmesh
let mdlIndexBufferData:MDLMeshBufferData = mdlSubmesh.indexBuffer as! MDLMeshBufferData
let d:Data = mdlIndexBufferData.data
let mtlIndexBuffer:MTKMeshBuffer = device.makeBuffer(bytes: ???, length: ???, options:MTLResourceOptions.storageModeShared) as! MTKMeshBuffer
The ???是我需要填寫的位。有人可以告訴我適當的API來從MDL緩衝區中提取位來填充MTK緩衝區嗎?
是的,我通過MDLMesh工廠方法 - 平面/立方體/球體/ ...成功創建網格。效果很好。我從頭創建緩衝區的動機 - indexBuffer和vertexBuffer與讀取SCNScene文件 - .scn - 並從中提取網格有關。關鍵的API - MDLMesh(scnGeometry:sceneGeometry,bufferAllocator:MTKMeshBufferAllocator(device:device)) - 被破壞了,我將提交一個針對它的雷達bug。親自嘗試一下。 – dugla