Text archives Help
- From: James Bigler <bigler@cs.utah.edu>
- To: "'manta@sci.utah.edu'" <manta@sci.utah.edu>
- Subject: [MANTA] Mesh and sparse texture coordinates
- Date: Tue, 24 Jul 2007 15:53:04 -0600
Anyone have any ideas how we could change Mesh to accommodate sparse texture
coordinates (i.e. not all triangles have texture coordinates, or very few have
texture coordinates).
One option would be to force all the triangles with texture coordinates to be at
the beginning of the mesh and check to see if the the triangle id is larger than
the number of texture coordinates we have. This could be kind of messy.
The other option would be yet another array of indices that would point to the
texture id group:
vector<Vector> texCoords;
vector<unsigned int> texture_indices;
vector<unsigned int> texture_index_start;
Then the lookup would be something like:
Vector tex0 = texCoords[texture_indices[texture_index_start[id]+0]];
Vector tex1 = texCoords[texture_indices[texture_index_start[id]+1]];
Vector tex2 = texCoords[texture_indices[texture_index_start[id]+2]];
We would have to come up with something that meant there wasn't an index (like
static_cast<unsigned int)(-1)).
So the code could look like this:
if (texture_index_start.size() > 0) {
// Sparse texture coordinates
unsigned int texture_start = texture_index_start[id];
if (texture_start != static_cast<unsigned int>(-1)) {
Vector tex0 = texCoords[texture_indices[texture_start+0]];
Vector tex1 = texCoords[texture_indices[texture_start+1]];
Vector tex2 = texCoords[texture_indices[texture_start+2]];
} else {
// use barycentric coords as texture coords, or some other default
}
} else {
// Assume the texture coordinates are fully populated
const int texture_start = id*3;
Vector tex0 = texCoords[texture_indices[texture_start+0]];
Vector tex1 = texCoords[texture_indices[texture_start+1]];
Vector tex2 = texCoords[texture_indices[texture_start+2]];
}
What do people think?
James
- [MANTA] Mesh and sparse texture coordinates, James Bigler, 07/24/2007
Archive powered by MHonArc 2.6.16.