Add io_fbx plugin
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
|
||||
class ImportFbx {
|
||||
|
||||
static run = (path: string, replaceExisting = true) => {
|
||||
Data.getBlob(path, (b: ArrayBuffer) => {
|
||||
|
||||
///if arm_fbx
|
||||
ParserFbx.parseTransform = Context.raw.parseTransform;
|
||||
ParserFbx.parseVCols = Context.raw.parseVCols;
|
||||
let obj = new ParserFbx(b);
|
||||
replaceExisting ? ImportMesh.makeMesh(obj, path) : ImportMesh.addMesh(obj);
|
||||
while (obj.next()) {
|
||||
ImportMesh.addMesh(obj);
|
||||
}
|
||||
Data.deleteBlob(path);
|
||||
///end
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
+24
-13
@@ -31,13 +31,24 @@ class ImportMesh {
|
||||
|
||||
let p = path.toLowerCase();
|
||||
if (p.endsWith(".obj")) ImportObj.run(path, replaceExisting);
|
||||
else if (p.endsWith(".fbx")) ImportFbx.run(path, replaceExisting);
|
||||
else if (p.endsWith(".blend")) ImportBlendMesh.run(path, replaceExisting);
|
||||
else {
|
||||
let ext = path.substr(path.lastIndexOf(".") + 1);
|
||||
let importer = Path.meshImporters.get(ext);
|
||||
importer(path, (mesh: any) => {
|
||||
replaceExisting ? ImportMesh.makeMesh(mesh, path) : ImportMesh.addMesh(mesh);
|
||||
|
||||
let has_next = mesh.has_next;
|
||||
while (has_next) {
|
||||
importer(path, (mesh: any) => {
|
||||
has_next = mesh.has_next;
|
||||
ImportMesh.addMesh(mesh);
|
||||
|
||||
// let m = Mat4.fromFloat32Array(mesh.transform);
|
||||
// Project.paintObjects[Project.paintObjects.length - 1].transform.localOnly = true;
|
||||
// Project.paintObjects[Project.paintObjects.length - 1].transform.setMatrix(m);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,18 +121,6 @@ class ImportMesh {
|
||||
Data.deleteMesh(handle);
|
||||
}
|
||||
|
||||
///if (is_paint || is_sculpt)
|
||||
if (ImportMesh.clearLayers) {
|
||||
while (Project.layers.length > 0) {
|
||||
let l = Project.layers.pop();
|
||||
l.unload();
|
||||
}
|
||||
Base.newLayer(false);
|
||||
App.notifyOnInit(Base.initLayers);
|
||||
History.reset();
|
||||
}
|
||||
///end
|
||||
|
||||
Context.raw.paintObject.setData(md);
|
||||
Context.raw.paintObject.name = mesh.name;
|
||||
Project.paintObjects = [Context.raw.paintObject];
|
||||
@@ -139,6 +138,18 @@ class ImportMesh {
|
||||
UtilUV.dilatemapCached = false;
|
||||
///end
|
||||
|
||||
///if (is_paint || is_sculpt)
|
||||
if (ImportMesh.clearLayers) {
|
||||
while (Project.layers.length > 0) {
|
||||
let l = Project.layers.pop();
|
||||
l.unload();
|
||||
}
|
||||
Base.newLayer(false);
|
||||
App.notifyOnInit(Base.initLayers);
|
||||
History.reset();
|
||||
}
|
||||
///end
|
||||
|
||||
// Wait for addMesh calls to finish
|
||||
if (ImportMesh.meshesToUnwrap != null) {
|
||||
Base.notifyOnNextFrame(ImportMesh.finishImport);
|
||||
|
||||
@@ -9,7 +9,7 @@ class Path {
|
||||
///end
|
||||
}
|
||||
|
||||
static meshFormats = ["obj", "fbx", "blend"];
|
||||
static meshFormats = ["obj", "blend"];
|
||||
static textureFormats = ["jpg", "jpeg", "png", "tga", "bmp", "psd", "gif", "hdr", "k"];
|
||||
|
||||
static meshImporters = new Map<string, (s: string, f: (a: any)=>void)=>void>();
|
||||
|
||||
@@ -391,13 +391,14 @@ class Project {
|
||||
if (ui.isHovered) ui.tooltip(tr("Split .obj mesh into objects"));
|
||||
}
|
||||
|
||||
if (path.toLowerCase().endsWith(".fbx")) {
|
||||
Context.raw.parseTransform = ui.check(Zui.handle("project_5", { selected: Context.raw.parseTransform }), tr("Parse Transforms"));
|
||||
if (ui.isHovered) ui.tooltip(tr("Load per-object transforms from .fbx"));
|
||||
}
|
||||
// if (path.toLowerCase().endsWith(".fbx")) {
|
||||
// Context.raw.parseTransform = ui.check(Zui.handle("project_5", { selected: Context.raw.parseTransform }), tr("Parse Transforms"));
|
||||
// if (ui.isHovered) ui.tooltip(tr("Load per-object transforms from .fbx"));
|
||||
// }
|
||||
|
||||
///if (is_paint || is_sculpt)
|
||||
if (path.toLowerCase().endsWith(".fbx") || path.toLowerCase().endsWith(".blend")) {
|
||||
// if (path.toLowerCase().endsWith(".fbx") || path.toLowerCase().endsWith(".blend")) {
|
||||
if (path.toLowerCase().endsWith(".blend")) {
|
||||
Context.raw.parseVCols = ui.check(Zui.handle("project_6", { selected: Context.raw.parseVCols }), tr("Parse Vertex Colors"));
|
||||
if (ui.isHovered) ui.tooltip(tr("Import vertex color data"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user