implement picker/getNameForEntity

This commit is contained in:
Nick Fisher
2023-10-11 11:10:47 +08:00
parent 79292914d2
commit 98bcf5d7ad
25 changed files with 704 additions and 393 deletions

View File

@@ -18,9 +18,10 @@ namespace polyvox {
class AssetManager {
public:
AssetManager(const ResourceLoaderWrapper* const loader,
NameComponentManager *ncm,
Engine *engine,
Scene *scene);
NameComponentManager* ncm,
Engine* engine,
Scene* scene,
const char* uberArchivePath);
~AssetManager();
EntityId loadGltf(const char* uri, const char* relativeResourcePath);
EntityId loadGlb(const char* uri, bool unlit);
@@ -69,6 +70,7 @@ namespace polyvox {
void setAnimationFrame(EntityId entity, int animationIndex, int animationFrame);
bool hide(EntityId entity, const char* meshName);
bool reveal(EntityId entity, const char* meshName);
const char* getNameForEntity(EntityId entityId);
private:
AssetLoader* _assetLoader = nullptr;

View File

@@ -49,7 +49,7 @@ namespace polyvox {
class FilamentViewer {
public:
FilamentViewer(const void* context, const ResourceLoaderWrapper* const resourceLoaderWrapper, void* const platform=nullptr);
FilamentViewer(const void* context, const ResourceLoaderWrapper* const resourceLoaderWrapper, void* const platform=nullptr, const char* uberArchivePath=nullptr);
~FilamentViewer();
void setToneMapping(ToneMapping toneMapping);
@@ -107,6 +107,8 @@ namespace polyvox {
void removeLight(EntityId entityId);
void clearLights();
void setPostProcessing(bool enabled);
void pick(uint32_t x, uint32_t y, EntityId* entityId);
AssetManager* const getAssetManager() {
return (AssetManager* const) _assetManager;

View File

@@ -53,7 +53,7 @@ extern "C" {
#endif
typedef int32_t EntityId;
FLUTTER_PLUGIN_EXPORT const void* create_filament_viewer(const void* const context, const ResourceLoaderWrapper* const loader, void* const platform);
FLUTTER_PLUGIN_EXPORT const void* create_filament_viewer(const void* const context, const ResourceLoaderWrapper* const loader, void* const platform, const char* uberArchivePath);
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer(const void* const viewer);
FLUTTER_PLUGIN_EXPORT ResourceLoaderWrapper* make_resource_loader(LoadFilamentResourceFromOwner loadFn, FreeFilamentResourceFromOwner freeFn, void* owner);
FLUTTER_PLUGIN_EXPORT void* get_asset_manager(const void* const viewer);
@@ -151,6 +151,8 @@ FLUTTER_PLUGIN_EXPORT void set_camera_focus_distance(const void* const viewer, f
FLUTTER_PLUGIN_EXPORT int hide_mesh(void* assetManager, EntityId asset, const char* meshName);
FLUTTER_PLUGIN_EXPORT int reveal_mesh(void* assetManager, EntityId asset, const char* meshName);
FLUTTER_PLUGIN_EXPORT void set_post_processing(void* const viewer, bool enabled);
FLUTTER_PLUGIN_EXPORT void pick(void* const viewer, int x, int y, EntityId* entityId);
FLUTTER_PLUGIN_EXPORT const char* get_name_for_entity(void* const assetManager, const EntityId entityId);
FLUTTER_PLUGIN_EXPORT void ios_dummy();
#ifdef __cplusplus
}

View File

@@ -1,6 +1,8 @@
#ifndef _POLYVOX_FILAMENT_FFI_API_H
#define _POLYVOX_FILAMENT_FFI_API_H
#include "PolyvoxFilamentApi.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -10,14 +12,12 @@ extern "C" {
/// 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 void (*FilamentRenderCallback)(void* const owner);
FLUTTER_PLUGIN_EXPORT void* const create_filament_viewer_ffi(void* const context, void* const platform, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner);
FLUTTER_PLUGIN_EXPORT void* const create_filament_viewer_ffi(void* const context, void* const platform, const char* uberArchivePath, const ResourceLoaderWrapper* const loader, void (*renderCallback)(void* const renderCallbackOwner), void* const renderCallbackOwner);
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);
FLUTTER_PLUGIN_EXPORT void create_render_target_ffi(void* const viewer, intptr_t nativeTextureId, uint32_t width, uint32_t height);
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer_ffi(void* const viewer);
FLUTTER_PLUGIN_EXPORT void render_ffi(void* const viewer);
FLUTTER_PLUGIN_EXPORT FilamentRenderCallback make_render_callback_fn_pointer(FilamentRenderCallback);
@@ -84,7 +84,7 @@ FLUTTER_PLUGIN_EXPORT void get_animation_name_ffi(void* const assetManager, Enti
FLUTTER_PLUGIN_EXPORT void get_morph_target_name_ffi(void* const assetManager, EntityId asset, const char *meshName, char *const outPtr, int index);
FLUTTER_PLUGIN_EXPORT int get_morph_target_name_count_ffi(void* const assetManager, EntityId asset, const char *meshName);
FLUTTER_PLUGIN_EXPORT void set_post_processing_ffi(void* const viewer, bool enabled);
FLUTTER_PLUGIN_EXPORT void pick_ffi(void* const viewer, int x, int y, EntityId* entityId);
FLUTTER_PLUGIN_EXPORT void ios_dummy_ffi();
#ifdef __cplusplus