UV mapping: importing meshes with multiple UVs per point

Hi folks,

I’m trying to solve a problem related to UV mapping (and I’m no expert on the subject). In our SketchUp plugin, we are importing geometry meshes. We have plugins that do this in several other 3D platforms—Cinema 4D, 3ds Max, Maya, etc. Unlike some of these, SketchUp does not allow us to assign multiple UVs to a single point. To handle this, I initially tried making duplicate points for these cases, so they could each be assigned different UVs, but this didn’t work: Geom::PolygonMesh deduplicates the points, so when you try to add a second point at the same coordinates, you get back the index value of the first point. No second point is added.

The problem here is needing to position some textures in specific ways on some faces, to handle where textures meet at wrapped-around seams.

I tried manually creating a simple example in SketchUp, to see how SketchUp normally handles textures that share an edge but have different texture coordinates (since they can’t have multiple UVs at the exact same vertices). I created a simple rectangle, divided it into two faces, applied a single material to both, then chose Make Texture Unique for one of the faces. Then I used Face.uv_tile_at to check what happened with the UV positions at the common edge.

To my surprise, the results indicated that the UV positions at the shared vertices were very slightly different. In other words, it looks like the way SketchUp handles vertices having multiple UVs (in this case, for two different textures, not the same texture) was by very slightly fudging the distances. The UV position values were not quite the same at those shared vertices, where I expected them to be exactly the same.

I realize that things might work differently with Face than with PolygonMesh, and that there may also be something I’m missing here (did I use Face.uv_tile_at correctly?), but this all suggests that the way to deal with our situation, when we need multiple UVs at certain points, is slightly fudge point positions (and therefore to create pseudo-dupe points where we had expected to create exact dupes). We would have to combine this with creating unique textures, rather than using a single texture discontinuously (since this can’t be done). Also, I’m aware that the decimal precision is limited with point positions, so those pseudo-duplicates may have to be fairly apart in order not to be deduplicated.

Does that sound right? I would love any insight on this. Thank you!

See this tracker issue. It may be related.

Thanks, that does seem related. We are faced with a similar problem, that it seems to require a lot of gymnastics around this issue to make our models work in SketchUp, while they work fine in many other platforms. I’m attempting it from the Ruby API, where it looks like the workaround options will distort the model more than from the C SDK. We might have to try from there instead, but neither case is ideal.

By the way, in the last release, the API added the EntitiesBuilder object which will often be better (and faster) than using the old PolygonMesh class.

However, I don’t think it will solve the UV issues because this is due to vertex merging.

Thanks. We’re definitely also looking into migrating to EntitiesBuilder once we can get this figured out.