camera fixes for assets with large bounding boxes

This commit is contained in:
Nick Fisher
2023-10-11 14:12:04 +08:00
parent 2923f5907f
commit b7f50df2dc
25 changed files with 4080 additions and 1692 deletions

View File

@@ -43,32 +43,32 @@ extern "C" {
((FilamentViewer*)viewer)->setBackgroundImage(path, fillHeight);
}
FLUTTER_PLUGIN_EXPORT void set_background_image_position(const void* const viewer, float x, float y, bool clamp) {
FLUTTER_PLUGIN_EXPORT void set_background_image_position(const void* const viewer, float x, float y, bool clamp) {
((FilamentViewer*)viewer)->setBackgroundImagePosition(x, y, clamp);
}
FLUTTER_PLUGIN_EXPORT void set_tone_mapping(const void* const viewer, int toneMapping) {
FLUTTER_PLUGIN_EXPORT void set_tone_mapping(const void* const viewer, int toneMapping) {
((FilamentViewer*)viewer)->setToneMapping((ToneMapping)toneMapping);
}
FLUTTER_PLUGIN_EXPORT void set_bloom(const void* const viewer, float strength) {
FLUTTER_PLUGIN_EXPORT void set_bloom(const void* const viewer, float strength) {
Log("Setting bloom to %f", strength);
((FilamentViewer*)viewer)->setBloom(strength);
}
FLUTTER_PLUGIN_EXPORT void load_skybox(const void* const viewer, const char* skyboxPath) {
FLUTTER_PLUGIN_EXPORT void load_skybox(const void* const viewer, const char* skyboxPath) {
((FilamentViewer*)viewer)->loadSkybox(skyboxPath);
}
FLUTTER_PLUGIN_EXPORT void load_ibl(const void* const viewer, const char* iblPath, float intensity) {
FLUTTER_PLUGIN_EXPORT void load_ibl(const void* const viewer, const char* iblPath, float intensity) {
((FilamentViewer*)viewer)->loadIbl(iblPath, intensity);
}
FLUTTER_PLUGIN_EXPORT void remove_skybox(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void remove_skybox(const void* const viewer) {
((FilamentViewer*)viewer)->removeSkybox();
}
FLUTTER_PLUGIN_EXPORT void remove_ibl(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void remove_ibl(const void* const viewer) {
((FilamentViewer*)viewer)->removeIbl();
}
@@ -76,11 +76,11 @@ extern "C" {
return ((FilamentViewer*)viewer)->addLight((LightManager::Type)type, colour, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows);
}
FLUTTER_PLUGIN_EXPORT void remove_light(const void* const viewer, int32_t entityId) {
FLUTTER_PLUGIN_EXPORT void remove_light(const void* const viewer, int32_t entityId) {
((FilamentViewer*)viewer)->removeLight(entityId);
}
FLUTTER_PLUGIN_EXPORT void clear_lights(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void clear_lights(const void* const viewer) {
((FilamentViewer*)viewer)->clearLights();
}
@@ -104,27 +104,27 @@ extern "C" {
((FilamentViewer*)viewer)->moveCameraToAsset(asset);
}
FLUTTER_PLUGIN_EXPORT void set_camera_focus_distance(const void* const viewer, float distance) {
FLUTTER_PLUGIN_EXPORT void set_camera_focus_distance(const void* const viewer, float distance) {
((FilamentViewer*)viewer)->setCameraFocusDistance(distance);
}
FLUTTER_PLUGIN_EXPORT void set_camera_exposure(const void* const viewer, float aperture, float shutterSpeed, float sensitivity) {
FLUTTER_PLUGIN_EXPORT void set_camera_exposure(const void* const viewer, float aperture, float shutterSpeed, float sensitivity) {
((FilamentViewer*)viewer)->setCameraExposure(aperture, shutterSpeed, sensitivity);
}
FLUTTER_PLUGIN_EXPORT void set_camera_position(const void* const viewer, float x, float y, float z) {
FLUTTER_PLUGIN_EXPORT void set_camera_position(const void* const viewer, float x, float y, float z) {
((FilamentViewer*)viewer)->setCameraPosition(x, y, z);
}
FLUTTER_PLUGIN_EXPORT void set_camera_rotation(const void* const viewer, float rads, float x, float y, float z) {
FLUTTER_PLUGIN_EXPORT void set_camera_rotation(const void* const viewer, float rads, float x, float y, float z) {
((FilamentViewer*)viewer)->setCameraRotation(rads, x, y, z);
}
FLUTTER_PLUGIN_EXPORT void set_camera_model_matrix(const void* const viewer, const float* const matrix) {
FLUTTER_PLUGIN_EXPORT void set_camera_model_matrix(const void* const viewer, const float* const matrix) {
((FilamentViewer*)viewer)->setCameraModelMatrix(matrix);
}
FLUTTER_PLUGIN_EXPORT void set_camera_focal_length(const void* const viewer, float focalLength) {
FLUTTER_PLUGIN_EXPORT void set_camera_focal_length(const void* const viewer, float focalLength) {
((FilamentViewer*)viewer)->setCameraFocalLength(focalLength);
}
@@ -137,46 +137,46 @@ extern "C" {
((FilamentViewer*)viewer)->render(frameTimeInNanos, pixelBuffer, callback, data);
}
FLUTTER_PLUGIN_EXPORT void set_frame_interval(
FLUTTER_PLUGIN_EXPORT void set_frame_interval(
const void* const viewer,
float frameInterval
) {
((FilamentViewer*)viewer)->setFrameInterval(frameInterval);
}
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain(const void* const viewer) {
((FilamentViewer*)viewer)->destroySwapChain();
}
FLUTTER_PLUGIN_EXPORT void create_swap_chain(const void* const viewer, const void* const window, uint32_t width, uint32_t height) {
FLUTTER_PLUGIN_EXPORT void create_swap_chain(const void* const viewer, const void* const window, uint32_t width, uint32_t height) {
((FilamentViewer*)viewer)->createSwapChain(window, width, height);
}
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection(const void* const viewer, uint32_t width, uint32_t height, float scaleFactor) {
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection(const void* const viewer, uint32_t width, uint32_t height, float scaleFactor) {
return ((FilamentViewer*)viewer)->updateViewportAndCameraProjection(width, height, scaleFactor);
}
FLUTTER_PLUGIN_EXPORT void scroll_update(const void* const viewer, float x, float y, float delta) {
FLUTTER_PLUGIN_EXPORT void scroll_update(const void* const viewer, float x, float y, float delta) {
((FilamentViewer*)viewer)->scrollUpdate(x, y, delta);
}
FLUTTER_PLUGIN_EXPORT void scroll_begin(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void scroll_begin(const void* const viewer) {
((FilamentViewer*)viewer)->scrollBegin();
}
FLUTTER_PLUGIN_EXPORT void scroll_end(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void scroll_end(const void* const viewer) {
((FilamentViewer*)viewer)->scrollEnd();
}
FLUTTER_PLUGIN_EXPORT void grab_begin(const void* const viewer, float x, float y, bool pan) {
FLUTTER_PLUGIN_EXPORT void grab_begin(const void* const viewer, float x, float y, bool pan) {
((FilamentViewer*)viewer)->grabBegin(x, y, pan);
}
FLUTTER_PLUGIN_EXPORT void grab_update(const void* const viewer, float x, float y) {
FLUTTER_PLUGIN_EXPORT void grab_update(const void* const viewer, float x, float y) {
((FilamentViewer*)viewer)->grabUpdate(x, y);
}
FLUTTER_PLUGIN_EXPORT void grab_end(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void grab_end(const void* const viewer) {
((FilamentViewer*)viewer)->grabEnd();
}
@@ -184,7 +184,7 @@ extern "C" {
return (void*)((FilamentViewer*)viewer)->getAssetManager();
}
FLUTTER_PLUGIN_EXPORT void apply_weights(
FLUTTER_PLUGIN_EXPORT void apply_weights(
void* assetManager,
EntityId asset,
const char* const entityName,
@@ -193,7 +193,7 @@ extern "C" {
// ((AssetManager*)assetManager)->setMorphTargetWeights(asset, entityName, weights, count);
}
FLUTTER_PLUGIN_EXPORT void set_morph_target_weights(
FLUTTER_PLUGIN_EXPORT void set_morph_target_weights(
void* assetManager,
EntityId asset,
const char* const entityName,
@@ -288,7 +288,7 @@ extern "C" {
// }
FLUTTER_PLUGIN_EXPORT void play_animation(
FLUTTER_PLUGIN_EXPORT void play_animation(
void* assetManager,
EntityId asset,
int index,
@@ -299,7 +299,7 @@ extern "C" {
((AssetManager*)assetManager)->playAnimation(asset, index, loop, reverse, replaceActive, crossfade);
}
FLUTTER_PLUGIN_EXPORT void set_animation_frame(
FLUTTER_PLUGIN_EXPORT void set_animation_frame(
void* assetManager,
EntityId asset,
int animationIndex,
@@ -319,7 +319,7 @@ extern "C" {
return (int)names->size();
}
FLUTTER_PLUGIN_EXPORT void get_animation_name(
FLUTTER_PLUGIN_EXPORT void get_animation_name(
void* assetManager,
EntityId asset,
char* const outPtr,
@@ -335,17 +335,17 @@ extern "C" {
return (int)names->size();
}
FLUTTER_PLUGIN_EXPORT void get_morph_target_name(void* assetManager, EntityId asset, const char* meshName, char* const outPtr, int index ) {
FLUTTER_PLUGIN_EXPORT void get_morph_target_name(void* assetManager, EntityId asset, const char* meshName, char* const outPtr, int index ) {
unique_ptr<vector<string>> names = ((AssetManager*)assetManager)->getMorphTargetNames(asset, meshName);
string name = names->at(index);
strcpy(outPtr, name.c_str());
}
FLUTTER_PLUGIN_EXPORT void remove_asset(const void* const viewer, EntityId asset) {
FLUTTER_PLUGIN_EXPORT void remove_asset(const void* const viewer, EntityId asset) {
((FilamentViewer*)viewer)->removeAsset(asset);
}
FLUTTER_PLUGIN_EXPORT void clear_assets(const void* const viewer) {
FLUTTER_PLUGIN_EXPORT void clear_assets(const void* const viewer) {
((FilamentViewer*)viewer)->clearAssets();
}
@@ -353,23 +353,23 @@ extern "C" {
return ((AssetManager*)assetManager)->setMaterialColor(asset, meshName, materialIndex, r, g, b, a);
}
FLUTTER_PLUGIN_EXPORT void transform_to_unit_cube(void* assetManager, EntityId asset) {
FLUTTER_PLUGIN_EXPORT void transform_to_unit_cube(void* assetManager, EntityId asset) {
((AssetManager*)assetManager)->transformToUnitCube(asset);
}
FLUTTER_PLUGIN_EXPORT void set_position(void* assetManager, EntityId asset, float x, float y, float z) {
FLUTTER_PLUGIN_EXPORT void set_position(void* assetManager, EntityId asset, float x, float y, float z) {
((AssetManager*)assetManager)->setPosition(asset, x, y, z);
}
FLUTTER_PLUGIN_EXPORT void set_rotation(void* assetManager, EntityId asset, float rads, float x, float y, float z) {
FLUTTER_PLUGIN_EXPORT void set_rotation(void* assetManager, EntityId asset, float rads, float x, float y, float z) {
((AssetManager*)assetManager)->setRotation(asset, rads, x, y, z);
}
FLUTTER_PLUGIN_EXPORT void set_scale(void* assetManager, EntityId asset, float scale) {
FLUTTER_PLUGIN_EXPORT void set_scale(void* assetManager, EntityId asset, float scale) {
((AssetManager*)assetManager)->setScale(asset, scale);
}
FLUTTER_PLUGIN_EXPORT void stop_animation(void* assetManager, EntityId asset, int index) {
FLUTTER_PLUGIN_EXPORT void stop_animation(void* assetManager, EntityId asset, int index) {
((AssetManager*)assetManager)->stopAnimation(asset, index);
}