Commit 86591b1c authored by artificiel's avatar artificiel
Browse files

CropFilter: ajout d'un lambda de ease sur attaque de zone (flash)

parent 59867279
......@@ -5,12 +5,14 @@
#include <pcl/common/transforms.h>
#include <pcl/point_types.h>
#include "ofxFunctionalEasing.h"
#include "ofxGui.h"
#include "ofxOsc.h"
#include "ofxTimeMeasurements.h"
#include "ofEasingParameterFloat.hpp"
#include "ofxCloudLib/ParsedParameterGroup.hpp"
namespace ofxCloudLib
......@@ -41,7 +43,7 @@ class CropFilterParameterGroup : public ofxCloudLib::ParsedParameterGroup
auto ease(glm::vec3 &to) -> void
{
ease_dim_.ease(to);
}
......@@ -53,7 +55,7 @@ class CropFilterParameterGroup : public ofxCloudLib::ParsedParameterGroup
void reset()
{
pos_ = glm::vec3(0, 0, .5);
pos_ = glm::vec3(0, 0, .5);
dim_.set(glm::vec3(.5, .5, 1));
capacity_ = 200;
slide_down_ = .5;
......@@ -90,17 +92,17 @@ class CropFilter
float get_fill()
{
auto fill = ofClamp(parameters_.count_.get() / parameters_.capacity_.get(), 0, 1);
fill_ = fill;
fill_ = fill;
if (fill < 0.02) {
fill_ = 0;
} else {
fill_ = fill;
}
return fill_;
}
float get_pan() {
float get_pan()
{
return ofMap(parameters_.pos_->x, -4, 4, 0, 1);
}
......@@ -186,6 +188,7 @@ class CropFilter
size_t index_;
float distance_ = 10000;
ofMaterial material_;
float flash_ = 0;
};
class CropBoxFilter : public CropFilter
......@@ -202,12 +205,13 @@ class CropBoxFilter : public CropFilter
ofDisableDepthTest();
if (parameters_.enabled_) {
ofSetColor(color_);
auto c = color_;
ofSetColor(c.lerp(ofColor::white, flash_));
ofNoFill();
ofDrawBox(parameters_.pos_, size.x, size.y, size.z);
ofFill();
auto c = color_;
c = color_;
c.a = ofMap(get_fill(), 0, .25, 10, 50, true);
if (parameters_.count_ > 10) {
......@@ -367,11 +371,13 @@ class FilterManager
}
}
void clear_preset_id(int num) {
void clear_preset_id(int num)
{
ofFile::removeFile("presets/zones/preset" + ofToString(num) + ".json");
}
bool is_there_such_a_preset_id(int num) {
bool is_there_such_a_preset_id(int num)
{
return ofFile::doesFileExist("presets/zones/preset" + ofToString(num) + ".json");
}
......@@ -400,6 +406,14 @@ class FilterManager
// if (filter->index_ > =8 && filter->parameters_.state_ == false) {
// filters_[filter->index_-1].newstate_ = false;
// }
if (filter->parameters_.newstate_) {
ofxFunctionalEasing([=](float progress) {
filter->flash_ = ofLerp(1.0, 0.0, progress);
}, .5, 0.0, "filter" + ofToString(filter->index_), [&](std::string label) {
// done
});
}
}
// m.addIntArg(filter->parameters_.count_);
......@@ -419,8 +433,8 @@ class FilterManager
if (m.getAddress() == "/filter_manager/filter/set") {
int filter_num = m.getArgAsInt(0);
if (filter_num >= 0 && filter_num < filters_.size()) {
auto filter = filters_[filter_num];
filter->parameters_.pos_ = glm::vec3(m.getArgAsFloat(1), m.getArgAsFloat(2), m.getArgAsFloat(3));
auto filter = filters_[filter_num];
filter->parameters_.pos_ = glm::vec3(m.getArgAsFloat(1), m.getArgAsFloat(2), m.getArgAsFloat(3));
filter->parameters_.dim_.set(glm::vec3(m.getArgAsFloat(4), m.getArgAsFloat(5), m.getArgAsFloat(6)));
filter->parameters_.slide_down_ = m.getArgAsFloat(7);
filter->parameters_.thresh_ = m.getArgAsFloat(8);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment