Hello everyone,
Starting from an initial mesh, I have created several sub-meshes using the script provided by Alexey (
https://www.agisoft.com/forum/index.php?topic=14150.0). I now want to texture each of these sub-meshes.
Instead of specifying a number of texture pages for each mesh, I want to define a pixel size so that the number of pages is automatically calculated based on the mesh size. In my algorithm, I specify a pixel size during the buildUV process without setting the page count because I want it to adjust automatically.
However, my problem is that, regardless of the mesh, only one texture file is created. How can I generate multiple texture files without specifying their number in advance?
Thank you in advance for your help,
Best regards,
Etienne
import Metashape
import time
# Start counting time
start = time.time()
doc = Metashape.app.document
# Ask the user for the chunk name
chunk_name = Metashape.app.getString("What is the chunk's name ?")
# Search for the chunk specified by the user
chunk = None
for chunk_it in doc.chunks:
if chunk_name == chunk_it.label:
chunk = chunk_it
break
if chunk is None:
print("Chunk not found. Script aborted.")
raise SystemExit
# Iterate over all Model components of the active chunk
for i in range(len(chunk.models)):
chunk.model = chunk.models[i]
if len(chunk.model.faces)>0 and chunk.model.label != "Modele_3D_final_Landeck":
# Build UVs for each mesh
chunk.buildUV(mapping_mode=Metashape.MappingMode.GenericMapping, pixel_size=0.01, texture_size=8192)
# Build the texture for each mesh
chunk.buildTexture(blending_mode=Metashape.BlendingMode.MosaicBlending, fill_holes=True, ghosting_filter=True)
doc.save()
# Calculate and display execution time
end = time.time()
print(f"Execution time: {end - start} seconds")