diff --git a/thermion_dart/lib/src/viewer/src/ffi/src/thermion_dart.g.dart b/thermion_dart/lib/src/viewer/src/ffi/src/thermion_dart.g.dart index 5b49e076..a0daa5d8 100644 --- a/thermion_dart/lib/src/viewer/src/ffi/src/thermion_dart.g.dart +++ b/thermion_dart/lib/src/viewer/src/ffi/src/thermion_dart.g.dart @@ -807,12 +807,30 @@ external void View_setSoftShadowOptions( double penumbraRatioScale, ); -@ffi.Native, ffi.Float)>(isLeaf: true) +@ffi.Native, ffi.Bool, ffi.Float)>( + isLeaf: true) external void View_setBloom( ffi.Pointer tView, + bool enabled, double strength, ); +@ffi.Native, ffi.UnsignedInt)>( + symbol: "View_setRenderQuality", isLeaf: true) +external void _View_setRenderQuality( + ffi.Pointer tView, + int qualityLevel, +); + +void View_setRenderQuality( + ffi.Pointer tView, + TQualityLevel qualityLevel, +) => + _View_setRenderQuality( + tView, + qualityLevel.value, + ); + @ffi.Native< ffi.Void Function(ffi.Pointer, ffi.Pointer, ffi.UnsignedInt)>(symbol: "View_setToneMapping", isLeaf: true) @@ -871,6 +889,361 @@ external ffi.Pointer View_getCamera( @ffi.Native, ffi.Bool)>(isLeaf: true) external void View_setStencilBufferEnabled( ffi.Pointer tView, + ffi.Pointer tEngine, + int thermion, +); + +@ffi.Native, ffi.Bool, ffi.Double)>( + isLeaf: true) +external void View_setBloomRenderThread( + ffi.Pointer tView, + bool enabled, + double strength, +); + +@ffi.Native( + isLeaf: true) +external FilamentRenderCallback make_render_callback_fn_pointer( + FilamentRenderCallback arg0, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Bool, + ffi.Pointer>)>(isLeaf: true) +external void set_rendering_render_thread( + ffi.Pointer viewer, + bool rendering, + ffi.Pointer> onComplete, +); + +@ffi.Native, ffi.Float)>(isLeaf: true) +external void set_frame_interval_render_thread( + ffi.Pointer viewer, + double frameInterval, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Float, ffi.Float, ffi.Float, + ffi.Float)>(isLeaf: true) +external void set_background_color_render_thread( + ffi.Pointer viewer, + double r, + double g, + double b, + double a, +); + +@ffi.Native)>(isLeaf: true) +external void clear_background_image_render_thread( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, ffi.Bool, + ffi.Pointer>)>(isLeaf: true) +external void set_background_image_render_thread( + ffi.Pointer viewer, + ffi.Pointer path, + bool fillHeight, + ffi.Pointer> onComplete, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, ffi.Float, ffi.Float, ffi.Bool)>(isLeaf: true) +external void set_background_image_position_render_thread( + ffi.Pointer viewer, + double x, + double y, + bool clamp, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer>)>(isLeaf: true) +external void load_skybox_render_thread( + ffi.Pointer viewer, + ffi.Pointer skyboxPath, + ffi.Pointer> onComplete, +); + +@ffi.Native)>(isLeaf: true) +external void remove_skybox_render_thread( + ffi.Pointer viewer, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Pointer, + ffi.Int, + ffi.Int, + ffi.Pointer, + ffi.Bool, + ffi.Pointer>)>( + isLeaf: true) +external void SceneManager_createGeometryRenderThread( + ffi.Pointer sceneManager, + ffi.Pointer vertices, + int numVertices, + ffi.Pointer normals, + int numNormals, + ffi.Pointer uvs, + int numUvs, + ffi.Pointer indices, + int numIndices, + int primitiveType, + ffi.Pointer materialInstance, + bool keepData, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Size, + ffi.Int, + ffi.Bool, + ffi.Int, + ffi.Int, + ffi.Bool, + ffi.Pointer>)>( + isLeaf: true) +external void SceneManager_loadGlbFromBufferRenderThread( + ffi.Pointer sceneManager, + ffi.Pointer data, + int length, + int numInstances, + bool keepData, + int priority, + int layer, + bool loadResourcesAsync, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer)>>)>(isLeaf: true) +external void SceneManager_createUnlitMaterialInstanceRenderThread( + ffi.Pointer sceneManager, + ffi.Pointer< + ffi.NativeFunction)>> + callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer< + ffi.NativeFunction< + ffi.Void Function( + ffi.Pointer)>>)>(isLeaf: true) +external void SceneManager_createUnlitFixedSizeMaterialInstanceRenderThread( + ffi.Pointer sceneManager, + ffi.Pointer< + ffi.NativeFunction)>> + callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Int, + ffi.Bool, + ffi.Pointer>)>( + isLeaf: true) +external void load_glb_render_thread( + ffi.Pointer sceneManager, + ffi.Pointer assetPath, + int numInstances, + bool keepData, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.Bool, + ffi.Pointer>)>( + isLeaf: true) +external void load_gltf_render_thread( + ffi.Pointer sceneManager, + ffi.Pointer assetPath, + ffi.Pointer relativePath, + bool keepData, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer>)>( + isLeaf: true) +external void create_instance_render_thread( + ffi.Pointer sceneManager, + int entityId, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer>)>(isLeaf: true) +external void remove_entity_render_thread( + ffi.Pointer viewer, + int asset, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, + ffi.Pointer>)>(isLeaf: true) +external void clear_entities_render_thread( + ffi.Pointer viewer, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer, ffi.Pointer, ffi.Int)>(isLeaf: true) +external void apply_weights_render_thread( + ffi.Pointer sceneManager, + int asset, + ffi.Pointer entityName, + ffi.Pointer weights, + int count, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, EntityId, ffi.Int, ffi.Int)>(isLeaf: true) +external void set_animation_frame_render_thread( + ffi.Pointer sceneManager, + int asset, + int animationIndex, + int animationFrame, +); + +@ffi.Native, EntityId, ffi.Int)>( + isLeaf: true) +external void stop_animation_render_thread( + ffi.Pointer sceneManager, + int asset, + int index, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer>)>( + isLeaf: true) +external void get_animation_count_render_thread( + ffi.Pointer sceneManager, + int asset, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Int, + ffi.Pointer>)>(isLeaf: true) +external void get_animation_name_render_thread( + ffi.Pointer sceneManager, + int asset, + ffi.Pointer outPtr, + int index, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + EntityId, + ffi.Pointer, + ffi.Int, + ffi.Pointer>)>(isLeaf: true) +external void get_morph_target_name_render_thread( + ffi.Pointer sceneManager, + int assetEntity, + int childEntity, + ffi.Pointer outPtr, + int index, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, EntityId, + ffi.Pointer>)>( + isLeaf: true) +external void get_morph_target_name_count_render_thread( + ffi.Pointer sceneManager, + int asset, + int childEntity, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Pointer, + ffi.Int, + ffi.Pointer>)>( + isLeaf: true) +external void set_morph_target_weights_render_thread( + ffi.Pointer sceneManager, + int asset, + ffi.Pointer morphData, + int numWeights, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function(ffi.Pointer, EntityId, + ffi.Pointer>)>( + isLeaf: true) +external void update_bone_matrices_render_thread( + ffi.Pointer sceneManager, + int asset, + ffi.Pointer> callback, +); + +@ffi.Native< + ffi.Void Function( + ffi.Pointer, + EntityId, + ffi.Int, + ffi.Int, + ffi.Pointer, + ffi.Pointer>)>( + isLeaf: true) +external void set_bone_transform_render_thread( + ffi.Pointer sceneManager, + int asset, + int skinIndex, + int boneIndex, + ffi.Pointer transform, + ffi.Pointer> callback, +); + +@ffi.Native, ffi.Bool)>(isLeaf: true) +external void set_post_processing_render_thread( + ffi.Pointer viewer, bool enabled, ); @@ -3161,6 +3534,89 @@ typedef LoadFilamentResourceIntoOutPointerFunction = ffi.Void Function( typedef DartLoadFilamentResourceIntoOutPointerFunction = void Function( ffi.Pointer uri, ffi.Pointer out); +/// This header replicates most of the methods in ThermionDartApi.h. +/// It represents the interface for: +/// - invoking those methods that must be called on the main Filament engine thread +/// - setting up a render loop +typedef EntityId = ffi.Int32; +typedef DartEntityId = int; + +final class TViewport extends ffi.Struct { + @ffi.Int32() + external int left; + + @ffi.Int32() + external int bottom; + + @ffi.Uint32() + external int width; + + @ffi.Uint32() + external int height; +} + +enum ToneMapping { + ACES(0), + FILMIC(1), + LINEAR(2); + + final int value; + const ToneMapping(this.value); + + static ToneMapping fromValue(int value) => switch (value) { + 0 => ACES, + 1 => FILMIC, + 2 => LINEAR, + _ => throw ArgumentError("Unknown value for ToneMapping: $value"), + }; +} + +enum TQualityLevel { + LOW(0), + MEDIUM(1), + HIGH(2), + ULTRA(3); + + final int value; + const TQualityLevel(this.value); + + static TQualityLevel fromValue(int value) => switch (value) { + 0 => LOW, + 1 => MEDIUM, + 2 => HIGH, + 3 => ULTRA, + _ => throw ArgumentError("Unknown value for TQualityLevel: $value"), + }; +} + +typedef FilamentRenderCallback + = ffi.Pointer>; +typedef FilamentRenderCallbackFunction = ffi.Void Function( + ffi.Pointer owner); +typedef DartFilamentRenderCallbackFunction = void Function( + ffi.Pointer owner); + +enum Projection { + Perspective(0), + Orthographic(1); + + final int value; + const Projection(this.value); + + static Projection fromValue(int value) => switch (value) { + 0 => Perspective, + 1 => Orthographic, + _ => throw ArgumentError("Unknown value for Projection: $value"), + }; +} + +typedef GizmoPickCallback + = ffi.Pointer>; +typedef GizmoPickCallbackFunction = ffi.Void Function( + EntityId entityId, ffi.Uint32 x, ffi.Uint32 y, ffi.Pointer view); +typedef DartGizmoPickCallbackFunction = void Function( + DartEntityId entityId, int x, int y, ffi.Pointer view); + const int __bool_true_false_are_defined = 1; const int true1 = 1;