Skip to content

Commit

Permalink
Sync with cddb3e0 (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
qnzhou committed Apr 5, 2024
1 parent fff2d84 commit 04ca90a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
CIBW_TEST_REQUIRES: pytest
MACOSX_DEPLOYMENT_TARGET: 11.00
CIBW_BUILD_VERBOSITY: 2
SYSTEM_VERSION_COMPAT: 1

- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.21.0
6.21.1
62 changes: 62 additions & 0 deletions modules/core/python/scripts/meshconvert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python

import argparse
import lagrange
from pathlib import Path


def parse_args():
parser = argparse.ArgumentParser(
description="Convert a mesh file to a different format."
)
parser.add_argument("input_mesh", help="input mesh file")
parser.add_argument("output_mesh", help="output mesh file")
parser.add_argument(
"--triangulate", "-t", action="store_true", help="triangulate the mesh"
)
parser.add_argument(
"--logging-level",
"-l",
default="info",
help="logging level",
choices=["debug", "info", "warning", "error", "critical"],
)
return parser.parse_args()


def main():
args = parse_args()
lagrange.logger.setLevel(args.logging_level.upper())
input_suffix = Path(args.input_mesh).suffix
output_suffix = Path(args.output_mesh).suffix
if input_suffix in [".fbx", ".gltf", ".glb"]:
lagrange.logger.info(f"Loading input scene from {args.input_mesh}")
scene = lagrange.io.load_simple_scene(args.input_mesh)
if input_suffix in [".gltf", ".glb"]:
for i in range(scene.num_meshes):
mesh = scene.ref_mesh(i)
lagrange.remove_duplicate_vertices(mesh)

if args.triangulate:
for i in range(scene.num_meshes):
mesh = scene.ref_mesh(i)
lagrange.triangulate_polygonal_facets(mesh)

if output_suffix in [".gltf", ".glb"]:
lagrange.logger.info(f"Saving output scene in {args.output_mesh}")
lagrange.io.save_simple_scene(args.output_mesh, scene)
else:
lagrange.logger.info(f"Saving output mesh in {args.output_mesh}")
mesh = lagrange.scene.simple_scene_to_mesh(scene)
lagrange.io.save_mesh(args.output_mesh, mesh)
else:
lagrange.logger.info(f"Loading input mesh from {args.input_mesh}")
mesh = lagrange.io.load_mesh(args.input_mesh)
if not mesh.is_regular and args.triangulate:
lagrange.triangulate_polygonal_facets(mesh)
lagrange.logger.info(f"Saving output mesh in {args.output_mesh}")
lagrange.io.save_mesh(args.output_mesh, mesh)


if __name__ == "__main__":
main()

0 comments on commit 04ca90a

Please sign in to comment.