Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save PLY/OBJ file with texture #64

Open
KatherineJames opened this issue Sep 25, 2024 · 2 comments
Open

Save PLY/OBJ file with texture #64

KatherineJames opened this issue Sep 25, 2024 · 2 comments
Assignees

Comments

@KatherineJames
Copy link

When I create a plant model in LPy, I am able to view it in the integrated PlantGL viewer with the relevant textures loaded on the plant organs correctly. However, when exporting to ply through the viewer, the textures do not save. It would be super if this could be fixed so that they do.

I have also tried to programmatically save an .obj, but textures cause the built in functions below to fail.

lstring = lsys.derive()
lscene = lsys.sceneInterpretation(lstring)
lscene.save(f"mesh.obj")

I have investigated further and am able to manually save points and faces to an .obj, but I have found that the texture coordinates are missing and just set to None for each shape. I was hoping you may be able to enlighten me as to how I can save my plant model with its textures as either ply or obj. I have tried recalculating texture vertices, but this currently maps the textures wrongly and I am sure that the real values are somehow lost at some point since it is mapped correctly in the PlantGL viewer from LPy.

Minimal code to illustrate issue below:

def tessellate_geometry(geometry):
"""Convert parametric shapes into a TriangleSet."""
tesselator = Tesselator()
tesselator.process(geometry)
return tesselator.triangulation

...
for shape in scene:
geometry = shape.geometry
     
if isinstance(geometry, Translated):
tesselated_geom = tessellate_geometry(geometry.geometry)
      # tesselated_geom.texCoordList is None

@KatherineJames
Copy link
Author

Upon further digging, saving as an .obj using lscene.save only fails if the special primitive ~l is used to make a leaf shape with a texture assigned to it somewhere in the production rules.

@pradal
Copy link
Contributor

pradal commented Oct 8, 2024

@fredboudon I think this is for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants