Skip to content

UV coordinates ignored by MeshOBJLoader #3012

Closed

Description

@ScheiklP

Problem

When passing an .obj file and texture .png to OglModel, they are correctly loaded and mapped.

visual_node.addObject(
        "OglModel",
        filename="mesh.obj",
        texturename="texture.png",
)

image

For the MeshOBJLoader the UV coordinates are ignored.


loader = visual_node.addObject(
        "MeshOBJLoader",
        filename="mesh.obj",
        handleSeams=True,
)

visual_node.addObject(
        "OglModel",
        texcoords=loader.texcoords,
        texturename="texture.png",
)

image


Environment

Context

  • System: Ubuntu 20.04
  • Version of SOFA: master branch at commit 06899d4
  • State: Install directory

Activity

  1. added
    issue: bug (minor)Bug affecting only some users or with no major impact on the framework
    on Jun 7, 2022
  2. ScheiklP commented on Jun 7, 2022

    @ScheiklP
    ContributorAuthor

    Did some more digging.

    In the code above texcoords=loader.texcoords, is not valid, because the loader did not actually read any data yet.

    image

    Changing it to

    loader = visual_node.addObject(
            "MeshOBJLoader",
            filename="mesh.obj",
            handleSeams=True,
    )
    
    loader.init()
    
    visual_node.addObject(
            "OglModel",
            texcoords=loader.texcoords,
            texturename="texture.png",
    )
    

    fixed the issue. Is this still valid behavior?

  3. epernod commented on Jun 7, 2022

    @epernod
    Contributor

    yes you need to use handleSeams = true if you want to use the vertices buffer + texcoords.
    But this mode can't be used as input of a mechanical mesh because some vertices are duplicated for the UV coordinates.

  4. ScheiklP commented on Jun 7, 2022

    @ScheiklP
    ContributorAuthor

    handleSeams = True was set in both cases. The main problem was that the loader was not initialized.
    It worked best (also without the init) when passing the LinkPath, and not the data container itself.
    So I guess this is more a thing of having example code than a bug.

    Where would be the best place to document an example like this?

    loader = visual_node.addObject(
            "MeshOBJLoader",
            filename="mesh.obj",
    )
    
    visual_node.addObject(
            "OglModel",
            texcoords=loader.texcoords.getLinkPath(),
            texturename="texture.png",
    )
    
  5. damienmarchal commented on Jun 9, 2022

    @damienmarchal
    Contributor

    Hi @ScheiklP

    Thanks for reporting and you are right in your conclusion (it is because that the object does not need to be initialize when created in python).

    Actually getting rid of the need to init the data is a long standing issue: see sofa-framework/SofaPython3#173

    This PR is probably the place to have future discussion on that topic and I close the issue,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue: bug (minor)Bug affecting only some users or with no major impact on the framework

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions