From b94764ce12dec281d7459c514be53a74a144161b Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Sun, 20 Aug 2023 23:24:00 +0800 Subject: [PATCH 1/2] reinstate old method channel handlers on Linux --- linux/polyvox_filament_plugin.cc | 874 ++++++++++++++++--------------- 1 file changed, 442 insertions(+), 432 deletions(-) diff --git a/linux/polyvox_filament_plugin.cc b/linux/polyvox_filament_plugin.cc index a401b790..5bfc9492 100644 --- a/linux/polyvox_filament_plugin.cc +++ b/linux/polyvox_filament_plugin.cc @@ -46,6 +46,17 @@ struct _PolyvoxFilamentPlugin { G_DEFINE_TYPE(PolyvoxFilamentPlugin, polyvox_filament_plugin, g_object_get_type()) +static gboolean on_frame_tick(GtkWidget* widget, GdkFrameClock* frame_clock, gpointer self) { + PolyvoxFilamentPlugin* plugin = (PolyvoxFilamentPlugin*)self; + + if(plugin->rendering) { + render(plugin->viewer, 0); + fl_texture_registrar_mark_texture_frame_available(plugin->texture_registrar, + plugin->texture); + } + return TRUE; +} + static FlMethodResponse* _create_texture(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { if(self->texture) { Log("Error - create_texture called when texture exists."); @@ -112,15 +123,95 @@ static void polyvox_filament_plugin_handle_method_call( g_autoptr(FlValue) result = fl_value_new_int(reinterpret_cast(resourceLoader)); response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - } else if(strcmp(method, "tick") == 0) { - fl_texture_registrar_mark_texture_frame_available(self->texture_registrar, - self->texture); + } else if(strcmp(method, "setRendering") == 0) { + self->rendering = fl_value_get_bool(fl_method_call_get_args(method_call)); response = FL_METHOD_RESPONSE(fl_method_success_response_new(fl_value_new_string("OK"))); + } else if(strcmp(method, "loadSkybox") == 0) { + response = _loadSkybox(self, method_call); + } else if(strcmp(method, "loadIbl") == 0) { + response = _loadIbl(self, method_call); + } else if(strcmp(method, "removeIbl") ==0) { + response = _remove_ibl(self, method_call); + } else if(strcmp(method, "removeSkybox") == 0) { + response = _removeSkybox(self, method_call); + } else if(strcmp(method, "render") == 0) { + render(self->viewer, 0); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); + } else if(strcmp(method, "setBackgroundColor") == 0) { + response = _set_background_color(self, method_call); + } else if(strcmp(method, "setBackgroundImage") == 0) { + response = _set_background_image(self, method_call); + } else if(strcmp(method, "addLight") == 0) { + response = _add_light(self, method_call); + } else if(strcmp(method, "loadGlb") == 0) { + response = _load_glb(self, method_call); + } else if(strcmp(method, "getAnimationNames") == 0) { + response = _get_animation_names(self, method_call); + } else if(strcmp(method, "clearAssets") == 0) { + clear_assets(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); + } else if(strcmp(method, "removeAsset") == 0) { + response = _remove_asset(self, method_call); + } else if(strcmp(method, "transformToUnitCube") == 0) { + response = _transform_to_unit_cube(self, method_call); + } else if(strcmp(method, "clearLights") == 0) { + clear_lights(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); + } else if(strcmp(method, "panStart") == 0) { + response = _pan_start(self, method_call); + } else if(strcmp(method, "panEnd") == 0) { + response = _pan_end(self, method_call); + } else if(strcmp(method, "panUpdate") == 0) { + response = _pan_update(self, method_call); + } else if(strcmp(method, "rotateStart") == 0) { + response = _rotate_start(self, method_call); + } else if(strcmp(method, "rotateEnd") == 0) { + response = _rotate_end(self, method_call); + } else if(strcmp(method, "rotateUpdate") == 0) { + response = _rotate_update(self, method_call); + } else if(strcmp(method, "setRotation") == 0) { + response = _set_rotation(self, method_call); + } else if(strcmp(method, "setCamera") == 0) { + response = _set_camera(self, method_call); + } else if(strcmp(method, "setCameraModelMatrix") == 0) { + response = _set_camera_model_matrix(self, method_call); + } else if(strcmp(method, "setCameraExposure") == 0) { + response = _set_camera_exposure(self, method_call); + } else if(strcmp(method, "setCameraPosition") == 0) { + response = _set_camera_position(self, method_call); + } else if(strcmp(method, "setCameraRotation") == 0) { + response = _set_camera_rotation(self, method_call); + } else if(strcmp(method, "setFrameInterval") == 0) { + response = _set_frame_interval(self, method_call); + } else if(strcmp(method, "zoomBegin") == 0) { + response = _zoom_begin(self, method_call); + } else if(strcmp(method, "zoomEnd") == 0) { + response = _zoom_end(self, method_call); + } else if(strcmp(method, "zoomUpdate") == 0) { + response = _zoom_update(self, method_call); + } else if(strcmp(method, "playAnimation") == 0) { + response = _play_animation(self, method_call); + } else if(strcmp(method, "stopAnimation") == 0) { + response = _stop_animation(self, method_call); + } else if(strcmp(method, "setMorphTargetWeights") == 0) { + response = _apply_weights(self, method_call); + } else if(strcmp(method, "setAnimation") == 0) { + response = _set_animation(self, method_call); + } else if(strcmp(method, "getMorphTargetNames") == 0) { + response = _get_morph_target_names(self, method_call); + } else if(strcmp(method, "setPosition") == 0) { + response = _set_position(self, method_call); + } else if(strcmp(method, "setBoneTransform") == 0) { + response = _set_bone_transform(self, method_call); } else { response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); } fl_method_call_respond(method_call, response, nullptr); + } static void polyvox_filament_plugin_dispose(GObject* object) { @@ -166,531 +257,450 @@ void polyvox_filament_plugin_register_with_registrar(FlPluginRegistrar* registra -// static FlMethodResponse* _loadSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); +static FlMethodResponse* _loadSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); -// const gchar* path = fl_value_get_string(args); + const gchar* path = fl_value_get_string(args); -// load_skybox(self->viewer, path); + load_skybox(self->viewer, path); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _remove_ibl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// remove_ibl(self->viewer); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _remove_ibl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + remove_ibl(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _loadIbl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); +static FlMethodResponse* _loadIbl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); -// auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); -// auto intensity = fl_value_get_float(fl_value_get_list_value(args, 1)); + auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); + auto intensity = fl_value_get_float(fl_value_get_list_value(args, 1)); -// load_ibl(self->viewer, path, intensity); + load_ibl(self->viewer, path, intensity); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _removeSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// std::cout << "Removing skybox" << std::endl; -// remove_skybox(self->viewer); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _removeSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + std::cout << "Removing skybox" << std::endl; + remove_skybox(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_background_image(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { +static FlMethodResponse* _set_background_image(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); + FlValue* args = fl_method_call_get_args(method_call); -// const gchar* path = fl_value_get_string(args); + const gchar* path = fl_value_get_string(args); -// set_background_image(self->viewer, path); + set_background_image(self->viewer, path); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_background_color(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { +static FlMethodResponse* _set_background_color(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// const float* color = fl_value_get_float32_list(fl_method_call_get_args(method_call)); -// set_background_color(self->viewer, color[0], color[1], color[2], color[2]); + const float* color = fl_value_get_float32_list(fl_method_call_get_args(method_call)); + set_background_color(self->viewer, color[0], color[1], color[2], color[2]); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _add_light(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { +static FlMethodResponse* _add_light(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); + FlValue* args = fl_method_call_get_args(method_call); -// auto type = (uint8_t)fl_value_get_int(fl_value_get_list_value(args, 0)); -// auto color = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// auto intensity = float(fl_value_get_float(fl_value_get_list_value(args, 2))); -// auto posX = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); -// auto posY = (float)fl_value_get_float(fl_value_get_list_value(args, 4)); -// auto posZ = (float)fl_value_get_float(fl_value_get_list_value(args, 5)); -// auto dirX = (float)fl_value_get_float(fl_value_get_list_value(args, 6)); -// auto dirY = (float)fl_value_get_float(fl_value_get_list_value(args, 7)); -// auto dirZ = (float)fl_value_get_float(fl_value_get_list_value(args, 8)); -// auto shadows = fl_value_get_bool(fl_value_get_list_value(args, 9)); + auto type = (uint8_t)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto color = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto intensity = float(fl_value_get_float(fl_value_get_list_value(args, 2))); + auto posX = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); + auto posY = (float)fl_value_get_float(fl_value_get_list_value(args, 4)); + auto posZ = (float)fl_value_get_float(fl_value_get_list_value(args, 5)); + auto dirX = (float)fl_value_get_float(fl_value_get_list_value(args, 6)); + auto dirY = (float)fl_value_get_float(fl_value_get_list_value(args, 7)); + auto dirZ = (float)fl_value_get_float(fl_value_get_list_value(args, 8)); + auto shadows = fl_value_get_bool(fl_value_get_list_value(args, 9)); -// auto entityId = add_light(self->viewer, type, color, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows); -// g_autoptr(FlValue) result = fl_value_new_int(entityId); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); + auto entityId = add_light(self->viewer, type, color, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows); + g_autoptr(FlValue) result = fl_value_new_int(entityId); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +} -// static FlMethodResponse* _load_glb(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); -// auto unlit = fl_value_get_bool(fl_value_get_list_value(args, 1)); -// auto entityId = load_glb(self->viewer, path, unlit); -// g_autoptr(FlValue) result = fl_value_new_int((int64_t)entityId); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _load_glb(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); + auto unlit = fl_value_get_bool(fl_value_get_list_value(args, 1)); + auto entityId = load_glb(self->viewer, path, unlit); + g_autoptr(FlValue) result = fl_value_new_int((int64_t)entityId); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _get_animation_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { +static FlMethodResponse* _get_animation_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(args); -// g_autoptr(FlValue) result = fl_value_new_list(); + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(args); + g_autoptr(FlValue) result = fl_value_new_list(); -// auto numNames = get_animation_count(assetPtr); + auto numNames = get_animation_count(assetPtr); -// for(int i = 0; i < numNames; i++) { -// gchar out[255]; -// get_animation_name(assetPtr, out, i); -// fl_value_append_take (result, fl_value_new_string (out)); -// } + for(int i = 0; i < numNames; i++) { + gchar out[255]; + get_animation_name(assetPtr, out, i); + fl_value_append_take (result, fl_value_new_string (out)); + } -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _remove_asset(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(args); -// remove_asset(self->viewer, assetPtr); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _remove_asset(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(args); + remove_asset(self->viewer, assetPtr); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _transform_to_unit_cube(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(args); -// transform_to_unit_cube(assetPtr); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _transform_to_unit_cube(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(args); + transform_to_unit_cube(assetPtr); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _rotate_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); +static FlMethodResponse* _rotate_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); -// auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); -// auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// grab_begin(self->viewer, x,y, false); + grab_begin(self->viewer, x,y, false); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _rotate_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// grab_end(self->viewer); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _rotate_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + grab_end(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _rotate_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); -// auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); +static FlMethodResponse* _rotate_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// grab_update(self->viewer, x,y); + grab_update(self->viewer, x,y); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _pan_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { +static FlMethodResponse* _pan_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); + FlValue* args = fl_method_call_get_args(method_call); -// auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); -// auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// grab_begin(self->viewer, x,y, true); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + grab_begin(self->viewer, x,y, true); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _pan_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); -// auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); +static FlMethodResponse* _pan_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// grab_update(self->viewer, x,y); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + grab_update(self->viewer, x,y); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _pan_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// grab_end(self->viewer); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _pan_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + grab_end(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); +static FlMethodResponse* _set_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// set_position( -// assetPtr, -// (float)fl_value_get_float(fl_value_get_list_value(args, 1)), // x -// (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // y -// (float)fl_value_get_float(fl_value_get_list_value(args, 3)) // z -// ); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + set_position( + assetPtr, + (float)fl_value_get_float(fl_value_get_list_value(args, 1)), // x + (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // y + (float)fl_value_get_float(fl_value_get_list_value(args, 3)) // z + ); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); +static FlMethodResponse* _set_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// set_rotation( -// assetPtr, -// (float)fl_value_get_float(fl_value_get_list_value(args, 1)), // rads -// (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // x -// (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // y -// (float)fl_value_get_float(fl_value_get_list_value(args, 4)) // z -// ); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + set_rotation( + assetPtr, + (float)fl_value_get_float(fl_value_get_list_value(args, 1)), // rads + (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // x + (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // y + (float)fl_value_get_float(fl_value_get_list_value(args, 4)) // z + ); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_bone_transform(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// auto boneName = fl_value_get_string(fl_value_get_list_value(args, 1)); -// auto meshName = fl_value_get_string(fl_value_get_list_value(args, 2)); +static FlMethodResponse* _set_bone_transform(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto boneName = fl_value_get_string(fl_value_get_list_value(args, 1)); + auto meshName = fl_value_get_string(fl_value_get_list_value(args, 2)); -// set_bone_transform( -// assetPtr, -// boneName, -// meshName, -// (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // transX -// (float)fl_value_get_float(fl_value_get_list_value(args, 4)), // transY -// (float)fl_value_get_float(fl_value_get_list_value(args, 5)), // transZ -// (float)fl_value_get_float(fl_value_get_list_value(args, 6)), // quatX -// (float)fl_value_get_float(fl_value_get_list_value(args, 7)), // quatY -// (float)fl_value_get_float(fl_value_get_list_value(args, 8)), // quatZ -// (float)fl_value_get_float(fl_value_get_list_value(args, 9)) // quatW -// ); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + set_bone_transform( + assetPtr, + boneName, + meshName, + (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // transX + (float)fl_value_get_float(fl_value_get_list_value(args, 4)), // transY + (float)fl_value_get_float(fl_value_get_list_value(args, 5)), // transZ + (float)fl_value_get_float(fl_value_get_list_value(args, 6)), // quatX + (float)fl_value_get_float(fl_value_get_list_value(args, 7)), // quatY + (float)fl_value_get_float(fl_value_get_list_value(args, 8)), // quatZ + (float)fl_value_get_float(fl_value_get_list_value(args, 9)) // quatW + ); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_camera(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// auto cameraName = fl_value_get_string(fl_value_get_list_value(args, 1)) ; +static FlMethodResponse* _set_camera(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto cameraName = fl_value_get_string(fl_value_get_list_value(args, 1)) ; -// set_camera(self->viewer, (void*)assetPtr, cameraName); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + set_camera(self->viewer, (void*)assetPtr, cameraName); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_camera_model_matrix(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// set_camera_model_matrix(self->viewer, fl_value_get_float32_list(args)); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _set_camera_model_matrix(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + set_camera_model_matrix(self->viewer, fl_value_get_float32_list(args)); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_camera_exposure(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto aperture = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); -// auto shutter_speed = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// auto sensitivity = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); -// set_camera_exposure(self->viewer, aperture, shutter_speed, sensitivity); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _set_camera_exposure(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto aperture = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto shutter_speed = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto sensitivity = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); + set_camera_exposure(self->viewer, aperture, shutter_speed, sensitivity); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_camera_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); -// auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); -// set_camera_position(self->viewer, x,y, z); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _set_camera_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); + set_camera_position(self->viewer, x,y, z); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_camera_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto rads = (float)fl_value_get_float(fl_value_get_list_value(args,0 )); -// auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); -// auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); +static FlMethodResponse* _set_camera_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto rads = (float)fl_value_get_float(fl_value_get_list_value(args,0 )); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); + auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); -// set_camera_rotation(self->viewer, rads, x,y, z); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + set_camera_rotation(self->viewer, rads, x,y, z); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_rendering(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// self->rendering = (bool)fl_value_get_bool(args); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _set_rendering(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + self->rendering = (bool)fl_value_get_bool(args); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_frame_interval(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto val = (float) fl_value_get_float(args); -// set_frame_interval(self->viewer, val); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _set_frame_interval(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto val = (float) fl_value_get_float(args); + set_frame_interval(self->viewer, val); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _zoom_begin(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// scroll_begin(self->viewer); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _zoom_begin(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + scroll_begin(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _zoom_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// scroll_end(self->viewer); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _zoom_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + scroll_end(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _zoom_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); -// auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); -// auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); +static FlMethodResponse* _zoom_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); -// scroll_update(self->viewer, x,y, z); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + scroll_update(self->viewer, x,y, z); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _play_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 1)); -// auto loop = (bool)fl_value_get_bool(fl_value_get_list_value(args, 2)); -// auto reverse = (bool)fl_value_get_bool(fl_value_get_list_value(args, 3)); -// play_animation(assetPtr, animationId, loop, reverse); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _play_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 1)); + auto loop = (bool)fl_value_get_bool(fl_value_get_list_value(args, 2)); + auto reverse = (bool)fl_value_get_bool(fl_value_get_list_value(args, 3)); + play_animation(assetPtr, animationId, loop, reverse); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _stop_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 1)); -// stop_animation(assetPtr, animationId); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _stop_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 1)); + stop_animation(assetPtr, animationId); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _apply_weights(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// auto entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); -// auto weightsValue = fl_value_get_list_value(args, 2); -// float* const weights = (float* const) fl_value_get_float32_list(weightsValue); -// size_t len = fl_value_get_length(weightsValue); -// apply_weights(assetPtr, entityName, weights, (int)len); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } +static FlMethodResponse* _apply_weights(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); + auto weightsValue = fl_value_get_list_value(args, 2); + float* const weights = (float* const) fl_value_get_float32_list(weightsValue); + size_t len = fl_value_get_length(weightsValue); + apply_weights(assetPtr, entityName, weights, (int)len); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _set_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); +static FlMethodResponse* _set_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// const char* entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); + const char* entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); -// float* const morphData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(args, 2)); + float* const morphData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(args, 2)); -// int64_t numMorphWeights = fl_value_get_int(fl_value_get_list_value(args, 3)); + int64_t numMorphWeights = fl_value_get_int(fl_value_get_list_value(args, 3)); -// FlValue* flBoneAnimations = fl_value_get_list_value(args, 4); + FlValue* flBoneAnimations = fl_value_get_list_value(args, 4); -// size_t numBoneAnimations = fl_value_get_length(flBoneAnimations); + size_t numBoneAnimations = fl_value_get_length(flBoneAnimations); -// vector boneAnimations; + vector boneAnimations; -// for(int i = 0; i < numBoneAnimations; i++) { + for(int i = 0; i < numBoneAnimations; i++) { -// FlValue* flBoneAnimation = fl_value_get_list_value(flBoneAnimations, i); + FlValue* flBoneAnimation = fl_value_get_list_value(flBoneAnimations, i); -// FlValue* flBoneNames = fl_value_get_list_value(flBoneAnimation, 0); -// FlValue* flMeshNames = fl_value_get_list_value(flBoneAnimation, 1); -// float* const frameData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(flBoneAnimation, 2)); + FlValue* flBoneNames = fl_value_get_list_value(flBoneAnimation, 0); + FlValue* flMeshNames = fl_value_get_list_value(flBoneAnimation, 1); + float* const frameData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(flBoneAnimation, 2)); -// Log("Framedata %f", frameData); + Log("Framedata %f", frameData); -// vector boneNames; -// boneNames.resize(fl_value_get_length(flBoneNames)); + vector boneNames; + boneNames.resize(fl_value_get_length(flBoneNames)); -// for(int i=0; i < boneNames.size(); i++) { -// boneNames[i] = fl_value_get_string(fl_value_get_list_value(flBoneNames, i)) ; -// } + for(int i=0; i < boneNames.size(); i++) { + boneNames[i] = fl_value_get_string(fl_value_get_list_value(flBoneNames, i)) ; + } -// vector meshNames; -// meshNames.resize(fl_value_get_length(flMeshNames)); -// for(int i=0; i < meshNames.size(); i++) { -// meshNames[i] = fl_value_get_string(fl_value_get_list_value(flMeshNames, i)); -// } + vector meshNames; + meshNames.resize(fl_value_get_length(flMeshNames)); + for(int i=0; i < meshNames.size(); i++) { + meshNames[i] = fl_value_get_string(fl_value_get_list_value(flMeshNames, i)); + } -// const char** boneNamesPtr = (const char**)malloc(boneNames.size() * sizeof(char*)); -// memcpy((void*)boneNamesPtr, (void*)boneNames.data(), boneNames.size() * sizeof(char*)); -// auto meshNamesPtr = (const char**)malloc(meshNames.size() * sizeof(char*)); -// memcpy((void*)meshNamesPtr, (void*)meshNames.data(), meshNames.size() * sizeof(char*)); + const char** boneNamesPtr = (const char**)malloc(boneNames.size() * sizeof(char*)); + memcpy((void*)boneNamesPtr, (void*)boneNames.data(), boneNames.size() * sizeof(char*)); + auto meshNamesPtr = (const char**)malloc(meshNames.size() * sizeof(char*)); + memcpy((void*)meshNamesPtr, (void*)meshNames.data(), meshNames.size() * sizeof(char*)); -// BoneAnimation animation { -// .boneNames = boneNamesPtr, -// .meshNames = meshNamesPtr, -// .data = frameData, -// .numBones = boneNames.size(), -// .numMeshTargets = meshNames.size() -// }; + BoneAnimation animation { + .boneNames = boneNamesPtr, + .meshNames = meshNamesPtr, + .data = frameData, + .numBones = boneNames.size(), + .numMeshTargets = meshNames.size() + }; -// boneAnimations.push_back(animation); + boneAnimations.push_back(animation); -// } + } -// int64_t numFrames = fl_value_get_int(fl_value_get_list_value(args, 5)); + int64_t numFrames = fl_value_get_int(fl_value_get_list_value(args, 5)); -// float frameLengthInMs = fl_value_get_float(fl_value_get_list_value(args, 6)); + float frameLengthInMs = fl_value_get_float(fl_value_get_list_value(args, 6)); -// auto boneAnimationsPointer = boneAnimations.data(); -// auto boneAnimationsSize = boneAnimations.size(); + auto boneAnimationsPointer = boneAnimations.data(); + auto boneAnimationsSize = boneAnimations.size(); -// set_animation( -// assetPtr, -// entityName, -// morphData, -// numMorphWeights, -// boneAnimationsPointer, -// boneAnimationsSize, -// numFrames, -// frameLengthInMs); + set_animation( + assetPtr, + entityName, + morphData, + numMorphWeights, + boneAnimationsPointer, + boneAnimationsSize, + numFrames, + frameLengthInMs); -// g_autoptr(FlValue) result = fl_value_new_string("OK"); -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} -// static FlMethodResponse* _get_morph_target_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { -// FlValue* args = fl_method_call_get_args(method_call); -// auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); -// auto meshName = fl_value_get_string(fl_value_get_list_value(args, 1)); -// g_autoptr(FlValue) result = fl_value_new_list(); +static FlMethodResponse* _get_morph_target_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto meshName = fl_value_get_string(fl_value_get_list_value(args, 1)); + g_autoptr(FlValue) result = fl_value_new_list(); -// auto numNames = get_morph_target_name_count(assetPtr, meshName); + auto numNames = get_morph_target_name_count(assetPtr, meshName); -// std::cout << numNames << " morph targets found in mesh " << meshName << std::endl; + std::cout << numNames << " morph targets found in mesh " << meshName << std::endl; -// for(int i = 0; i < numNames; i++) { -// gchar out[255]; -// get_morph_target_name(assetPtr, meshName, out, i); -// fl_value_append_take (result, fl_value_new_string (out)); -// } + for(int i = 0; i < numNames; i++) { + gchar out[255]; + get_morph_target_name(assetPtr, meshName, out, i); + fl_value_append_take (result, fl_value_new_string (out)); + } -// return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -// } + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} - // } else if(strcmp(method, "loadSkybox") == 0) { - // response = _loadSkybox(self, method_call); - // } else if(strcmp(method, "loadIbl") == 0) { - // response = _loadIbl(self, method_call); - // } else if(strcmp(method, "removeIbl") ==0) { - // response = _remove_ibl(self, method_call); - // } else if(strcmp(method, "removeSkybox") == 0) { - // response = _removeSkybox(self, method_call); - - // } else if(strcmp(method, "render") == 0) { - // render(self->viewer, 0); - // g_autoptr(FlValue) result = fl_value_new_string("OK"); - // response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - // } else if(strcmp(method, "setBackgroundColor") == 0) { - // response = _set_background_color(self, method_call); - // } else if(strcmp(method, "setBackgroundImage") == 0) { - // response = _set_background_image(self, method_call); - // } else if(strcmp(method, "addLight") == 0) { - // response = _add_light(self, method_call); - // } else if(strcmp(method, "loadGlb") == 0) { - // response = _load_glb(self, method_call); - // } else if(strcmp(method, "getAnimationNames") == 0) { - // response = _get_animation_names(self, method_call); - // } else if(strcmp(method, "clearAssets") == 0) { - // clear_assets(self->viewer); - // g_autoptr(FlValue) result = fl_value_new_string("OK"); - // response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - // } else if(strcmp(method, "removeAsset") == 0) { - // response = _remove_asset(self, method_call); - // } else if(strcmp(method, "transformToUnitCube") == 0) { - // response = _transform_to_unit_cube(self, method_call); - // } else if(strcmp(method, "clearLights") == 0) { - // clear_lights(self->viewer); - // g_autoptr(FlValue) result = fl_value_new_string("OK"); - // response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - // } else if(strcmp(method, "panStart") == 0) { - // response = _pan_start(self, method_call); - // } else if(strcmp(method, "panEnd") == 0) { - // response = _pan_end(self, method_call); - // } else if(strcmp(method, "panUpdate") == 0) { - // response = _pan_update(self, method_call); - // } else if(strcmp(method, "rotateStart") == 0) { - // response = _rotate_start(self, method_call); - // } else if(strcmp(method, "rotateEnd") == 0) { - // response = _rotate_end(self, method_call); - // } else if(strcmp(method, "rotateUpdate") == 0) { - // response = _rotate_update(self, method_call); - // } else if(strcmp(method, "setRotation") == 0) { - // response = _set_rotation(self, method_call); - // } else if(strcmp(method, "setCamera") == 0) { - // response = _set_camera(self, method_call); - // } else if(strcmp(method, "setCameraModelMatrix") == 0) { - // response = _set_camera_model_matrix(self, method_call); - // } else if(strcmp(method, "setCameraExposure") == 0) { - // response = _set_camera_exposure(self, method_call); - // } else if(strcmp(method, "setCameraPosition") == 0) { - // response = _set_camera_position(self, method_call); - // } else if(strcmp(method, "setCameraRotation") == 0) { - // response = _set_camera_rotation(self, method_call); - - // } else if(strcmp(method, "setFrameInterval") == 0) { - // response = _set_frame_interval(self, method_call); - // } else if(strcmp(method, "zoomBegin") == 0) { - // response = _zoom_begin(self, method_call); - // } else if(strcmp(method, "zoomEnd") == 0) { - // response = _zoom_end(self, method_call); - // } else if(strcmp(method, "zoomUpdate") == 0) { - // response = _zoom_update(self, method_call); - // } else if(strcmp(method, "playAnimation") == 0) { - // response = _play_animation(self, method_call); - // } else if(strcmp(method, "stopAnimation") == 0) { - // response = _stop_animation(self, method_call); - // } else if(strcmp(method, "setMorphTargetWeights") == 0) { - // response = _apply_weights(self, method_call); - // } else if(strcmp(method, "setAnimation") == 0) { - // response = _set_animation(self, method_call); - // } else if(strcmp(method, "getMorphTargetNames") == 0) { - // response = _get_morph_target_names(self, method_call); - // } else if(strcmp(method, "setPosition") == 0) { - // response = _set_position(self, method_call); - // } else if(strcmp(method, "setBoneTransform") == 0) { - // // response = _set_bone_transform(self, method_call); \ No newline at end of file + \ No newline at end of file From d08b0f2488e1ad7728ad02f37186b53d77373a59 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Mon, 21 Aug 2023 02:03:18 +0800 Subject: [PATCH 2/2] Linux fixes for v1.41.0 --- ios/src/FilamentViewer.cpp | 9 +- linux/CMakeLists.txt | 5 + linux/Untitled-1.cpp | 356 +++++++ linux/lib/filament-v1.41.0-linux.tgz | 3 + linux/lib/libbackend.a | 4 +- linux/lib/libbasis_encoder.a | 4 +- linux/lib/libbasis_transcoder.a | 4 +- linux/lib/libbluegl.a | 4 +- linux/lib/libbluevk.a | 4 +- linux/lib/libcamutils.a | 4 +- linux/lib/libcivetweb.a | 4 +- linux/lib/libdracodec.a | 4 +- linux/lib/libfilabridge.a | 4 +- linux/lib/libfilaflat.a | 4 +- linux/lib/libfilamat.a | 4 +- linux/lib/libfilamat_lite.a | 4 +- linux/lib/libfilament-iblprefilter.a | 4 +- linux/lib/libfilament.a | 4 +- linux/lib/libfilameshio.a | 4 +- linux/lib/libgeometry.a | 4 +- linux/lib/libgltfio.a | 4 +- linux/lib/libgltfio_core.a | 4 +- linux/lib/libibl-lite.a | 4 +- linux/lib/libibl.a | 4 +- linux/lib/libimage.a | 4 +- linux/lib/libimageio.a | 4 +- linux/lib/libktxreader.a | 4 +- linux/lib/libmatdbg.a | 4 +- linux/lib/libmathio.a | 4 +- linux/lib/libmeshoptimizer.a | 4 +- linux/lib/libmikktspace.a | 3 + linux/lib/libshaders.a | 4 +- linux/lib/libsmol-v.a | 4 +- linux/lib/libstb.a | 4 +- linux/lib/libuberarchive.a | 4 +- linux/lib/libuberzlib.a | 4 +- linux/lib/libutils.a | 4 +- linux/lib/libviewer.a | 4 +- linux/lib/libvkshaders.a | 4 +- linux/lib/libzstd.a | 4 +- linux/lib/{ => old}/libOGLCompiler.a | 0 linux/lib/{ => old}/libOSDependent.a | 0 linux/lib/{ => old}/libSPIRV-Tools-diff.a | 0 linux/lib/{ => old}/libSPIRV-Tools-link.a | 0 linux/lib/{ => old}/libSPIRV-Tools-lint.a | 0 linux/lib/{ => old}/libSPIRV-Tools-opt.a | 0 linux/lib/{ => old}/libSPIRV-Tools-reduce.a | 0 linux/lib/{ => old}/libSPIRV-Tools.a | 0 linux/lib/{ => old}/libSPIRV.a | 0 linux/lib/{ => old}/libassimp.a | 0 linux/lib/old/libbackend.a | 3 + linux/lib/old/libbasis_encoder.a | 3 + linux/lib/old/libbasis_transcoder.a | 3 + linux/lib/{ => old}/libbenchmark.a | 0 linux/lib/{ => old}/libbenchmark_main.a | 0 linux/lib/old/libbluegl.a | 3 + linux/lib/old/libbluevk.a | 3 + linux/lib/old/libcamutils.a | 3 + linux/lib/old/libcivetweb.a | 3 + linux/lib/old/libdracodec.a | 3 + linux/lib/old/libfilabridge.a | 3 + linux/lib/old/libfilaflat.a | 3 + linux/lib/{ => old}/libfilagui.a | 0 linux/lib/old/libfilamat.a | 3 + linux/lib/{ => old}/libfilamat_combined.a | 0 linux/lib/old/libfilamat_lite.a | 3 + linux/lib/old/libfilament-iblprefilter.a | 3 + linux/lib/old/libfilament.a | 3 + .../lib/{ => old}/libfilamentapp-resources.a | 0 linux/lib/{ => old}/libfilamentapp.a | 0 linux/lib/old/libfilameshio.a | 3 + linux/lib/old/libgeometry.a | 3 + linux/lib/{ => old}/libgetopt.a | 0 linux/lib/{ => old}/libglslang.a | 0 linux/lib/{ => old}/libgltf-demo-resources.a | 0 linux/lib/old/libgltfio.a | 3 + linux/lib/old/libgltfio_core.a | 3 + linux/lib/{ => old}/libgtest.a | 0 linux/lib/old/libibl-lite.a | 3 + linux/lib/old/libibl.a | 3 + linux/lib/old/libimage.a | 3 + linux/lib/{ => old}/libimgui.a | 0 linux/lib/old/libktxreader.a | 3 + linux/lib/old/libmatdbg.a | 3 + linux/lib/{ => old}/libmatdbg_combined.a | 0 linux/lib/{ => old}/libmatdbg_resources.a | 0 linux/lib/{ => old}/libmatlang.a | 0 linux/lib/old/libmeshoptimizer.a | 3 + linux/lib/old/libmikktspace.a | 3 + linux/lib/{ => old}/libpng.a | 0 linux/lib/{ => old}/libsample-resources.a | 0 linux/lib/{ => old}/libsdl2.a | 0 linux/lib/old/libshaders.a | 3 + linux/lib/old/libsmol-v.a | 3 + linux/lib/{ => old}/libspirv-cross-core.a | 0 linux/lib/{ => old}/libspirv-cross-glsl.a | 0 linux/lib/{ => old}/libspirv-cross-msl.a | 0 linux/lib/old/libstb.a | 3 + linux/lib/{ => old}/libsuzanne-resources.a | 0 linux/lib/old/libuberarchive.a | 3 + linux/lib/old/libuberzlib.a | 3 + linux/lib/old/libutils.a | 3 + linux/lib/old/libviewer.a | 3 + linux/lib/old/libvkshaders.a | 3 + linux/lib/{ => old}/libz.a | 0 linux/lib/old/libzstd.a | 3 + linux/polyvox_filament_plugin.cc | 969 ++++++++++-------- 107 files changed, 1064 insertions(+), 523 deletions(-) create mode 100644 linux/Untitled-1.cpp create mode 100644 linux/lib/filament-v1.41.0-linux.tgz create mode 100644 linux/lib/libmikktspace.a rename linux/lib/{ => old}/libOGLCompiler.a (100%) rename linux/lib/{ => old}/libOSDependent.a (100%) rename linux/lib/{ => old}/libSPIRV-Tools-diff.a (100%) rename linux/lib/{ => old}/libSPIRV-Tools-link.a (100%) rename linux/lib/{ => old}/libSPIRV-Tools-lint.a (100%) rename linux/lib/{ => old}/libSPIRV-Tools-opt.a (100%) rename linux/lib/{ => old}/libSPIRV-Tools-reduce.a (100%) rename linux/lib/{ => old}/libSPIRV-Tools.a (100%) rename linux/lib/{ => old}/libSPIRV.a (100%) rename linux/lib/{ => old}/libassimp.a (100%) create mode 100644 linux/lib/old/libbackend.a create mode 100644 linux/lib/old/libbasis_encoder.a create mode 100644 linux/lib/old/libbasis_transcoder.a rename linux/lib/{ => old}/libbenchmark.a (100%) rename linux/lib/{ => old}/libbenchmark_main.a (100%) create mode 100644 linux/lib/old/libbluegl.a create mode 100644 linux/lib/old/libbluevk.a create mode 100644 linux/lib/old/libcamutils.a create mode 100644 linux/lib/old/libcivetweb.a create mode 100644 linux/lib/old/libdracodec.a create mode 100644 linux/lib/old/libfilabridge.a create mode 100644 linux/lib/old/libfilaflat.a rename linux/lib/{ => old}/libfilagui.a (100%) create mode 100644 linux/lib/old/libfilamat.a rename linux/lib/{ => old}/libfilamat_combined.a (100%) create mode 100644 linux/lib/old/libfilamat_lite.a create mode 100644 linux/lib/old/libfilament-iblprefilter.a create mode 100644 linux/lib/old/libfilament.a rename linux/lib/{ => old}/libfilamentapp-resources.a (100%) rename linux/lib/{ => old}/libfilamentapp.a (100%) create mode 100644 linux/lib/old/libfilameshio.a create mode 100644 linux/lib/old/libgeometry.a rename linux/lib/{ => old}/libgetopt.a (100%) rename linux/lib/{ => old}/libglslang.a (100%) rename linux/lib/{ => old}/libgltf-demo-resources.a (100%) create mode 100644 linux/lib/old/libgltfio.a create mode 100644 linux/lib/old/libgltfio_core.a rename linux/lib/{ => old}/libgtest.a (100%) create mode 100644 linux/lib/old/libibl-lite.a create mode 100644 linux/lib/old/libibl.a create mode 100644 linux/lib/old/libimage.a rename linux/lib/{ => old}/libimgui.a (100%) create mode 100644 linux/lib/old/libktxreader.a create mode 100644 linux/lib/old/libmatdbg.a rename linux/lib/{ => old}/libmatdbg_combined.a (100%) rename linux/lib/{ => old}/libmatdbg_resources.a (100%) rename linux/lib/{ => old}/libmatlang.a (100%) create mode 100644 linux/lib/old/libmeshoptimizer.a create mode 100644 linux/lib/old/libmikktspace.a rename linux/lib/{ => old}/libpng.a (100%) rename linux/lib/{ => old}/libsample-resources.a (100%) rename linux/lib/{ => old}/libsdl2.a (100%) create mode 100644 linux/lib/old/libshaders.a create mode 100644 linux/lib/old/libsmol-v.a rename linux/lib/{ => old}/libspirv-cross-core.a (100%) rename linux/lib/{ => old}/libspirv-cross-glsl.a (100%) rename linux/lib/{ => old}/libspirv-cross-msl.a (100%) create mode 100644 linux/lib/old/libstb.a rename linux/lib/{ => old}/libsuzanne-resources.a (100%) create mode 100644 linux/lib/old/libuberarchive.a create mode 100644 linux/lib/old/libuberzlib.a create mode 100644 linux/lib/old/libutils.a create mode 100644 linux/lib/old/libviewer.a create mode 100644 linux/lib/old/libvkshaders.a rename linux/lib/{ => old}/libz.a (100%) create mode 100644 linux/lib/old/libzstd.a diff --git a/ios/src/FilamentViewer.cpp b/ios/src/FilamentViewer.cpp index 66847d79..a4420ea5 100644 --- a/ios/src/FilamentViewer.cpp +++ b/ios/src/FilamentViewer.cpp @@ -113,7 +113,7 @@ FilamentViewer::FilamentViewer(const void* context, const ResourceLoaderWrapper* #if TARGET_OS_IPHONE _engine = Engine::create(Engine::Backend::METAL); #else - _engine = Engine::create(Engine::Backend::OPENGL, nullptr, context, nullptr); + _engine = Engine::create(Engine::Backend::OPENGL, nullptr, (void*)context, nullptr); #endif _renderer = _engine->createRenderer(); @@ -272,8 +272,7 @@ void FilamentViewer::removeLight(EntityId entityId) { if(entity.isNull()) { Log("Error: light entity not found under ID %d", entityId); } else { - - remove(_lights.begin(), _lights.end(), entity); + auto removed = remove(_lights.begin(), _lights.end(), entity); _scene->remove(entity); EntityManager::get().destroy(1, &entity); } @@ -533,9 +532,9 @@ void FilamentViewer::createSwapChain(const void *surface, uint32_t width, uint32 _swapChain = _engine->createSwapChain((void*)surface, filament::backend::SWAP_CHAIN_CONFIG_APPLE_CVPIXELBUFFER); #else if(surface) { - _swapChain = _engine->createSwapChain(surface); - } else { _swapChain = _engine->createSwapChain(width, height, filament::backend::SWAP_CHAIN_CONFIG_TRANSPARENT | filament::backend::SWAP_CHAIN_CONFIG_READABLE); + } else { + _swapChain = _engine->createSwapChain((void*)surface, filament::backend::SWAP_CHAIN_CONFIG_TRANSPARENT | filament::backend::SWAP_CHAIN_CONFIG_READABLE); } #endif Log("Swapchain created."); diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index a222614d..efb26142 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -118,6 +118,10 @@ add_library(mathio STATIC IMPORTED) set_property(TARGET mathio PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libmathio.a") add_library(math STATIC IMPORTED) set_property(TARGET math PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libmath.a") +add_library(basis_transcoder STATIC IMPORTED) +set_property(TARGET basis_transcoder PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libbasis_transcoder.a") +# add_library(basis_encoder STATIC IMPORTED) +# set_property(TARGET basis_encoder PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/lib/libbasis_encoder.a") target_link_libraries(${PLUGIN_NAME} PRIVATE FILAMENT_SHADERS @@ -153,6 +157,7 @@ target_link_libraries(${PLUGIN_NAME} PRIVATE mathio math geometry + basis_transcoder ) # List of absolute paths to libraries that should be bundled with the plugin. diff --git a/linux/Untitled-1.cpp b/linux/Untitled-1.cpp new file mode 100644 index 00000000..e8ac9ba7 --- /dev/null +++ b/linux/Untitled-1.cpp @@ -0,0 +1,356 @@ +// static gboolean +// create_contextp (GtkGLArea *area, GdkGLContext *context) +// { +// std::cout << "CREATE CONTEXT" << std::endl; +// gdk_gl_context_set_debug_enabled(context, true); + +// // gtk_gl_area_make_current (area); +// std::cout << "MADE CURENTR" << std::endl; +// return TRUE; +// } + + +/* position and color information for each vertex */ +struct vertex_info { + float position[3]; + float color[3]; +}; + +/* the vertex data is constant */ +static const struct vertex_info vertex_data[] = { + { { 0.0f, 0.500f, 0.0f }, { 1.f, 0.f, 0.f } }, + { { 0.5f, -0.366f, 0.0f }, { 0.f, 1.f, 0.f } }, + { { -0.5f, -0.366f, 0.0f }, { 0.f, 0.f, 1.f } }, +}; + +static void +init_buffers (guint position_index, + guint color_index, + guint *vao_out) +{ + guint vao, buffer; + + /* we need to create a VAO to store the other buffers */ + glGenVertexArrays (1, &vao); + glBindVertexArray (vao); + + /* this is the VBO that holds the vertex data */ + glGenBuffers (1, &buffer); + glBindBuffer (GL_ARRAY_BUFFER, buffer); + glBufferData (GL_ARRAY_BUFFER, sizeof (vertex_data), vertex_data, GL_STATIC_DRAW); + + /* enable and set the position attribute */ + glEnableVertexAttribArray (position_index); + glVertexAttribPointer (position_index, 3, GL_FLOAT, GL_FALSE, + sizeof (struct vertex_info), + (GLvoid *) (G_STRUCT_OFFSET (struct vertex_info, position))); + + /* enable and set the color attribute */ + glEnableVertexAttribArray (color_index); + glVertexAttribPointer (color_index, 3, GL_FLOAT, GL_FALSE, + sizeof (struct vertex_info), + (GLvoid *) (G_STRUCT_OFFSET (struct vertex_info, color))); + + /* reset the state; we will re-enable the VAO when needed */ + glBindBuffer (GL_ARRAY_BUFFER, 0); + glBindVertexArray (0); + + /* the VBO is referenced by the VAO */ + glDeleteBuffers (1, &buffer); + + if (vao_out != NULL) + *vao_out = vao; +} + +static guint +create_shader (int shader_type, + const char *source, + GError **error, + guint *shader_out) +{ + guint shader = glCreateShader (shader_type); + glShaderSource (shader, 1, &source, NULL); + glCompileShader (shader); + + int status; + glGetShaderiv (shader, GL_COMPILE_STATUS, &status); + if (status == GL_FALSE) + { + std::cout << "SHADER IV ERROR" << std::endl; + } + + if (shader_out != NULL) + *shader_out = shader; + + return shader != 0; +} + +static gboolean +init_shaders (guint *program_out, + guint *position_location_out, + guint *color_location_out, + GError **error) +{ + const char *vsource = R"POO(#version 130 + +in vec3 position; +in vec3 color; + +uniform mat4 mvp; + +smooth out vec4 vertexColor; + +void main() { + gl_Position = vec4(position, 1.0); + vertexColor = vec4(color, 1.0); +})POO"; + +const char *fsource = R"POO(#version 130 + +smooth in vec4 vertexColor; + +out vec4 outputColor; + +void main() { + outputColor = vertexColor; +})POO"; + guint program = 0; + + guint vertex = 0, fragment = 0; + + guint position_location = 0; + guint color_location = 0; + + /* load the vertex shader */ + // source = g_resources_lookup_data ("/io/bassi/glarea/glarea-vertex.glsl", 0, NULL); + create_shader (GL_VERTEX_SHADER, vsource, error, &vertex); + // g_bytes_unref (source); + if (vertex == 0) { + std::cout << "VERTEX ERROR" << std::endl; + } + + + /* load the fragment shader */ + // source = g_resources_lookup_data ("/io/bassi/glarea/glarea-fragment.glsl", 0, NULL); + create_shader (GL_FRAGMENT_SHADER, fsource, error, &fragment); + + if (fragment == 0) + std::cout << "FRAF ERROR" << std::endl; + + /* link the vertex and fragment shaders together */ + program = glCreateProgram (); + + if(program == 0) { + std::cout << "PROG ZERO" << std::endl; + } + glAttachShader (program, vertex); + glAttachShader (program, fragment); + glLinkProgram (program); + + int status = 0; + glGetProgramiv (program, GL_LINK_STATUS, &status); + if (status == GL_FALSE) + { + std::cout << "glGetProgramiv ERROR" << std::endl; + goto out; + } + + position_location = glGetAttribLocation (program, "position"); + + /* get the location of the "position" and "color" attributes */ + color_location = glGetAttribLocation (program, "color"); + + /* the individual shaders can be detached and destroyed */ + glDetachShader (program, vertex); + glDetachShader (program, fragment); + +out: + if (vertex != 0) + glDeleteShader (vertex); + if (fragment != 0) + glDeleteShader (fragment); + + if (program_out != NULL) + *program_out = program; + if (position_location_out != NULL) + *position_location_out = position_location; + if (color_location_out != NULL) + *color_location_out = color_location; + + return program != 0; +} + +static void +gl_init (PolyvoxFilamentPlugin *self) +{ + + /* we need to ensure that the GdkGLContext is set before calling GL API */ + gtk_gl_area_make_current (GTK_GL_AREA (self->gl_drawing_area)); + + /* if the GtkGLArea is in an error state we don't do anything */ + if (gtk_gl_area_get_error (GTK_GL_AREA (self->gl_drawing_area)) != NULL) + return; + + /* initialize the shaders and retrieve the program data */ + GError *error = NULL; + if (!init_shaders (&self->program, + &self->position_index, + &self->color_index, + &error)) + { + /* set the GtkGLArea in error state, so we'll see the error message + * rendered inside the viewport + */ + gtk_gl_area_set_error (GTK_GL_AREA (self->gl_drawing_area), error); + g_error_free (error); + return; + } + + /* initialize the vertex buffers */ + init_buffers (self->position_index, self->color_index, &self->vao); + +} + +// static void +// gl_fini (PolyvoxFilamentPlugin *self) +// { +// /* we need to ensure that the GdkGLContext is set before calling GL API */ +// gtk_gl_area_make_current (GTK_GL_AREA (self->gl_drawing_area)); + +// /* skip everything if we're in error state */ +// if (gtk_gl_area_get_error (GTK_GL_AREA (self->gl_drawing_area)) != NULL) +// return; + +// /* destroy all the resources we created */ +// if (self->vao != 0) +// glDeleteVertexArrays (1, &self->vao); +// if (self->program != 0) +// glDeleteProgram (self->program); +// } + +static void +draw_triangle (PolyvoxFilamentPlugin *self) +{ + if (self->program == 0 || self->vao == 0) + return; + + /* load our program */ + glUseProgram (self->program); + + /* use the buffers in the VAO */ + glBindVertexArray (self->vao); + + /* draw the three vertices as a triangle */ + glDrawArrays (GL_TRIANGLES, 0, 3); + + /* we finished using the buffers and program */ + glBindVertexArray (0); + glUseProgram (0); +} + +static gboolean +gl_draw (PolyvoxFilamentPlugin *self) +{ + /* clear the viewport; the viewport is automatically resized when + * the GtkGLArea gets a new size allocation + */ + glClearColor (0.5, 0.5, 0.5, 1.0); + glClear (GL_COLOR_BUFFER_BIT); + + /* draw our object */ + draw_triangle (self); + + /* flush the contents of the pipeline */ + glFlush (); + + return FALSE; +} + + +// static void +// on_realize (GtkGLArea *area, PolyvoxFilamentPlugin* self) +// { +// std::cout << "REALIZE" << std::endl; + +// // GdkGLContext* context = gtk_gl_area_get_context(area); // gdk_window_create_gl_context(window, &error); + +// gtk_gl_area_make_current(area); + + +// if(gtk_gl_area_get_error (area)) { +// std::cout << "ERROR" << std::endl; +// } + + +// } + +// static gboolean +// renderp (GtkGLArea *area, GdkGLContext *context) +// { + +// glClearColor (0.0f, 1.0f, 0.0f, 1.0f); +// glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +// GLuint vao; +// glGenVertexArrays(1, &vao); +// glBindVertexArray(vao); + +// GLuint texture_id = 0; +// glGenTextures (1, &texture_id); + +// glBindTexture (GL_TEXTURE_2D, texture_id); + +// // further configuration here. + +// int len = 2000 * 2000 * 3; +// auto buffer = new std::vector(len); +// for (int i = 0; i < len; i++) +// { +// if(i % 3 == 0) { +// buffer->at(i) = (uint8_t)255; +// } else { +// buffer->at(i) = (uint8_t)0; +// } + +// } +// glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB8, 2000, 2000, 0, GL_RGB, +// GL_UNSIGNED_BYTE, buffer->data()); + +// std::cout << "RENDER texture iD" << texture_id << std::endl; + +// // create_filament_texture(400, 200, self->texture_registrar); +// glFinish(); + + +// std::cout << "RENDER" << std::endl; +// // we completed our drawing; the draw commands will be +// // flushed at the end of the signal emission chain, and +// // the buffers will be drawn on the window +// return TRUE; +// } + + + // GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET(self->fl_view)); + // if (gtk_widget_is_toplevel (toplevel)) + // { + // std::cout << "TOPLEVLE" << std::endl; + // } + + // gdk_gl_context_set_debug_enabled(context, true); + + + // GtkGLArea *gl_area = (GtkGLArea *) gtk_gl_area_new (); + // gtk_widget_show(GTK_WIDGET(gl_area)); + // GtkBox* parent = GTK_BOX(gtk_widget_get_parent(GTK_WIDGET(self->fl_view))); + // gtk_box_pack_start(parent, GTK_WIDGET(gl_area), true, true,0); + // self->gl_drawing_area = GTK_WIDGET(gl_area); + // GdkGLContext* context = gtk_gl_area_get_context(gl_area); + + // g_signal_connect_swapped(gl_area, "realize", G_CALLBACK (gl_init), self); + // g_signal_connect_swapped (gl_area, "render", G_CALLBACK (gl_draw), self); + + // g_signal_connect (gl_area, "create-context", G_CALLBACK (create_contextp), NULL); + + + + \ No newline at end of file diff --git a/linux/lib/filament-v1.41.0-linux.tgz b/linux/lib/filament-v1.41.0-linux.tgz new file mode 100644 index 00000000..8fcd2653 --- /dev/null +++ b/linux/lib/filament-v1.41.0-linux.tgz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0429489aafde09944e90e916a20bed6bc528b52f3137fbb0bf954ef5a3803c05 +size 44636732 diff --git a/linux/lib/libbackend.a b/linux/lib/libbackend.a index 6c356b3f..dc7ae499 100644 --- a/linux/lib/libbackend.a +++ b/linux/lib/libbackend.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b820222f26597b9af6e3212c8e926f158030e916237886bbae27beda14a656aa -size 31732550 +oid sha256:326d07e9416af38355057d2ad449d757cbc037cfaaa3e9759bd25c4c4466be6b +size 2097612 diff --git a/linux/lib/libbasis_encoder.a b/linux/lib/libbasis_encoder.a index 1996b229..a876f948 100644 --- a/linux/lib/libbasis_encoder.a +++ b/linux/lib/libbasis_encoder.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:17bd4166018341677a88d292dd7304a3fcf8a2e7fff90efda230baac0fdf2f1d -size 1410760 +oid sha256:9d633d3e1c66902e7ab8acd85d8acfa1d0612aeff1bfbbbe288eec0082b896dc +size 1437550 diff --git a/linux/lib/libbasis_transcoder.a b/linux/lib/libbasis_transcoder.a index 0e2be0d8..97c9a5c9 100644 --- a/linux/lib/libbasis_transcoder.a +++ b/linux/lib/libbasis_transcoder.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:89be1e60cb7e7849c0dd4b6c14449ed85c7004b47ffbc44bd27d32a14209aae3 -size 1371718 +oid sha256:1e4d4cbf8e87082cd8d4d36f8f8baae8ac89b507d24619470d31d5544d30df01 +size 552520 diff --git a/linux/lib/libbluegl.a b/linux/lib/libbluegl.a index b9a69736..e80bc87c 100644 --- a/linux/lib/libbluegl.a +++ b/linux/lib/libbluegl.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:20367af389d24aae3bf3896bf6be399c35b1d8d8f452d4343053653e9b8ffd00 -size 1534950 +oid sha256:19b9a4b82cdbc0ecacaadeda185dafe8ef5c38ad86f24deb39d6e437c3ba1706 +size 1135364 diff --git a/linux/lib/libbluevk.a b/linux/lib/libbluevk.a index 3989ed36..ed97c33c 100644 --- a/linux/lib/libbluevk.a +++ b/linux/lib/libbluevk.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ede8c534040169e0d74bfb477b7245cf7d1adfc8436ea27b57fd23ea31ca3e02 -size 734164 +oid sha256:f211ae118c26fa779eb80ce946311ea9597f54a089b270d4333109760816dd92 +size 175332 diff --git a/linux/lib/libcamutils.a b/linux/lib/libcamutils.a index ef2a54f0..7dca0668 100644 --- a/linux/lib/libcamutils.a +++ b/linux/lib/libcamutils.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:40ed049d42f05de2db7fb34a0b809c35c93fece473cb6745fb1857b13e0554f4 -size 327616 +oid sha256:647973c7591d20305f238802e9516683e69af4db32fe78cdbe99af7623b62ef7 +size 59964 diff --git a/linux/lib/libcivetweb.a b/linux/lib/libcivetweb.a index ad4f9c36..084ead59 100644 --- a/linux/lib/libcivetweb.a +++ b/linux/lib/libcivetweb.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eb4eb48d51f1a1c030789d66c6e53ed5ea4f1e1e8d8c24b248a7fa92f358095f -size 1186754 +oid sha256:8a767cd1119a855e22bb46efa786531dcd35beb27917f486d33da27eb5cbe408 +size 301758 diff --git a/linux/lib/libdracodec.a b/linux/lib/libdracodec.a index 2612a742..cc465882 100644 --- a/linux/lib/libdracodec.a +++ b/linux/lib/libdracodec.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:153a8457e327a7a552fc10a5c3d70eaa72e13daea70e1014f50b9f27b396ac91 -size 54009912 +oid sha256:55dda86e14d75a839289c58edd04a21166e7e4c9d354bad990545806d0f297e2 +size 2736460 diff --git a/linux/lib/libfilabridge.a b/linux/lib/libfilabridge.a index bc305f4a..c3f8bebe 100644 --- a/linux/lib/libfilabridge.a +++ b/linux/lib/libfilabridge.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b962736bfa43aa99195fcfdbf7ae4d7b3d4932be478c75f84f136c94bbb4a1d2 -size 1386898 +oid sha256:b62f0c4515df6b474eddc310e66da0e99f748ceb3b29153a5cac832db6dfbbb3 +size 64862 diff --git a/linux/lib/libfilaflat.a b/linux/lib/libfilaflat.a index c956e46a..0a728b1d 100644 --- a/linux/lib/libfilaflat.a +++ b/linux/lib/libfilaflat.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cdb933d401f4d0aa241781e4a7ba0197c0f84129c4210b0da25eb0d2113f9e08 -size 1501026 +oid sha256:06ca6bd13d07735ba2c6a4003d724b91aa979d884be271d78f0dd149a28b7f8d +size 53684 diff --git a/linux/lib/libfilamat.a b/linux/lib/libfilamat.a index 0c3f4c38..d48e3a8d 100644 --- a/linux/lib/libfilamat.a +++ b/linux/lib/libfilamat.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0542b794707db51a3a160621ea35d9486f61c8d3a23683816227594aecee3d3d -size 1008730486 +oid sha256:d0fb9205d81b49c661cd8d34a68f6613b44a8b1ed3dec8a8e3749d678373b67c +size 31198232 diff --git a/linux/lib/libfilamat_lite.a b/linux/lib/libfilamat_lite.a index 64d9f902..ccf0ae70 100644 --- a/linux/lib/libfilamat_lite.a +++ b/linux/lib/libfilamat_lite.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c6e6173c87286389dbe604c4fd6a1a8e556509d1d12c83da72f7654778a31fad -size 12165036 +oid sha256:b6942efce112eb25a0dd557d7943a4e3be3f1080a173ee2670cfa5b0d1aed0f4 +size 663716 diff --git a/linux/lib/libfilament-iblprefilter.a b/linux/lib/libfilament-iblprefilter.a index 7ef57c38..6d8e151c 100644 --- a/linux/lib/libfilament-iblprefilter.a +++ b/linux/lib/libfilament-iblprefilter.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:23f76e93ddf5165cf295912e550844e9e982f9ff36a081a3198a8bf0efacf288 -size 335102 +oid sha256:baf0f9103beb8f77efea06a2c938f77b27c2af090d52427a6e1eeb19f7787f33 +size 70040 diff --git a/linux/lib/libfilament.a b/linux/lib/libfilament.a index 4eae32fb..f01ae8a7 100644 --- a/linux/lib/libfilament.a +++ b/linux/lib/libfilament.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:28b9d34cfb3019b7462133e96aeb7a5ad5c3efd124b1c6bbd4c146e830723ea9 -size 111038978 +oid sha256:0af2e6d391839ae00e24ff1ca0bb098ef10ae1107f185735df50f1133ca747a5 +size 2859018 diff --git a/linux/lib/libfilameshio.a b/linux/lib/libfilameshio.a index 432f6b39..8b52f286 100644 --- a/linux/lib/libfilameshio.a +++ b/linux/lib/libfilameshio.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c4a7d0aeab3307be5a2065363d93d34c41d3c1654c4c0272ddcea832b7655bca -size 671884 +oid sha256:14e17d4f05c5c05d01c910dda66ed0e0b143d6d7f00b69123d68bbcbcb6daa72 +size 42216 diff --git a/linux/lib/libgeometry.a b/linux/lib/libgeometry.a index d1445477..c799b1b1 100644 --- a/linux/lib/libgeometry.a +++ b/linux/lib/libgeometry.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:66e39b7f8817ba761bfe1319fc54562b184d4ff110659b5b5d46cd3634a9d46d -size 656226 +oid sha256:2288510e5247d3b4bbb0928399c1b1ac9ca19dc2756f5ab3791a39167964e0d3 +size 122340 diff --git a/linux/lib/libgltfio.a b/linux/lib/libgltfio.a index bb821741..00f3f211 100644 --- a/linux/lib/libgltfio.a +++ b/linux/lib/libgltfio.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:941a6fb250fc9999a9991c5f834971eccfac5e6f8beccf43b60d224de140543b -size 846332 +oid sha256:058ef55c342dd39ab7a8aecef52f4f867b1479169780072ee14fa9e14fca1ea3 +size 51056 diff --git a/linux/lib/libgltfio_core.a b/linux/lib/libgltfio_core.a index 22ad90e8..062a9c6e 100644 --- a/linux/lib/libgltfio_core.a +++ b/linux/lib/libgltfio_core.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bedddf754f9c6d3bf688cdbbd93676b6f937a94053cdb1149cb93a2a0875a2b7 -size 31640360 +oid sha256:a7c19ebc166180597907382df8893a1cb6b0107445f798f491fb5e02e8880bb1 +size 1273720 diff --git a/linux/lib/libibl-lite.a b/linux/lib/libibl-lite.a index 99cc5c2d..53952809 100644 --- a/linux/lib/libibl-lite.a +++ b/linux/lib/libibl-lite.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d27640fc4d8d9a46e3d45430b09b944684ed3bfdc014d4adc33e0c519085a941 -size 5608136 +oid sha256:b925eaf3d01cd86cbd93e5ac3b7cf0aa5c250f5f0aee0ff1df867ae9d890d864 +size 389598 diff --git a/linux/lib/libibl.a b/linux/lib/libibl.a index 67517364..948743fe 100644 --- a/linux/lib/libibl.a +++ b/linux/lib/libibl.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f9702c3836edf9d64c95ec0a60e409451a4d1789e36677339dfcb6c2946e3a48 -size 6749272 +oid sha256:5237908b95431159cae48b1ec459650dee0dd9106c2ec93503d28824c5a4d420 +size 476644 diff --git a/linux/lib/libimage.a b/linux/lib/libimage.a index 64bb90bd..4c31b6ec 100644 --- a/linux/lib/libimage.a +++ b/linux/lib/libimage.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:512d872f6d11cc604affeef0f547583c59513d5712d1088015eada9d312a0980 -size 1650788 +oid sha256:ef7ee4e72d8acc062ccf4cb82f50758ca5cb7186f9b6fbb1e80e0e4e13c44b21 +size 112214 diff --git a/linux/lib/libimageio.a b/linux/lib/libimageio.a index 65f80a3d..d52f1225 100644 --- a/linux/lib/libimageio.a +++ b/linux/lib/libimageio.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4e78d760c308860e373d864912f74a0c48a967eb761cf56cb6f57db530c3e05a -size 210192 +oid sha256:8f1f111242f014ee41cb1f6aae70294d1d98a7513d35531d805cc900d534c205 +size 220784 diff --git a/linux/lib/libktxreader.a b/linux/lib/libktxreader.a index 874fa7a3..b3cc4f28 100644 --- a/linux/lib/libktxreader.a +++ b/linux/lib/libktxreader.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:80e8f5cace42fc806401bde510c2859ca434abdb9c876476e028d4a14c9beb2b -size 613150 +oid sha256:bf545ab255a85b85f05f72758752a1f5ed475a3a881f7371e18f0e65b5636ec1 +size 85610 diff --git a/linux/lib/libmatdbg.a b/linux/lib/libmatdbg.a index fb0761d2..0edb1c73 100644 --- a/linux/lib/libmatdbg.a +++ b/linux/lib/libmatdbg.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b9c6dae196747f02010047679497fddf0a0e2795e2306da74e2a2f362d5c85cd -size 186363098 +oid sha256:10ec95bf983a21338b92208fc1604025ca891ceac7356a4886e9b05619a7e5fb +size 8348552 diff --git a/linux/lib/libmathio.a b/linux/lib/libmathio.a index 339df238..92e8f69a 100644 --- a/linux/lib/libmathio.a +++ b/linux/lib/libmathio.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:125e41bf05c5569bbab1a9a4e730952171f1d1ecd3c9ac51201c5b703b431d2e -size 62396 +oid sha256:ab4b4bbd27990a32da29f7a93f4685daa14d89d1489bf2bf86723585dafb7823 +size 61086 diff --git a/linux/lib/libmeshoptimizer.a b/linux/lib/libmeshoptimizer.a index 17f2f244..4dc6350d 100644 --- a/linux/lib/libmeshoptimizer.a +++ b/linux/lib/libmeshoptimizer.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08885808fb57981901601d52709389deb627f0ad8dc297d894d5fc541b7e5cdb -size 567252 +oid sha256:5698733c2f0ec022fbf73a3ef560962fe705445605a8c92d2a753d2ca4a30054 +size 174864 diff --git a/linux/lib/libmikktspace.a b/linux/lib/libmikktspace.a new file mode 100644 index 00000000..83623385 --- /dev/null +++ b/linux/lib/libmikktspace.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e81e890eea666a2e19f3c1d56ba91f39d71a55fab00c6b0585a7d958e11de2ed +size 26814 diff --git a/linux/lib/libshaders.a b/linux/lib/libshaders.a index 7cc4bc21..882882b0 100644 --- a/linux/lib/libshaders.a +++ b/linux/lib/libshaders.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3912f3a85ba6027a19f30dcaffb65de0fc7bd4ea9c2bf239cd9c92657475bf6c -size 199246 +oid sha256:9d96b998912cba46a10df603a2935a8c6648c4f9ecd81e3ef01d08d3ab5deada +size 127214 diff --git a/linux/lib/libsmol-v.a b/linux/lib/libsmol-v.a index cde68db9..a4fb2e76 100644 --- a/linux/lib/libsmol-v.a +++ b/linux/lib/libsmol-v.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5d40543f1fb63d1f8e64d3abffb56fbec337437364b1fdbd04f30280e37f97fa -size 225558 +oid sha256:385ab5a76cf98b5ab185e36ea341fa78ef62402d57613d8be648a4dd141fd859 +size 52676 diff --git a/linux/lib/libstb.a b/linux/lib/libstb.a index 63d0b595..2aa9b8f7 100644 --- a/linux/lib/libstb.a +++ b/linux/lib/libstb.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c2f9fa8c26008fad8866d2b20dfd5ec5361c96f518568878428899ad56f9b989 -size 253050 +oid sha256:8aba29a52ef1dbbdc3d48f1ad9d9616ab544f7d3045733adc9b9de1172ec383e +size 128686 diff --git a/linux/lib/libuberarchive.a b/linux/lib/libuberarchive.a index 35130f44..aa50a973 100644 --- a/linux/lib/libuberarchive.a +++ b/linux/lib/libuberarchive.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cfb8e82fc885e3d07669e4d1d9c7fce52e36c1c70c10aad66c337b4db6b9c449 -size 8246308 +oid sha256:b99bfdfd707379e878d4412014345b29029f90d9ad44072832fc9f4f4e3a2c60 +size 1318116 diff --git a/linux/lib/libuberzlib.a b/linux/lib/libuberzlib.a index 271d8548..f8723cf1 100644 --- a/linux/lib/libuberzlib.a +++ b/linux/lib/libuberzlib.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:43ae7f3612e422d54c2b33494dc2332a505923385f4a203249f1189168b73103 -size 782492 +oid sha256:ac377730ab0d180e7e7c0a0a20f0f87a224d5f133b2a5e0a786f9196609a9623 +size 33806 diff --git a/linux/lib/libutils.a b/linux/lib/libutils.a index be74aa6e..c483d3c2 100644 --- a/linux/lib/libutils.a +++ b/linux/lib/libutils.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:54e20708c379b3da2667c1258e2209d6e482ef9d8c3584259ea28d2aa9d51190 -size 4089942 +oid sha256:796695f0dc99759a6c17a0c3a8382ff1f57b62155224ad051ae9f3fee325f455 +size 323506 diff --git a/linux/lib/libviewer.a b/linux/lib/libviewer.a index 7338a7cd..0481530a 100644 --- a/linux/lib/libviewer.a +++ b/linux/lib/libviewer.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:480dbda40bd0d12b6ed5fa564f25b12820599e68ba989c5e4ff8d81d0800cebb -size 4343164 +oid sha256:6238d9c7ce9d5943c1df2875ebf32bb07b5004c707afa4d6d083d31d320a2ca5 +size 572924 diff --git a/linux/lib/libvkshaders.a b/linux/lib/libvkshaders.a index 63c245ea..37f01e8a 100644 --- a/linux/lib/libvkshaders.a +++ b/linux/lib/libvkshaders.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:904d6add89b410cac49baa53c8cfc408b1baf76f90a5ddfee06749696693f7cd -size 2510 +oid sha256:9d63c579457652ff0fa3b588004d48e8fdb351f15e51b024a359c86f1cb218c5 +size 2358 diff --git a/linux/lib/libzstd.a b/linux/lib/libzstd.a index 18b0196f..9cd61aa5 100644 --- a/linux/lib/libzstd.a +++ b/linux/lib/libzstd.a @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d05e0bd7d82c121d01252b44809242f3147a204d698cef7438134fda02eba9f9 -size 2728394 +oid sha256:c169b961355c52a1213efa6703339007a124cab6be92bf56b8031889b1aa7866 +size 823082 diff --git a/linux/lib/libOGLCompiler.a b/linux/lib/old/libOGLCompiler.a similarity index 100% rename from linux/lib/libOGLCompiler.a rename to linux/lib/old/libOGLCompiler.a diff --git a/linux/lib/libOSDependent.a b/linux/lib/old/libOSDependent.a similarity index 100% rename from linux/lib/libOSDependent.a rename to linux/lib/old/libOSDependent.a diff --git a/linux/lib/libSPIRV-Tools-diff.a b/linux/lib/old/libSPIRV-Tools-diff.a similarity index 100% rename from linux/lib/libSPIRV-Tools-diff.a rename to linux/lib/old/libSPIRV-Tools-diff.a diff --git a/linux/lib/libSPIRV-Tools-link.a b/linux/lib/old/libSPIRV-Tools-link.a similarity index 100% rename from linux/lib/libSPIRV-Tools-link.a rename to linux/lib/old/libSPIRV-Tools-link.a diff --git a/linux/lib/libSPIRV-Tools-lint.a b/linux/lib/old/libSPIRV-Tools-lint.a similarity index 100% rename from linux/lib/libSPIRV-Tools-lint.a rename to linux/lib/old/libSPIRV-Tools-lint.a diff --git a/linux/lib/libSPIRV-Tools-opt.a b/linux/lib/old/libSPIRV-Tools-opt.a similarity index 100% rename from linux/lib/libSPIRV-Tools-opt.a rename to linux/lib/old/libSPIRV-Tools-opt.a diff --git a/linux/lib/libSPIRV-Tools-reduce.a b/linux/lib/old/libSPIRV-Tools-reduce.a similarity index 100% rename from linux/lib/libSPIRV-Tools-reduce.a rename to linux/lib/old/libSPIRV-Tools-reduce.a diff --git a/linux/lib/libSPIRV-Tools.a b/linux/lib/old/libSPIRV-Tools.a similarity index 100% rename from linux/lib/libSPIRV-Tools.a rename to linux/lib/old/libSPIRV-Tools.a diff --git a/linux/lib/libSPIRV.a b/linux/lib/old/libSPIRV.a similarity index 100% rename from linux/lib/libSPIRV.a rename to linux/lib/old/libSPIRV.a diff --git a/linux/lib/libassimp.a b/linux/lib/old/libassimp.a similarity index 100% rename from linux/lib/libassimp.a rename to linux/lib/old/libassimp.a diff --git a/linux/lib/old/libbackend.a b/linux/lib/old/libbackend.a new file mode 100644 index 00000000..93f628e9 --- /dev/null +++ b/linux/lib/old/libbackend.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9233bbaf23bf4b02ca13f93b2bbb7a6c40ee0d933dfc0dfe3830ecd6ec68b38 +size 2107852 diff --git a/linux/lib/old/libbasis_encoder.a b/linux/lib/old/libbasis_encoder.a new file mode 100644 index 00000000..1996b229 --- /dev/null +++ b/linux/lib/old/libbasis_encoder.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:17bd4166018341677a88d292dd7304a3fcf8a2e7fff90efda230baac0fdf2f1d +size 1410760 diff --git a/linux/lib/old/libbasis_transcoder.a b/linux/lib/old/libbasis_transcoder.a new file mode 100644 index 00000000..5b99d570 --- /dev/null +++ b/linux/lib/old/libbasis_transcoder.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:281309f415bd4ecc69dcb29e77629fe40abd6f7c9ca242026ce797a907984fc1 +size 551702 diff --git a/linux/lib/libbenchmark.a b/linux/lib/old/libbenchmark.a similarity index 100% rename from linux/lib/libbenchmark.a rename to linux/lib/old/libbenchmark.a diff --git a/linux/lib/libbenchmark_main.a b/linux/lib/old/libbenchmark_main.a similarity index 100% rename from linux/lib/libbenchmark_main.a rename to linux/lib/old/libbenchmark_main.a diff --git a/linux/lib/old/libbluegl.a b/linux/lib/old/libbluegl.a new file mode 100644 index 00000000..b5c36026 --- /dev/null +++ b/linux/lib/old/libbluegl.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2ba9458f588d16f7ba1fffaddb71cac3b918266bbe88d30710547d03fe7f533 +size 1135298 diff --git a/linux/lib/old/libbluevk.a b/linux/lib/old/libbluevk.a new file mode 100644 index 00000000..2312d7fa --- /dev/null +++ b/linux/lib/old/libbluevk.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:88fb5b1d62898e8f6e5d485f4e7e60b6d71c2e2246aa81aea70e300a7a91068e +size 175364 diff --git a/linux/lib/old/libcamutils.a b/linux/lib/old/libcamutils.a new file mode 100644 index 00000000..a54cff57 --- /dev/null +++ b/linux/lib/old/libcamutils.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcb1603eb181df3098f80f150b8a0d23d32f772f152fee063599ba85c3818b9b +size 62092 diff --git a/linux/lib/old/libcivetweb.a b/linux/lib/old/libcivetweb.a new file mode 100644 index 00000000..92934f10 --- /dev/null +++ b/linux/lib/old/libcivetweb.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d57782d4dca672e74332d51c534b78d03b3646725e86710f3556184ba71e3f9c +size 300742 diff --git a/linux/lib/old/libdracodec.a b/linux/lib/old/libdracodec.a new file mode 100644 index 00000000..09c01d96 --- /dev/null +++ b/linux/lib/old/libdracodec.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5bc48d7c66f24823f093b1dfc7d45073526b2a1f7f8660e337cadbc82081182 +size 2745300 diff --git a/linux/lib/old/libfilabridge.a b/linux/lib/old/libfilabridge.a new file mode 100644 index 00000000..3969919c --- /dev/null +++ b/linux/lib/old/libfilabridge.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bda7d726a5c7fc7dc6bacb6460dbc338d86d63d7cfb311b3aa2678cf118fad8d +size 71580 diff --git a/linux/lib/old/libfilaflat.a b/linux/lib/old/libfilaflat.a new file mode 100644 index 00000000..6d22d093 --- /dev/null +++ b/linux/lib/old/libfilaflat.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d06d5f9fe917fbe6095c1cee333fced10a07f295e689e8bc91eefee3ab7aa934 +size 50170 diff --git a/linux/lib/libfilagui.a b/linux/lib/old/libfilagui.a similarity index 100% rename from linux/lib/libfilagui.a rename to linux/lib/old/libfilagui.a diff --git a/linux/lib/old/libfilamat.a b/linux/lib/old/libfilamat.a new file mode 100644 index 00000000..f2f950f3 --- /dev/null +++ b/linux/lib/old/libfilamat.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2bf46fcbae5a2472d09a321119ef0e094018a6185dda50cd94671f4827a9fe49 +size 31487058 diff --git a/linux/lib/libfilamat_combined.a b/linux/lib/old/libfilamat_combined.a similarity index 100% rename from linux/lib/libfilamat_combined.a rename to linux/lib/old/libfilamat_combined.a diff --git a/linux/lib/old/libfilamat_lite.a b/linux/lib/old/libfilamat_lite.a new file mode 100644 index 00000000..0aeec211 --- /dev/null +++ b/linux/lib/old/libfilamat_lite.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a648a8f87cd29bc9bf44c9ee2a80d79d9ecd1e008d421409f5f512e449af9860 +size 685184 diff --git a/linux/lib/old/libfilament-iblprefilter.a b/linux/lib/old/libfilament-iblprefilter.a new file mode 100644 index 00000000..e782aa7c --- /dev/null +++ b/linux/lib/old/libfilament-iblprefilter.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac11be97f3bcc3c00f52185d8489e64781c99691579b31be14790a73111cadf2 +size 70144 diff --git a/linux/lib/old/libfilament.a b/linux/lib/old/libfilament.a new file mode 100644 index 00000000..1e0d9318 --- /dev/null +++ b/linux/lib/old/libfilament.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86f8afa67a774faab4d30bc295b67801d8d70df6dbd2cd893459484592cc43cb +size 2849794 diff --git a/linux/lib/libfilamentapp-resources.a b/linux/lib/old/libfilamentapp-resources.a similarity index 100% rename from linux/lib/libfilamentapp-resources.a rename to linux/lib/old/libfilamentapp-resources.a diff --git a/linux/lib/libfilamentapp.a b/linux/lib/old/libfilamentapp.a similarity index 100% rename from linux/lib/libfilamentapp.a rename to linux/lib/old/libfilamentapp.a diff --git a/linux/lib/old/libfilameshio.a b/linux/lib/old/libfilameshio.a new file mode 100644 index 00000000..1655c198 --- /dev/null +++ b/linux/lib/old/libfilameshio.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f1748f7b321170f0d2c62c344f79dd18aa544bcc15e24012a08171508e87070a +size 41324 diff --git a/linux/lib/old/libgeometry.a b/linux/lib/old/libgeometry.a new file mode 100644 index 00000000..4c55794d --- /dev/null +++ b/linux/lib/old/libgeometry.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:382b1617880bf2553a51debd2ce2a8171d8e3a7739287ea583dfda5747150783 +size 123772 diff --git a/linux/lib/libgetopt.a b/linux/lib/old/libgetopt.a similarity index 100% rename from linux/lib/libgetopt.a rename to linux/lib/old/libgetopt.a diff --git a/linux/lib/libglslang.a b/linux/lib/old/libglslang.a similarity index 100% rename from linux/lib/libglslang.a rename to linux/lib/old/libglslang.a diff --git a/linux/lib/libgltf-demo-resources.a b/linux/lib/old/libgltf-demo-resources.a similarity index 100% rename from linux/lib/libgltf-demo-resources.a rename to linux/lib/old/libgltf-demo-resources.a diff --git a/linux/lib/old/libgltfio.a b/linux/lib/old/libgltfio.a new file mode 100644 index 00000000..c7f9b8f5 --- /dev/null +++ b/linux/lib/old/libgltfio.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a3bc7fa31ee5a598e4398c76da43d4631cefb717d3b4edeb6382c0a0c9adffe +size 47924 diff --git a/linux/lib/old/libgltfio_core.a b/linux/lib/old/libgltfio_core.a new file mode 100644 index 00000000..de7d639a --- /dev/null +++ b/linux/lib/old/libgltfio_core.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e9c3fa5af012fec4c7b416319295ed1d596c41e050bc6fbc0569cec624a532a +size 1250160 diff --git a/linux/lib/libgtest.a b/linux/lib/old/libgtest.a similarity index 100% rename from linux/lib/libgtest.a rename to linux/lib/old/libgtest.a diff --git a/linux/lib/old/libibl-lite.a b/linux/lib/old/libibl-lite.a new file mode 100644 index 00000000..e775e6c8 --- /dev/null +++ b/linux/lib/old/libibl-lite.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a05e4b140cf4d8e6444401308c636a877c01399533798e73d1430a3b6765a512 +size 399170 diff --git a/linux/lib/old/libibl.a b/linux/lib/old/libibl.a new file mode 100644 index 00000000..1a0ffeec --- /dev/null +++ b/linux/lib/old/libibl.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d45dd173257b3b3df778bb923a324f2e57cb61b4b5fa226839d646cae530a10d +size 486290 diff --git a/linux/lib/old/libimage.a b/linux/lib/old/libimage.a new file mode 100644 index 00000000..160fdb9e --- /dev/null +++ b/linux/lib/old/libimage.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a4aded9717cd630ceda3bf468cdc9b383c2e6cb0f6f5b8191642bef55677eac +size 113934 diff --git a/linux/lib/libimgui.a b/linux/lib/old/libimgui.a similarity index 100% rename from linux/lib/libimgui.a rename to linux/lib/old/libimgui.a diff --git a/linux/lib/old/libktxreader.a b/linux/lib/old/libktxreader.a new file mode 100644 index 00000000..793dd53f --- /dev/null +++ b/linux/lib/old/libktxreader.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5a99686de9781302ad3989167352dbe3050c63f611d9d9825dea50a25722253 +size 85792 diff --git a/linux/lib/old/libmatdbg.a b/linux/lib/old/libmatdbg.a new file mode 100644 index 00000000..aec48d19 --- /dev/null +++ b/linux/lib/old/libmatdbg.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abcbab3fe10636113804ee35f706132b1c689312df6e64b3cc12241fd8807e3f +size 8427566 diff --git a/linux/lib/libmatdbg_combined.a b/linux/lib/old/libmatdbg_combined.a similarity index 100% rename from linux/lib/libmatdbg_combined.a rename to linux/lib/old/libmatdbg_combined.a diff --git a/linux/lib/libmatdbg_resources.a b/linux/lib/old/libmatdbg_resources.a similarity index 100% rename from linux/lib/libmatdbg_resources.a rename to linux/lib/old/libmatdbg_resources.a diff --git a/linux/lib/libmatlang.a b/linux/lib/old/libmatlang.a similarity index 100% rename from linux/lib/libmatlang.a rename to linux/lib/old/libmatlang.a diff --git a/linux/lib/old/libmeshoptimizer.a b/linux/lib/old/libmeshoptimizer.a new file mode 100644 index 00000000..5e851a57 --- /dev/null +++ b/linux/lib/old/libmeshoptimizer.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2181fb9a0a814117e6f427741fca5b94a74ff7d1c561e42a2ac3fda45cb978e7 +size 177664 diff --git a/linux/lib/old/libmikktspace.a b/linux/lib/old/libmikktspace.a new file mode 100644 index 00000000..bbda7ace --- /dev/null +++ b/linux/lib/old/libmikktspace.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a52df85ad23304c30afbc5c07831c2ac030ecb5eccdaa8eef0cfb5a04fd80109 +size 26798 diff --git a/linux/lib/libpng.a b/linux/lib/old/libpng.a similarity index 100% rename from linux/lib/libpng.a rename to linux/lib/old/libpng.a diff --git a/linux/lib/libsample-resources.a b/linux/lib/old/libsample-resources.a similarity index 100% rename from linux/lib/libsample-resources.a rename to linux/lib/old/libsample-resources.a diff --git a/linux/lib/libsdl2.a b/linux/lib/old/libsdl2.a similarity index 100% rename from linux/lib/libsdl2.a rename to linux/lib/old/libsdl2.a diff --git a/linux/lib/old/libshaders.a b/linux/lib/old/libshaders.a new file mode 100644 index 00000000..882882b0 --- /dev/null +++ b/linux/lib/old/libshaders.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d96b998912cba46a10df603a2935a8c6648c4f9ecd81e3ef01d08d3ab5deada +size 127214 diff --git a/linux/lib/old/libsmol-v.a b/linux/lib/old/libsmol-v.a new file mode 100644 index 00000000..31f43b55 --- /dev/null +++ b/linux/lib/old/libsmol-v.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2055559c7fd28e2c5ab6fa95571e7b804dada6c0264403a7691e9d48864fad2f +size 49236 diff --git a/linux/lib/libspirv-cross-core.a b/linux/lib/old/libspirv-cross-core.a similarity index 100% rename from linux/lib/libspirv-cross-core.a rename to linux/lib/old/libspirv-cross-core.a diff --git a/linux/lib/libspirv-cross-glsl.a b/linux/lib/old/libspirv-cross-glsl.a similarity index 100% rename from linux/lib/libspirv-cross-glsl.a rename to linux/lib/old/libspirv-cross-glsl.a diff --git a/linux/lib/libspirv-cross-msl.a b/linux/lib/old/libspirv-cross-msl.a similarity index 100% rename from linux/lib/libspirv-cross-msl.a rename to linux/lib/old/libspirv-cross-msl.a diff --git a/linux/lib/old/libstb.a b/linux/lib/old/libstb.a new file mode 100644 index 00000000..fb31d88f --- /dev/null +++ b/linux/lib/old/libstb.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:78c97d940ac5dfd3fbc146f8168c7b89c20d4aa6ba8c323dc26c022d4155d8e1 +size 130070 diff --git a/linux/lib/libsuzanne-resources.a b/linux/lib/old/libsuzanne-resources.a similarity index 100% rename from linux/lib/libsuzanne-resources.a rename to linux/lib/old/libsuzanne-resources.a diff --git a/linux/lib/old/libuberarchive.a b/linux/lib/old/libuberarchive.a new file mode 100644 index 00000000..e1e4e6f3 --- /dev/null +++ b/linux/lib/old/libuberarchive.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a766234ee09ccaee43e9e7e8ea162dd8d247cc299f3963372da64660166fa61b +size 1318108 diff --git a/linux/lib/old/libuberzlib.a b/linux/lib/old/libuberzlib.a new file mode 100644 index 00000000..f22c5089 --- /dev/null +++ b/linux/lib/old/libuberzlib.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fc90bdc0cf7a3181de1f7b768b00615a43e484d76d940362b34d23983cdeaaca +size 33632 diff --git a/linux/lib/old/libutils.a b/linux/lib/old/libutils.a new file mode 100644 index 00000000..f9855c7e --- /dev/null +++ b/linux/lib/old/libutils.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ed36b2ab76f7698d107a9d9943e0bf17bd1ba3e2f11103134ad8df583eb919e3 +size 327224 diff --git a/linux/lib/old/libviewer.a b/linux/lib/old/libviewer.a new file mode 100644 index 00000000..5f2ceeaf --- /dev/null +++ b/linux/lib/old/libviewer.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1d7fedd4fe79bc4a8ffe668830b21211e95d167676b0bea7376daef211b2eb4b +size 571874 diff --git a/linux/lib/old/libvkshaders.a b/linux/lib/old/libvkshaders.a new file mode 100644 index 00000000..e462e398 --- /dev/null +++ b/linux/lib/old/libvkshaders.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3175887fd3d05fb95619930273ea26f80200eef48f1a7a82b9f94ba0d895ee3 +size 2350 diff --git a/linux/lib/libz.a b/linux/lib/old/libz.a similarity index 100% rename from linux/lib/libz.a rename to linux/lib/old/libz.a diff --git a/linux/lib/old/libzstd.a b/linux/lib/old/libzstd.a new file mode 100644 index 00000000..0f89e87b --- /dev/null +++ b/linux/lib/old/libzstd.a @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:909eac77748638ea1d56bd0c3017b0c4adaf4b027051e716c8b7b185b4c092bc +size 849602 diff --git a/linux/polyvox_filament_plugin.cc b/linux/polyvox_filament_plugin.cc index 5bfc9492..1bdca77f 100644 --- a/linux/polyvox_filament_plugin.cc +++ b/linux/polyvox_filament_plugin.cc @@ -40,8 +40,10 @@ struct _PolyvoxFilamentPlugin { FlTextureRegistrar* texture_registrar; FlView* fl_view; FlTexture* texture; - double width; - double height; + double width = 0; + double height = 0; + bool rendering = false; + polyvox::FilamentViewer* viewer; }; G_DEFINE_TYPE(PolyvoxFilamentPlugin, polyvox_filament_plugin, g_object_get_type()) @@ -57,6 +59,19 @@ static gboolean on_frame_tick(GtkWidget* widget, GdkFrameClock* frame_clock, gpo return TRUE; } +static FlMethodResponse* _create_filament_viewer(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + auto callback = new ResourceLoaderWrapper(loadResource, freeResource); + + auto context = glXGetCurrentContext(); + self->viewer = (polyvox::FilamentViewer*)create_filament_viewer( + (void*)context, + callback + ); + g_autoptr(FlValue) result = + fl_value_new_int(reinterpret_cast(self->viewer)); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + static FlMethodResponse* _create_texture(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { if(self->texture) { Log("Error - create_texture called when texture exists."); @@ -89,6 +104,11 @@ static FlMethodResponse* _resize(PolyvoxFilamentPlugin* self, FlMethodCall* meth destroy_filament_texture(self->texture, self->texture_registrar); self->texture = create_filament_texture(uint32_t(width), uint32_t(height), self->texture_registrar); + + create_swap_chain(self->viewer, nullptr, width, height); + create_render_target(self->viewer, ((FilamentTextureGL*)self->texture)->texture_id,width,height); + + update_viewport_and_camera_projection(self->viewer, width, height, 1.0f); g_autoptr(FlValue) result = fl_value_new_int(reinterpret_cast(self->texture)); @@ -96,6 +116,502 @@ static FlMethodResponse* _resize(PolyvoxFilamentPlugin* self, FlMethodCall* meth return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); } +static FlMethodResponse* _loadSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + + const gchar* path = fl_value_get_string(args); + + load_skybox(self->viewer, path); + + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _remove_ibl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + remove_ibl(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _loadIbl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + + auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); + auto intensity = fl_value_get_float(fl_value_get_list_value(args, 1)); + + load_ibl(self->viewer, path, intensity); + + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _removeSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + std::cout << "Removing skybox" << std::endl; + remove_skybox(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_background_image(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + + FlValue* args = fl_method_call_get_args(method_call); + + const gchar* path = fl_value_get_string(args); + + set_background_image(self->viewer, path); + + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_background_color(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + + const float* color = fl_value_get_float32_list(fl_method_call_get_args(method_call)); + set_background_color(self->viewer, color[0], color[1], color[2], color[2]); + + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _add_light(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + + FlValue* args = fl_method_call_get_args(method_call); + + auto type = (uint8_t)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto color = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto intensity = float(fl_value_get_float(fl_value_get_list_value(args, 2))); + auto posX = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); + auto posY = (float)fl_value_get_float(fl_value_get_list_value(args, 4)); + auto posZ = (float)fl_value_get_float(fl_value_get_list_value(args, 5)); + auto dirX = (float)fl_value_get_float(fl_value_get_list_value(args, 6)); + auto dirY = (float)fl_value_get_float(fl_value_get_list_value(args, 7)); + auto dirZ = (float)fl_value_get_float(fl_value_get_list_value(args, 8)); + auto shadows = fl_value_get_bool(fl_value_get_list_value(args, 9)); + + auto entityId = add_light(self->viewer, type, color, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows); + g_autoptr(FlValue) result = fl_value_new_int(entityId); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); + +} + +static FlMethodResponse* _load_glb(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); + auto unlit = fl_value_get_bool(fl_value_get_list_value(args, 1)); + auto entityId = load_glb(self->viewer, path, unlit); + g_autoptr(FlValue) result = fl_value_new_int((int64_t)entityId); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _get_animation_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + + FlValue* args = fl_method_call_get_args(method_call); + auto assetManager = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + g_autoptr(FlValue) result = fl_value_new_list(); + + auto numNames = get_animation_count(assetManager, asset); + + for(int i = 0; i < numNames; i++) { + gchar out[255]; + get_animation_name(assetManager, asset, out, i); + fl_value_append_take (result, fl_value_new_string (out)); + } + + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _remove_asset(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + remove_asset(self->viewer, asset); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _transform_to_unit_cube(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetManager = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + transform_to_unit_cube(assetManager, asset); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _rotate_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + + grab_begin(self->viewer, x,y, false); + + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _rotate_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + grab_end(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _rotate_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + + grab_update(self->viewer, x,y); + + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _pan_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + + FlValue* args = fl_method_call_get_args(method_call); + + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + + grab_begin(self->viewer, x,y, true); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _pan_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + + grab_update(self->viewer, x,y); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _pan_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + grab_end(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetManager = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + + set_position( + assetManager, + asset, + (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // x + (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // y + (float)fl_value_get_float(fl_value_get_list_value(args, 4)) // z + ); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetManager = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + + set_rotation( + assetManager, + asset, + (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // rads + (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // x + (float)fl_value_get_float(fl_value_get_list_value(args, 4)), // y + (float)fl_value_get_float(fl_value_get_list_value(args, 5 )) // z + ); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + + + +static FlMethodResponse* _set_bone_transform(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + throw std::invalid_argument( "received negative value" ); + // FlValue* args = fl_method_call_get_args(method_call); + // auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + // auto boneName = fl_value_get_string(fl_value_get_list_value(args, 1)); + // auto meshName = fl_value_get_string(fl_value_get_list_value(args, 2)); + + // set_bone_transform( + // assetPtr, + // boneName, + // meshName, + // (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // transX + // (float)fl_value_get_float(fl_value_get_list_value(args, 4)), // transY + // (float)fl_value_get_float(fl_value_get_list_value(args, 5)), // transZ + // (float)fl_value_get_float(fl_value_get_list_value(args, 6)), // quatX + // (float)fl_value_get_float(fl_value_get_list_value(args, 7)), // quatY + // (float)fl_value_get_float(fl_value_get_list_value(args, 8)), // quatZ + // (float)fl_value_get_float(fl_value_get_list_value(args, 9)) // quatW + // ); + // g_autoptr(FlValue) result = fl_value_new_string("OK"); + // return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_camera(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto cameraName = fl_value_get_string(fl_value_get_list_value(args, 1)) ; + + set_camera(self->viewer, asset, cameraName); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_camera_model_matrix(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + set_camera_model_matrix(self->viewer, fl_value_get_float32_list(args)); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_camera_exposure(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto aperture = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto shutter_speed = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto sensitivity = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); + set_camera_exposure(self->viewer, aperture, shutter_speed, sensitivity); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_camera_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); + set_camera_position(self->viewer, x,y, z); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_camera_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto rads = (float)fl_value_get_float(fl_value_get_list_value(args,0 )); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); + auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); + + set_camera_rotation(self->viewer, rads, x,y, z); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_rendering(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + self->rendering = (bool)fl_value_get_bool(args); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_frame_interval(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto val = (float) fl_value_get_float(args); + set_frame_interval(self->viewer, val); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _zoom_begin(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + scroll_begin(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _zoom_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + scroll_end(self->viewer); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _zoom_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); + auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); + auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); + + scroll_update(self->viewer, x,y, z); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _play_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetManager = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 2)); + auto loop = (bool)fl_value_get_bool(fl_value_get_list_value(args, 3)); + auto reverse = (bool)fl_value_get_bool(fl_value_get_list_value(args, 4)); + auto replaceActive = (bool)fl_value_get_bool(fl_value_get_list_value(args, 5)); + auto crossfade = (bool)fl_value_get_float(fl_value_get_list_value(args, 6)); + play_animation(assetManager, asset, animationId, loop, reverse, replaceActive, crossfade); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + + +static FlMethodResponse* _stop_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetManager = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 2)); + stop_animation(assetManager, asset, animationId); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _apply_weights(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + // FlValue* args = fl_method_call_get_args(method_call); + // auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + // auto entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); + // auto weightsValue = fl_value_get_list_value(args, 2); + // float* const weights = (float* const) fl_value_get_float32_list(weightsValue); + // size_t len = fl_value_get_length(weightsValue); + // apply_weights(assetPtr, entityName, weights, (int)len); + g_autoptr(FlValue) result = fl_value_new_string("OK"); + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _set_morph_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + throw std::invalid_argument( "received negative value" ); + // int64_t assetManager = std::any_cast(args[0]); + // EntityId asset = std::any_cast(args[1]); + // std::string entityName = std::any_cast(fl_value_get_string(fl_value_get_list_value(args, 2))); + + // std::vector morphData = std::any_cast>(args[3]); + // std::vector morphIndices = std::any_cast>(args[4]); + // int32_t numMorphTargets = std::any_cast(args[5]); + // int32_t numFrames = std::any_cast(args[6]); + // double frameLengthInMs = std::any_cast(args[7]); + + // // Convert morphData from double to float + // std::vector frameData; + // frameData.reserve(morphData.size()); + // for (double value : morphData) { + // frameData.push_back(static_cast(value)); + // } + + // void* am = reinterpret_cast(assetManager); + + // bool success = set_morph_animation( + // am, + // asset, + // entityName.c_str(), + // frameData, + // morphIndices, + // numMorphTargets, + // numFrames, + // static_cast(frameLengthInMs) + // ); + + // return success; +} + +static FlMethodResponse* _set_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + throw std::invalid_argument( "received negative value" ); + // FlValue* args = fl_method_call_get_args(method_call); + // auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + + // const char* entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); + + // float* const morphData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(args, 2)); + + // int64_t numMorphWeights = fl_value_get_int(fl_value_get_list_value(args, 3)); + + // FlValue* flBoneAnimations = fl_value_get_list_value(args, 4); + + // size_t numBoneAnimations = fl_value_get_length(flBoneAnimations); + + // vector boneAnimations; + + // for(int i = 0; i < numBoneAnimations; i++) { + + // FlValue* flBoneAnimation = fl_value_get_list_value(flBoneAnimations, i); + + // FlValue* flBoneNames = fl_value_get_list_value(flBoneAnimation, 0); + // FlValue* flMeshNames = fl_value_get_list_value(flBoneAnimation, 1); + // float* const frameData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(flBoneAnimation, 2)); + + // Log("Framedata %f", frameData); + + // vector boneNames; + // boneNames.resize(fl_value_get_length(flBoneNames)); + + // for(int i=0; i < boneNames.size(); i++) { + // boneNames[i] = fl_value_get_string(fl_value_get_list_value(flBoneNames, i)) ; + // } + + // vector meshNames; + // meshNames.resize(fl_value_get_length(flMeshNames)); + // for(int i=0; i < meshNames.size(); i++) { + // meshNames[i] = fl_value_get_string(fl_value_get_list_value(flMeshNames, i)); + // } + + // const char** boneNamesPtr = (const char**)malloc(boneNames.size() * sizeof(char*)); + // memcpy((void*)boneNamesPtr, (void*)boneNames.data(), boneNames.size() * sizeof(char*)); + // auto meshNamesPtr = (const char**)malloc(meshNames.size() * sizeof(char*)); + // memcpy((void*)meshNamesPtr, (void*)meshNames.data(), meshNames.size() * sizeof(char*)); + + // BoneAnimation animation { + // .boneNames = boneNamesPtr, + // .meshNames = meshNamesPtr, + // .data = frameData, + // .numBones = boneNames.size(), + // .numMeshTargets = meshNames.size() + // }; + + // boneAnimations.push_back(animation); + + // } + + // int64_t numFrames = fl_value_get_int(fl_value_get_list_value(args, 5)); + + // float frameLengthInMs = fl_value_get_float(fl_value_get_list_value(args, 6)); + + // auto boneAnimationsPointer = boneAnimations.data(); + // auto boneAnimationsSize = boneAnimations.size(); + + // set_animation( + // assetPtr, + // entityName, + // morphData, + // numMorphWeights, + // boneAnimationsPointer, + // boneAnimationsSize, + // numFrames, + // frameLengthInMs); + + // g_autoptr(FlValue) result = fl_value_new_string("OK"); + // return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + +static FlMethodResponse* _get_morph_target_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { + FlValue* args = fl_method_call_get_args(method_call); + auto assetManager = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); + auto asset = (EntityId)fl_value_get_int(fl_value_get_list_value(args, 1)); + auto meshName = fl_value_get_string(fl_value_get_list_value(args, 2)); + g_autoptr(FlValue) result = fl_value_new_list(); + + auto numNames = get_morph_target_name_count(assetManager, asset, meshName); + + std::cout << numNames << " morph targets found in mesh " << meshName << std::endl; + + for(int i = 0; i < numNames; i++) { + gchar out[255]; + get_morph_target_name(assetManager, asset, meshName, out, i); + fl_value_append_take (result, fl_value_new_string (out)); + } + + return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); +} + + // Called when a method call is received from Flutter. static void polyvox_filament_plugin_handle_method_call( @@ -106,7 +622,9 @@ static void polyvox_filament_plugin_handle_method_call( const gchar* method = fl_method_call_get_name(method_call); - if(strcmp(method, "createTexture") == 0) { + if(strcmp(method, "createFilamentViewer") == 0) { + response = _create_filament_viewer(self, method_call); + } else if(strcmp(method, "createTexture") == 0) { response = _create_texture(self, method_call); } else if(strcmp(method, "resize") == 0) { response = _resize(self, method_call); @@ -257,450 +775,5 @@ void polyvox_filament_plugin_register_with_registrar(FlPluginRegistrar* registra -static FlMethodResponse* _loadSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - - const gchar* path = fl_value_get_string(args); - - load_skybox(self->viewer, path); - - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _remove_ibl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - remove_ibl(self->viewer); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _loadIbl(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - - auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); - auto intensity = fl_value_get_float(fl_value_get_list_value(args, 1)); - - load_ibl(self->viewer, path, intensity); - - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _removeSkybox(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - std::cout << "Removing skybox" << std::endl; - remove_skybox(self->viewer); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_background_image(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - - FlValue* args = fl_method_call_get_args(method_call); - - const gchar* path = fl_value_get_string(args); - - set_background_image(self->viewer, path); - - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_background_color(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - - const float* color = fl_value_get_float32_list(fl_method_call_get_args(method_call)); - set_background_color(self->viewer, color[0], color[1], color[2], color[2]); - - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _add_light(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - - FlValue* args = fl_method_call_get_args(method_call); - - auto type = (uint8_t)fl_value_get_int(fl_value_get_list_value(args, 0)); - auto color = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - auto intensity = float(fl_value_get_float(fl_value_get_list_value(args, 2))); - auto posX = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); - auto posY = (float)fl_value_get_float(fl_value_get_list_value(args, 4)); - auto posZ = (float)fl_value_get_float(fl_value_get_list_value(args, 5)); - auto dirX = (float)fl_value_get_float(fl_value_get_list_value(args, 6)); - auto dirY = (float)fl_value_get_float(fl_value_get_list_value(args, 7)); - auto dirZ = (float)fl_value_get_float(fl_value_get_list_value(args, 8)); - auto shadows = fl_value_get_bool(fl_value_get_list_value(args, 9)); - - auto entityId = add_light(self->viewer, type, color, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows); - g_autoptr(FlValue) result = fl_value_new_int(entityId); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - -} - -static FlMethodResponse* _load_glb(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto path = fl_value_get_string(fl_value_get_list_value(args, 0)); - auto unlit = fl_value_get_bool(fl_value_get_list_value(args, 1)); - auto entityId = load_glb(self->viewer, path, unlit); - g_autoptr(FlValue) result = fl_value_new_int((int64_t)entityId); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _get_animation_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(args); - g_autoptr(FlValue) result = fl_value_new_list(); - - auto numNames = get_animation_count(assetPtr); - - for(int i = 0; i < numNames; i++) { - gchar out[255]; - get_animation_name(assetPtr, out, i); - fl_value_append_take (result, fl_value_new_string (out)); - } - - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _remove_asset(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(args); - remove_asset(self->viewer, assetPtr); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _transform_to_unit_cube(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(args); - transform_to_unit_cube(assetPtr); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _rotate_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - - auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); - auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - - grab_begin(self->viewer, x,y, false); - - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _rotate_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - grab_end(self->viewer); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _rotate_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); - auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - - grab_update(self->viewer, x,y); - - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _pan_start(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - - FlValue* args = fl_method_call_get_args(method_call); - - auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); - auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - - grab_begin(self->viewer, x,y, true); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _pan_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); - auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - - grab_update(self->viewer, x,y); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _pan_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - grab_end(self->viewer); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - - set_position( - assetPtr, - (float)fl_value_get_float(fl_value_get_list_value(args, 1)), // x - (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // y - (float)fl_value_get_float(fl_value_get_list_value(args, 3)) // z - ); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - - set_rotation( - assetPtr, - (float)fl_value_get_float(fl_value_get_list_value(args, 1)), // rads - (float)fl_value_get_float(fl_value_get_list_value(args, 2)), // x - (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // y - (float)fl_value_get_float(fl_value_get_list_value(args, 4)) // z - ); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - - - -static FlMethodResponse* _set_bone_transform(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - auto boneName = fl_value_get_string(fl_value_get_list_value(args, 1)); - auto meshName = fl_value_get_string(fl_value_get_list_value(args, 2)); - - set_bone_transform( - assetPtr, - boneName, - meshName, - (float)fl_value_get_float(fl_value_get_list_value(args, 3)), // transX - (float)fl_value_get_float(fl_value_get_list_value(args, 4)), // transY - (float)fl_value_get_float(fl_value_get_list_value(args, 5)), // transZ - (float)fl_value_get_float(fl_value_get_list_value(args, 6)), // quatX - (float)fl_value_get_float(fl_value_get_list_value(args, 7)), // quatY - (float)fl_value_get_float(fl_value_get_list_value(args, 8)), // quatZ - (float)fl_value_get_float(fl_value_get_list_value(args, 9)) // quatW - ); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_camera(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - auto cameraName = fl_value_get_string(fl_value_get_list_value(args, 1)) ; - - set_camera(self->viewer, (void*)assetPtr, cameraName); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_camera_model_matrix(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - set_camera_model_matrix(self->viewer, fl_value_get_float32_list(args)); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_camera_exposure(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto aperture = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); - auto shutter_speed = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - auto sensitivity = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); - set_camera_exposure(self->viewer, aperture, shutter_speed, sensitivity); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_camera_position(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); - auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); - set_camera_position(self->viewer, x,y, z); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_camera_rotation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto rads = (float)fl_value_get_float(fl_value_get_list_value(args,0 )); - auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); - auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 3)); - - set_camera_rotation(self->viewer, rads, x,y, z); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_rendering(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - self->rendering = (bool)fl_value_get_bool(args); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_frame_interval(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto val = (float) fl_value_get_float(args); - set_frame_interval(self->viewer, val); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _zoom_begin(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - scroll_begin(self->viewer); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _zoom_end(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - scroll_end(self->viewer); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _zoom_update(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto x = (float)fl_value_get_float(fl_value_get_list_value(args, 0)); - auto y = (float)fl_value_get_float(fl_value_get_list_value(args, 1)); - auto z = (float)fl_value_get_float(fl_value_get_list_value(args, 2)); - - scroll_update(self->viewer, x,y, z); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _play_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 1)); - auto loop = (bool)fl_value_get_bool(fl_value_get_list_value(args, 2)); - auto reverse = (bool)fl_value_get_bool(fl_value_get_list_value(args, 3)); - play_animation(assetPtr, animationId, loop, reverse); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - - -static FlMethodResponse* _stop_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - auto animationId = (int)fl_value_get_int(fl_value_get_list_value(args, 1)); - stop_animation(assetPtr, animationId); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _apply_weights(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - auto entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); - auto weightsValue = fl_value_get_list_value(args, 2); - float* const weights = (float* const) fl_value_get_float32_list(weightsValue); - size_t len = fl_value_get_length(weightsValue); - apply_weights(assetPtr, entityName, weights, (int)len); - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _set_animation(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - - const char* entityName = fl_value_get_string(fl_value_get_list_value(args, 1)); - - float* const morphData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(args, 2)); - - int64_t numMorphWeights = fl_value_get_int(fl_value_get_list_value(args, 3)); - - FlValue* flBoneAnimations = fl_value_get_list_value(args, 4); - - size_t numBoneAnimations = fl_value_get_length(flBoneAnimations); - - vector boneAnimations; - - for(int i = 0; i < numBoneAnimations; i++) { - - FlValue* flBoneAnimation = fl_value_get_list_value(flBoneAnimations, i); - - FlValue* flBoneNames = fl_value_get_list_value(flBoneAnimation, 0); - FlValue* flMeshNames = fl_value_get_list_value(flBoneAnimation, 1); - float* const frameData = (float* const) fl_value_get_float32_list(fl_value_get_list_value(flBoneAnimation, 2)); - - Log("Framedata %f", frameData); - - vector boneNames; - boneNames.resize(fl_value_get_length(flBoneNames)); - - for(int i=0; i < boneNames.size(); i++) { - boneNames[i] = fl_value_get_string(fl_value_get_list_value(flBoneNames, i)) ; - } - - vector meshNames; - meshNames.resize(fl_value_get_length(flMeshNames)); - for(int i=0; i < meshNames.size(); i++) { - meshNames[i] = fl_value_get_string(fl_value_get_list_value(flMeshNames, i)); - } - - const char** boneNamesPtr = (const char**)malloc(boneNames.size() * sizeof(char*)); - memcpy((void*)boneNamesPtr, (void*)boneNames.data(), boneNames.size() * sizeof(char*)); - auto meshNamesPtr = (const char**)malloc(meshNames.size() * sizeof(char*)); - memcpy((void*)meshNamesPtr, (void*)meshNames.data(), meshNames.size() * sizeof(char*)); - - BoneAnimation animation { - .boneNames = boneNamesPtr, - .meshNames = meshNamesPtr, - .data = frameData, - .numBones = boneNames.size(), - .numMeshTargets = meshNames.size() - }; - - boneAnimations.push_back(animation); - - } - - int64_t numFrames = fl_value_get_int(fl_value_get_list_value(args, 5)); - - float frameLengthInMs = fl_value_get_float(fl_value_get_list_value(args, 6)); - - auto boneAnimationsPointer = boneAnimations.data(); - auto boneAnimationsSize = boneAnimations.size(); - - set_animation( - assetPtr, - entityName, - morphData, - numMorphWeights, - boneAnimationsPointer, - boneAnimationsSize, - numFrames, - frameLengthInMs); - - g_autoptr(FlValue) result = fl_value_new_string("OK"); - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} - -static FlMethodResponse* _get_morph_target_names(PolyvoxFilamentPlugin* self, FlMethodCall* method_call) { - FlValue* args = fl_method_call_get_args(method_call); - auto assetPtr = (void*)fl_value_get_int(fl_value_get_list_value(args, 0)); - auto meshName = fl_value_get_string(fl_value_get_list_value(args, 1)); - g_autoptr(FlValue) result = fl_value_new_list(); - - auto numNames = get_morph_target_name_count(assetPtr, meshName); - - std::cout << numNames << " morph targets found in mesh " << meshName << std::endl; - - for(int i = 0; i < numNames; i++) { - gchar out[255]; - get_morph_target_name(assetPtr, meshName, out, i); - fl_value_append_take (result, fl_value_new_string (out)); - } - - return FL_METHOD_RESPONSE(fl_method_success_response_new(result)); -} \ No newline at end of file