Godot Version
4.2
Question
So I am trying to import .vox files to the editor. For this I want to use CPP. I did not implement the _import yet because it seems it does not even get called. I tried using the vox plugin as an example and I left in the gdexample so I can check if even something gets loaded.
So to check if the vox_importer gets loaded I use “ERR_PRINT(“vox_importer hello”);” but this does not get called. And it should print the message /error message “imported vox” if i try to import a .vox file. I just want to create a working base but I think i am doing something wrong with the register_types.
Please someone help/explain. This is killing me ^^
register_types.cpp :
#include "register_types.h"
#include "gdexample.h"
#include "vox_importer.h"
#include <gdextension_interface.h>
#include <godot_cpp/core/defs.hpp>
#include <godot_cpp/godot.hpp>
#include <godot_cpp/variant/utility_functions.hpp>
using namespace godot;
void initialize_example_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
ClassDB::register_class<GDExample>();
}
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
ClassDB::register_internal_class<vox_importer>();
}
}
void uninitialize_example_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
}
extern "C" {
// Initialization.
GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
init_obj.register_initializer(initialize_example_module);
init_obj.register_terminator(uninitialize_example_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
return init_obj.init();
}
}
vox_importer.cpp:
#include "vox_importer.h"
#include <godot_cpp/variant/utility_functions.hpp>
using namespace godot;
String vox_importer::_get_importer_name() const
{
return "VoxImporter";
}
String vox_importer::_get_visible_name() const
{
return "VoxImporter";
}
PackedStringArray vox_importer::_get_recognized_extensions() const
{
PackedStringArray extensions;
extensions.append("vox");
return extensions;
}
String vox_importer::_get_preset_name(int p_idx) const
{
return "Default";
}
int vox_importer::_get_preset_count() const
{
return 1;
}
String vox_importer::_get_save_extension() const
{
return "mesh";
}
String vox_importer::_get_resource_type() const
{
return "ArrayMesh";
}
double vox_importer::_get_priority() const
{
return 0.0;
}
TypedArray<Dictionary> vox_importer::_get_import_options(const String &path, int32_t preset_index) const
{
return TypedArray<Dictionary>();
}
bool vox_importer::_get_option_visibility(const String &path, const StringName &option_name, const Dictionary &options) const
{
return true;
}
Error vox_importer::_import(const String &source_file, const String &save_path, const Dictionary &options, const TypedArray<String> &platform_variants, const TypedArray<String> &gen_files) const
{
UtilityFunctions::print("imported vox");
ERR_PRINT("imported vox");
return Error();
}
vox_importer::vox_importer()
{
ERR_PRINT("vox_importer hello");
}