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 point and line primitives #39

Open
virtualritz opened this issue Apr 28, 2021 · 7 comments
Open

Add support for point and line primitives #39

virtualritz opened this issue Apr 28, 2021 · 7 comments

Comments

@virtualritz
Copy link
Contributor

The code already handles Lines but just stashes them as normal faces (as triangles even, if triangulate_faces is on).
Points need to be added and then two more indices.

@virtualritz
Copy link
Contributor Author

The reordering branch in my fork has support for points but still only as degenerate faces for now.

@Twinklebear
Copy link
Owner

Twinklebear commented May 12, 2021

Partial support now in 3.0.0 which includes your PR?

@virtualritz
Copy link
Contributor Author

virtualritz commented May 12, 2021

Actually, not really. What I m thinking now is this:

  1. Add support for the p and l elements.
  2. Remove the filter_out_* flags and Add an keep_degenerate_faces flag instead.
  3. Add a treat_degenerate_faces_as_other_elements that allows treating f elements with one or two indices only as if they were p or l elements.

The last point is for the case where you have an OBJ file that contains degenerate faces which are meant to represent points or lines. I dunno if this is actually common enough in the wild to warrant adding more code to allow these to be represented as such.

In general, we probably want to better model what is in an OBJ using maybe an enum?

enum Entity {
    Points(Mesh)
    Lines(Mesh)
    Mesh(Mesh)
    Curves(tbd)
    Surface(tbd)
}

P.S. Regarding Curves/Surface – I am working on a wrapper around the Ayam core to bring first class NURBS support to Rust.
While I also have a rudimentary wrapper around OpenNURBS I think using OBJ files containing (trimmed) NURBS (e.g. exported from Rhino or Maya) is way easier to test this wrapper. So I will likely add support for that soon and at that point the how (see above) becomes relevant.

@Twinklebear
Copy link
Owner

The degenerate faces thing I haven't run into, but I also pretty much just use triangulated meshes exported from Blender. I think your proposed changes and the enum sound good. Then in the case of degenerate faces when not specifying to treat them as other elements we'd return an error back to the user.

A NURBS crate would be cool to have in Rust! From the tobj side we can add support for importing them as well but leave the actual NURBS interpretation to another standalone crate.

@virtualritz
Copy link
Contributor Author

virtualritz commented May 12, 2021

Then in the case of degenerate faces when not specifying to treat them as other elements we'd return an error back to the user.

Hmm, I understand the reasoning. But we have functionality to filter them out already. I.e. I would expect them to get filtered out when keep_degenerate_faces is set to false (by default). Silently. I.e. no error.
Maybe we have use use an degenerate_face_handling enum in the LoadSettings instead:

enum DegenerateFaceHandling {
    Keep,
    FilterOut,
    /// Convert to points or lines (once we support them)
    Convert,
    /// Inflate to triangles.
    Inflate,
}

@virtualritz
Copy link
Contributor Author

virtualritz commented May 12, 2021

A NURBS crate would be cool to have in Rust! From the tobj side we can add support for importing them as well but leave the actual NURBS interpretation to another standalone crate.

I do not have time to write one. I just started working on an OpenNURBS wrapper until I realized there is actually no code for polygonal meshing meshing in the lib.
The best OSS alternative seems to be Ayam. And it's author has recently gotten back to work on it (maybe the lockdown) and it is no longer under GPL. And the API is C.

@Twinklebear
Copy link
Owner

Oh yeah, not one from scratch in Rust that's a ton of work, a wrapper over something that's working well in C or C++ is good

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