Robmaister / SharpNav

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

Can't load obj file #19

Closed NotAlkaline closed 9 years ago

NotAlkaline commented 10 years ago

Hi,

I'm looking to load a file to Sharnav, but the demo project keep crashing at parsing the file. I have tryed do modify the way it parses, but no lock with it, It still crashes when drawing the triangles.

obj file : https://mega.co.nz/#!HdZDnBKB!bqMTKoxDiy9TLZIT8y8Prt3v-hXPQjdL8evQjRTqdzg

Robmaister commented 10 years ago

I'll take a look at it when I get off work today.

Robmaister commented 10 years ago

Re-export the model with vertex normals. The current .obj loader assumes you have surface normals.

I'm not going to make any changes to the project, but here's how you would get it to work if you can't re-export the model for some reason:

in ObjModel.cs, comment out lines 85-87, 92-94, 97-99, 105, 108, 116-117, 121-122, and 125-127. in ExampleWindow.Drawing.cs comment out lines 108-110, 127-131, 160, 189, 193-194, and 201. in ExampleWindow.cs comment out lines 251-253 and 257-258

This stops the OBJ loader from reading in normals (which are missing from the file), then prevents it from creating a VBO for the normals, then stops the use of that VBO anywhere, and then disables lighting, which requires normals. I might have missed a few lines or something, didn't actually try it out myself but it should get you pretty close.

We are going to write a more versatile OBJ loader as part of the editor we are planning, and it will also be used in the examples project. Spending any time on the existing loader will only be duplicated work.

Robmaister commented 10 years ago

also taking a peek at the model elsewhere, you're going to have some issues unless you export the model with Y as the up axis instead of Z.

NotAlkaline commented 10 years ago

Thanks a lot, I will make those changes today. The Z axis troubles are fixed too, I figured out when opening with another obj program :)

Robmaister commented 10 years ago

Cool, feel free to ask if you have any other issues getting the model to load. I'll let you close the issue once you've got it working.