Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCMesh is missing textureData after meshing is done #50

Open
1agora opened this issue Nov 27, 2024 · 0 comments
Open

SCMesh is missing textureData after meshing is done #50

1agora opened this issue Nov 27, 2024 · 0 comments

Comments

@1agora
Copy link

1agora commented Nov 27, 2024

greetings all, perhaps anyone can point me to the right direction on this issue:

  • scanning + viewing works perfectly.
  • SCPointCloud is fine, no issues
  • Mesh is displayed in color and all is well.
  • crashing while OBJZip saving the mesh (or even accessing textureData), which is unexpectedly nil.
  • textureHeight and width is 0
  • SCReconstructionManager.includesColorBuffersInMetadata = true
  • SCReconstructionManager.includesDepthBuffersInMetadata = true

SCMesh:
image

SCMeshTexturing:
image

here is the code:

private func _processMeshTexturingIntoMesh(withPointCloud pointCloud: SCPointCloud,
                                               meshTexturing: SCMeshTexturing,
                                               completion: @escaping ((Result<SCMesh, Error>) -> Void)) {
        meshingProgressView.isHidden = false
        meshingProgressView.setProgress(0, animated: false)
        
        let meshingParameters = SCMeshingParameters()
        meshingParameters.resolution = 5
        meshingParameters.smoothness = 2
        meshingParameters.surfaceTrimmingAmount = 5
        meshingParameters.closed = true
        
        _meshingHelper = SCMeshingHelper(pointCloud: pointCloud, meshTexturing: meshTexturing, meshingParameters: meshingParameters)
        
        _meshingHelper?.processMesh(coloringStrategy: .vertex) { meshingStatus in
            DispatchQueue.main.async {
                switch meshingStatus {
                case .inProgress(let progress):
                    self.meshingProgressView.setProgress(progress, animated: false)
                case .failure(let error):
                    self.meshingProgressView.isHidden = true
                    completion(.failure(error))    // Error is guaranteed to be set for the failure case
                    
                case .success(let mesh):
                    self.meshingProgressView.isHidden = true

                        let zip_url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!.appendingPathComponent("Scan.zip")
                        
                        if mesh.writeToOBJZip(atPath: zip_url.path) {
                            print("Mesh ZIP saved.")
                        } 

                        print("🌶🌶🌶 textureData: \(mesh.textureData.count / 1024)kb") // EXC_BAD_ACCESS crash here
                        print("🌶🌶🌶 texCoordData: \(mesh.texCoordData.count / 1024)kb")
                        
                        print("🌶🌶🌶 textureWidth: \(mesh.textureWidth)")
                        print("🌶🌶🌶 textureWidth: \(mesh.textureHeight)")
                        
                    completion(.success(mesh))
                }
            }
        }
    }

and here's the error:

image

what can be the reason? any help greatly appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant