-
Notifications
You must be signed in to change notification settings - Fork 46
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
Vertex colors #44
Vertex colors #44
Conversation
Does not yet work with the merge_identical_points feature.
Thanks @stisol, this looks great! The interaction with |
Thanks for the feedback! Yeah, inline vertex colors are by their nature very memory inefficient. I think you're right - introducing a color index and merging vertex colors like the other attributes feels like the most natural way to support them in this context. I added a This works as expected in my simple reordered quad unit test. I also temporarily (and messily) converted the program I'm working on make use of reordering to give the feature a more thorough test run, and it worked as expected. 20k vertices, with only 3 elements in the Since the merging unit test only runs on nightly, do you want me to add a commit to this PR that adds a CI job to compile and test on nightly will all features enabled? This snippet appended to the end of nightly_features_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose --all-features |
Great! Yeah adding a nightly CI runner would be good, I usually am not developing on nightly so it'll be useful to make sure things don't break |
Awesome, thanks @stisol ! I'll cut a release shortly with this addition |
Hi @Twinklebear, thanks so much for making and maintaining tobj! I wanted to make use of a model with vertex colors and decided to try to add the functionality to my favourite obj parsing crate, resolving #26 🙂
The changes are fairly straightforward:
vertex_color
toMesh
, following the style ofnormals
andtexcoords
, and updated the README accordingly.v
, it will now add the vertex color on the same line if it is present.FaceColorOutOfBounds
error variant to match the existing OutOfBounds errors for normals and uv coords.parse_floatn
take theSplitWhitespace
by a mutable reference instead of by ownership in order to allow the iterator to be used again. As it will now only consumen
items, it is now called a second time onv
lines to see if there is a second trio of floats on it.simple_triangle_colored
test that checks that the triangle file with vertex colors added is still parsed the same way, with the extra vertex color array now filled.I still need to make this work with the
merge_identical_points
feature. As the vertex colors currently share indices with vertices, this is not entirely trivial. I did add a test for this, which is currently failing. As this test can only run on nightly with themerging
feature, this will not show up with the current CI configuration.