add animation fading and revert to platform channel handler
This commit is contained in:
@@ -37,7 +37,7 @@ using namespace utils;
|
||||
using namespace filament;
|
||||
using namespace filament::gltfio;
|
||||
|
||||
AssetManager::AssetManager(ResourceLoaderWrapper* resourceLoaderWrapper,
|
||||
AssetManager::AssetManager(const ResourceLoaderWrapper* const resourceLoaderWrapper,
|
||||
NameComponentManager *ncm,
|
||||
Engine *engine,
|
||||
Scene *scene)
|
||||
@@ -249,37 +249,34 @@ void AssetManager::updateAnimations() {
|
||||
asset.mAnimating = false;
|
||||
|
||||
// GLTF animations
|
||||
for(int j = 0; j < asset.mAnimations.size() - 2; j++) {
|
||||
AnimationStatus& anim = asset.mAnimations[j];
|
||||
AnimationStatus& anim = asset.mAnimations[2];
|
||||
|
||||
if(!anim.mAnimating) {
|
||||
// Log("Skipping anim at %d", j);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(anim.mActive) {
|
||||
auto elapsed = float(std::chrono::duration_cast<std::chrono::milliseconds>(now - anim.mStart).count()) / 1000.0f;
|
||||
|
||||
if(anim.mLoop || elapsed < anim.mDuration) {
|
||||
asset.mAnimator->applyAnimation(j, elapsed);
|
||||
asset.mAnimator->applyAnimation(asset.gltfAnimationIndex, elapsed);
|
||||
asset.mAnimating = true;
|
||||
} else if(elapsed - anim.mDuration < 0.3) {
|
||||
// cross-fade
|
||||
// animator->applyCrossFade(j-2, anim.mDuration - 0.05, elapsed / 0.3);
|
||||
// asset.mAnimating = true;
|
||||
// anim.mStart = time_point_t::max();
|
||||
if(asset.fadeGltfAnimationIndex != -1 && elapsed < asset.fadeDuration) {
|
||||
// cross-fade
|
||||
auto fadeFromTime = asset.fadeOutAnimationStart + elapsed;
|
||||
auto alpha = elapsed / asset.fadeDuration;
|
||||
asset.mAnimator->applyCrossFade(asset.fadeGltfAnimationIndex, fadeFromTime, alpha);
|
||||
}
|
||||
} else {
|
||||
// stop
|
||||
anim.mStart = time_point_t::max();
|
||||
anim.mAnimating = false;
|
||||
Log("Finished");
|
||||
anim.mActive = false;
|
||||
asset.gltfAnimationIndex = -1;
|
||||
asset.fadeGltfAnimationIndex = -1;
|
||||
}
|
||||
asset.mAnimator->updateBoneMatrices();
|
||||
}
|
||||
|
||||
// dynamically constructed morph animation
|
||||
AnimationStatus& morphAnimation = asset.mAnimations[asset.mAnimations.size() - 2];
|
||||
// dynamic morph animation
|
||||
AnimationStatus& morphAnimation = asset.mAnimations[0];
|
||||
|
||||
if(morphAnimation.mAnimating) {
|
||||
if(morphAnimation.mActive) {
|
||||
|
||||
auto elapsed = float(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
@@ -290,13 +287,11 @@ void AssetManager::updateAnimations() {
|
||||
asset.mMorphAnimationBuffer.mFrameLengthInMs
|
||||
);
|
||||
|
||||
// if more time has elapsed than the animation duration && not looping
|
||||
// mark the animation as complete
|
||||
// if more time has elapsed than the animation duration && we aren't looping, then mark the animation as complete
|
||||
if(elapsed >= morphAnimation.mDuration && !morphAnimation.mLoop) {
|
||||
morphAnimation.mStart = time_point_t::max();
|
||||
morphAnimation.mAnimating = false;
|
||||
morphAnimation.mActive = false;
|
||||
} else {
|
||||
|
||||
asset.mAnimating = true;
|
||||
int frameNumber = static_cast<int>(elapsed * 1000.0f / asset.mMorphAnimationBuffer.mFrameLengthInMs) % lengthInFrames;
|
||||
// offset from the end if reverse
|
||||
@@ -304,17 +299,18 @@ void AssetManager::updateAnimations() {
|
||||
frameNumber = lengthInFrames - frameNumber;
|
||||
}
|
||||
|
||||
// set the weights appropriately
|
||||
rm.setMorphWeights(
|
||||
// set the weights appropriately
|
||||
rm.setMorphWeights(
|
||||
rm.getInstance(asset.mMorphAnimationBuffer.mMeshTarget),
|
||||
asset.mMorphAnimationBuffer.mFrameData.data() + (frameNumber * asset.mMorphAnimationBuffer.mNumMorphWeights),
|
||||
asset.mMorphAnimationBuffer.mNumMorphWeights);
|
||||
asset.mMorphAnimationBuffer.mNumMorphWeights
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// bone animation
|
||||
AnimationStatus boneAnimation = asset.mAnimations[asset.mAnimations.size() - 1];
|
||||
if(boneAnimation.mAnimating) {
|
||||
// dynamic bone animations
|
||||
AnimationStatus boneAnimation = asset.mAnimations[1];
|
||||
if(boneAnimation.mActive) {
|
||||
auto elapsed = float(
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
now - boneAnimation.mStart
|
||||
@@ -324,11 +320,10 @@ void AssetManager::updateAnimations() {
|
||||
asset.mBoneAnimationBuffer.mFrameLengthInMs
|
||||
);
|
||||
|
||||
// if more time has elapsed than the animation duration && not looping
|
||||
// mark the animation as complete
|
||||
// if more time has elapsed than the animation duration and we are not looping, mark the animation as complete
|
||||
if(elapsed >= boneAnimation.mDuration && !boneAnimation.mLoop) {
|
||||
boneAnimation.mStart = time_point_t::max();
|
||||
boneAnimation.mAnimating = false;
|
||||
boneAnimation.mActive = false;
|
||||
} else {
|
||||
|
||||
asset.mAnimating = true;
|
||||
@@ -347,7 +342,6 @@ void AssetManager::updateAnimations() {
|
||||
asset.mAnimator->updateBoneMatrices();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void AssetManager::setBoneTransform(SceneAsset& asset, int frameNumber) {
|
||||
@@ -482,15 +476,11 @@ bool AssetManager::setMorphAnimationBuffer(
|
||||
asset.mMorphAnimationBuffer.mFrameLengthInMs = frameLengthInMs;
|
||||
asset.mMorphAnimationBuffer.mNumMorphWeights = numMorphWeights;
|
||||
|
||||
AnimationStatus& animation = asset.mAnimations[asset.mAnimations.size() - 2];
|
||||
AnimationStatus& animation = asset.mAnimations[0];
|
||||
animation.mDuration = (frameLengthInMs * numFrames) / 1000.0f;
|
||||
animation.mStart = high_resolution_clock::now();
|
||||
animation.mAnimating = true;
|
||||
animation.mActive = true;
|
||||
asset.mAnimating = true;
|
||||
Log("set start to %d, dur is %f",
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(animation.mStart.time_since_epoch()).count(),
|
||||
animation.mDuration
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -504,8 +494,6 @@ bool AssetManager::setBoneAnimationBuffer(
|
||||
int numMeshTargets,
|
||||
float frameLengthInMs) {
|
||||
|
||||
|
||||
|
||||
const auto& pos = _entityIdLookup.find(entityId);
|
||||
if(pos == _entityIdLookup.end()) {
|
||||
Log("ERROR: asset not found for entity.");
|
||||
@@ -585,9 +573,9 @@ bool AssetManager::setBoneAnimationBuffer(
|
||||
animationBuffer.mMeshTargets.push_back(entity);
|
||||
}
|
||||
|
||||
auto& animation = asset.mAnimations[asset.mAnimations.size() - 1];
|
||||
auto& animation = asset.mAnimations[1];
|
||||
animation.mStart = std::chrono::high_resolution_clock::now();
|
||||
animation.mAnimating = true;
|
||||
animation.mActive = true;
|
||||
animation.mReverse = false;
|
||||
animation.mDuration = (frameLengthInMs * numFrames) / 1000.0f;
|
||||
asset.mAnimating = true;
|
||||
@@ -596,21 +584,31 @@ bool AssetManager::setBoneAnimationBuffer(
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AssetManager::playAnimation(EntityId e, int index, bool loop, bool reverse) {
|
||||
void AssetManager::playAnimation(EntityId e, int index, bool loop, bool reverse, float crossfade) {
|
||||
const auto& pos = _entityIdLookup.find(e);
|
||||
if(pos == _entityIdLookup.end()) {
|
||||
Log("ERROR: asset not found for entity.");
|
||||
return;
|
||||
}
|
||||
auto& asset = _assets[pos->second];
|
||||
Log("Playing animation at %d", index);
|
||||
|
||||
asset.mAnimations[index].mStart = std::chrono::high_resolution_clock::now();
|
||||
asset.mAnimations[index].mLoop = loop;
|
||||
asset.mAnimations[index].mReverse = reverse;
|
||||
asset.mAnimations[index].mAnimating = true;
|
||||
// Log("new start %d, dur is %f", std::chrono::duration_cast<std::chrono::milliseconds>(asset.mAnimations[index+2].mStart.time_since_epoch()).count(), asset.mAnimations[index+2].mDuration);
|
||||
|
||||
if(asset.gltfAnimationIndex != -1) {
|
||||
asset.fadeGltfAnimationIndex = asset.gltfAnimationIndex;
|
||||
asset.fadeDuration = crossfade;
|
||||
auto now = high_resolution_clock::now();
|
||||
auto elapsed = float(std::chrono::duration_cast<std::chrono::milliseconds>(now - asset.mAnimations[2].mStart).count()) / 1000.0f;
|
||||
asset.fadeOutAnimationStart = elapsed;
|
||||
} else {
|
||||
asset.fadeGltfAnimationIndex = -1;
|
||||
asset.fadeDuration = 0.0f;
|
||||
}
|
||||
|
||||
asset.gltfAnimationIndex = index;
|
||||
asset.mAnimations[2].mStart = std::chrono::high_resolution_clock::now();
|
||||
asset.mAnimations[2].mLoop = loop;
|
||||
asset.mAnimations[2].mReverse = reverse;
|
||||
asset.mAnimations[2].mActive = true;
|
||||
asset.mAnimations[2].mDuration = asset.mAnimator->getAnimationDuration(index);
|
||||
asset.mAnimating = true;
|
||||
}
|
||||
|
||||
@@ -621,7 +619,12 @@ void AssetManager::stopAnimation(EntityId entityId, int index) {
|
||||
return;
|
||||
}
|
||||
auto& asset = _assets[pos->second];
|
||||
asset.mAnimations[index].mStart = time_point_t::max();
|
||||
if(asset.gltfAnimationIndex != index) {
|
||||
// ignore?
|
||||
} else {
|
||||
asset.mAnimations[2].mStart = time_point_t::max();
|
||||
asset.mAnimations[2].mActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
void AssetManager::loadTexture(EntityId entity, const char* resourcePath, int renderableIndex) {
|
||||
@@ -898,4 +901,4 @@ size_t AssetManager::getLightEntityCount(EntityId entity) const noexcept {
|
||||
// Log("%f %f %f %f", localTransform[0][1], localTransform[1][1], localTransform[2][1], localTransform[3][1] ) ;
|
||||
// Log("%f %f %f %f", localTransform[0][2], localTransform[1][2], localTransform[2][2], localTransform[3][2] ) ;
|
||||
// Log("%f %f %f %f", localTransform[0][3], localTransform[1][3], localTransform[2][3], localTransform[3][3] ) ;
|
||||
// transformManager.getTransform(jointInstance);
|
||||
// transformManager.getTransform(jointInstance);
|
||||
|
||||
@@ -107,7 +107,7 @@ static constexpr float4 sFullScreenTriangleVertices[3] = {
|
||||
|
||||
static const uint16_t sFullScreenTriangleIndices[3] = {0, 1, 2};
|
||||
|
||||
FilamentViewer::FilamentViewer(void* context, ResourceLoaderWrapper* resourceLoaderWrapper)
|
||||
FilamentViewer::FilamentViewer(const void* context, const ResourceLoaderWrapper* const resourceLoaderWrapper)
|
||||
: _resourceLoaderWrapper(resourceLoaderWrapper) {
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
@@ -137,13 +137,14 @@ FilamentViewer::FilamentViewer(void* context, ResourceLoaderWrapper* resourceLoa
|
||||
_view = _engine->createView();
|
||||
|
||||
decltype(_view->getBloomOptions()) opts;
|
||||
opts.enabled = false;//true;
|
||||
// opts.strength = 0.6f;
|
||||
opts.enabled = true;
|
||||
opts.strength = 0.6f;
|
||||
_view->setBloomOptions(opts);
|
||||
|
||||
_view->setScene(_scene);
|
||||
_view->setCamera(_mainCamera);
|
||||
|
||||
// ToneMapper *tm = new ACESToneMapper();
|
||||
ToneMapper *tm = new LinearToneMapper();
|
||||
colorGrading = ColorGrading::Builder().toneMapper(tm).build(*_engine);
|
||||
delete tm;
|
||||
@@ -168,8 +169,7 @@ FilamentViewer::FilamentViewer(void* context, ResourceLoaderWrapper* resourceLoa
|
||||
// options.minScale = filament::math::float2{ minScale };
|
||||
// options.maxScale = filament::math::float2{ maxScale };
|
||||
// options.sharpness = sharpness;
|
||||
options.quality = View::QualityLevel::ULTRA;
|
||||
|
||||
// options.quality = View::QualityLevel::ULTRA;
|
||||
_view->setDynamicResolutionOptions(options);
|
||||
|
||||
View::MultiSampleAntiAliasingOptions multiSampleAntiAliasingOptions;
|
||||
@@ -206,7 +206,7 @@ FilamentViewer::FilamentViewer(void* context, ResourceLoaderWrapper* resourceLoa
|
||||
.package(IMAGE_PACKAGE, IMAGE_IMAGE_SIZE)
|
||||
.build(*_engine);
|
||||
_imageMaterial->setDefaultParameter("showImage",0);
|
||||
_imageMaterial->setDefaultParameter("backgroundColor", RgbType::sRGB, float3(0.f));
|
||||
_imageMaterial->setDefaultParameter("backgroundColor", RgbaType::sRGB, float4(0.5f, 0.5f, 0.5f, 1.0f));
|
||||
_imageMaterial->setDefaultParameter("image", _imageTexture, _imageSampler);
|
||||
_imageScale = mat4f { 1.0f , 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
@@ -251,7 +251,6 @@ void FilamentViewer::setFrameInterval(float frameInterval) {
|
||||
}
|
||||
|
||||
int32_t FilamentViewer::addLight(LightManager::Type t, float colour, float intensity, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, bool shadows) {
|
||||
Log("Adding light of type %d with colour %f intensity %f at (%f, %f, %f) with direction (%f, %f, %f) with shadows %d", t, colour, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows);
|
||||
auto light = EntityManager::get().create();
|
||||
LightManager::Builder(t)
|
||||
.color(Color::cct(colour))
|
||||
@@ -262,14 +261,22 @@ int32_t FilamentViewer::addLight(LightManager::Type t, float colour, float inten
|
||||
.build(*_engine, light);
|
||||
_scene->addEntity(light);
|
||||
_lights.push_back(light);
|
||||
return Entity::smuggle(light);
|
||||
auto entityId = Entity::smuggle(light);
|
||||
Log("Added light under entity ID %d of type %d with colour %f intensity %f at (%f, %f, %f) with direction (%f, %f, %f) with shadows %d", entityId, t, colour, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows);
|
||||
return entityId;
|
||||
}
|
||||
|
||||
void FilamentViewer::removeLight(int32_t id) {
|
||||
Log("Removing light with entity ID %d", id);
|
||||
auto e = utils::Entity::import(id);
|
||||
_scene->removeEntities(&e, 1);
|
||||
EntityManager::get().destroy(1, &e);
|
||||
void FilamentViewer::removeLight(EntityId entityId) {
|
||||
Log("Removing light with entity ID %d", entityId);
|
||||
auto entity = utils::Entity::import(entityId);
|
||||
if(entity.isNull()) {
|
||||
Log("Error: light entity not found under ID %d", entityId);
|
||||
} else {
|
||||
|
||||
remove(_lights.begin(), _lights.end(), entity);
|
||||
_scene->remove(entity);
|
||||
EntityManager::get().destroy(1, &entity);
|
||||
}
|
||||
}
|
||||
|
||||
void FilamentViewer::clearLights() {
|
||||
@@ -388,7 +395,6 @@ void FilamentViewer::setBackgroundColor(const float r, const float g, const floa
|
||||
_imageMaterial->setDefaultParameter("showImage", 0);
|
||||
_imageMaterial->setDefaultParameter("backgroundColor", RgbaType::sRGB, float4(r, g, b, a));
|
||||
const Viewport& vp = _view->getViewport();
|
||||
Log("Image width %d height %d vp width %d height %d", _imageWidth, _imageHeight, vp.width, vp.height);
|
||||
_imageMaterial->setDefaultParameter("transform", _imageScale);
|
||||
}
|
||||
|
||||
@@ -522,9 +528,9 @@ FilamentViewer::~FilamentViewer() {
|
||||
|
||||
Renderer *FilamentViewer::getRenderer() { return _renderer; }
|
||||
|
||||
void FilamentViewer::createSwapChain(void *surface, uint32_t width, uint32_t height) {
|
||||
void FilamentViewer::createSwapChain(const void *surface, uint32_t width, uint32_t height) {
|
||||
#if TARGET_OS_IPHONE
|
||||
_swapChain = _engine->createSwapChain(surface, filament::backend::SWAP_CHAIN_CONFIG_APPLE_CVPIXELBUFFER);
|
||||
_swapChain = _engine->createSwapChain((void*)surface, filament::backend::SWAP_CHAIN_CONFIG_APPLE_CVPIXELBUFFER);
|
||||
#else
|
||||
if(surface) {
|
||||
_swapChain = _engine->createSwapChain(surface);
|
||||
|
||||
@@ -12,310 +12,158 @@ using namespace polyvox;
|
||||
|
||||
#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default")))
|
||||
|
||||
|
||||
|
||||
// static ThreadPool* _tp;
|
||||
|
||||
extern "C" {
|
||||
|
||||
#include "PolyvoxFilamentApi.h"
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void* create_filament_viewer(void* context, ResourceLoaderWrapper* loader) {
|
||||
// if(!_tp) {
|
||||
// _tp = new ThreadPool();
|
||||
// }
|
||||
// //std::packaged_task<void*()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT const void* create_filament_viewer(const void* context, const ResourceLoaderWrapper* const loader) {
|
||||
return (void*) new FilamentViewer(context, loader);
|
||||
// });
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
// //return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT ResourceLoaderWrapper* make_resource_loader(LoadResourceFromOwner loadFn, FreeResourceFromOwner freeFn, void* const owner) {
|
||||
return new ResourceLoaderWrapper(loadFn, freeFn, owner);
|
||||
// ResourceLoaderWrapper* lod(loadFn, freeFn, owner);
|
||||
// return &lod;
|
||||
return new ResourceLoaderWrapper(loadFn, freeFn, owner);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void create_render_target(void* viewer, uint32_t textureId, uint32_t width, uint32_t height) {
|
||||
// //std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void create_render_target(const void* const viewer, uint32_t textureId, uint32_t width, uint32_t height) {
|
||||
((FilamentViewer*)viewer)->createRenderTarget(textureId, width, height);
|
||||
// });
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void delete_filament_viewer(void* viewer) {
|
||||
FLUTTER_PLUGIN_EXPORT void delete_filament_viewer(const void* const viewer) {
|
||||
delete((FilamentViewer*)viewer);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_color(void* viewer, const float r, const float g, const float b, const float a) {
|
||||
// //std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_color(const void* const viewer, const float r, const float g, const float b, const float a) {
|
||||
((FilamentViewer*)viewer)->setBackgroundColor(r, g, b, a);
|
||||
// });
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void clear_background_image(void* viewer) {
|
||||
// //std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void clear_background_image(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->clearBackgroundImage();
|
||||
// });
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_image(void* viewer, const char* path) {
|
||||
// //std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_image(const void* const viewer, const char* path) {
|
||||
((FilamentViewer*)viewer)->setBackgroundImage(path);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_image_position(void* viewer, float x, float y, bool clamp) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_image_position(const void* const viewer, float x, float y, bool clamp) {
|
||||
((FilamentViewer*)viewer)->setBackgroundImagePosition(x, y, clamp);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void load_skybox(void* viewer, const char* skyboxPath) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void load_skybox(const void* const viewer, const char* skyboxPath) {
|
||||
((FilamentViewer*)viewer)->loadSkybox(skyboxPath);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void load_ibl(void* viewer, const char* iblPath, float intensity) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void load_ibl(const void* const viewer, const char* iblPath, float intensity) {
|
||||
((FilamentViewer*)viewer)->loadIbl(iblPath, intensity);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void remove_skybox(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void remove_skybox(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->removeSkybox();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void remove_ibl(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void remove_ibl(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->removeIbl();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT EntityId add_light(void* 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([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT EntityId add_light(const void* const viewer, uint8_t type, float colour, float intensity, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, bool shadows) {
|
||||
return ((FilamentViewer*)viewer)->addLight((LightManager::Type)type, colour, intensity, posX, posY, posZ, dirX, dirY, dirZ, shadows);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void remove_light(void* viewer, int32_t entityId) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void remove_light(const void* const viewer, int32_t entityId) {
|
||||
((FilamentViewer*)viewer)->removeLight(entityId);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void clear_lights(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void clear_lights(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->clearLights();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT EntityId load_glb(void* assetManager, const char* assetPath, bool unlit) {
|
||||
//std::packaged_task<EntityId()> lambda([=]() mutable {
|
||||
return ((AssetManager*)assetManager)->loadGlb(assetPath, unlit);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT EntityId load_gltf(void* assetManager, const char* assetPath, const char* relativePath) {
|
||||
//std::packaged_task<EntityId()> lambda([=]() mutable {
|
||||
return ((AssetManager*)assetManager)->loadGltf(assetPath, relativePath);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT bool set_camera(void* viewer, EntityId asset, const char* nodeName) {
|
||||
//std::packaged_task<bool()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT bool set_camera(const void* const viewer, EntityId asset, const char* nodeName) {
|
||||
return ((FilamentViewer*)viewer)->setCamera(asset, nodeName);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_exposure(void* viewer, float aperture, float shutterSpeed, float sensitivity) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
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) {
|
||||
((FilamentViewer*)viewer)->setCameraExposure(aperture, shutterSpeed, sensitivity);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_position(void* viewer, float x, float y, float z) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_position(const void* const viewer, float x, float y, float z) {
|
||||
((FilamentViewer*)viewer)->setCameraPosition(x, y, z);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_rotation(void* viewer, float rads, float x, float y, float z) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
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);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_model_matrix(void* viewer, const float* const matrix) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_model_matrix(const void* const viewer, const float* const matrix) {
|
||||
((FilamentViewer*)viewer)->setCameraModelMatrix(matrix);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_focal_length(void* viewer, float focalLength) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void set_camera_focal_length(const void* const viewer, float focalLength) {
|
||||
((FilamentViewer*)viewer)->setCameraFocalLength(focalLength);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void render(
|
||||
void* viewer,
|
||||
const void* const viewer,
|
||||
uint64_t frameTimeInNanos
|
||||
) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((FilamentViewer*)viewer)->render(frameTimeInNanos);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_frame_interval(
|
||||
void* viewer,
|
||||
const void* const viewer,
|
||||
float frameInterval
|
||||
) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((FilamentViewer*)viewer)->setFrameInterval(frameInterval);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void destroy_swap_chain(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->destroySwapChain();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void create_swap_chain(void* viewer, void* surface=nullptr, uint32_t width=0, uint32_t height=0) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void create_swap_chain(const void* const viewer, const void* const surface=nullptr, uint32_t width=0, uint32_t height=0) {
|
||||
((FilamentViewer*)viewer)->createSwapChain(surface, width, height);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void* get_renderer(void* viewer) {
|
||||
//std::packaged_task<void*()> lambda([=]() mutable {
|
||||
return ((FilamentViewer*)viewer)->getRenderer();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection(void* viewer, int width, int height, float scaleFactor) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void update_viewport_and_camera_projection(const void* const viewer, int width, int height, float scaleFactor) {
|
||||
return ((FilamentViewer*)viewer)->updateViewportAndCameraProjection(width, height, scaleFactor);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void scroll_update(void* viewer, float x, float y, float delta) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void scroll_update(const void* const viewer, float x, float y, float delta) {
|
||||
((FilamentViewer*)viewer)->scrollUpdate(x, y, delta);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void scroll_begin(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void scroll_begin(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->scrollBegin();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void scroll_end(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void scroll_end(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->scrollEnd();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void grab_begin(void* viewer, float x, float y, bool pan) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void grab_begin(const void* const viewer, float x, float y, bool pan) {
|
||||
((FilamentViewer*)viewer)->grabBegin(x, y, pan);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void grab_update(void* viewer, float x, float y) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void grab_update(const void* const viewer, float x, float y) {
|
||||
((FilamentViewer*)viewer)->grabUpdate(x, y);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void grab_end(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void grab_end(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->grabEnd();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void* get_asset_manager(void* viewer) {
|
||||
//std::packaged_task<void*()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void* get_asset_manager(const void* const viewer) {
|
||||
return (void*)((FilamentViewer*)viewer)->getAssetManager();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void apply_weights(
|
||||
@@ -324,11 +172,7 @@ extern "C" {
|
||||
const char* const entityName,
|
||||
float* const weights,
|
||||
int count) {
|
||||
// //std::packaged_task<void()> lambda([=]() mutable {
|
||||
// ((AssetManager*)assetManager)->setMorphTargetWeights(asset, entityName, weights, count);
|
||||
// });
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_morph_target_weights(
|
||||
@@ -339,16 +183,12 @@ extern "C" {
|
||||
const int numWeights
|
||||
) {
|
||||
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
return ((AssetManager*)assetManager)->setMorphTargetWeights(
|
||||
asset,
|
||||
entityName,
|
||||
weights,
|
||||
numWeights
|
||||
);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT bool set_morph_animation(
|
||||
@@ -360,7 +200,6 @@ extern "C" {
|
||||
int numFrames,
|
||||
float frameLengthInMs) {
|
||||
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
return ((AssetManager*)assetManager)->setMorphAnimationBuffer(
|
||||
asset,
|
||||
entityName,
|
||||
@@ -369,9 +208,6 @@ extern "C" {
|
||||
numFrames,
|
||||
frameLengthInMs
|
||||
);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_bone_animation(
|
||||
@@ -384,7 +220,6 @@ extern "C" {
|
||||
const char** const meshNames,
|
||||
int numMeshTargets,
|
||||
float frameLengthInMs) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((AssetManager*)assetManager)->setBoneAnimationBuffer(
|
||||
asset,
|
||||
frameData,
|
||||
@@ -395,10 +230,7 @@ extern "C" {
|
||||
numMeshTargets,
|
||||
frameLengthInMs
|
||||
);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -435,13 +267,9 @@ extern "C" {
|
||||
EntityId asset,
|
||||
int index,
|
||||
bool loop,
|
||||
bool reverse) {
|
||||
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((AssetManager*)assetManager)->playAnimation(asset, index, loop, reverse);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
bool reverse,
|
||||
float crossfade) {
|
||||
((AssetManager*)assetManager)->playAnimation(asset, index, loop, reverse, crossfade);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_animation_frame(
|
||||
@@ -449,11 +277,7 @@ extern "C" {
|
||||
EntityId asset,
|
||||
int animationIndex,
|
||||
int animationFrame) {
|
||||
// //std::packaged_task<void()> lambda([=]() mutable {
|
||||
// ((AssetManager*)assetManager)->setAnimationFrame(asset, animationIndex, animationFrame);
|
||||
// });
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT int get_animation_count(
|
||||
@@ -462,9 +286,8 @@ extern "C" {
|
||||
//std::packaged_task<int()> lambda([=]() mutable {
|
||||
auto names = ((AssetManager*)assetManager)->getAnimationNames(asset);
|
||||
return names->size();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
|
||||
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
@@ -474,49 +297,32 @@ extern "C" {
|
||||
char* const outPtr,
|
||||
int index
|
||||
) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
auto names = ((AssetManager*)assetManager)->getAnimationNames(asset);
|
||||
string name = names->at(index);
|
||||
strcpy(outPtr, name.c_str());
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT int get_morph_target_name_count(void* assetManager, EntityId asset, const char* meshName) {
|
||||
//std::packaged_task<int()> lambda([=]() mutable {
|
||||
unique_ptr<vector<string>> names = ((AssetManager*)assetManager)->getMorphTargetNames(asset, meshName);
|
||||
return names->size();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
|
||||
|
||||
//return fut.get();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void get_morph_target_name(void* assetManager, EntityId asset, const char* meshName, char* const outPtr, int index ) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
unique_ptr<vector<string>> names = ((AssetManager*)assetManager)->getMorphTargetNames(asset, meshName);
|
||||
string name = names->at(index);
|
||||
strcpy(outPtr, name.c_str());
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void remove_asset(void* viewer, EntityId asset) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void remove_asset(const void* const viewer, EntityId asset) {
|
||||
((FilamentViewer*)viewer)->removeAsset(asset);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void clear_assets(void* viewer) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
FLUTTER_PLUGIN_EXPORT void clear_assets(const void* const viewer) {
|
||||
((FilamentViewer*)viewer)->clearAssets();
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void load_texture(void* assetManager, EntityId asset, const char* assetPath, int renderableIndex) {
|
||||
@@ -528,59 +334,31 @@ extern "C" {
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void transform_to_unit_cube(void* assetManager, EntityId asset) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((AssetManager*)assetManager)->transformToUnitCube(asset);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_position(void* assetManager, EntityId asset, float x, float y, float z) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((AssetManager*)assetManager)->setPosition(asset, x, y, z);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_rotation(void* assetManager, EntityId asset, float rads, float x, float y, float z) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((AssetManager*)assetManager)->setRotation(asset, rads, x, y, z);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_scale(void* assetManager, EntityId asset, float scale) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((AssetManager*)assetManager)->setScale(asset, scale);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void stop_animation(void* assetManager, EntityId asset, int index) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
((AssetManager*)assetManager)->stopAnimation(asset, index);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT int hide_mesh(void* assetManager, EntityId asset, const char* meshName) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
return ((AssetManager*)assetManager)->hide(asset, meshName);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT int reveal_mesh(void* assetManager, EntityId asset, const char* meshName) {
|
||||
//std::packaged_task<void()> lambda([=]() mutable {
|
||||
return ((AssetManager*)assetManager)->reveal(asset, meshName);
|
||||
//});
|
||||
// auto fut = _tp->add_task(lambda);
|
||||
// fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void ios_dummy() {
|
||||
|
||||
Reference in New Issue
Block a user