Thursday, April 25, 2024
HomeiOS Developmentios - ParticleUniforms to MDLMesh

ios – ParticleUniforms to MDLMesh


I’m engaged on 3D iOS Scanner with Lidar and I attempt to extract pointcloud information in particle uniforms to 3D object and export it as OBJ. However I do not understand how. Any solution to convert particle uniforms to MDLMesh ?

Right here is my code:

  func saveOBJFormat() {
        
        let allocator = MTKMeshBufferAllocator(machine: machine)
        let asset = MDLAsset(bufferAllocator: allocator)
        let vertexDescriptor = MDLVertexDescriptor()
        vertexDescriptor.attributes[0] = MDLVertexAttribute(identify: MDLVertexAttributePosition, format: .float3, offset: 0, bufferIndex: 0)
        vertexDescriptor.attributes[1] = MDLVertexAttribute(identify: MDLVertexAttributeColor, format: .float3, offset: MemoryLayout<SIMD3<Float>>.stride, bufferIndex: 0)
        vertexDescriptor.layouts[0] = MDLVertexBufferLayout(stride: MemoryLayout<ParticleUniforms>.stride)
            
        
        for i in 0..<currentPointCount {
            let level = particlesBuffer[i]
            let colours = level.shade
            let place = level.place
            print(level, "level")
        }
        
        //  I clean in right here
                
        let pic = cvPixelBuffer2UIImage(pixelBuffer: sampleFrame.capturedImage)
        print(pic, "image")
        
        let asset = MDLAsset()
        asset.add(mdlMesh)
        
        let fileExtension = "obj"
        guard MDLAsset.canExportFileExtension(fileExtension) else {
            fatalError("Cant export a .(fileExtension) format")
        }

        do {
            let url = getDocumentsDirectory().appendingPathComponent(currentFolder, isDirectory: true).appendingPathComponent("(getTimeStr()).obj")
            attempt asset.export(to: url)
        } catch {
            fatalError("Error (error.localizedDescription)")
        }
    }

Thanks

How you can convert particle uniforms to MDLMesh ?



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments