add toggle for postprocessing and minor cleanup work
This commit is contained in:
@@ -143,7 +143,6 @@ FilamentViewer::FilamentViewer(const void* sharedContext, const ResourceLoaderWr
|
||||
|
||||
Log("Main camera created");
|
||||
_view = _engine->createView();
|
||||
_view->setPostProcessingEnabled(false);
|
||||
Log("View created");
|
||||
|
||||
setToneMapping(ToneMapping::ACES);
|
||||
@@ -247,6 +246,10 @@ FilamentViewer::FilamentViewer(const void* sharedContext, const ResourceLoaderWr
|
||||
_scene->addEntity(imageEntity);
|
||||
}
|
||||
|
||||
void FilamentViewer::setPostProcessing(bool enabled) {
|
||||
_view->setPostProcessingEnabled(enabled);
|
||||
}
|
||||
|
||||
void FilamentViewer::setBloom(float strength) {
|
||||
decltype(_view->getBloomOptions()) opts;
|
||||
opts.enabled = true;
|
||||
@@ -259,14 +262,20 @@ void FilamentViewer::setToneMapping(ToneMapping toneMapping) {
|
||||
ToneMapper* tm;
|
||||
switch(toneMapping) {
|
||||
case ToneMapping::ACES:
|
||||
Log("Setting tone mapping to ACES");
|
||||
tm = new ACESToneMapper();
|
||||
break;
|
||||
case ToneMapping::LINEAR:
|
||||
Log("Setting tone mapping to Linear");
|
||||
tm = new LinearToneMapper();
|
||||
break;
|
||||
case ToneMapping::FILMIC:
|
||||
Log("Setting tone mapping to Filmic");
|
||||
tm = new FilmicToneMapper();
|
||||
break;
|
||||
default:
|
||||
Log("ERROR: Unsupported tone mapping");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -305,7 +314,7 @@ void FilamentViewer::removeLight(EntityId entityId) {
|
||||
if(entity.isNull()) {
|
||||
Log("Error: light entity not found under ID %d", entityId);
|
||||
} else {
|
||||
auto removed = remove(_lights.begin(), _lights.end(), entity);
|
||||
remove(_lights.begin(), _lights.end(), entity);
|
||||
_scene->remove(entity);
|
||||
EntityManager::get().destroy(1, &entity);
|
||||
}
|
||||
@@ -437,7 +446,6 @@ void FilamentViewer::loadTextureFromPath(string path) {
|
||||
void FilamentViewer::setBackgroundColor(const float r, const float g, const float b, const float a) {
|
||||
_imageMaterial->setDefaultParameter("showImage", 0);
|
||||
_imageMaterial->setDefaultParameter("backgroundColor", RgbaType::sRGB, float4(r, g, b, a));
|
||||
const Viewport& vp = _view->getViewport();
|
||||
_imageMaterial->setDefaultParameter("transform", _imageScale);
|
||||
}
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ extern "C" {
|
||||
);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_bone_animation(
|
||||
FLUTTER_PLUGIN_EXPORT void set_bone_animation(
|
||||
void* assetManager,
|
||||
EntityId asset,
|
||||
const float* const frameData,
|
||||
@@ -254,6 +254,10 @@ extern "C" {
|
||||
);
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_post_processing(void* const viewer, bool enabled) {
|
||||
((FilamentViewer*)viewer)->setPostProcessing(enabled);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// void set_bone_transform(
|
||||
|
||||
@@ -369,28 +369,31 @@ extern "C"
|
||||
// TODO
|
||||
}
|
||||
|
||||
void play_animation_ffi(void* const assetManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade)
|
||||
FLUTTER_PLUGIN_EXPORT void play_animation_ffi(void* const assetManager, EntityId asset, int index, bool loop, bool reverse, bool replaceActive, float crossfade)
|
||||
{
|
||||
std::packaged_task<void()> lambda([&]
|
||||
{ play_animation(assetManager, asset, index, loop, reverse, replaceActive, crossfade); });
|
||||
auto fut = _rl->add_task(lambda);
|
||||
fut.wait();
|
||||
}
|
||||
void set_animation_frame_ffi(void* const assetManager, EntityId asset, int animationIndex, int animationFrame)
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_animation_frame_ffi(void* const assetManager, EntityId asset, int animationIndex, int animationFrame)
|
||||
{
|
||||
std::packaged_task<void()> lambda([&]
|
||||
{ set_animation_frame(assetManager, asset, animationIndex, animationFrame); });
|
||||
auto fut = _rl->add_task(lambda);
|
||||
fut.wait();
|
||||
}
|
||||
void stop_animation_ffi(void* const assetManager, EntityId asset, int index)
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void stop_animation_ffi(void* const assetManager, EntityId asset, int index)
|
||||
{
|
||||
std::packaged_task<void()> lambda([&]
|
||||
{ stop_animation(assetManager, asset, index); });
|
||||
auto fut = _rl->add_task(lambda);
|
||||
fut.wait();
|
||||
}
|
||||
int get_animation_count_ffi(void* const assetManager, EntityId asset)
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT int get_animation_count_ffi(void* const assetManager, EntityId asset)
|
||||
{
|
||||
std::packaged_task<int()> lambda([&]
|
||||
{ return get_animation_count(assetManager, asset); });
|
||||
@@ -398,7 +401,7 @@ extern "C"
|
||||
fut.wait();
|
||||
return fut.get();
|
||||
}
|
||||
void get_animation_name_ffi(void* const assetManager, EntityId asset, char *const outPtr, int index)
|
||||
FLUTTER_PLUGIN_EXPORT void get_animation_name_ffi(void* const assetManager, EntityId asset, char *const outPtr, int index)
|
||||
{
|
||||
std::packaged_task<void()> lambda([&] {
|
||||
get_animation_name(assetManager, asset, outPtr, index);
|
||||
@@ -407,6 +410,14 @@ extern "C"
|
||||
fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void set_post_processing_ffi(void* const viewer, bool enabled) {
|
||||
std::packaged_task<void()> lambda([&] {
|
||||
set_post_processing(viewer, enabled);
|
||||
});
|
||||
auto fut = _rl->add_task(lambda);
|
||||
fut.wait();
|
||||
}
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT void ios_dummy_ffi() {
|
||||
Log("Dummy called");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user