Robmaister / SharpNav

Advanced Pathfinding for C#
sharpnav.com
Other
537 stars 129 forks source link

Import OBJ to mesh #2

Closed SallyDT closed 9 years ago

SallyDT commented 10 years ago

Does this fully support the OBJ specification? I tried custom meshes (instead of the recast sample) and they don't load.

Robmaister commented 10 years ago

Nope, the OBJ loader is very much hacked together, I made it work with the Recast sample model and that was good enough. The only immediately obvious thing I can see for it not loading or crashing is if the file lacked normals, since I assume that each face index is provided as v//n or v/t/n. If it's v or v/t, it should crash with an IndexOutOfBoundsException.

If you give me the .obj file (or at least one that was made by the same exporter), I'll generalize the loader to make it work with that file as well.

I can also throw in a button that lets you open a .obj file to make it easier to test various files.

SallyDT commented 10 years ago

I sent to your email.

Robmaister commented 10 years ago

The scale of the level you emailed me was significantly greater than the scale of the Recast sample, increasing the size of the far-clip plane and setting the camera position to the center of the model made it all visible (though moving really slow)

At the moment, it's crashing at the same part in NavMeshDetail that the Recast sample does when the cell size is set large enough to avoid running out of memory, so I'd consider this issue solved.

AqlaSolutions commented 10 years ago

Just noticed that your obj importer can't import meshes made with quads.

Robmaister commented 10 years ago

It should have the ability to do so. In fact, nav_test.obj is mostly quads. Are you having an issue with a specific obj file? My obj importer was written very quickly and not with compatibility, maintainability, or performance in mind. It's just a shim to get a basic level loaded. If you've got a specific obj that isn't working, either try and debug it yourself and send me a pull request with the fix, or send the obj file my way and I might look at it when I have some free time.

Robmaister commented 9 years ago

The OBJ loader included in SharpNavEditor should support the spec and most (if not all) edge cases gracefully. I'll leave this open for a week if either of you still have issues with OBJ loading. @SallyDT @AqlaSolutions

Robmaister commented 9 years ago

Assuming this is solved. Feel free to reopen this one or create a new one if that's not the case.