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

Add support for n-gons #22

Closed
virtualritz opened this issue Mar 28, 2020 · 11 comments
Closed

Add support for n-gons #22

virtualritz opened this issue Mar 28, 2020 · 11 comments

Comments

@virtualritz
Copy link
Contributor

virtualritz commented Mar 28, 2020

Many geometries found in OBJs are not made out of triangles and this is a feature. If I load an OBJ to send to an high end offline renderer, the last thing I want is probably triangles (as such I also do not want the reader to convert the OBJ to triangles, on-the-fly, as tobj does).

Basically the mesh returned would then consist of:

mesh.positions
mesh.facevertices // number of vertices per each face (u32)
mesh.indices
@virtualritz
Copy link
Contributor Author

I quickly made a file in Wings3D – this is an all quad model. Feel free to use however you want.

knotty02.zip

@Twinklebear
Copy link
Owner

Hey @virtualritz , yeah this can be added as an option telling tobj not to triangulate. Then it can just give you back the face vertex counts of the quads/polygons directly. Thanks for the test model!

@virtualritz
Copy link
Contributor Author

Yes, this would be super useful.
I am using tobj here (have a play).

@Twinklebear
Copy link
Owner

Very cool! I'll ping you on this issue when I've added support and released and updated crate

@virtualritz
Copy link
Contributor Author

Cheers!

@Twinklebear
Copy link
Owner

Twinklebear commented May 10, 2020

Should be done in 1ae79e6 , I'll cut a release shortly. This is a breaking change for the API since I'm just adding a bool option to load_obj which will set whether or not to triangulate the loaded faces

The number of indices used by each face are now stored in Mesh::num_face_indices, check out the print mesh example. This is the same as tinyobjloader, though I named the list of verts/indices used per-face as num_face_indices instead of num_face_vertices

@Twinklebear
Copy link
Owner

Let me know if you run into any issues!

@virtualritz
Copy link
Contributor Author

Yeah, cool. I am trying this in a few hours. Will let you know.

@virtualritz
Copy link
Contributor Author

Done.

A two line change. Nice one. The commit only looks big because of Rustfmt stuff.

@virtualritz
Copy link
Contributor Author

You should update the README since your crate is actually the only one in the whole Rust universe that doesn't triangulate on import (if not asked to).

@Twinklebear
Copy link
Owner

That's a good point! I'll update it

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

2 participants