StandardCyborg / StandardCyborgCocoa

Everything you need for 3D scanning on iOS
https://www.standardcyborg.com
Other
143 stars 49 forks source link

Extracting the mesh #25

Closed martintseng closed 1 month ago

martintseng commented 2 years ago

I am trying to export the 3d model as a OBJ file. Within the ViewController, I am using: scenePreviewVC!.scenePreviewVC!.scScene.mesh.writeToOBJZip(atPath: filePath), but it gives me a file that does not work.

However, exporting the point clouds work, by using: scenePreviewVC!.scScene..pointCloud?.writeToPLY(atPath: filePath).

However, I am not sure if I am using the correct method. If not, can you please tell me what would be the best way to extract the mesh into an OBJ file?

inubushi commented 1 year ago

I am trying to read the created GLTF files using other applications, but it does not seem to work. Is there any limitation as to which applications can open the GLTF files?

pressanykeyplease commented 10 months ago

I am trying to export the 3d model as a OBJ file. Within the ViewController, I am using: scenePreviewVC!.scenePreviewVC!.scScene.mesh.writeToOBJZip(atPath: filePath), but it gives me a file that does not work.

However, exporting the point clouds work, by using: scenePreviewVC!.scScene..pointCloud?.writeToPLY(atPath: filePath).

However, I am not sure if I am using the correct method. If not, can you please tell me what would be the best way to extract the mesh into an OBJ file?

Hey @martintseng I am facing exact the same issue. Have you figured it out?

martintseng commented 10 months ago

Hey, they have not yet fixed the method yet, so you cannot use it.

Best,

Martin

On Sun, Aug 13, 2023 at 9:08 AM Eduard @.***> wrote:

I am trying to export the 3d model as a OBJ file. Within the ViewController, I am using: scenePreviewVC!.scenePreviewVC!.scScene.mesh.writeToOBJZip(atPath: filePath), but it gives me a file that does not work.

However, exporting the point clouds work, by using: scenePreviewVC!.scScene..pointCloud?.writeToPLY(atPath: filePath).

However, I am not sure if I am using the correct method. If not, can you please tell me what would be the best way to extract the mesh into an OBJ file?

Hey @martintseng https://github.com/martintseng I am facing exact the same issue. Have you figured it out?

— Reply to this email directly, view it on GitHub https://github.com/StandardCyborg/StandardCyborgCocoa/issues/25#issuecomment-1676355597, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG2WQHDGKSDXQQ7A5UFW5K3XVDGWLANCNFSM52CRBJPQ . You are receiving this because you were mentioned.Message ID: @.***>

aaptho commented 10 months ago

Hello @martintseng, does the mesh work if you export to PLY instead of OBJ? It’s possible there’s a bug in OBJ export. Can you provide more detail about what doesn’t work with OBJ export?

martintseng commented 10 months ago

Unfortunately, i dont have the details. I asked Standard Cyborg if they were going to fix it and they asked me to create an issue in github. i believe you can do the same and if enough people wants that function to be working, they will fix it.

Also, i think the whole method is bugged as its incomplete so you cannot fix it…

On Sun, Aug 27, 2023 at 1:00 AM Aaron Thompson @.***> wrote:

Hello @martintseng https://github.com/martintseng, does the mesh work if you export to PLY instead of OBJ? It’s possible there’s a bug in OBJ export. Can you provide more detail about what doesn’t work with OBJ export?

— Reply to this email directly, view it on GitHub https://github.com/StandardCyborg/StandardCyborgCocoa/issues/25#issuecomment-1694570526, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG2WQHFVGQXPBFSY5LRUOVLXXLH5NANCNFSM52CRBJPQ . You are receiving this because you were mentioned.Message ID: @.***>

pressanykeyplease commented 10 months ago

Hello @martintseng, does the mesh work if you export to PLY instead of OBJ? It’s possible there’s a bug in OBJ export. Can you provide more detail about what doesn’t work with OBJ export?

Hi @aaptho thanks for reaching out! I am using a default UI from the example in the code. Here's how I save the file:

var objURL = documentsURL.appendingPathComponent("sample.obj")
scene.pointCloud?.writeToOBJ(atPath: objURL.path)

Exported OBJ file is empty - you can check an example file here.

However, seems like writeToUSDZ method works good, but I cannot use it because it is not a surface, but a collection of points. Please help

pressanykeyplease commented 10 months ago

Hey @aaptho how do you think, will this be fixed in the foreseeable future?

aaptho commented 9 months ago

The exported OBJ file you linked looks corrupted, not at all like any OBJ file this framework writes. You might want to run with address sanitizer or zombies enabled to verify nothing in your app’s memory has been corrupted.

If you want to export a mesh, first use SCMeshingOperation to generate a mesh, then write that result to PLY. writeToGLBAtPath might work for you too if you can use a GLB file, it’s worth a shot.

aaptho commented 1 month ago

It sounds like the core issue here is GLTF export not working. That is tracked by https://github.com/StandardCyborg/StandardCyborgCocoa/issues/28 I’m not sure why OBJ did not work for you both, but if you’re still able to reproduce, please comment with further detail and steps.