weixin_39554775
weixin_39554775
2020-11-26 09:20

Texture indices not aligned to face indices

While parsing an OBJ file, the texture coordinates are indexed immediately: https://github.com/mikedh/trimesh/blob/952d3807849646595fb892d39d75ec8010c3b157/trimesh/io/wavefront.py#L87-L89 and then put in the metadata: https://github.com/mikedh/trimesh/blob/952d3807849646595fb892d39d75ec8010c3b157/trimesh/io/wavefront.py#L44-L46 The vertex coordinates and the faces are passed to Trimesh object. Later _validate_face_normals and update_faces are called that mixes up the face indices. Due to this the face indices not match the texture indices (that has been already indexed), obviously it renders a bad texture: bug

Not sure what would be an easy way to keep the changes of the face indices the same with the texture coordinate indices. It could start by storing the texture coordinates and texture coordinate indices separately in metadata.

该提问来源于开源项目:mikedh/trimesh

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

9条回答

  • weixin_39554775 weixin_39554775 5月前

    Totally forgot about this. I made some changes a while ago but didnt commit because its a mess and still sort of unfinished. Ill clean up and actualize the changes and provide a link to my commit so you can decide if its okay or not.

    点赞 评论 复制链接分享
  • weixin_39795479 weixin_39795479 5月前

    No worries, thanks for putting it together!

    点赞 评论 复制链接分享
  • weixin_39554775 weixin_39554775 5月前

    You can find the changes here https://github.com/feketeimre/trimesh/commit/d24a32a18b59ba5394778ff66555d866c6e9d851 Its pretty messy, not sure if it helps at all.

    点赞 评论 复制链接分享
  • weixin_39795479 weixin_39795479 5月前

    Thanks that’s helpful!

    点赞 评论 复制链接分享
  • weixin_39795479 weixin_39795479 5月前

    Consolidating all texture issues into #218

    点赞 评论 复制链接分享
  • weixin_39554775 weixin_39554775 5月前

    I updated, but the problem still exits, the face indices change differently. A render of it for your viewing pleasure: bug2

    Ill take a little more time familiarizing myself with update_faces, and what really happens.

    For rendering i use the pyqtgraph system. It doesnt support texturing either, i hacked together a simple display that does it.

    点赞 评论 复制链接分享
  • weixin_39554775 weixin_39554775 5月前

    whops

    点赞 评论 复制链接分享
  • weixin_39795479 weixin_39795479 5月前

    Hey I may have time to mess with this in the next couple days- would you be able to provide a minimal working demo that shows this? If you don't want to publish it feel free to email me, my gmail is mik3dh

    It's also possible the recent order- preserving changes in https://github.com/mikedh/trimesh/commit/c019a25874fec33ca6ec3094621743711a29623f fixed this.

    点赞 评论 复制链接分享
  • weixin_39795479 weixin_39795479 5月前

    Ah, there were some very recent changes that may effect this (meshes have face validation off by default). Could you try doing a pip install -U trimesh and see if that helps?

    Texture is only kind of supported- probably the way this should work is meshes loaded with texture should have its mesh.visual object be a TexturedVisual rather than a ColorVisual, which could then support update_faces properly.

    How are you rendering by the way, looks good (at least the non- mangled one 😁)?

    点赞 评论 复制链接分享

相关推荐