Fix arm mesh import export

This commit is contained in:
luboslenco
2024-09-26 18:44:23 +02:00
parent 50c403313f
commit 4cc0b38aa0
2 changed files with 41 additions and 7 deletions
+16 -7
View File
@@ -1,11 +1,21 @@
let scene_raw_gc: scene_t;
function import_arm_run_project(path: string) {
let b: buffer_t = data_get_blob(path);
let project: project_format_t;
let import_as_mesh: bool = false;
if (import_arm_is_legacy(b)) {
project = import_arm_from_legacy(b);
}
else if (!import_arm_has_version(b)) {
import_as_mesh = true;
scene_raw_gc = armpack_decode(b);
project = {
mesh_datas: scene_raw_gc.mesh_datas
};
}
else {
project = armpack_decode(b);
}
@@ -26,16 +36,10 @@ function import_arm_run_project(path: string) {
}
return;
}
let import_as_mesh: bool = b[10] != 118; // 'v', no version
context_raw.layers_preview_dirty = true;
context_raw.layer_filter = 0;
///end
///if is_lab
let import_as_mesh: bool = true;
///end
project_new(import_as_mesh);
project_filepath = path;
ui_files_filename = substring(path, string_last_index_of(path, path_sep) + 1, string_last_index_of(path, "."));
@@ -402,7 +406,7 @@ function import_arm_run_project(path: string) {
}
///if (is_paint || is_sculpt)
function import_arm_run_mesh(raw: scene_t) {
function import_arm_run_mesh(raw: project_format_t) {
project_paint_objects = [];
for (let i: i32 = 0; i < raw.mesh_datas.length; ++i) {
let md: mesh_data_t = mesh_data_create(raw.mesh_datas[i]);
@@ -827,6 +831,11 @@ function _import_arm_get_node_canvas_array(map: map_t<string, any>, key: string)
return ar;
}
function import_arm_has_version(b: buffer_t): bool {
let has_version: bool = b[10] == 118; // 'v';
return has_version;
}
function import_arm_is_legacy(b: buffer_t): bool {
// Cloud materials are at version 0.8 / 0.9
let has_version: bool = b[10] == 118; // 'v'
+25
View File
@@ -4,7 +4,32 @@ function util_encode_scene(raw: scene_t): buffer_t {
let encoded: buffer_t = buffer_create(size);
armpack_encode_start(encoded.buffer);
armpack_encode_map(13);
armpack_encode_string("name");
armpack_encode_null();
armpack_encode_string("objects");
armpack_encode_null();
util_encode_mesh_datas(raw.mesh_datas);
armpack_encode_string("light_datas");
armpack_encode_null();
armpack_encode_string("camera_datas");
armpack_encode_null();
armpack_encode_string("camera_ref");
armpack_encode_null();
armpack_encode_string("material_datas");
armpack_encode_null();
armpack_encode_string("shader_datas");
armpack_encode_null();
armpack_encode_string("world_datas");
armpack_encode_null();
armpack_encode_string("world_ref");
armpack_encode_null();
armpack_encode_string("particle_datas");
armpack_encode_null();
armpack_encode_string("speaker_datas");
armpack_encode_null();
armpack_encode_string("embedded_datas");
armpack_encode_null();
let ei: i32 = armpack_encode_end();
encoded.length = ei;