Rig a 3D model for animation. Args: model_task_id: Task ID of the model to rig. output_dir: Directory to save output files. rig_type: Type of rigging (biped, quadruped, etc.). spec: Rigging specification (mixamo or tripo). out_format: Output format (
(model_task_id: str, output_dir: str, rig_type: str, spec: str, out_format: str)
| 12 | |
| 13 | |
| 14 | async def main(model_task_id: str, output_dir: str, rig_type: str, spec: str, out_format: str): |
| 15 | """ |
| 16 | Rig a 3D model for animation. |
| 17 | |
| 18 | Args: |
| 19 | model_task_id: Task ID of the model to rig. |
| 20 | output_dir: Directory to save output files. |
| 21 | rig_type: Type of rigging (biped, quadruped, etc.). |
| 22 | spec: Rigging specification (mixamo or tripo). |
| 23 | out_format: Output format (glb or fbx). |
| 24 | """ |
| 25 | async with TripoClient() as client: |
| 26 | # Rig the model |
| 27 | print(f"Rigging model with type: {rig_type}, spec: {spec}, format: {out_format}") |
| 28 | rig_task_id = await client.rig_model( |
| 29 | original_model_task_id=model_task_id, |
| 30 | out_format=out_format, |
| 31 | rig_type=RigType(rig_type) if rig_type else None, |
| 32 | spec=RigSpec(spec) if spec else None |
| 33 | ) |
| 34 | |
| 35 | # Wait for rigging completion and show progress |
| 36 | rig_result = await client.wait_for_task(rig_task_id, verbose=True) |
| 37 | |
| 38 | if rig_result.status == TaskStatus.SUCCESS: |
| 39 | print(f"Rigging completed successfully!") |
| 40 | |
| 41 | # Create output directory (if it doesn't exist) |
| 42 | os.makedirs(output_dir, exist_ok=True) |
| 43 | |
| 44 | # Download rigged model files |
| 45 | try: |
| 46 | print("Downloading rigged model files...") |
| 47 | downloaded_files = await client.download_task_models(rig_result, output_dir) |
| 48 | |
| 49 | # Print downloaded file paths |
| 50 | for model_type, file_path in downloaded_files.items(): |
| 51 | if file_path: |
| 52 | print(f"Downloaded {model_type}: {file_path}") |
| 53 | |
| 54 | except Exception as e: |
| 55 | print(f"Failed to download rigged models: {str(e)}") |
| 56 | else: |
| 57 | print(f"Rigging failed with status: {rig_result.status}") |
| 58 | if rig_result.error_msg: |
| 59 | print(f"Error message: {rig_result.error_msg}") |
| 60 | |
| 61 | |
| 62 | if __name__ == "__main__": |
no test coverage detected