more FFI work
This commit is contained in:
@@ -3,13 +3,15 @@
|
|||||||
|
|
||||||
#include "ResourceBuffer.hpp"
|
#include "ResourceBuffer.hpp"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef int32_t EntityId;
|
typedef int32_t EntityId;
|
||||||
|
|
||||||
const void* create_filament_viewer(const void* const context, const ResourceLoaderWrapper* const loader);
|
const void* create_filament_viewer(const void* const context, const ResourceLoaderWrapper* const loader);
|
||||||
ResourceLoaderWrapper* make_resource_loader(LoadFilamentResourceFromOwner loadFn, FreeFilamentResourceFromOwner freeFn, void* owner);
|
ResourceLoaderWrapper* make_resource_loader(LoadFilamentResourceFromOwner loadFn, FreeFilamentResourceFromOwner freeFn, void* owner);
|
||||||
void destroy_filament_viewer(const void* const viewer);
|
void destroy_filament_viewer(const void* const viewer);
|
||||||
void* get_asset_manager(const void* const viewer);
|
void* get_asset_manager(const void* const viewer);
|
||||||
void create_render_target(const void* const viewer, uint32_t textureId, uint32_t width, uint32_t height);
|
void create_render_target(const void* const viewer, intptr_t texture, uint32_t width, uint32_t height);
|
||||||
void clear_background_image(const void* const viewer);
|
void clear_background_image(const void* const viewer);
|
||||||
void set_background_image(const void* const viewer, const char *path, bool fillHeight);
|
void set_background_image(const void* const viewer, const char *path, bool fillHeight);
|
||||||
void set_background_image_position(const void* const viewer, float x, float y, bool clamp);
|
void set_background_image_position(const void* const viewer, float x, float y, bool clamp);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#ifndef _POLYVOX_FILAMENT_FFI_API_H
|
#ifndef _POLYVOX_FILAMENT_FFI_API_H
|
||||||
#define _POLYVOX_FILAMENT_FFI_API_H
|
#define _POLYVOX_FILAMENT_FFI_API_H
|
||||||
|
|
||||||
#include "PolyvoxFilamentApi.h"
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// This header replicates most of the methods in PolyvoxFilamentApi.h, and is only intended to be used to generate client FFI bindings.
|
/// This header replicates most of the methods in PolyvoxFilamentApi.h, and is only intended to be used to generate client FFI bindings.
|
||||||
/// The intention is that calling one of these methods will call its respective method in PolyvoxFilamentApi.h, but wrapped in some kind of thread runner to ensure thread safety.
|
/// The intention is that calling one of these methods will call its respective method in PolyvoxFilamentApi.h, but wrapped in some kind of thread runner to ensure thread safety.
|
||||||
///
|
///
|
||||||
|
|
||||||
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
typedef int32_t EntityId;
|
typedef int32_t EntityId;
|
||||||
|
|
||||||
void* const create_filament_viewer_ffi(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner);
|
void* const create_filament_viewer_ffi(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner);
|
||||||
@@ -33,25 +33,25 @@ void remove_light_ffi(void* const viewer, EntityId entityId);
|
|||||||
void clear_lights_ffi(void* const viewer);
|
void clear_lights_ffi(void* const viewer);
|
||||||
EntityId load_glb_ffi(void* const assetManager, const char *assetPath, bool unlit);
|
EntityId load_glb_ffi(void* const assetManager, const char *assetPath, bool unlit);
|
||||||
EntityId load_gltf_ffi(void* const assetManager, const char *assetPath, const char *relativePath);
|
EntityId load_gltf_ffi(void* const assetManager, const char *assetPath, const char *relativePath);
|
||||||
void remove_asset_ffi(void* const const viewer, EntityId asset);
|
void remove_asset_ffi(void* const viewer, EntityId asset);
|
||||||
void clear_assets_ffi(void* const const viewer);
|
void clear_assets_ffi(void* const viewer);
|
||||||
bool set_camera_ffi(void* const viewer, EntityId asset, const char *nodeName);
|
bool set_camera_ffi(void* const viewer, EntityId asset, const char *nodeName);
|
||||||
void apply_weights_ffi(
|
void apply_weights_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
const char *const entityName,
|
||||||
float *const weights,
|
float *const weights,
|
||||||
int count
|
int count
|
||||||
);
|
);
|
||||||
void set_morph_target_weights_ffi(
|
void set_morph_target_weights_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
const char *const entityName,
|
||||||
const float *const morphData,
|
const float *const morphData,
|
||||||
int numWeights
|
int numWeights
|
||||||
);
|
);
|
||||||
bool set_morph_animation_ffi(
|
bool set_morph_animation_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
const char *const entityName,
|
||||||
const float *const morphData,
|
const float *const morphData,
|
||||||
@@ -61,7 +61,7 @@ bool set_morph_animation_ffi(
|
|||||||
float frameLengthInMs);
|
float frameLengthInMs);
|
||||||
|
|
||||||
void set_bone_animation_ffi(
|
void set_bone_animation_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const float* const frameData,
|
const float* const frameData,
|
||||||
int numFrames,
|
int numFrames,
|
||||||
@@ -71,13 +71,13 @@ void set_bone_animation_ffi(
|
|||||||
int numMeshTargets,
|
int numMeshTargets,
|
||||||
float frameLengthInMs);
|
float frameLengthInMs);
|
||||||
|
|
||||||
void play_animation_ffi(void* assetManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade);
|
void play_animation_ffi(void* const assetManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade);
|
||||||
void set_animation_frame_ffi(void* assetManager, EntityId asset, int animationIndex, int animationFrame);
|
void set_animation_frame_ffi(void* const assetManager, EntityId asset, int animationIndex, int animationFrame);
|
||||||
void stop_animation_ffi(void* assetManager, EntityId asset, int index);
|
void stop_animation_ffi(void* const assetManager, EntityId asset, int index);
|
||||||
int get_animation_count_ffi(void* assetManager, EntityId asset);
|
int get_animation_count_ffi(void* const assetManager, EntityId asset);
|
||||||
void get_animation_name_ffi(void* assetManager, EntityId asset, char *const outPtr, int index);
|
void get_animation_name_ffi(void* const assetManager, EntityId asset, char *const outPtr, int index);
|
||||||
float get_animation_duration_ffi(void* assetManager, EntityId asset, int index);
|
float get_animation_duration_ffi(void* const assetManager, EntityId asset, int index);
|
||||||
void get_morph_target_name_ffi(void* assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
|
void get_morph_target_name_ffi(void* const assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
|
||||||
int get_morph_target_name_count_ffi(void* assetManager, EntityId asset, const char *meshName);
|
int get_morph_target_name_count_ffi(void* const assetManager, EntityId asset, const char *meshName);
|
||||||
|
|
||||||
#endif // _POLYVOX_FILAMENT_FFI_API_H
|
#endif // _POLYVOX_FILAMENT_FFI_API_H
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ extern "C" {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
const void * const data;
|
const void * const data;
|
||||||
const uint32_t size;
|
const int64_t size;
|
||||||
const uint32_t id;
|
const uint32_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ FilamentViewer::FilamentViewer(const void* context, const ResourceLoaderWrapper*
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
_engine = Engine::create(Engine::Backend::METAL);
|
_engine = Engine::create(Engine::Backend::METAL);
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
_engine = Engine::create(Engine::Backend::METAL);
|
||||||
#else
|
#else
|
||||||
_engine = Engine::create(Engine::Backend::OPENGL); //L, nullptr, (void*)context, nullptr);
|
_engine = Engine::create(Engine::Backend::OPENGL); //L, nullptr, (void*)context, nullptr);
|
||||||
#endif
|
#endif
|
||||||
@@ -565,7 +567,7 @@ void FilamentViewer::createSwapChain(const void *window, uint32_t width, uint32_
|
|||||||
Log("Swapchain created.");
|
Log("Swapchain created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilamentViewer::createRenderTarget(intptr_t textureId, uint32_t width, uint32_t height) {
|
void FilamentViewer::createRenderTarget(intptr_t texture, uint32_t width, uint32_t height) {
|
||||||
// Create filament textures and render targets (note the color buffer has the import call)
|
// Create filament textures and render targets (note the color buffer has the import call)
|
||||||
_rtColor = filament::Texture::Builder()
|
_rtColor = filament::Texture::Builder()
|
||||||
.width(width)
|
.width(width)
|
||||||
@@ -573,7 +575,7 @@ void FilamentViewer::createRenderTarget(intptr_t textureId, uint32_t width, uint
|
|||||||
.levels(1)
|
.levels(1)
|
||||||
.usage(filament::Texture::Usage::COLOR_ATTACHMENT | filament::Texture::Usage::SAMPLEABLE)
|
.usage(filament::Texture::Usage::COLOR_ATTACHMENT | filament::Texture::Usage::SAMPLEABLE)
|
||||||
.format(filament::Texture::InternalFormat::RGBA8)
|
.format(filament::Texture::InternalFormat::RGBA8)
|
||||||
.import(textureId)
|
.import(texture)
|
||||||
.build(*_engine);
|
.build(*_engine);
|
||||||
_rtDepth = filament::Texture::Builder()
|
_rtDepth = filament::Texture::Builder()
|
||||||
.width(width)
|
.width(width)
|
||||||
@@ -590,7 +592,7 @@ void FilamentViewer::createRenderTarget(intptr_t textureId, uint32_t width, uint
|
|||||||
// Make a specific viewport just for our render target
|
// Make a specific viewport just for our render target
|
||||||
_view->setRenderTarget(_rt);
|
_view->setRenderTarget(_rt);
|
||||||
|
|
||||||
Log("Set render target for glTextureId %u %u x %u", textureId, width, height);
|
Log("Set render target for glTextureId %u %u x %u", texture, width, height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "PolyvoxFilamentApi.h"
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT const void* create_filament_viewer(const void* context, const ResourceLoaderWrapper* const loader) {
|
FLUTTER_PLUGIN_EXPORT const void* create_filament_viewer(const void* context, const ResourceLoaderWrapper* const loader) {
|
||||||
return (const void*) new FilamentViewer(context, loader);
|
return (const void*) new FilamentViewer(context, loader);
|
||||||
}
|
}
|
||||||
@@ -24,8 +25,8 @@ extern "C" {
|
|||||||
return new ResourceLoaderWrapper(loadFn, freeFn, owner);
|
return new ResourceLoaderWrapper(loadFn, freeFn, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_render_target(const void* const viewer, uint32_t textureId, uint32_t width, uint32_t height) {
|
FLUTTER_PLUGIN_EXPORT void create_render_target(const void* const viewer, intptr_t texture, uint32_t width, uint32_t height) {
|
||||||
((FilamentViewer*)viewer)->createRenderTarget(textureId, width, height);
|
((FilamentViewer*)viewer)->createRenderTarget(texture, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer(const void* const viewer) {
|
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer(const void* const viewer) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Log.hpp"
|
#include "Log.hpp"
|
||||||
#include "ThreadPool.hpp"
|
#include "ThreadPool.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@@ -12,10 +13,13 @@ using namespace polyvox;
|
|||||||
|
|
||||||
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
||||||
|
|
||||||
class RenderLoop {
|
class RenderLoop
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit RenderLoop() {
|
explicit RenderLoop()
|
||||||
_t = new std::thread([this]() {
|
{
|
||||||
|
_t = new std::thread([this]()
|
||||||
|
{
|
||||||
while(!_stop) {
|
while(!_stop) {
|
||||||
std::function<void()> task;
|
std::function<void()> task;
|
||||||
{
|
{
|
||||||
@@ -35,121 +39,294 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
task();
|
task();
|
||||||
}
|
} });
|
||||||
});
|
}
|
||||||
}
|
~RenderLoop()
|
||||||
~RenderLoop() {
|
{
|
||||||
_stop = true;
|
_stop = true;
|
||||||
_t->join();
|
_t->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void* const createViewer(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void*), void* const owner) {
|
void *const createViewer(void *const context, const ResourceLoaderWrapper *const loader, void (*renderCallback)(void *), void *const owner)
|
||||||
|
{
|
||||||
_renderCallback = renderCallback;
|
_renderCallback = renderCallback;
|
||||||
_renderCallbackOwner = owner;
|
_renderCallbackOwner = owner;
|
||||||
std::packaged_task<FilamentViewer* const()> lambda([&]() mutable {
|
std::packaged_task<FilamentViewer *const()> lambda([&]() mutable
|
||||||
return new FilamentViewer(context, loader);
|
{ return new FilamentViewer(context, loader); });
|
||||||
});
|
|
||||||
auto fut = add_task(lambda);
|
auto fut = add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
_viewer = fut.get();
|
_viewer = fut.get();
|
||||||
return (void* const)_viewer;
|
return (void *const)_viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRendering(bool rendering) {
|
void setRendering(bool rendering)
|
||||||
|
{
|
||||||
_rendering = rendering;
|
_rendering = rendering;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doRender() {
|
void doRender()
|
||||||
|
{
|
||||||
render(_viewer, 0);
|
render(_viewer, 0);
|
||||||
_renderCallback(_renderCallbackOwner);
|
_renderCallback(_renderCallbackOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Rt>
|
template <class Rt>
|
||||||
auto add_task(std::packaged_task<Rt()>& pt) -> std::future<Rt> {
|
auto add_task(std::packaged_task<Rt()> &pt) -> std::future<Rt>
|
||||||
std::unique_lock<std::mutex> lock(_access);
|
{
|
||||||
auto ret = pt.get_future();
|
std::unique_lock<std::mutex> lock(_access);
|
||||||
_tasks.push_back([pt=std::make_shared<std::packaged_task<Rt()>>(std::move(pt))]{ (*pt)();});
|
auto ret = pt.get_future();
|
||||||
_cond.notify_one();
|
_tasks.push_back([pt = std::make_shared<std::packaged_task<Rt()>>(std::move(pt))]
|
||||||
return ret;
|
{ (*pt)(); });
|
||||||
}
|
_cond.notify_one();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _stop = false;
|
bool _stop = false;
|
||||||
bool _rendering = false;
|
bool _rendering = false;
|
||||||
int _frameIntervalInMilliseconds = 1000 / 60;
|
int _frameIntervalInMilliseconds = 1000 / 60;
|
||||||
std::mutex _access;
|
std::mutex _access;
|
||||||
FilamentViewer* _viewer = nullptr;
|
FilamentViewer *_viewer = nullptr;
|
||||||
void (*_renderCallback)(void* const) = nullptr;
|
void (*_renderCallback)(void *const) = nullptr;
|
||||||
void* _renderCallbackOwner = nullptr;
|
void *_renderCallbackOwner = nullptr;
|
||||||
std::thread* _t = nullptr;
|
std::thread *_t = nullptr;
|
||||||
std::condition_variable _cond;
|
std::condition_variable _cond;
|
||||||
std::deque<std::function<void()>> _tasks;
|
std::deque<std::function<void()>> _tasks;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
|
static RenderLoop *_rl;
|
||||||
|
|
||||||
extern "C" {
|
FLUTTER_PLUGIN_EXPORT void *const create_filament_viewer_ffi(void *const context, const ResourceLoaderWrapper *const loader, void (*renderCallback)(void *const renderCallbackOwner), void *const renderCallbackOwner)
|
||||||
|
{
|
||||||
#include "PolyvoxFilamentApi.h"
|
if (!_rl)
|
||||||
|
{
|
||||||
static RenderLoop* _rl;
|
_rl = new RenderLoop();
|
||||||
|
}
|
||||||
FLUTTER_PLUGIN_EXPORT void* const create_filament_viewer_ffi(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner) {
|
return _rl->createViewer(context, loader, renderCallback, renderCallbackOwner);
|
||||||
if(!_rl) {
|
|
||||||
_rl = new RenderLoop();
|
|
||||||
}
|
}
|
||||||
return _rl->createViewer(context, loader, renderCallback, renderCallbackOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void *const viewer, void *const surface, uint32_t width, uint32_t height)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
|
{ create_swap_chain(viewer, surface, width, height); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void* const viewer, void* const surface, uint32_t width, uint32_t height) {
|
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void *const viewer, uint32_t nativeTextureId, uint32_t width, uint32_t height)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
create_swap_chain(viewer, surface, width, height);
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
});
|
{ create_render_target(viewer, nativeTextureId, width, height); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void* const viewer, uint32_t nativeTextureId, uint32_t width, uint32_t height) {
|
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection_ffi(void *const viewer, const uint32_t width, const uint32_t height, const float scaleFactor)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
create_render_target(viewer, nativeTextureId, width, height);
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
});
|
{ update_viewport_and_camera_projection(viewer, width, height, scaleFactor); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_rendering_ffi(bool rendering)
|
||||||
|
{
|
||||||
|
if (!_rl)
|
||||||
|
{
|
||||||
|
Log("No render loop!"); // PANIC?
|
||||||
|
} else {
|
||||||
|
if(rendering) {
|
||||||
|
Log("Set rendering to true");
|
||||||
|
} else {
|
||||||
|
Log("Set rendering to false");
|
||||||
|
}
|
||||||
|
_rl->setRendering(rendering);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection_ffi(void* const viewer, const uint32_t width, const uint32_t height, const float scaleFactor) {
|
FLUTTER_PLUGIN_EXPORT void render_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
update_viewport_and_camera_projection(viewer, width, height, scaleFactor);
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
});
|
{ _rl->doRender(); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_background_color_ffi(void *const viewer, const float r, const float g, const float b, const float a)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
|
{ set_background_color(viewer, r, g, b, a); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT bool set_rendering_ffi(bool rendering) {
|
FLUTTER_PLUGIN_EXPORT EntityId load_glb_ffi(void *const assetManager, const char *path)
|
||||||
if(!_rl) {
|
{
|
||||||
return false;
|
std::packaged_task<EntityId()> lambda([&]() mutable
|
||||||
}
|
{ return load_glb(assetManager, path, false); });
|
||||||
_rl->setRendering(rendering);
|
auto fut = _rl->add_task(lambda);
|
||||||
return true;
|
fut.wait();
|
||||||
}
|
return fut.get();
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void render_ffi(void* const viewer) {
|
FLUTTER_PLUGIN_EXPORT void clear_background_image_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
_rl->doRender();
|
std::packaged_task<void()> lambda([&]
|
||||||
});
|
{ clear_background_image(viewer); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_background_color_ffi(void* const viewer, const float r, const float g, const float b, const float a) {
|
FLUTTER_PLUGIN_EXPORT void set_background_image_ffi(void *const viewer, const char *path, bool fillHeight)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
set_background_color(viewer, r, g,b, a);
|
std::packaged_task<void()> lambda([&]
|
||||||
});
|
{ set_background_image(viewer, path, fillHeight); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_background_image_position_ffi(void *const viewer, float x, float y, bool clamp)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_background_image_position(viewer, x, y, clamp); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_tone_mapping_ffi(void *const viewer, int toneMapping)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_tone_mapping(viewer, toneMapping); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_bloom_ffi(void *const viewer, float strength)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_bloom(viewer, strength); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void load_skybox_ffi(void *const viewer, const char *skyboxPath)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ load_skybox(viewer, skyboxPath); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void load_ibl_ffi(void *const viewer, const char *iblPath, float intensity)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ load_ibl(viewer, iblPath, intensity); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_skybox_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_skybox(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_ibl_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_ibl(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
EntityId add_light_ffi(void *const viewer, uint8_t type, float colour, float intensity, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, bool shadows)
|
||||||
|
{
|
||||||
|
std::packaged_task<EntityId()> lambda([&]
|
||||||
|
{ return add_light(viewer, type, colour, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
return fut.get();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_light_ffi(void *const viewer, EntityId entityId)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_light(viewer, entityId); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void clear_lights_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ clear_lights(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_asset_ffi(void *const viewer, EntityId asset)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_asset(viewer, asset); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void clear_assets_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ clear_assets(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT bool set_camera_ffi(void *const viewer, EntityId asset, const char *nodeName)
|
||||||
|
{
|
||||||
|
std::packaged_task<bool()> lambda([&]
|
||||||
|
{ return set_camera(viewer, asset, nodeName); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
return fut.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_bone_animation_ffi(
|
||||||
|
void *assetManager,
|
||||||
|
EntityId asset,
|
||||||
|
const float *const frameData,
|
||||||
|
int numFrames,
|
||||||
|
int numBones,
|
||||||
|
const char **const boneNames,
|
||||||
|
const char **const meshName,
|
||||||
|
int numMeshTargets,
|
||||||
|
float frameLengthInMs)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_bone_animation(
|
||||||
|
assetManager, asset, frameData, numFrames, numBones,
|
||||||
|
boneNames, meshName, numMeshTargets, frameLengthInMs); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
// implementations of rest of animation functions
|
||||||
|
FLUTTER_PLUGIN_EXPORT void get_morph_target_name_ffi(void *assetManager, EntityId asset, const char *meshName, char *const outPtr, int index)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ get_morph_target_name(assetManager, asset, meshName, outPtr, index); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT int get_morph_target_name_count_ffi(void *assetManager, EntityId asset, const char *meshName)
|
||||||
|
{
|
||||||
|
std::packaged_task<int()> lambda([&]
|
||||||
|
{ return get_morph_target_name_count(assetManager, asset, meshName); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
return fut.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_morph_target_weights_ffi(
|
||||||
|
void* const assetManager,
|
||||||
|
EntityId asset,
|
||||||
|
const char *const entityName,
|
||||||
|
const float *const morphData,
|
||||||
|
int numWeights
|
||||||
|
) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
_lib.set_rendering_ffi(_viewer!, render ? 1 : 0);
|
_lib.set_rendering_ffi(_viewer!, render);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future render() async {
|
Future render() async {
|
||||||
@@ -59,7 +59,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future setFrameRate(int framerate) async {
|
Future setFrameRate(int framerate) async {
|
||||||
await _channel.invokeMethod("setFrameInterval", 1.0 / framerate);
|
_lib.set_frame_interval_ffi(1.0 / framerate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPixelRatio(double ratio) {
|
void setPixelRatio(double ratio) {
|
||||||
@@ -107,7 +107,9 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
await _channel.invokeMethod("createTexture", [size.width, size.height]);
|
await _channel.invokeMethod("createTexture", [size.width, size.height]);
|
||||||
var flutterTextureId = textures[0];
|
var flutterTextureId = textures[0];
|
||||||
_textureId = flutterTextureId;
|
_textureId = flutterTextureId;
|
||||||
var pixelBuffer = textures[1] as int;
|
var surfaceAddress = textures[1] as int? ?? 0;
|
||||||
|
|
||||||
|
// void* on iOS/MacOS, GLuid on Android/Windows/Linux
|
||||||
var nativeTexture = textures[2] as int;
|
var nativeTexture = textures[2] as int;
|
||||||
|
|
||||||
var renderCallbackResult = await _channel.invokeMethod("getRenderCallback");
|
var renderCallbackResult = await _channel.invokeMethod("getRenderCallback");
|
||||||
@@ -127,9 +129,11 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
renderCallbackOwner);
|
renderCallbackOwner);
|
||||||
|
|
||||||
_lib.create_swap_chain(
|
_lib.create_swap_chain(
|
||||||
_viewer!, Pointer<Void>.fromAddress(pixelBuffer), width, height);
|
_viewer!, Pointer<Void>.fromAddress(surfaceAddress), width, height);
|
||||||
|
if (nativeTexture != 0) {
|
||||||
_lib.create_render_target(_viewer!, nativeTexture, width, height);
|
assert(surfaceAddress == 0);
|
||||||
|
_lib.create_render_target(_viewer!, nativeTexture, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
_lib.update_viewport_and_camera_projection_ffi(
|
_lib.update_viewport_and_camera_projection_ffi(
|
||||||
_viewer!, width, height, 1.0);
|
_viewer!, width, height, 1.0);
|
||||||
@@ -162,7 +166,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
_lib.set_background_image_ffi(
|
_lib.set_background_image_ffi(
|
||||||
_viewer!, path.toNativeUtf8().cast<Char>(), fillHeight ? 1 : 0);
|
_viewer!, path.toNativeUtf8().cast<Char>(), fillHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future setBackgroundColor(Color color) async {
|
Future setBackgroundColor(Color color) async {
|
||||||
@@ -182,7 +186,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
_lib.set_background_image_position_ffi(_viewer!, x, y, clamp ? 1 : 0);
|
_lib.set_background_image_position_ffi(_viewer!, x, y, clamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future loadSkybox(String skyboxPath) async {
|
Future loadSkybox(String skyboxPath) async {
|
||||||
@@ -229,7 +233,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
var entity = _lib.add_light_ffi(_viewer!, type, colour, intensity, posX,
|
var entity = _lib.add_light_ffi(_viewer!, type, colour, intensity, posX,
|
||||||
posY, posZ, dirX, dirY, dirZ, castShadows ? 1 : 0);
|
posY, posZ, dirX, dirY, dirZ, castShadows);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +259,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
throw Exception("Not yet implemented");
|
throw Exception("Not yet implemented");
|
||||||
}
|
}
|
||||||
var asset = _lib.load_glb_ffi(
|
var asset = _lib.load_glb_ffi(
|
||||||
_assetManager!, path.toNativeUtf8().cast<Char>(), unlit ? 1 : 0);
|
_assetManager!, path.toNativeUtf8().cast<Char>(), unlit);
|
||||||
if (asset == FILAMENT_ASSET_ERROR) {
|
if (asset == FILAMENT_ASSET_ERROR) {
|
||||||
throw Exception("An error occurred loading the asset at $path");
|
throw Exception("An error occurred loading the asset at $path");
|
||||||
}
|
}
|
||||||
@@ -278,7 +282,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
_lib.grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, 1);
|
_lib.grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future panUpdate(double x, double y) async {
|
Future panUpdate(double x, double y) async {
|
||||||
@@ -299,7 +303,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
_lib.grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, 0);
|
_lib.grab_begin(_viewer!, x * _pixelRatio, y * _pixelRatio, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future rotateUpdate(double x, double y) async {
|
Future rotateUpdate(double x, double y) async {
|
||||||
@@ -372,9 +376,10 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
var duration = await _channel.invokeMethod(
|
var duration =
|
||||||
"getAnimationDuration", [_assetManager!, asset, animationIndex]);
|
_lib.get_animation_duration_ffi(_assetManager!, asset, animationIndex);
|
||||||
return duration as double;
|
|
||||||
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -470,7 +475,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
await _channel.invokeMethod("scrollBegin");
|
_lib.scroll_begin(_viewer!);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future zoomUpdate(double z) async {
|
Future zoomUpdate(double z) async {
|
||||||
@@ -495,8 +500,8 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
_lib.play_animation_ffi(_assetManager!, asset, index, loop ? 1 : 0,
|
_lib.play_animation_ffi(
|
||||||
reverse ? 1 : 0, replaceActive ? 1 : 0, crossfade);
|
_assetManager!, asset, index, loop, reverse, replaceActive, crossfade);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future setAnimationFrame(
|
Future setAnimationFrame(
|
||||||
@@ -504,23 +509,23 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
await _channel.invokeMethod(
|
_lib.set_animation_frame(_assetManager!, asset, index, animationFrame);
|
||||||
"setAnimationFrame", [_assetManager!, asset, index, animationFrame]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future stopAnimation(FilamentEntity asset, int animationIndex) async {
|
Future stopAnimation(FilamentEntity asset, int animationIndex) async {
|
||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
await _channel
|
_lib.stop_animation(_assetManager!, asset, animationIndex);
|
||||||
.invokeMethod("stopAnimation", [_assetManager!, asset, animationIndex]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future setCamera(FilamentEntity asset, String? name) async {
|
Future setCamera(FilamentEntity asset, String? name) async {
|
||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
if (await _channel.invokeMethod("setCamera", [asset, name]) != true) {
|
var result = _lib.set_camera(
|
||||||
|
_viewer!, asset, name?.toNativeUtf8()?.cast<Char>() ?? nullptr);
|
||||||
|
if (result != 1) {
|
||||||
throw Exception("Failed to set camera");
|
throw Exception("Failed to set camera");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -572,7 +577,7 @@ class FilamentControllerFFI extends FilamentController {
|
|||||||
if (_viewer == null || _resizing) {
|
if (_viewer == null || _resizing) {
|
||||||
throw Exception("No viewer available, ignoring");
|
throw Exception("No viewer available, ignoring");
|
||||||
}
|
}
|
||||||
_lib.set_view_frustum_culling(_viewer!, enabled ? 1 : 0);
|
_lib.set_view_frustum_culling(_viewer!, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future setCameraExposure(
|
Future setCameraExposure(
|
||||||
|
|||||||
@@ -71,39 +71,39 @@ class _FilamentWidgetState extends State<FilamentWidget> {
|
|||||||
Timer? _resizeTimer;
|
Timer? _resizeTimer;
|
||||||
|
|
||||||
void _handleStateChange(AppLifecycleState state) async {
|
void _handleStateChange(AppLifecycleState state) async {
|
||||||
switch (state) {
|
// switch (state) {
|
||||||
case AppLifecycleState.detached:
|
// case AppLifecycleState.detached:
|
||||||
print("Detached");
|
// print("Detached");
|
||||||
_textureId = null;
|
// _textureId = null;
|
||||||
|
|
||||||
await widget.controller.destroyViewer();
|
// await widget.controller.destroyViewer();
|
||||||
await widget.controller.destroyTexture();
|
// await widget.controller.destroyTexture();
|
||||||
break;
|
// break;
|
||||||
case AppLifecycleState.hidden:
|
// case AppLifecycleState.hidden:
|
||||||
print("Hidden");
|
// print("Hidden");
|
||||||
if (Platform.isIOS) {
|
// if (Platform.isIOS) {
|
||||||
_textureId = null;
|
// _textureId = null;
|
||||||
await widget.controller.destroyViewer();
|
// await widget.controller.destroyViewer();
|
||||||
await widget.controller.destroyTexture();
|
// await widget.controller.destroyTexture();
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case AppLifecycleState.inactive:
|
// case AppLifecycleState.inactive:
|
||||||
print("Inactive");
|
// print("Inactive");
|
||||||
break;
|
// break;
|
||||||
case AppLifecycleState.paused:
|
// case AppLifecycleState.paused:
|
||||||
print("Paused");
|
// print("Paused");
|
||||||
break;
|
// break;
|
||||||
case AppLifecycleState.resumed:
|
// case AppLifecycleState.resumed:
|
||||||
print("Resumed");
|
// print("Resumed");
|
||||||
if (_textureId == null) {
|
// if (_textureId == null) {
|
||||||
var size = ((context.findRenderObject()) as RenderBox).size;
|
// var size = ((context.findRenderObject()) as RenderBox).size;
|
||||||
print("Size after resuming : $size");
|
// print("Size after resuming : $size");
|
||||||
await widget.controller
|
// await widget.controller
|
||||||
.createViewer(size.width.toInt(), size.height.toInt());
|
// .createViewer(size.width.toInt(), size.height.toInt());
|
||||||
print("Created viewer Size after resuming");
|
// print("Created viewer Size after resuming");
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
_lastState = state;
|
_lastState = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -90,13 +90,13 @@ class NativeLibrary {
|
|||||||
|
|
||||||
void create_render_target(
|
void create_render_target(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
int textureId,
|
int texture,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
) {
|
) {
|
||||||
return _create_render_target(
|
return _create_render_target(
|
||||||
viewer,
|
viewer,
|
||||||
textureId,
|
texture,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
);
|
);
|
||||||
@@ -104,7 +104,7 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _create_render_targetPtr = _lookup<
|
late final _create_render_targetPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Uint32, ffi.Uint32,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.IntPtr, ffi.Uint32,
|
||||||
ffi.Uint32)>>('create_render_target');
|
ffi.Uint32)>>('create_render_target');
|
||||||
late final _create_render_target = _create_render_targetPtr
|
late final _create_render_target = _create_render_targetPtr
|
||||||
.asFunction<void Function(ffi.Pointer<ffi.Void>, int, int, int)>();
|
.asFunction<void Function(ffi.Pointer<ffi.Void>, int, int, int)>();
|
||||||
@@ -126,7 +126,7 @@ class NativeLibrary {
|
|||||||
void set_background_image(
|
void set_background_image(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
ffi.Pointer<ffi.Char> path,
|
ffi.Pointer<ffi.Char> path,
|
||||||
int fillHeight,
|
bool fillHeight,
|
||||||
) {
|
) {
|
||||||
return _set_background_image(
|
return _set_background_image(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -138,15 +138,15 @@ class NativeLibrary {
|
|||||||
late final _set_background_imagePtr = _lookup<
|
late final _set_background_imagePtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Int)>>('set_background_image');
|
ffi.Bool)>>('set_background_image');
|
||||||
late final _set_background_image = _set_background_imagePtr.asFunction<
|
late final _set_background_image = _set_background_imagePtr.asFunction<
|
||||||
void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, int)>();
|
void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, bool)>();
|
||||||
|
|
||||||
void set_background_image_position(
|
void set_background_image_position(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
double x,
|
double x,
|
||||||
double y,
|
double y,
|
||||||
int clamp,
|
bool clamp,
|
||||||
) {
|
) {
|
||||||
return _set_background_image_position(
|
return _set_background_image_position(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -159,9 +159,9 @@ class NativeLibrary {
|
|||||||
late final _set_background_image_positionPtr = _lookup<
|
late final _set_background_image_positionPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Float, ffi.Float,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Float, ffi.Float,
|
||||||
ffi.Int)>>('set_background_image_position');
|
ffi.Bool)>>('set_background_image_position');
|
||||||
late final _set_background_image_position = _set_background_image_positionPtr
|
late final _set_background_image_position = _set_background_image_positionPtr
|
||||||
.asFunction<void Function(ffi.Pointer<ffi.Void>, double, double, int)>();
|
.asFunction<void Function(ffi.Pointer<ffi.Void>, double, double, bool)>();
|
||||||
|
|
||||||
void set_background_color(
|
void set_background_color(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
@@ -295,7 +295,7 @@ class NativeLibrary {
|
|||||||
double dirX,
|
double dirX,
|
||||||
double dirY,
|
double dirY,
|
||||||
double dirZ,
|
double dirZ,
|
||||||
int shadows,
|
bool shadows,
|
||||||
) {
|
) {
|
||||||
return _add_light(
|
return _add_light(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -325,10 +325,10 @@ class NativeLibrary {
|
|||||||
ffi.Float,
|
ffi.Float,
|
||||||
ffi.Float,
|
ffi.Float,
|
||||||
ffi.Float,
|
ffi.Float,
|
||||||
ffi.Int)>>('add_light');
|
ffi.Bool)>>('add_light');
|
||||||
late final _add_light = _add_lightPtr.asFunction<
|
late final _add_light = _add_lightPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, int, double, double, double, double,
|
int Function(ffi.Pointer<ffi.Void>, int, double, double, double, double,
|
||||||
double, double, double, double, int)>();
|
double, double, double, double, bool)>();
|
||||||
|
|
||||||
void remove_light(
|
void remove_light(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
@@ -364,7 +364,7 @@ class NativeLibrary {
|
|||||||
int load_glb(
|
int load_glb(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
ffi.Pointer<ffi.Char> assetPath,
|
ffi.Pointer<ffi.Char> assetPath,
|
||||||
int unlit,
|
bool unlit,
|
||||||
) {
|
) {
|
||||||
return _load_glb(
|
return _load_glb(
|
||||||
assetManager,
|
assetManager,
|
||||||
@@ -376,9 +376,9 @@ class NativeLibrary {
|
|||||||
late final _load_glbPtr = _lookup<
|
late final _load_glbPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
EntityId Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
EntityId Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Int)>>('load_glb');
|
ffi.Bool)>>('load_glb');
|
||||||
late final _load_glb = _load_glbPtr.asFunction<
|
late final _load_glb = _load_glbPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, int)>();
|
int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, bool)>();
|
||||||
|
|
||||||
int load_gltf(
|
int load_gltf(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
@@ -400,7 +400,7 @@ class NativeLibrary {
|
|||||||
int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Pointer<ffi.Char>)>();
|
ffi.Pointer<ffi.Char>)>();
|
||||||
|
|
||||||
int set_camera(
|
bool set_camera(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
int asset,
|
int asset,
|
||||||
ffi.Pointer<ffi.Char> nodeName,
|
ffi.Pointer<ffi.Char> nodeName,
|
||||||
@@ -414,14 +414,14 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _set_cameraPtr = _lookup<
|
late final _set_cameraPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Int Function(ffi.Pointer<ffi.Void>, EntityId,
|
ffi.Bool Function(ffi.Pointer<ffi.Void>, EntityId,
|
||||||
ffi.Pointer<ffi.Char>)>>('set_camera');
|
ffi.Pointer<ffi.Char>)>>('set_camera');
|
||||||
late final _set_camera = _set_cameraPtr.asFunction<
|
late final _set_camera = _set_cameraPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>)>();
|
bool Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>)>();
|
||||||
|
|
||||||
void set_view_frustum_culling(
|
void set_view_frustum_culling(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
int enabled,
|
bool enabled,
|
||||||
) {
|
) {
|
||||||
return _set_view_frustum_culling(
|
return _set_view_frustum_culling(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -431,10 +431,10 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _set_view_frustum_cullingPtr = _lookup<
|
late final _set_view_frustum_cullingPtr = _lookup<
|
||||||
ffi
|
ffi
|
||||||
.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Int)>>(
|
.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Bool)>>(
|
||||||
'set_view_frustum_culling');
|
'set_view_frustum_culling');
|
||||||
late final _set_view_frustum_culling = _set_view_frustum_cullingPtr
|
late final _set_view_frustum_culling = _set_view_frustum_cullingPtr
|
||||||
.asFunction<void Function(ffi.Pointer<ffi.Void>, int)>();
|
.asFunction<void Function(ffi.Pointer<ffi.Void>, bool)>();
|
||||||
|
|
||||||
void render(
|
void render(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
@@ -579,7 +579,7 @@ class NativeLibrary {
|
|||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
double x,
|
double x,
|
||||||
double y,
|
double y,
|
||||||
int pan,
|
bool pan,
|
||||||
) {
|
) {
|
||||||
return _grab_begin(
|
return _grab_begin(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -592,9 +592,9 @@ class NativeLibrary {
|
|||||||
late final _grab_beginPtr = _lookup<
|
late final _grab_beginPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Float, ffi.Float,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Float, ffi.Float,
|
||||||
ffi.Int)>>('grab_begin');
|
ffi.Bool)>>('grab_begin');
|
||||||
late final _grab_begin = _grab_beginPtr
|
late final _grab_begin = _grab_beginPtr
|
||||||
.asFunction<void Function(ffi.Pointer<ffi.Void>, double, double, int)>();
|
.asFunction<void Function(ffi.Pointer<ffi.Void>, double, double, bool)>();
|
||||||
|
|
||||||
void grab_update(
|
void grab_update(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
@@ -686,7 +686,7 @@ class NativeLibrary {
|
|||||||
void Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
void Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Pointer<ffi.Float>, int)>();
|
ffi.Pointer<ffi.Float>, int)>();
|
||||||
|
|
||||||
int set_morph_animation(
|
bool set_morph_animation(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
int asset,
|
int asset,
|
||||||
ffi.Pointer<ffi.Char> entityName,
|
ffi.Pointer<ffi.Char> entityName,
|
||||||
@@ -710,7 +710,7 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _set_morph_animationPtr = _lookup<
|
late final _set_morph_animationPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Int Function(
|
ffi.Bool Function(
|
||||||
ffi.Pointer<ffi.Void>,
|
ffi.Pointer<ffi.Void>,
|
||||||
EntityId,
|
EntityId,
|
||||||
ffi.Pointer<ffi.Char>,
|
ffi.Pointer<ffi.Char>,
|
||||||
@@ -720,7 +720,7 @@ class NativeLibrary {
|
|||||||
ffi.Int,
|
ffi.Int,
|
||||||
ffi.Float)>>('set_morph_animation');
|
ffi.Float)>>('set_morph_animation');
|
||||||
late final _set_morph_animation = _set_morph_animationPtr.asFunction<
|
late final _set_morph_animation = _set_morph_animationPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
bool Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Pointer<ffi.Float>, ffi.Pointer<ffi.Int>, int, int, double)>();
|
ffi.Pointer<ffi.Float>, ffi.Pointer<ffi.Int>, int, int, double)>();
|
||||||
|
|
||||||
void set_bone_animation(
|
void set_bone_animation(
|
||||||
@@ -775,9 +775,9 @@ class NativeLibrary {
|
|||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
int asset,
|
int asset,
|
||||||
int index,
|
int index,
|
||||||
int loop,
|
bool loop,
|
||||||
int reverse,
|
bool reverse,
|
||||||
int replaceActive,
|
bool replaceActive,
|
||||||
double crossfade,
|
double crossfade,
|
||||||
) {
|
) {
|
||||||
return _play_animation(
|
return _play_animation(
|
||||||
@@ -793,10 +793,11 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _play_animationPtr = _lookup<
|
late final _play_animationPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int, ffi.Int,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int, ffi.Bool,
|
||||||
ffi.Int, ffi.Int, ffi.Float)>>('play_animation');
|
ffi.Bool, ffi.Bool, ffi.Float)>>('play_animation');
|
||||||
late final _play_animation = _play_animationPtr.asFunction<
|
late final _play_animation = _play_animationPtr.asFunction<
|
||||||
void Function(ffi.Pointer<ffi.Void>, int, int, int, int, int, double)>();
|
void Function(
|
||||||
|
ffi.Pointer<ffi.Void>, int, int, bool, bool, bool, double)>();
|
||||||
|
|
||||||
void set_animation_frame(
|
void set_animation_frame(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
@@ -974,7 +975,7 @@ class NativeLibrary {
|
|||||||
late final _clear_assets =
|
late final _clear_assets =
|
||||||
_clear_assetsPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
|
_clear_assetsPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
|
||||||
|
|
||||||
int set_material_color(
|
bool set_material_color(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
int asset,
|
int asset,
|
||||||
ffi.Pointer<ffi.Char> meshName,
|
ffi.Pointer<ffi.Char> meshName,
|
||||||
@@ -998,7 +999,7 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _set_material_colorPtr = _lookup<
|
late final _set_material_colorPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Int Function(
|
ffi.Bool Function(
|
||||||
ffi.Pointer<ffi.Void>,
|
ffi.Pointer<ffi.Void>,
|
||||||
EntityId,
|
EntityId,
|
||||||
ffi.Pointer<ffi.Char>,
|
ffi.Pointer<ffi.Char>,
|
||||||
@@ -1008,7 +1009,7 @@ class NativeLibrary {
|
|||||||
ffi.Float,
|
ffi.Float,
|
||||||
ffi.Float)>>('set_material_color');
|
ffi.Float)>>('set_material_color');
|
||||||
late final _set_material_color = _set_material_colorPtr.asFunction<
|
late final _set_material_color = _set_material_colorPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>, int,
|
bool Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>, int,
|
||||||
double, double, double, double)>();
|
double, double, double, double)>();
|
||||||
|
|
||||||
void transform_to_unit_cube(
|
void transform_to_unit_cube(
|
||||||
@@ -1385,7 +1386,7 @@ class NativeLibrary {
|
|||||||
|
|
||||||
void set_rendering_ffi(
|
void set_rendering_ffi(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
int rendering,
|
bool rendering,
|
||||||
) {
|
) {
|
||||||
return _set_rendering_ffi(
|
return _set_rendering_ffi(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -1395,10 +1396,10 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _set_rendering_ffiPtr = _lookup<
|
late final _set_rendering_ffiPtr = _lookup<
|
||||||
ffi
|
ffi
|
||||||
.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Int)>>(
|
.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Bool)>>(
|
||||||
'set_rendering_ffi');
|
'set_rendering_ffi');
|
||||||
late final _set_rendering_ffi = _set_rendering_ffiPtr
|
late final _set_rendering_ffi = _set_rendering_ffiPtr
|
||||||
.asFunction<void Function(ffi.Pointer<ffi.Void>, int)>();
|
.asFunction<void Function(ffi.Pointer<ffi.Void>, bool)>();
|
||||||
|
|
||||||
void set_frame_interval_ffi(
|
void set_frame_interval_ffi(
|
||||||
double frameInterval,
|
double frameInterval,
|
||||||
@@ -1478,7 +1479,7 @@ class NativeLibrary {
|
|||||||
void set_background_image_ffi(
|
void set_background_image_ffi(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
ffi.Pointer<ffi.Char> path,
|
ffi.Pointer<ffi.Char> path,
|
||||||
int fillHeight,
|
bool fillHeight,
|
||||||
) {
|
) {
|
||||||
return _set_background_image_ffi(
|
return _set_background_image_ffi(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -1490,16 +1491,16 @@ class NativeLibrary {
|
|||||||
late final _set_background_image_ffiPtr = _lookup<
|
late final _set_background_image_ffiPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Int)>>('set_background_image_ffi');
|
ffi.Bool)>>('set_background_image_ffi');
|
||||||
late final _set_background_image_ffi =
|
late final _set_background_image_ffi =
|
||||||
_set_background_image_ffiPtr.asFunction<
|
_set_background_image_ffiPtr.asFunction<
|
||||||
void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, int)>();
|
void Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, bool)>();
|
||||||
|
|
||||||
void set_background_image_position_ffi(
|
void set_background_image_position_ffi(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
double x,
|
double x,
|
||||||
double y,
|
double y,
|
||||||
int clamp,
|
bool clamp,
|
||||||
) {
|
) {
|
||||||
return _set_background_image_position_ffi(
|
return _set_background_image_position_ffi(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -1512,10 +1513,10 @@ class NativeLibrary {
|
|||||||
late final _set_background_image_position_ffiPtr = _lookup<
|
late final _set_background_image_position_ffiPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Float, ffi.Float,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Float, ffi.Float,
|
||||||
ffi.Int)>>('set_background_image_position_ffi');
|
ffi.Bool)>>('set_background_image_position_ffi');
|
||||||
late final _set_background_image_position_ffi =
|
late final _set_background_image_position_ffi =
|
||||||
_set_background_image_position_ffiPtr.asFunction<
|
_set_background_image_position_ffiPtr.asFunction<
|
||||||
void Function(ffi.Pointer<ffi.Void>, double, double, int)>();
|
void Function(ffi.Pointer<ffi.Void>, double, double, bool)>();
|
||||||
|
|
||||||
void set_tone_mapping_ffi(
|
void set_tone_mapping_ffi(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
@@ -1626,7 +1627,7 @@ class NativeLibrary {
|
|||||||
double dirX,
|
double dirX,
|
||||||
double dirY,
|
double dirY,
|
||||||
double dirZ,
|
double dirZ,
|
||||||
int shadows,
|
bool shadows,
|
||||||
) {
|
) {
|
||||||
return _add_light_ffi(
|
return _add_light_ffi(
|
||||||
viewer,
|
viewer,
|
||||||
@@ -1656,10 +1657,10 @@ class NativeLibrary {
|
|||||||
ffi.Float,
|
ffi.Float,
|
||||||
ffi.Float,
|
ffi.Float,
|
||||||
ffi.Float,
|
ffi.Float,
|
||||||
ffi.Int)>>('add_light_ffi');
|
ffi.Bool)>>('add_light_ffi');
|
||||||
late final _add_light_ffi = _add_light_ffiPtr.asFunction<
|
late final _add_light_ffi = _add_light_ffiPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, int, double, double, double, double,
|
int Function(ffi.Pointer<ffi.Void>, int, double, double, double, double,
|
||||||
double, double, double, double, int)>();
|
double, double, double, double, bool)>();
|
||||||
|
|
||||||
void remove_light_ffi(
|
void remove_light_ffi(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
@@ -1695,7 +1696,7 @@ class NativeLibrary {
|
|||||||
int load_glb_ffi(
|
int load_glb_ffi(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
ffi.Pointer<ffi.Char> assetPath,
|
ffi.Pointer<ffi.Char> assetPath,
|
||||||
int unlit,
|
bool unlit,
|
||||||
) {
|
) {
|
||||||
return _load_glb_ffi(
|
return _load_glb_ffi(
|
||||||
assetManager,
|
assetManager,
|
||||||
@@ -1707,9 +1708,9 @@ class NativeLibrary {
|
|||||||
late final _load_glb_ffiPtr = _lookup<
|
late final _load_glb_ffiPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
EntityId Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
EntityId Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Int)>>('load_glb_ffi');
|
ffi.Bool)>>('load_glb_ffi');
|
||||||
late final _load_glb_ffi = _load_glb_ffiPtr.asFunction<
|
late final _load_glb_ffi = _load_glb_ffiPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, int)>();
|
int Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>, bool)>();
|
||||||
|
|
||||||
int load_gltf_ffi(
|
int load_gltf_ffi(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
@@ -1762,7 +1763,7 @@ class NativeLibrary {
|
|||||||
late final _clear_assets_ffi =
|
late final _clear_assets_ffi =
|
||||||
_clear_assets_ffiPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
|
_clear_assets_ffiPtr.asFunction<void Function(ffi.Pointer<ffi.Void>)>();
|
||||||
|
|
||||||
int set_camera_ffi(
|
bool set_camera_ffi(
|
||||||
ffi.Pointer<ffi.Void> viewer,
|
ffi.Pointer<ffi.Void> viewer,
|
||||||
int asset,
|
int asset,
|
||||||
ffi.Pointer<ffi.Char> nodeName,
|
ffi.Pointer<ffi.Char> nodeName,
|
||||||
@@ -1776,10 +1777,10 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _set_camera_ffiPtr = _lookup<
|
late final _set_camera_ffiPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Int Function(ffi.Pointer<ffi.Void>, EntityId,
|
ffi.Bool Function(ffi.Pointer<ffi.Void>, EntityId,
|
||||||
ffi.Pointer<ffi.Char>)>>('set_camera_ffi');
|
ffi.Pointer<ffi.Char>)>>('set_camera_ffi');
|
||||||
late final _set_camera_ffi = _set_camera_ffiPtr.asFunction<
|
late final _set_camera_ffi = _set_camera_ffiPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>)>();
|
bool Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>)>();
|
||||||
|
|
||||||
void apply_weights_ffi(
|
void apply_weights_ffi(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
@@ -1838,7 +1839,7 @@ class NativeLibrary {
|
|||||||
void Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
void Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Pointer<ffi.Float>, int)>();
|
ffi.Pointer<ffi.Float>, int)>();
|
||||||
|
|
||||||
int set_morph_animation_ffi(
|
bool set_morph_animation_ffi(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
int asset,
|
int asset,
|
||||||
ffi.Pointer<ffi.Char> entityName,
|
ffi.Pointer<ffi.Char> entityName,
|
||||||
@@ -1862,7 +1863,7 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _set_morph_animation_ffiPtr = _lookup<
|
late final _set_morph_animation_ffiPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Int Function(
|
ffi.Bool Function(
|
||||||
ffi.Pointer<ffi.Void>,
|
ffi.Pointer<ffi.Void>,
|
||||||
EntityId,
|
EntityId,
|
||||||
ffi.Pointer<ffi.Char>,
|
ffi.Pointer<ffi.Char>,
|
||||||
@@ -1872,7 +1873,7 @@ class NativeLibrary {
|
|||||||
ffi.Int,
|
ffi.Int,
|
||||||
ffi.Float)>>('set_morph_animation_ffi');
|
ffi.Float)>>('set_morph_animation_ffi');
|
||||||
late final _set_morph_animation_ffi = _set_morph_animation_ffiPtr.asFunction<
|
late final _set_morph_animation_ffi = _set_morph_animation_ffiPtr.asFunction<
|
||||||
int Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
bool Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>,
|
||||||
ffi.Pointer<ffi.Float>, ffi.Pointer<ffi.Int>, int, int, double)>();
|
ffi.Pointer<ffi.Float>, ffi.Pointer<ffi.Int>, int, int, double)>();
|
||||||
|
|
||||||
void set_bone_animation_ffi(
|
void set_bone_animation_ffi(
|
||||||
@@ -1927,9 +1928,9 @@ class NativeLibrary {
|
|||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
int asset,
|
int asset,
|
||||||
int index,
|
int index,
|
||||||
int loop,
|
bool loop,
|
||||||
int reverse,
|
bool reverse,
|
||||||
int replaceActive,
|
bool replaceActive,
|
||||||
double crossfade,
|
double crossfade,
|
||||||
) {
|
) {
|
||||||
return _play_animation_ffi(
|
return _play_animation_ffi(
|
||||||
@@ -1945,10 +1946,11 @@ class NativeLibrary {
|
|||||||
|
|
||||||
late final _play_animation_ffiPtr = _lookup<
|
late final _play_animation_ffiPtr = _lookup<
|
||||||
ffi.NativeFunction<
|
ffi.NativeFunction<
|
||||||
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int, ffi.Int,
|
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int, ffi.Bool,
|
||||||
ffi.Int, ffi.Int, ffi.Float)>>('play_animation_ffi');
|
ffi.Bool, ffi.Bool, ffi.Float)>>('play_animation_ffi');
|
||||||
late final _play_animation_ffi = _play_animation_ffiPtr.asFunction<
|
late final _play_animation_ffi = _play_animation_ffiPtr.asFunction<
|
||||||
void Function(ffi.Pointer<ffi.Void>, int, int, int, int, int, double)>();
|
void Function(
|
||||||
|
ffi.Pointer<ffi.Void>, int, int, bool, bool, bool, double)>();
|
||||||
|
|
||||||
void set_animation_frame_ffi(
|
void set_animation_frame_ffi(
|
||||||
ffi.Pointer<ffi.Void> assetManager,
|
ffi.Pointer<ffi.Void> assetManager,
|
||||||
@@ -2097,10 +2099,102 @@ class NativeLibrary {
|
|||||||
int Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>)>();
|
int Function(ffi.Pointer<ffi.Void>, int, ffi.Pointer<ffi.Char>)>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final class __mbstate_t extends ffi.Union {
|
||||||
|
@ffi.Array.multi([128])
|
||||||
|
external ffi.Array<ffi.Char> __mbstate8;
|
||||||
|
|
||||||
|
@ffi.LongLong()
|
||||||
|
external int _mbstateL;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class __darwin_pthread_handler_rec extends ffi.Struct {
|
||||||
|
external ffi
|
||||||
|
.Pointer<ffi.NativeFunction<ffi.Void Function(ffi.Pointer<ffi.Void>)>>
|
||||||
|
__routine;
|
||||||
|
|
||||||
|
external ffi.Pointer<ffi.Void> __arg;
|
||||||
|
|
||||||
|
external ffi.Pointer<__darwin_pthread_handler_rec> __next;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_attr_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([56])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_cond_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([40])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_condattr_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([8])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_mutex_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([56])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_mutexattr_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([8])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_once_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([8])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_rwlock_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([192])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_rwlockattr_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
@ffi.Array.multi([16])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
|
final class _opaque_pthread_t extends ffi.Struct {
|
||||||
|
@ffi.Long()
|
||||||
|
external int __sig;
|
||||||
|
|
||||||
|
external ffi.Pointer<__darwin_pthread_handler_rec> __cleanup_stack;
|
||||||
|
|
||||||
|
@ffi.Array.multi([8176])
|
||||||
|
external ffi.Array<ffi.Char> __opaque;
|
||||||
|
}
|
||||||
|
|
||||||
final class ResourceBuffer extends ffi.Struct {
|
final class ResourceBuffer extends ffi.Struct {
|
||||||
external ffi.Pointer<ffi.Void> data;
|
external ffi.Pointer<ffi.Void> data;
|
||||||
|
|
||||||
@ffi.Uint32()
|
@ffi.Int64()
|
||||||
external int size;
|
external int size;
|
||||||
|
|
||||||
@ffi.Uint32()
|
@ffi.Uint32()
|
||||||
@@ -2131,128 +2225,174 @@ typedef FreeFilamentResourceFromOwner = ffi.Pointer<
|
|||||||
.NativeFunction<ffi.Void Function(ResourceBuffer, ffi.Pointer<ffi.Void>)>>;
|
.NativeFunction<ffi.Void Function(ResourceBuffer, ffi.Pointer<ffi.Void>)>>;
|
||||||
typedef EntityId = ffi.Int32;
|
typedef EntityId = ffi.Int32;
|
||||||
|
|
||||||
const int INT64_MAX = 9223372036854775807;
|
const int __WORDSIZE = 64;
|
||||||
|
|
||||||
const int INT64_MIN = -9223372036854775808;
|
const int __DARWIN_ONLY_64_BIT_INO_T = 1;
|
||||||
|
|
||||||
const int UINT64_MAX = -1;
|
const int __DARWIN_ONLY_UNIX_CONFORMANCE = 1;
|
||||||
|
|
||||||
const int __INT_LEAST64_MIN = -9223372036854775808;
|
const int __DARWIN_ONLY_VERS_1050 = 1;
|
||||||
|
|
||||||
const int __INT_LEAST64_MAX = 9223372036854775807;
|
const int __DARWIN_UNIX03 = 1;
|
||||||
|
|
||||||
const int __UINT_LEAST64_MAX = -1;
|
const int __DARWIN_64_BIT_INO_T = 1;
|
||||||
|
|
||||||
const int __INT_LEAST32_MIN = -2147483648;
|
const int __DARWIN_VERS_1050 = 1;
|
||||||
|
|
||||||
const int __INT_LEAST32_MAX = 2147483647;
|
const int __DARWIN_NON_CANCELABLE = 0;
|
||||||
|
|
||||||
const int __UINT_LEAST32_MAX = 4294967295;
|
const String __DARWIN_SUF_EXTSN = '\$DARWIN_EXTSN';
|
||||||
|
|
||||||
const int __INT_LEAST16_MIN = -32768;
|
const int __DARWIN_C_ANSI = 4096;
|
||||||
|
|
||||||
const int __INT_LEAST16_MAX = 32767;
|
const int __DARWIN_C_FULL = 900000;
|
||||||
|
|
||||||
const int __UINT_LEAST16_MAX = 65535;
|
const int __DARWIN_C_LEVEL = 900000;
|
||||||
|
|
||||||
const int __INT_LEAST8_MIN = -128;
|
const int __STDC_WANT_LIB_EXT1__ = 1;
|
||||||
|
|
||||||
const int __INT_LEAST8_MAX = 127;
|
const int __DARWIN_NO_LONG_LONG = 0;
|
||||||
|
|
||||||
const int __UINT_LEAST8_MAX = 255;
|
const int _DARWIN_FEATURE_64_BIT_INODE = 1;
|
||||||
|
|
||||||
const int INT_LEAST64_MIN = -9223372036854775808;
|
const int _DARWIN_FEATURE_ONLY_64_BIT_INODE = 1;
|
||||||
|
|
||||||
const int INT_LEAST64_MAX = 9223372036854775807;
|
const int _DARWIN_FEATURE_ONLY_VERS_1050 = 1;
|
||||||
|
|
||||||
const int UINT_LEAST64_MAX = -1;
|
const int _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1;
|
||||||
|
|
||||||
const int INT_FAST64_MIN = -9223372036854775808;
|
const int _DARWIN_FEATURE_UNIX_CONFORMANCE = 3;
|
||||||
|
|
||||||
const int INT_FAST64_MAX = 9223372036854775807;
|
const int __has_ptrcheck = 0;
|
||||||
|
|
||||||
const int UINT_FAST64_MAX = -1;
|
const int __DARWIN_NULL = 0;
|
||||||
|
|
||||||
const int INT32_MAX = 2147483647;
|
const int __PTHREAD_SIZE__ = 8176;
|
||||||
|
|
||||||
const int INT32_MIN = -2147483648;
|
const int __PTHREAD_ATTR_SIZE__ = 56;
|
||||||
|
|
||||||
const int UINT32_MAX = 4294967295;
|
const int __PTHREAD_MUTEXATTR_SIZE__ = 8;
|
||||||
|
|
||||||
const int INT_LEAST32_MIN = -2147483648;
|
const int __PTHREAD_MUTEX_SIZE__ = 56;
|
||||||
|
|
||||||
const int INT_LEAST32_MAX = 2147483647;
|
const int __PTHREAD_CONDATTR_SIZE__ = 8;
|
||||||
|
|
||||||
const int UINT_LEAST32_MAX = 4294967295;
|
const int __PTHREAD_COND_SIZE__ = 40;
|
||||||
|
|
||||||
const int INT_FAST32_MIN = -2147483648;
|
const int __PTHREAD_ONCE_SIZE__ = 8;
|
||||||
|
|
||||||
const int INT_FAST32_MAX = 2147483647;
|
const int __PTHREAD_RWLOCK_SIZE__ = 192;
|
||||||
|
|
||||||
const int UINT_FAST32_MAX = 4294967295;
|
const int __PTHREAD_RWLOCKATTR_SIZE__ = 16;
|
||||||
|
|
||||||
const int INT16_MAX = 32767;
|
const int USER_ADDR_NULL = 0;
|
||||||
|
|
||||||
const int INT16_MIN = -32768;
|
|
||||||
|
|
||||||
const int UINT16_MAX = 65535;
|
|
||||||
|
|
||||||
const int INT_LEAST16_MIN = -32768;
|
|
||||||
|
|
||||||
const int INT_LEAST16_MAX = 32767;
|
|
||||||
|
|
||||||
const int UINT_LEAST16_MAX = 65535;
|
|
||||||
|
|
||||||
const int INT_FAST16_MIN = -32768;
|
|
||||||
|
|
||||||
const int INT_FAST16_MAX = 32767;
|
|
||||||
|
|
||||||
const int UINT_FAST16_MAX = 65535;
|
|
||||||
|
|
||||||
const int INT8_MAX = 127;
|
const int INT8_MAX = 127;
|
||||||
|
|
||||||
|
const int INT16_MAX = 32767;
|
||||||
|
|
||||||
|
const int INT32_MAX = 2147483647;
|
||||||
|
|
||||||
|
const int INT64_MAX = 9223372036854775807;
|
||||||
|
|
||||||
const int INT8_MIN = -128;
|
const int INT8_MIN = -128;
|
||||||
|
|
||||||
|
const int INT16_MIN = -32768;
|
||||||
|
|
||||||
|
const int INT32_MIN = -2147483648;
|
||||||
|
|
||||||
|
const int INT64_MIN = -9223372036854775808;
|
||||||
|
|
||||||
const int UINT8_MAX = 255;
|
const int UINT8_MAX = 255;
|
||||||
|
|
||||||
|
const int UINT16_MAX = 65535;
|
||||||
|
|
||||||
|
const int UINT32_MAX = 4294967295;
|
||||||
|
|
||||||
|
const int UINT64_MAX = -1;
|
||||||
|
|
||||||
const int INT_LEAST8_MIN = -128;
|
const int INT_LEAST8_MIN = -128;
|
||||||
|
|
||||||
|
const int INT_LEAST16_MIN = -32768;
|
||||||
|
|
||||||
|
const int INT_LEAST32_MIN = -2147483648;
|
||||||
|
|
||||||
|
const int INT_LEAST64_MIN = -9223372036854775808;
|
||||||
|
|
||||||
const int INT_LEAST8_MAX = 127;
|
const int INT_LEAST8_MAX = 127;
|
||||||
|
|
||||||
|
const int INT_LEAST16_MAX = 32767;
|
||||||
|
|
||||||
|
const int INT_LEAST32_MAX = 2147483647;
|
||||||
|
|
||||||
|
const int INT_LEAST64_MAX = 9223372036854775807;
|
||||||
|
|
||||||
const int UINT_LEAST8_MAX = 255;
|
const int UINT_LEAST8_MAX = 255;
|
||||||
|
|
||||||
|
const int UINT_LEAST16_MAX = 65535;
|
||||||
|
|
||||||
|
const int UINT_LEAST32_MAX = 4294967295;
|
||||||
|
|
||||||
|
const int UINT_LEAST64_MAX = -1;
|
||||||
|
|
||||||
const int INT_FAST8_MIN = -128;
|
const int INT_FAST8_MIN = -128;
|
||||||
|
|
||||||
|
const int INT_FAST16_MIN = -32768;
|
||||||
|
|
||||||
|
const int INT_FAST32_MIN = -2147483648;
|
||||||
|
|
||||||
|
const int INT_FAST64_MIN = -9223372036854775808;
|
||||||
|
|
||||||
const int INT_FAST8_MAX = 127;
|
const int INT_FAST8_MAX = 127;
|
||||||
|
|
||||||
|
const int INT_FAST16_MAX = 32767;
|
||||||
|
|
||||||
|
const int INT_FAST32_MAX = 2147483647;
|
||||||
|
|
||||||
|
const int INT_FAST64_MAX = 9223372036854775807;
|
||||||
|
|
||||||
const int UINT_FAST8_MAX = 255;
|
const int UINT_FAST8_MAX = 255;
|
||||||
|
|
||||||
const int INTPTR_MIN = -9223372036854775808;
|
const int UINT_FAST16_MAX = 65535;
|
||||||
|
|
||||||
|
const int UINT_FAST32_MAX = 4294967295;
|
||||||
|
|
||||||
|
const int UINT_FAST64_MAX = -1;
|
||||||
|
|
||||||
const int INTPTR_MAX = 9223372036854775807;
|
const int INTPTR_MAX = 9223372036854775807;
|
||||||
|
|
||||||
|
const int INTPTR_MIN = -9223372036854775808;
|
||||||
|
|
||||||
const int UINTPTR_MAX = -1;
|
const int UINTPTR_MAX = -1;
|
||||||
|
|
||||||
|
const int INTMAX_MAX = 9223372036854775807;
|
||||||
|
|
||||||
|
const int UINTMAX_MAX = -1;
|
||||||
|
|
||||||
|
const int INTMAX_MIN = -9223372036854775808;
|
||||||
|
|
||||||
const int PTRDIFF_MIN = -9223372036854775808;
|
const int PTRDIFF_MIN = -9223372036854775808;
|
||||||
|
|
||||||
const int PTRDIFF_MAX = 9223372036854775807;
|
const int PTRDIFF_MAX = 9223372036854775807;
|
||||||
|
|
||||||
const int SIZE_MAX = -1;
|
const int SIZE_MAX = -1;
|
||||||
|
|
||||||
const int INTMAX_MIN = -9223372036854775808;
|
const int RSIZE_MAX = 9223372036854775807;
|
||||||
|
|
||||||
const int INTMAX_MAX = 9223372036854775807;
|
const int WCHAR_MAX = 2147483647;
|
||||||
|
|
||||||
const int UINTMAX_MAX = -1;
|
const int WCHAR_MIN = -2147483648;
|
||||||
|
|
||||||
const int SIG_ATOMIC_MIN = -2147483648;
|
|
||||||
|
|
||||||
const int SIG_ATOMIC_MAX = 2147483647;
|
|
||||||
|
|
||||||
const int WINT_MIN = -2147483648;
|
const int WINT_MIN = -2147483648;
|
||||||
|
|
||||||
const int WINT_MAX = 2147483647;
|
const int WINT_MAX = 2147483647;
|
||||||
|
|
||||||
const int WCHAR_MAX = 2147483647;
|
const int SIG_ATOMIC_MIN = -2147483648;
|
||||||
|
|
||||||
const int WCHAR_MIN = -2147483648;
|
const int SIG_ATOMIC_MAX = 2147483647;
|
||||||
|
|
||||||
|
const int __bool_true_false_are_defined = 1;
|
||||||
|
|
||||||
|
const int true1 = 1;
|
||||||
|
|
||||||
|
const int false1 = 0;
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
instance.resources[resId] = nsData
|
instance.resources[resId] = nsData
|
||||||
let length = nsData.length
|
let length = nsData.length
|
||||||
print("Resolved asset to file of length \(length) at path \(path!)")
|
print("Resolved asset to file of length \(length) at path \(path!)")
|
||||||
return ResourceBuffer(data:nsData.bytes, size:UInt32(nsData.count), id:UInt32(resId))
|
|
||||||
|
return ResourceBuffer(data:nsData.bytes, size:Int64(nsData.length), id:UInt32(resId))
|
||||||
} catch {
|
} catch {
|
||||||
print("ERROR LOADING RESOURCE")
|
print("ERROR LOADING RESOURCE")
|
||||||
}
|
}
|
||||||
@@ -160,8 +161,10 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
result([
|
result([
|
||||||
unsafeBitCast(renderCallback, to:Int64.self), unsafeBitCast(Unmanaged.passUnretained(self), to:UInt64.self)])
|
unsafeBitCast(renderCallback, to:Int64.self), unsafeBitCast(Unmanaged.passUnretained(self), to:UInt64.self)])
|
||||||
case "createTexture":
|
case "createTexture":
|
||||||
let args = call.arguments as! Array<Int32>
|
let args = call.arguments as! [Any]
|
||||||
createPixelBuffer(width:Int(args[0]), height:Int(args[1]))
|
let width = UInt32(args[0] as! Int64)
|
||||||
|
let height = UInt32(args[1] as! Int64)
|
||||||
|
createPixelBuffer(width:Int(width), height:Int(height))
|
||||||
|
|
||||||
var cvret = CVMetalTextureCacheCreate(
|
var cvret = CVMetalTextureCacheCreate(
|
||||||
kCFAllocatorDefault,
|
kCFAllocatorDefault,
|
||||||
@@ -178,14 +181,19 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
cvMetalTextureCache!,
|
cvMetalTextureCache!,
|
||||||
pixelBuffer!, nil,
|
pixelBuffer!, nil,
|
||||||
MTLPixelFormat.bgra8Unorm,
|
MTLPixelFormat.bgra8Unorm,
|
||||||
Int(args[0]), Int(args[1]),
|
Int(width), Int(height),
|
||||||
0,
|
0,
|
||||||
&cvMetalTexture);
|
&cvMetalTexture);
|
||||||
metalTexture = CVMetalTextureGetTexture(cvMetalTexture!);
|
metalTexture = CVMetalTextureGetTexture(cvMetalTexture!);
|
||||||
// createDisplayLink()
|
// createDisplayLink()
|
||||||
let pixelBufferAddress = Int(bitPattern:CVPixelBufferGetBaseAddress(pixelBuffer!));
|
let pixelBufferPtr = CVPixelBufferGetBaseAddress(pixelBuffer!);
|
||||||
let metalTextureAddress = Int(bitPattern:Unmanaged.passUnretained(metalTexture!).toOpaque())
|
let pixelBufferAddress = Int(bitPattern:pixelBufferPtr);
|
||||||
result([self.flutterTextureId as! Any, pixelBufferAddress, metalTextureAddress])
|
let metalTexturePtr = Unmanaged.passUnretained(metalTexture!).toOpaque()
|
||||||
|
let metalTextureAddress = Int(bitPattern:metalTexturePtr)
|
||||||
|
|
||||||
|
let callback = make_resource_loader(loadResource, freeResource, Unmanaged.passUnretained(self).toOpaque())
|
||||||
|
|
||||||
|
result([self.flutterTextureId as Any, nil, metalTextureAddress])
|
||||||
case "destroyTexture":
|
case "destroyTexture":
|
||||||
if(viewer != nil) {
|
if(viewer != nil) {
|
||||||
result(FlutterError(code: "INVALID_ARGUMENTS", message: "Destroy the viewer before destroying the texture", details: nil))
|
result(FlutterError(code: "INVALID_ARGUMENTS", message: "Destroy the viewer before destroying the texture", details: nil))
|
||||||
@@ -217,7 +225,7 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
|||||||
resize(width:Int32(width), height:Int32(height))
|
resize(width:Int32(width), height:Int32(height))
|
||||||
create_swap_chain(viewer, CVPixelBufferGetBaseAddress(pixelBuffer!), width, height)
|
create_swap_chain(viewer, CVPixelBufferGetBaseAddress(pixelBuffer!), width, height)
|
||||||
let metalTextureId = Int(bitPattern:Unmanaged.passUnretained(metalTexture!).toOpaque())
|
let metalTextureId = Int(bitPattern:Unmanaged.passUnretained(metalTexture!).toOpaque())
|
||||||
create_render_target(viewer, UInt32(metalTextureId), width, height);
|
create_render_target(viewer, metalTextureId, width, height);
|
||||||
update_viewport_and_camera_projection(viewer, width, height, Float(args[2] as! Double))
|
update_viewport_and_camera_projection(viewer, width, height, Float(args[2] as! Double))
|
||||||
rendering = true
|
rendering = true
|
||||||
print("Resized to \(args[0])x\(args[1])")
|
print("Resized to \(args[0])x\(args[1])")
|
||||||
|
|||||||
@@ -3,13 +3,15 @@
|
|||||||
|
|
||||||
#include "ResourceBuffer.hpp"
|
#include "ResourceBuffer.hpp"
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
typedef int32_t EntityId;
|
typedef int32_t EntityId;
|
||||||
|
|
||||||
const void* create_filament_viewer(const void* const context, const ResourceLoaderWrapper* const loader);
|
const void* create_filament_viewer(const void* const context, const ResourceLoaderWrapper* const loader);
|
||||||
ResourceLoaderWrapper* make_resource_loader(LoadFilamentResourceFromOwner loadFn, FreeFilamentResourceFromOwner freeFn, void* owner);
|
ResourceLoaderWrapper* make_resource_loader(LoadFilamentResourceFromOwner loadFn, FreeFilamentResourceFromOwner freeFn, void* owner);
|
||||||
void destroy_filament_viewer(const void* const viewer);
|
void destroy_filament_viewer(const void* const viewer);
|
||||||
void* get_asset_manager(const void* const viewer);
|
void* get_asset_manager(const void* const viewer);
|
||||||
void create_render_target(const void* const viewer, uint32_t textureId, uint32_t width, uint32_t height);
|
void create_render_target(const void* const viewer, intptr_t texture, uint32_t width, uint32_t height);
|
||||||
void clear_background_image(const void* const viewer);
|
void clear_background_image(const void* const viewer);
|
||||||
void set_background_image(const void* const viewer, const char *path, bool fillHeight);
|
void set_background_image(const void* const viewer, const char *path, bool fillHeight);
|
||||||
void set_background_image_position(const void* const viewer, float x, float y, bool clamp);
|
void set_background_image_position(const void* const viewer, float x, float y, bool clamp);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#ifndef _POLYVOX_FILAMENT_FFI_API_H
|
#ifndef _POLYVOX_FILAMENT_FFI_API_H
|
||||||
#define _POLYVOX_FILAMENT_FFI_API_H
|
#define _POLYVOX_FILAMENT_FFI_API_H
|
||||||
|
|
||||||
#include "PolyvoxFilamentApi.h"
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// This header replicates most of the methods in PolyvoxFilamentApi.h, and is only intended to be used to generate client FFI bindings.
|
/// This header replicates most of the methods in PolyvoxFilamentApi.h, and is only intended to be used to generate client FFI bindings.
|
||||||
/// The intention is that calling one of these methods will call its respective method in PolyvoxFilamentApi.h, but wrapped in some kind of thread runner to ensure thread safety.
|
/// The intention is that calling one of these methods will call its respective method in PolyvoxFilamentApi.h, but wrapped in some kind of thread runner to ensure thread safety.
|
||||||
///
|
///
|
||||||
|
|
||||||
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
typedef int32_t EntityId;
|
typedef int32_t EntityId;
|
||||||
|
|
||||||
void* const create_filament_viewer_ffi(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner);
|
void* const create_filament_viewer_ffi(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner);
|
||||||
@@ -33,25 +33,25 @@ void remove_light_ffi(void* const viewer, EntityId entityId);
|
|||||||
void clear_lights_ffi(void* const viewer);
|
void clear_lights_ffi(void* const viewer);
|
||||||
EntityId load_glb_ffi(void* const assetManager, const char *assetPath, bool unlit);
|
EntityId load_glb_ffi(void* const assetManager, const char *assetPath, bool unlit);
|
||||||
EntityId load_gltf_ffi(void* const assetManager, const char *assetPath, const char *relativePath);
|
EntityId load_gltf_ffi(void* const assetManager, const char *assetPath, const char *relativePath);
|
||||||
void remove_asset_ffi(void* const const viewer, EntityId asset);
|
void remove_asset_ffi(void* const viewer, EntityId asset);
|
||||||
void clear_assets_ffi(void* const const viewer);
|
void clear_assets_ffi(void* const viewer);
|
||||||
bool set_camera_ffi(void* const viewer, EntityId asset, const char *nodeName);
|
bool set_camera_ffi(void* const viewer, EntityId asset, const char *nodeName);
|
||||||
void apply_weights_ffi(
|
void apply_weights_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
const char *const entityName,
|
||||||
float *const weights,
|
float *const weights,
|
||||||
int count
|
int count
|
||||||
);
|
);
|
||||||
void set_morph_target_weights_ffi(
|
void set_morph_target_weights_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
const char *const entityName,
|
||||||
const float *const morphData,
|
const float *const morphData,
|
||||||
int numWeights
|
int numWeights
|
||||||
);
|
);
|
||||||
bool set_morph_animation_ffi(
|
bool set_morph_animation_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const char *const entityName,
|
const char *const entityName,
|
||||||
const float *const morphData,
|
const float *const morphData,
|
||||||
@@ -61,7 +61,7 @@ bool set_morph_animation_ffi(
|
|||||||
float frameLengthInMs);
|
float frameLengthInMs);
|
||||||
|
|
||||||
void set_bone_animation_ffi(
|
void set_bone_animation_ffi(
|
||||||
void* assetManager,
|
void* const assetManager,
|
||||||
EntityId asset,
|
EntityId asset,
|
||||||
const float* const frameData,
|
const float* const frameData,
|
||||||
int numFrames,
|
int numFrames,
|
||||||
@@ -71,13 +71,13 @@ void set_bone_animation_ffi(
|
|||||||
int numMeshTargets,
|
int numMeshTargets,
|
||||||
float frameLengthInMs);
|
float frameLengthInMs);
|
||||||
|
|
||||||
void play_animation_ffi(void* assetManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade);
|
void play_animation_ffi(void* const assetManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade);
|
||||||
void set_animation_frame_ffi(void* assetManager, EntityId asset, int animationIndex, int animationFrame);
|
void set_animation_frame_ffi(void* const assetManager, EntityId asset, int animationIndex, int animationFrame);
|
||||||
void stop_animation_ffi(void* assetManager, EntityId asset, int index);
|
void stop_animation_ffi(void* const assetManager, EntityId asset, int index);
|
||||||
int get_animation_count_ffi(void* assetManager, EntityId asset);
|
int get_animation_count_ffi(void* const assetManager, EntityId asset);
|
||||||
void get_animation_name_ffi(void* assetManager, EntityId asset, char *const outPtr, int index);
|
void get_animation_name_ffi(void* const assetManager, EntityId asset, char *const outPtr, int index);
|
||||||
float get_animation_duration_ffi(void* assetManager, EntityId asset, int index);
|
float get_animation_duration_ffi(void* const assetManager, EntityId asset, int index);
|
||||||
void get_morph_target_name_ffi(void* assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
|
void get_morph_target_name_ffi(void* const assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
|
||||||
int get_morph_target_name_count_ffi(void* assetManager, EntityId asset, const char *meshName);
|
int get_morph_target_name_count_ffi(void* const assetManager, EntityId asset, const char *meshName);
|
||||||
|
|
||||||
#endif // _POLYVOX_FILAMENT_FFI_API_H
|
#endif // _POLYVOX_FILAMENT_FFI_API_H
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ extern "C" {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
const void * const data;
|
const void * const data;
|
||||||
const uint32_t size;
|
const int64_t size;
|
||||||
const uint32_t id;
|
const uint32_t id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ FilamentViewer::FilamentViewer(const void* context, const ResourceLoaderWrapper*
|
|||||||
|
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
_engine = Engine::create(Engine::Backend::METAL);
|
_engine = Engine::create(Engine::Backend::METAL);
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
_engine = Engine::create(Engine::Backend::METAL);
|
||||||
#else
|
#else
|
||||||
_engine = Engine::create(Engine::Backend::OPENGL); //L, nullptr, (void*)context, nullptr);
|
_engine = Engine::create(Engine::Backend::OPENGL); //L, nullptr, (void*)context, nullptr);
|
||||||
#endif
|
#endif
|
||||||
@@ -565,7 +567,7 @@ void FilamentViewer::createSwapChain(const void *window, uint32_t width, uint32_
|
|||||||
Log("Swapchain created.");
|
Log("Swapchain created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilamentViewer::createRenderTarget(intptr_t textureId, uint32_t width, uint32_t height) {
|
void FilamentViewer::createRenderTarget(intptr_t texture, uint32_t width, uint32_t height) {
|
||||||
// Create filament textures and render targets (note the color buffer has the import call)
|
// Create filament textures and render targets (note the color buffer has the import call)
|
||||||
_rtColor = filament::Texture::Builder()
|
_rtColor = filament::Texture::Builder()
|
||||||
.width(width)
|
.width(width)
|
||||||
@@ -573,7 +575,7 @@ void FilamentViewer::createRenderTarget(intptr_t textureId, uint32_t width, uint
|
|||||||
.levels(1)
|
.levels(1)
|
||||||
.usage(filament::Texture::Usage::COLOR_ATTACHMENT | filament::Texture::Usage::SAMPLEABLE)
|
.usage(filament::Texture::Usage::COLOR_ATTACHMENT | filament::Texture::Usage::SAMPLEABLE)
|
||||||
.format(filament::Texture::InternalFormat::RGBA8)
|
.format(filament::Texture::InternalFormat::RGBA8)
|
||||||
.import(textureId)
|
.import(texture)
|
||||||
.build(*_engine);
|
.build(*_engine);
|
||||||
_rtDepth = filament::Texture::Builder()
|
_rtDepth = filament::Texture::Builder()
|
||||||
.width(width)
|
.width(width)
|
||||||
@@ -590,7 +592,7 @@ void FilamentViewer::createRenderTarget(intptr_t textureId, uint32_t width, uint
|
|||||||
// Make a specific viewport just for our render target
|
// Make a specific viewport just for our render target
|
||||||
_view->setRenderTarget(_rt);
|
_view->setRenderTarget(_rt);
|
||||||
|
|
||||||
Log("Set render target for glTextureId %u %u x %u", textureId, width, height);
|
Log("Set render target for glTextureId %u %u x %u", texture, width, height);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "PolyvoxFilamentApi.h"
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT const void* create_filament_viewer(const void* context, const ResourceLoaderWrapper* const loader) {
|
FLUTTER_PLUGIN_EXPORT const void* create_filament_viewer(const void* context, const ResourceLoaderWrapper* const loader) {
|
||||||
return (const void*) new FilamentViewer(context, loader);
|
return (const void*) new FilamentViewer(context, loader);
|
||||||
}
|
}
|
||||||
@@ -24,8 +25,8 @@ extern "C" {
|
|||||||
return new ResourceLoaderWrapper(loadFn, freeFn, owner);
|
return new ResourceLoaderWrapper(loadFn, freeFn, owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_render_target(const void* const viewer, uint32_t textureId, uint32_t width, uint32_t height) {
|
FLUTTER_PLUGIN_EXPORT void create_render_target(const void* const viewer, intptr_t texture, uint32_t width, uint32_t height) {
|
||||||
((FilamentViewer*)viewer)->createRenderTarget(textureId, width, height);
|
((FilamentViewer*)viewer)->createRenderTarget(texture, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer(const void* const viewer) {
|
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer(const void* const viewer) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "Log.hpp"
|
#include "Log.hpp"
|
||||||
#include "ThreadPool.hpp"
|
#include "ThreadPool.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
@@ -12,10 +13,13 @@ using namespace polyvox;
|
|||||||
|
|
||||||
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
||||||
|
|
||||||
class RenderLoop {
|
class RenderLoop
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
explicit RenderLoop() {
|
explicit RenderLoop()
|
||||||
_t = new std::thread([this]() {
|
{
|
||||||
|
_t = new std::thread([this]()
|
||||||
|
{
|
||||||
while(!_stop) {
|
while(!_stop) {
|
||||||
std::function<void()> task;
|
std::function<void()> task;
|
||||||
{
|
{
|
||||||
@@ -35,121 +39,294 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
task();
|
task();
|
||||||
}
|
} });
|
||||||
});
|
}
|
||||||
}
|
~RenderLoop()
|
||||||
~RenderLoop() {
|
{
|
||||||
_stop = true;
|
_stop = true;
|
||||||
_t->join();
|
_t->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void* const createViewer(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void*), void* const owner) {
|
void *const createViewer(void *const context, const ResourceLoaderWrapper *const loader, void (*renderCallback)(void *), void *const owner)
|
||||||
|
{
|
||||||
_renderCallback = renderCallback;
|
_renderCallback = renderCallback;
|
||||||
_renderCallbackOwner = owner;
|
_renderCallbackOwner = owner;
|
||||||
std::packaged_task<FilamentViewer* const()> lambda([&]() mutable {
|
std::packaged_task<FilamentViewer *const()> lambda([&]() mutable
|
||||||
return new FilamentViewer(context, loader);
|
{ return new FilamentViewer(context, loader); });
|
||||||
});
|
|
||||||
auto fut = add_task(lambda);
|
auto fut = add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
_viewer = fut.get();
|
_viewer = fut.get();
|
||||||
return (void* const)_viewer;
|
return (void *const)_viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setRendering(bool rendering) {
|
void setRendering(bool rendering)
|
||||||
|
{
|
||||||
_rendering = rendering;
|
_rendering = rendering;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doRender() {
|
void doRender()
|
||||||
|
{
|
||||||
render(_viewer, 0);
|
render(_viewer, 0);
|
||||||
_renderCallback(_renderCallbackOwner);
|
_renderCallback(_renderCallbackOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Rt>
|
template <class Rt>
|
||||||
auto add_task(std::packaged_task<Rt()>& pt) -> std::future<Rt> {
|
auto add_task(std::packaged_task<Rt()> &pt) -> std::future<Rt>
|
||||||
std::unique_lock<std::mutex> lock(_access);
|
{
|
||||||
auto ret = pt.get_future();
|
std::unique_lock<std::mutex> lock(_access);
|
||||||
_tasks.push_back([pt=std::make_shared<std::packaged_task<Rt()>>(std::move(pt))]{ (*pt)();});
|
auto ret = pt.get_future();
|
||||||
_cond.notify_one();
|
_tasks.push_back([pt = std::make_shared<std::packaged_task<Rt()>>(std::move(pt))]
|
||||||
return ret;
|
{ (*pt)(); });
|
||||||
}
|
_cond.notify_one();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _stop = false;
|
bool _stop = false;
|
||||||
bool _rendering = false;
|
bool _rendering = false;
|
||||||
int _frameIntervalInMilliseconds = 1000 / 60;
|
int _frameIntervalInMilliseconds = 1000 / 60;
|
||||||
std::mutex _access;
|
std::mutex _access;
|
||||||
FilamentViewer* _viewer = nullptr;
|
FilamentViewer *_viewer = nullptr;
|
||||||
void (*_renderCallback)(void* const) = nullptr;
|
void (*_renderCallback)(void *const) = nullptr;
|
||||||
void* _renderCallbackOwner = nullptr;
|
void *_renderCallbackOwner = nullptr;
|
||||||
std::thread* _t = nullptr;
|
std::thread *_t = nullptr;
|
||||||
std::condition_variable _cond;
|
std::condition_variable _cond;
|
||||||
std::deque<std::function<void()>> _tasks;
|
std::deque<std::function<void()>> _tasks;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "PolyvoxFilamentApi.h"
|
||||||
|
|
||||||
|
static RenderLoop *_rl;
|
||||||
|
|
||||||
extern "C" {
|
FLUTTER_PLUGIN_EXPORT void *const create_filament_viewer_ffi(void *const context, const ResourceLoaderWrapper *const loader, void (*renderCallback)(void *const renderCallbackOwner), void *const renderCallbackOwner)
|
||||||
|
{
|
||||||
#include "PolyvoxFilamentApi.h"
|
if (!_rl)
|
||||||
|
{
|
||||||
static RenderLoop* _rl;
|
_rl = new RenderLoop();
|
||||||
|
}
|
||||||
FLUTTER_PLUGIN_EXPORT void* const create_filament_viewer_ffi(void* const context, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner) {
|
return _rl->createViewer(context, loader, renderCallback, renderCallbackOwner);
|
||||||
if(!_rl) {
|
|
||||||
_rl = new RenderLoop();
|
|
||||||
}
|
}
|
||||||
return _rl->createViewer(context, loader, renderCallback, renderCallbackOwner);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void *const viewer, void *const surface, uint32_t width, uint32_t height)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
|
{ create_swap_chain(viewer, surface, width, height); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_swap_chain_ffi(void* const viewer, void* const surface, uint32_t width, uint32_t height) {
|
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void *const viewer, uint32_t nativeTextureId, uint32_t width, uint32_t height)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
create_swap_chain(viewer, surface, width, height);
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
});
|
{ create_render_target(viewer, nativeTextureId, width, height); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void* const viewer, uint32_t nativeTextureId, uint32_t width, uint32_t height) {
|
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection_ffi(void *const viewer, const uint32_t width, const uint32_t height, const float scaleFactor)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
create_render_target(viewer, nativeTextureId, width, height);
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
});
|
{ update_viewport_and_camera_projection(viewer, width, height, scaleFactor); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_rendering_ffi(bool rendering)
|
||||||
|
{
|
||||||
|
if (!_rl)
|
||||||
|
{
|
||||||
|
Log("No render loop!"); // PANIC?
|
||||||
|
} else {
|
||||||
|
if(rendering) {
|
||||||
|
Log("Set rendering to true");
|
||||||
|
} else {
|
||||||
|
Log("Set rendering to false");
|
||||||
|
}
|
||||||
|
_rl->setRendering(rendering);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection_ffi(void* const viewer, const uint32_t width, const uint32_t height, const float scaleFactor) {
|
FLUTTER_PLUGIN_EXPORT void render_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
update_viewport_and_camera_projection(viewer, width, height, scaleFactor);
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
});
|
{ _rl->doRender(); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_background_color_ffi(void *const viewer, const float r, const float g, const float b, const float a)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]() mutable
|
||||||
|
{ set_background_color(viewer, r, g, b, a); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT bool set_rendering_ffi(bool rendering) {
|
FLUTTER_PLUGIN_EXPORT EntityId load_glb_ffi(void *const assetManager, const char *path)
|
||||||
if(!_rl) {
|
{
|
||||||
return false;
|
std::packaged_task<EntityId()> lambda([&]() mutable
|
||||||
}
|
{ return load_glb(assetManager, path, false); });
|
||||||
_rl->setRendering(rendering);
|
auto fut = _rl->add_task(lambda);
|
||||||
return true;
|
fut.wait();
|
||||||
}
|
return fut.get();
|
||||||
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void render_ffi(void* const viewer) {
|
FLUTTER_PLUGIN_EXPORT void clear_background_image_ffi(void *const viewer)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
_rl->doRender();
|
std::packaged_task<void()> lambda([&]
|
||||||
});
|
{ clear_background_image(viewer); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
FLUTTER_PLUGIN_EXPORT void set_background_color_ffi(void* const viewer, const float r, const float g, const float b, const float a) {
|
FLUTTER_PLUGIN_EXPORT void set_background_image_ffi(void *const viewer, const char *path, bool fillHeight)
|
||||||
std::packaged_task<void()> lambda([&]() mutable {
|
{
|
||||||
set_background_color(viewer, r, g,b, a);
|
std::packaged_task<void()> lambda([&]
|
||||||
});
|
{ set_background_image(viewer, path, fillHeight); });
|
||||||
auto fut = _rl->add_task(lambda);
|
auto fut = _rl->add_task(lambda);
|
||||||
fut.wait();
|
fut.wait();
|
||||||
}
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_background_image_position_ffi(void *const viewer, float x, float y, bool clamp)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_background_image_position(viewer, x, y, clamp); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_tone_mapping_ffi(void *const viewer, int toneMapping)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_tone_mapping(viewer, toneMapping); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_bloom_ffi(void *const viewer, float strength)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_bloom(viewer, strength); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void load_skybox_ffi(void *const viewer, const char *skyboxPath)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ load_skybox(viewer, skyboxPath); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void load_ibl_ffi(void *const viewer, const char *iblPath, float intensity)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ load_ibl(viewer, iblPath, intensity); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_skybox_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_skybox(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_ibl_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_ibl(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
EntityId add_light_ffi(void *const viewer, uint8_t type, float colour, float intensity, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, bool shadows)
|
||||||
|
{
|
||||||
|
std::packaged_task<EntityId()> lambda([&]
|
||||||
|
{ return add_light(viewer, type, colour, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
return fut.get();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_light_ffi(void *const viewer, EntityId entityId)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_light(viewer, entityId); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void clear_lights_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ clear_lights(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void remove_asset_ffi(void *const viewer, EntityId asset)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ remove_asset(viewer, asset); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
FLUTTER_PLUGIN_EXPORT void clear_assets_ffi(void *const viewer)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ clear_assets(viewer); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT bool set_camera_ffi(void *const viewer, EntityId asset, const char *nodeName)
|
||||||
|
{
|
||||||
|
std::packaged_task<bool()> lambda([&]
|
||||||
|
{ return set_camera(viewer, asset, nodeName); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
return fut.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT void set_bone_animation_ffi(
|
||||||
|
void *assetManager,
|
||||||
|
EntityId asset,
|
||||||
|
const float *const frameData,
|
||||||
|
int numFrames,
|
||||||
|
int numBones,
|
||||||
|
const char **const boneNames,
|
||||||
|
const char **const meshName,
|
||||||
|
int numMeshTargets,
|
||||||
|
float frameLengthInMs)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ set_bone_animation(
|
||||||
|
assetManager, asset, frameData, numFrames, numBones,
|
||||||
|
boneNames, meshName, numMeshTargets, frameLengthInMs); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
// implementations of rest of animation functions
|
||||||
|
FLUTTER_PLUGIN_EXPORT void get_morph_target_name_ffi(void *assetManager, EntityId asset, const char *meshName, char *const outPtr, int index)
|
||||||
|
{
|
||||||
|
std::packaged_task<void()> lambda([&]
|
||||||
|
{ get_morph_target_name(assetManager, asset, meshName, outPtr, index); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
FLUTTER_PLUGIN_EXPORT int get_morph_target_name_count_ffi(void *assetManager, EntityId asset, const char *meshName)
|
||||||
|
{
|
||||||
|
std::packaged_task<int()> lambda([&]
|
||||||
|
{ return get_morph_target_name_count(assetManager, asset, meshName); });
|
||||||
|
auto fut = _rl->add_task(lambda);
|
||||||
|
fut.wait();
|
||||||
|
return fut.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_morph_target_weights_ffi(
|
||||||
|
void* const assetManager,
|
||||||
|
EntityId asset,
|
||||||
|
const char *const entityName,
|
||||||
|
const float *const morphData,
|
||||||
|
int numWeights
|
||||||
|
) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,17 +22,13 @@ dev_dependencies:
|
|||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
flutter_lints: ^1.0.0
|
flutter_lints: ^1.0.0
|
||||||
ffigen: ^9.0.1
|
ffigen: ^8.0.2
|
||||||
|
|
||||||
ffigen:
|
ffigen:
|
||||||
output: 'lib/generated_bindings.dart'
|
output: 'lib/generated_bindings.dart'
|
||||||
headers:
|
headers:
|
||||||
entry-points:
|
entry-points:
|
||||||
- 'ios/include/PolyvoxFilamentApi.h'
|
|
||||||
- 'ios/include/PolyvoxFilamentFFIApi.h'
|
- 'ios/include/PolyvoxFilamentFFIApi.h'
|
||||||
compiler-opts-automatic:
|
|
||||||
macos:
|
|
||||||
include-c-standard-library: false
|
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
assets:
|
assets:
|
||||||
|
|||||||
Reference in New Issue
Block a user