Skip to content

Save PLY/OBJ file with texture #64

@KatherineJames

Description

@KatherineJames

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions