Saalvage / AssimpNetter

Maintained fork of AssimpNet that adds better interop with modern C#
https://www.nuget.org/packages/AssimpNetter
Other
3 stars 0 forks source link

Is it possible to create fbx files from vertices, normals etc rather than using exisiting files? #10

Closed MarioGladiator closed 4 days ago

Saalvage commented 4 days ago

Yep, it's possible to create a scene from scratch and export it to a file (e.g. fbx). Here's a minimal example that creates a plane:

using var ctx = new AssimpContext();
var scene = new Scene();
scene.Meshes.Add(new(PrimitiveType.Triangle) {
    Vertices = { new(0, 0, 0), new(1, 0, 0), new(0, 0, 1), new(1, 0, 1) },
    Faces = { new([0, 1, 2]), new([1, 2, 3]) },
});
// Mesh needs a material.
scene.Materials.Add(new());
// Scene needs a root node, mesh should be attached to a node.
scene.RootNode = new() { MeshIndices = { 0 }};
ctx.ExportFile(scene, "test.fbx", "fbx");