Duplicating vertices so the count is equal to UV Coordinates

Started by
10 comments, last by L. Spiro 10 years, 5 months ago

The source data indexes multiple streams/pools of vmaps (position, uv) for each individual vertex element. Your mesh may also store discontinuous uv-map data meaning a vertex may have different uv-values associated with it for different triangles connected to the vertex. You can only set a single index buffer, so you'll have to combine position- and uv-data into a single indexable stream.

So, you need to unweld/duplicate vertices. The most intuitive way is to construct both the vertex- and the index stream in a single pass:

- Set up an "unweld-buffer" of vertex-count number of elements, each element in this buffer stores a linked-list of possible position-uv-normal etc. sets for a specific vertex combined with an index into the vertex buffer.

- Loop over all vertices in all triangles. (foreach(mesh->triangles as triangle) foreach(triangle->vertices as vertex))

- Grab for each vertex the set of position, uv, etc. data (relative to the current triangle for discontinuous maps)

- Look for a compatible existing element in the unweld-buffer, if it exists place the existing index associated with this element into the index buffer, if it does not, create a new element, assign it the index "vertex-buffer count + 1" and add it to both the linked list and the vertex buffer.

Advertisement

so yep, it absolutely does have to do with the format specifics

I guess what I meant was that every format requires you build up a vertex buffer and then deconstruct it, and that they all keep things in pools, though COLLADA’s pools seem to be 1-for-1 with the other pools. Rare, but still fully applicable.

But those details should be covered in the documentation.
Not only those details but everything else you need except to understand that those formats are not how they are represented in games and that you need to reconstruct the data for games (as described in detail by eppo).

It was my hope that any problems related to any specific API could be resolved by the poster on his or her own by checking the documentation for said API…on his or her own. The thing that caught me so many years ago was being in a mind-trap where I thought the original file format was something like what games use, and it was only when I escaped from that that I realized how to do it right, and I was hoping he’d be able to look at his API and take my words in combination and figure that out for himself.


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

This topic is closed to new replies.

Advertisement