Skip to content

Commit

Permalink
QBO format importer work
Browse files Browse the repository at this point in the history
get animations to import

fix animation name replacement logic for scene resource imports given "/" prefix scheme from "get_animation_list"

still debugging animations

Apply code formatting.

Implement QBODocument.

Move into modules.

Add append_from_buffer.

Calculate skins before skeletons.

Add qbo editor import.

Apply code style.

Add error checking.

Fixes.

Handling for Closing Braces (} to correctly pop the parent stack when a joint's block ends.

Set the node names correctly.

Set the gltf node to be a joint.

Finish parsing animations

_create_skeletons isn't working.

Reduce.

Save work.

Apply format.

Add debug.

Fixes

Add a qbo unit test.

Add unit tests for QBODocument.

I tested with `./bin/godot.macos.editor.dev.double.arm64 --test --test-case="*[QBODocument]*"` and ` scons vulkan=no precision=double compiledb=yes tests=yes dev_build=yes`.

Update modules/qbo/config.py
Update modules/qbo/qbo_document.cpp
Add more logging.

Use p_state.

Avoid crash.

compute qbo node heights

Make the tests work.

Handle surface indexing better, and satisfy gltf node's mesh instance child expectation

Update tests.

Tune down the logging.

Reverse triangle winding.

Fix skeleton offset axis convention first.

Fix skeleton axis convention try 2.

Revert.

Co-Authored-By: Pierce Brooks <[email protected]>
  • Loading branch information
PierceLBrooks authored and fire committed Feb 12, 2025
1 parent 296de7d commit d6609bb
Show file tree
Hide file tree
Showing 17 changed files with 1,398 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/gltf/gltf_document.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class GLTFDocument : public Resource {
protected:
static void _bind_methods();
String _gen_unique_name(Ref<GLTFState> p_state, const String &p_name);
void _compute_node_heights(Ref<GLTFState> p_state);
static Vector<Ref<GLTFDocumentExtension>> all_document_extensions;
Vector<Ref<GLTFDocumentExtension>> document_extensions;

Expand Down Expand Up @@ -127,7 +128,6 @@ class GLTFDocument : public Resource {
const GLTFTextureIndex p_texture);
Error _parse_json(const String &p_path, Ref<GLTFState> p_state);
Error _parse_glb(Ref<FileAccess> p_file, Ref<GLTFState> p_state);
void _compute_node_heights(Ref<GLTFState> p_state);
Error _parse_buffers(Ref<GLTFState> p_state, const String &p_base_path);
Error _parse_buffer_views(Ref<GLTFState> p_state);
GLTFAccessor::GLTFAccessorType _get_accessor_type_from_str(const String &p_string);
Expand Down
1 change: 1 addition & 0 deletions modules/gltf/gltf_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
class GLTFState : public Resource {
GDCLASS(GLTFState, Resource);
friend class GLTFDocument;
friend class QBODocument;
friend class GLTFNode;

protected:
Expand Down
1 change: 1 addition & 0 deletions modules/gltf/structures/gltf_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GLTFNode : public Resource {
friend class GLTFDocument;
friend class SkinTool;
friend class FBXDocument;
friend class QBODocument;

private:
String original_name;
Expand Down
33 changes: 33 additions & 0 deletions modules/qbo/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *

Import("env")
Import("env_modules")

env_qbo = env_modules.Clone()

# Thirdparty source files

thirdparty_obj = []

env_thirdparty = env_qbo.Clone()
env_thirdparty.disable_warnings()

thirdparty_sources = []

env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
env.modules_sources += thirdparty_obj

# Godot source files

module_obj = []

env_qbo.add_source_files(module_obj, "*.cpp")

env.modules_sources += module_obj

# Needed to force rebuilding the module files when the thirdparty library is updated.
env.Depends(module_obj, thirdparty_obj)

if env.editor_build:
env_qbo.add_source_files(env.modules_sources, "editor/*.cpp")
15 changes: 15 additions & 0 deletions modules/qbo/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def can_build(env, platform):
env.module_add_dependencies("qbo", ["gltf"])
return not env["disable_3d"]


def configure(env):
pass


def get_doc_classes():
return ["QBODocument", "EditorSceneFormatImporterQBO"]


def get_doc_path():
return "doc_classes"
9 changes: 9 additions & 0 deletions modules/qbo/doc_classes/EditorSceneFormatImporterQBO.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorSceneFormatImporterQBO" inherits="EditorSceneFormatImporter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
</class>
9 changes: 9 additions & 0 deletions modules/qbo/doc_classes/QBODocument.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="QBODocument" inherits="GLTFDocument" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
</class>
77 changes: 77 additions & 0 deletions modules/qbo/editor/editor_scene_importer_qbo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/**************************************************************************/
/* editor_scene_importer_qbo.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#include "editor_scene_importer_qbo.h"

#ifdef TOOLS_ENABLED

#include "modules/qbo/qbo_document.h"

void EditorSceneFormatImporterQBO::get_extensions(List<String> *r_extensions) const {
r_extensions->push_back("qbo");
}

Node *EditorSceneFormatImporterQBO::import_scene(const String &p_path, uint32_t p_flags,
const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err) {
Ref<QBODocument> gltf;
gltf.instantiate();
Ref<GLTFState> state;
state.instantiate();
if (p_options.has("gltf/naming_version")) {
int naming_version = p_options["gltf/naming_version"];
gltf->set_naming_version(naming_version);
}
if (p_options.has("gltf/embedded_image_handling")) {
int32_t enum_option = p_options["gltf/embedded_image_handling"];
state->set_handle_binary_image(enum_option);
}
if (p_options.has(SNAME("nodes/import_as_skeleton_bones")) ? (bool)p_options[SNAME("nodes/import_as_skeleton_bones")] : false) {
state->set_import_as_skeleton_bones(true);
}
if (p_options.has(SNAME("extract_path"))) {
state->set_extract_path(p_options["extract_path"]);
}
state->set_bake_fps(p_options["animation/fps"]);
Error err = gltf->append_from_file(p_path, state, p_flags);
if (err != OK) {
if (r_err) {
*r_err = err;
}
return nullptr;
}
if (p_options.has("animation/import")) {
state->set_create_animations(bool(p_options["animation/import"]));
}

return gltf->generate_scene(state, state->get_bake_fps(), (bool)p_options["animation/trimming"], false);
}

#endif // TOOLS_ENABLED
53 changes: 53 additions & 0 deletions modules/qbo/editor/editor_scene_importer_qbo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**************************************************************************/
/* editor_scene_importer_qbo.h */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/

#ifndef EDITOR_SCENE_IMPORTER_QBO_H
#define EDITOR_SCENE_IMPORTER_QBO_H

#ifdef TOOLS_ENABLED

#include "editor/import/3d/resource_importer_scene.h"

class Animation;
class Node;

class EditorSceneFormatImporterQBO : public EditorSceneFormatImporter {
GDCLASS(EditorSceneFormatImporterQBO, EditorSceneFormatImporter);

public:
virtual void get_extensions(List<String> *r_extensions) const override;
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err = nullptr) override;
};

#endif // TOOLS_ENABLED

#endif // EDITOR_SCENE_IMPORTER_QBO_H
Loading

0 comments on commit d6609bb

Please sign in to comment.