Repository navigation
WaveFrontReader: read per-vertex colors from "v x y z r g b" - #329
Open
Joel Kiptoo (Kiptoo-Deus) wants to merge 1 commit into
Open
Joel Kiptoo (Kiptoo-Deus) wants to merge 1 commit into
Joel Kiptoo (Kiptoo-Deus) wants to merge 1 commit into
Conversation
Some tools, such as MeshLab, write a per-vertex color after the position on 'v' lines. The reader ignored everything after x y z, so these colors were dropped. When a 'v' line has exactly three extra values they are read as an RGB color. A single extra value is still treated as the optional 'w' coordinate and ignored. Positions without a color default to white. The colors go into a new vertexColors array, one entry per vertex, alongside a hasVertexColors flag. Vertex itself is unchanged, so the .vbo format and existing callers are unaffected.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #75.
Tools such as MeshLab write a per-vertex color after the position on
vlines (v x y z r g b). The reader readx y zand dropped the rest of the line, so these colors were lost.Changes in
WaveFrontReader.h:vline, the rest of the line is parsed afterx y z. If there are exactly three extra values they are read as an RGB color. A single extra value is still the optionalwcoordinate from the OBJ spec and is ignored, and any other count is ignored as well. Positions without a color default to white.vertexColorsarray (XMFLOAT3, one entry per entry invertices) with ahasVertexColorsflag, filled in as vertices are created from faces. When the file has no colors the array stays empty.Vertexitself is unchanged, so the.vbolayout used byLoadVBOand existing callers are not affected.std::wstringrather than a fixed buffer, so an overlongvline can't put the stream into a failed state.Vertex deduplication is keyed on the position index, so vertices that share a position also share its color and the existing dedup behaviour doesn't change.
Testing: on macOS with clang, using the same small shim as in #324 (
std::wifstreamfrom awchar_t*path is an MSVC extension libc++ doesn't have), I loaded:0.984314 0.764706 1.0etc. come through with the right positions and normalsv x y z w:hasVertexColorsis false andvertexColorsis emptyvline with 1,700 extra values: the rest of the file still loadsI didn't touch meshconvert. If you'd like the colors passed through to its output formats I can follow up on that separately.