Skip to content

Add: [AssimpImport], [AssimpExport]#956

Open
banidu-512 wants to merge 1 commit intotixl3d:mainfrom
banidu-512:feat/assimp
Open

Add: [AssimpImport], [AssimpExport]#956
banidu-512 wants to merge 1 commit intotixl3d:mainfrom
banidu-512:feat/assimp

Conversation

@banidu-512
Copy link
Contributor

Operators for importing and exporting 3D model files using the Assimp library (via AssimpNetter).

AssimpImport

The ultimate simple 3D model loader supporting 40+ file formats including OBJ, FBX, GLTF, GLB, STL, PLY, COLLADA, 3DS, BLEND, and more.

Inputs

Name Type Default Description
FilePath string "" Path to 3D model file
PostProcessFlags enum Basic Preprocessing preset: None, Basic, Full
Scale float 1.0 Uniform scale multiplier
Normalize bool true Normalize model to fit in unit cube
AxisConversion enum None Axis conversion mode
FlipNormals bool false Flip all vertex normals
SelectedMeshIndex int -1 Load specific mesh (-1 for all)

PostProcessFlags Options

  • None - Raw mesh data, no processing
  • Basic - Triangulate + generate smooth normals (default)
  • Full - All optimizations: triangulation, smooth normals, UV generation, tangent space calculation, vertex joining, material cleanup, cache locality optimization

AxisConversion Options

  • None - No transformation
  • YUpToZUp - Convert Y-up coordinate system to Z-up
  • ZUpToYUp - Convert Z-up coordinate system to Y-up
  • FlipX - Mirror across X axis
  • FlipY - Mirror across Y axis
  • FlipZ - Mirror across Z axis

Outputs

Name Type Description
MeshData MeshBuffers GPU buffers for mesh rendering (vertices + indices)
Points BufferWithViews Points at each vertex position
Metadata string Human-readable info (vertices, faces, bounds, etc.)
VertexCount int Total vertex count
FaceCount int Total face/triangle count
MeshCount int Number of meshes in file
BoundsMin Vector3 Bounding box minimum corner
BoundsMax Vector3 Bounding box maximum corner
MeshNames string Pipe-delimited list of mesh names
SkeletonBuffers SkeletonBuffers Bone buffers, skin weight buffers, and animation metadata
BoneCount int Number of bones in skeleton
AnimationCount int Number of animation clips
AnimationNames string Pipe-delimited list of animation names

Features

  • Multi-mesh support - Load all meshes from a file or select a specific one by index
  • Automatic tangent calculation - Computes proper tangent space for normal mapping with degenerate UV handling
  • Vertex color support - Stores first color channel in Selection field
  • Metadata output - Get statistics about loaded models
  • Resource caching - Efficient file loading with automatic caching
  • Parameter change detection - PostProcessFlags changes trigger automatic reload
  • Proper normalization - Normals are renormalized after scaling/normalization
  • Animation support - Extract bone hierarchy, skin weights, and animation clip metadata
  • Skeletal animation buffers - GPU buffers for bones (bind/offset matrices) and vertex skin weights (up to 4 influences per vertex)

AssimpExport

Export mesh or point cloud data to various 3D file formats with automatic counter-based naming.

Inputs

Name Type Default Description
MeshData MeshBuffers null GPU mesh buffers to export
Points BufferWithViews null Points to export (alternative to mesh)
FolderPath string "exports" Output folder path (files auto-named)
ExportMesh bool trigger Trigger button to export mesh data
ExportPoints bool trigger Trigger button to export point data
ExportFormat enum Auto Format preset (determines file extension)
MeshName string "mesh" Base name for exported files
ResetCounter bool trigger Reset export counter to 1
MaxVertexCount int 0 Maximum vertices/points to export (0 = no limit)
CustomFormat string "" Custom format ID (when ExportFormat is Custom)
GltfOptions enum Default glTF/GLB export options (reserved)

ExportFormat Options

  • Auto - Default to FBX format
  • Obj - Wavefront OBJ (.obj)
  • Fbx - Autodesk FBX (.fbx)
  • Gltf - glTF 2.0 JSON (.gltf)
  • Glb - glTF 2.0 Binary (.glb)
  • Stl - STL for 3D printing (.stl)
  • Ply - Stanford PLY (.ply)
  • Collada - COLLADA (.dae)
  • ThreeDs - 3D Studio (.3ds)
  • Custom - Use custom format ID

Outputs

Name Type Description
Success bool True if export succeeded
StatusMessage string Export result: filename or error message

Features

  • Automatic counter-based naming - Files are named MeshName_001.ext, MeshName_002.ext, etc.
  • Folder-based output - Specify a folder; filenames are generated automatically
  • Dual export triggers - Separate buttons for mesh and point cloud export
  • Counter reset - Reset the counter to start a new export sequence
  • Vertex/Point limiter - Set MaxVertexCount > 0 to limit exported vertices/points (0 = no limit)
  • Wide format support - Export to 20+ formats (FBX, glTF, OBJ, STL, PLY, COLLADA, 3DS, etc.)
  • Complete data export - Includes tangents, bitangents, and vertex colors when present
  • Automatic directory creation - Creates output directories if they don't exist
  • Filename sanitization - Invalid characters in MeshName are automatically replaced with underscores

Usage Examples

Basic mesh export

CubeMesh → AssimpExport (FolderPath: "exports", MeshName: "cube", ExportFormat: Fbx, ExportMesh: trigger)
→ Creates: exports/cube_001.fbx, cube_002.fbx, etc.

Export to glTF

Model → AssimpExport (FolderPath: "C:/Models/glTF", MeshName: "character", ExportFormat: Glb, ExportMesh: trigger)
→ Creates: C:/Models/glTF/character_001.glb

Export point cloud

PointCloud → AssimpExport (FolderPath: "pointclouds", ExportFormat: Ply, ExportPoints: trigger)
→ Creates: pointclouds/mesh_001.ply

Reset counter and start new sequence

Counter → IntDisplay
AssimpExport (ResetCounter: trigger) → Counter resets to 1

Export loop (exporting frames)

Time (0..1) → AssimpExport (ExportMesh: triggered each time)
→ Creates: mesh_001.fbx, mesh_002.fbx, ..., mesh_999.fbx

Technical Notes

  • Uses AssimpNetter v6.0.2.1 (Assimp 6.x)
  • Import uses Resource caching pattern for efficient file loading
  • Export reads back GPU buffers using staging resources
  • Proper disposal of GPU resources implemented
  • Tangent space calculation uses the Lengyel algorithm with degenerate UV protection
  • Automatic triangulation of quads and n-gons
  • Smoothing groups converted to vertex normals
  • PostProcessFlags changes trigger automatic reload via cache invalidation
  • Normals are renormalized after scaling/normalization to maintain unit length
  • Export includes tangents, bitangents, and vertex colors when available
  • Output directories are created automatically if needed
  • Filename sanitization removes invalid characters (<>:"/\|?*) and limits length to 100 characters

Supported Formats

Import Formats (40+)

3DS, 3D, AC, AC3D, ACC, AMJ, ASE, ASK, B3D, BLEND, BVH, COB, DXF, ENFF, FBX, GLTF, GLB, IRR, IRRMESH, LWO, LWS, LXO, MD2, MD3, MD5, MDC, MDL, NFF, NDO, OBJ, OFF, OGEX, PLY, MS3D, LWO, RRM, Q3D, Q3BSP, RAW, SIB, SMD, STP, STL, TERRAGEN, 3D, X, X3D, XGL, ZGL

Export Formats (20+)

3DS, ASE, ASSBIN, ASSXML, BVH, COLLADA, DXF, FBX, GLB, GLTF, M3D, OBJ, PLY, PMD, PMX, STEP, STL, TER, X, X3D, XGL

Operators for importing and exporting 3D model files using the Assimp library (via AssimpNetter).

## AssimpImport

The ultimate simple 3D model loader supporting 40+ file formats including OBJ, FBX, GLTF, GLB, STL, PLY, COLLADA, 3DS, BLEND, and more.

### Inputs

| Name                | Type   | Default | Description                             |
|---------------------|--------|---------|-----------------------------------------|
| `FilePath`          | string | ""      | Path to 3D model file                   |
| `PostProcessFlags`  | enum   | Basic   | Preprocessing preset: None, Basic, Full |
| `Scale`             | float  | 1.0     | Uniform scale multiplier                |
| `Normalize`         | bool   | true    | Normalize model to fit in unit cube     |
| `AxisConversion`    | enum   | None    | Axis conversion mode                    |
| `FlipNormals`       | bool   | false   | Flip all vertex normals                 |
| `SelectedMeshIndex` | int    | -1      | Load specific mesh (-1 for all)         |

### PostProcessFlags Options

- **None** - Raw mesh data, no processing
- **Basic** - Triangulate + generate smooth normals (default)
- **Full** - All optimizations: triangulation, smooth normals, UV generation, tangent space calculation, vertex joining, material cleanup, cache locality
  optimization

### AxisConversion Options

- **None** - No transformation
- **YUpToZUp** - Convert Y-up coordinate system to Z-up
- **ZUpToYUp** - Convert Z-up coordinate system to Y-up
- **FlipX** - Mirror across X axis
- **FlipY** - Mirror across Y axis
- **FlipZ** - Mirror across Z axis

### Outputs

| Name              | Type            | Description                                               |
|-------------------|-----------------|-----------------------------------------------------------|
| `MeshData`        | MeshBuffers     | GPU buffers for mesh rendering (vertices + indices)       |
| `Points`          | BufferWithViews | Points at each vertex position                            |
| `Metadata`        | string          | Human-readable info (vertices, faces, bounds, etc.)       |
| `VertexCount`     | int             | Total vertex count                                        |
| `FaceCount`       | int             | Total face/triangle count                                 |
| `MeshCount`       | int             | Number of meshes in file                                  |
| `BoundsMin`       | Vector3         | Bounding box minimum corner                               |
| `BoundsMax`       | Vector3         | Bounding box maximum corner                               |
| `MeshNames`       | string          | Pipe-delimited list of mesh names                         |
| `SkeletonBuffers` | SkeletonBuffers | Bone buffers, skin weight buffers, and animation metadata |
| `BoneCount`       | int             | Number of bones in skeleton                               |
| `AnimationCount`  | int             | Number of animation clips                                 |
| `AnimationNames`  | string          | Pipe-delimited list of animation names                    |

### Features

- **Multi-mesh support** - Load all meshes from a file or select a specific one by index
- **Automatic tangent calculation** - Computes proper tangent space for normal mapping with degenerate UV handling
- **Vertex color support** - Stores first color channel in Selection field
- **Metadata output** - Get statistics about loaded models
- **Resource caching** - Efficient file loading with automatic caching
- **Parameter change detection** - PostProcessFlags changes trigger automatic reload
- **Proper normalization** - Normals are renormalized after scaling/normalization
- **Animation support** - Extract bone hierarchy, skin weights, and animation clip metadata
- **Skeletal animation buffers** - GPU buffers for bones (bind/offset matrices) and vertex skin weights (up to 4 influences per vertex)

## AssimpExport

Export mesh or point cloud data to various 3D file formats with automatic counter-based naming.

### Inputs

| Name             | Type            | Default   | Description                                      |
|------------------|-----------------|-----------|--------------------------------------------------|
| `MeshData`       | MeshBuffers     | null      | GPU mesh buffers to export                       |
| `Points`         | BufferWithViews | null      | Points to export (alternative to mesh)           |
| `FolderPath`     | string          | "exports" | Output folder path (files auto-named)            |
| `ExportMesh`     | bool            | trigger   | Trigger button to export mesh data               |
| `ExportPoints`   | bool            | trigger   | Trigger button to export point data              |
| `ExportFormat`   | enum            | Auto      | Format preset (determines file extension)        |
| `MeshName`       | string          | "mesh"    | Base name for exported files                     |
| `ResetCounter`   | bool            | trigger   | Reset export counter to 1                        |
| `MaxVertexCount` | int             | 0         | Maximum vertices/points to export (0 = no limit) |
| `CustomFormat`   | string          | ""        | Custom format ID (when ExportFormat is Custom)   |
| `GltfOptions`    | enum            | Default   | glTF/GLB export options (reserved)               |

### ExportFormat Options

- **Auto** - Default to FBX format
- **Obj** - Wavefront OBJ (.obj)
- **Fbx** - Autodesk FBX (.fbx)
- **Gltf** - glTF 2.0 JSON (.gltf)
- **Glb** - glTF 2.0 Binary (.glb)
- **Stl** - STL for 3D printing (.stl)
- **Ply** - Stanford PLY (.ply)
- **Collada** - COLLADA (.dae)
- **ThreeDs** - 3D Studio (.3ds)
- **Custom** - Use custom format ID

### Outputs

| Name            | Type   | Description                              |
|-----------------|--------|------------------------------------------|
| `Success`       | bool   | True if export succeeded                 |
| `StatusMessage` | string | Export result: filename or error message |

### Features

- **Automatic counter-based naming** - Files are named `MeshName_001.ext`, `MeshName_002.ext`, etc.
- **Folder-based output** - Specify a folder; filenames are generated automatically
- **Dual export triggers** - Separate buttons for mesh and point cloud export
- **Counter reset** - Reset the counter to start a new export sequence
- **Vertex/Point limiter** - Set `MaxVertexCount` > 0 to limit exported vertices/points (0 = no limit)
- **Wide format support** - Export to 20+ formats (FBX, glTF, OBJ, STL, PLY, COLLADA, 3DS, etc.)
- **Complete data export** - Includes tangents, bitangents, and vertex colors when present
- **Automatic directory creation** - Creates output directories if they don't exist
- **Filename sanitization** - Invalid characters in MeshName are automatically replaced with underscores

### Usage Examples

#### Basic mesh export

```
CubeMesh → AssimpExport (FolderPath: "exports", MeshName: "cube", ExportFormat: Fbx, ExportMesh: trigger)
→ Creates: exports/cube_001.fbx, cube_002.fbx, etc.
```

#### Export to glTF

```
Model → AssimpExport (FolderPath: "C:/Models/glTF", MeshName: "character", ExportFormat: Glb, ExportMesh: trigger)
→ Creates: C:/Models/glTF/character_001.glb
```

#### Export point cloud

```
PointCloud → AssimpExport (FolderPath: "pointclouds", ExportFormat: Ply, ExportPoints: trigger)
→ Creates: pointclouds/mesh_001.ply
```

#### Reset counter and start new sequence

```
Counter → IntDisplay
AssimpExport (ResetCounter: trigger) → Counter resets to 1
```

#### Export loop (exporting frames)

```
Time (0..1) → AssimpExport (ExportMesh: triggered each time)
→ Creates: mesh_001.fbx, mesh_002.fbx, ..., mesh_999.fbx
```

## Technical Notes

- Uses AssimpNetter v6.0.2.1 (Assimp 6.x)
- Import uses Resource<T> caching pattern for efficient file loading
- Export reads back GPU buffers using staging resources
- Proper disposal of GPU resources implemented
- Tangent space calculation uses the Lengyel algorithm with degenerate UV protection
- Automatic triangulation of quads and n-gons
- Smoothing groups converted to vertex normals
- PostProcessFlags changes trigger automatic reload via cache invalidation
- Normals are renormalized after scaling/normalization to maintain unit length
- Export includes tangents, bitangents, and vertex colors when available
- Output directories are created automatically if needed
- Filename sanitization removes invalid characters (<>:"/\\|?*) and limits length to 100 characters

## Supported Formats

### Import Formats (40+)

3DS, 3D, AC, AC3D, ACC, AMJ, ASE, ASK, B3D, BLEND, BVH, COB, DXF, ENFF, FBX, GLTF, GLB, IRR, IRRMESH, LWO, LWS, LXO, MD2, MD3, MD5, MDC, MDL, NFF, NDO, OBJ,
OFF, OGEX, PLY, MS3D, LWO, RRM, Q3D, Q3BSP, RAW, SIB, SMD, STP, STL, TERRAGEN, 3D, X, X3D, XGL, ZGL

### Export Formats (20+)

3DS, ASE, ASSBIN, ASSXML, BVH, COLLADA, DXF, FBX, GLB, GLTF, M3D, OBJ, PLY, PMD, PMX, STEP, STL, TER, X, X3D, XGL
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

Successfully merging this pull request may close these issues.

1 participant