Commit b0903e6d authored by artificiel's avatar artificiel
Browse files

CropFilter: ajout d'un param ghost pour animations interpolees

parent b5288867
......@@ -9,6 +9,8 @@
#include "ofxOsc.h"
#include "ofxTimeMeasurements.h"
#include "ofEasingParameterFloat.hpp"
#include "ofxCloudLib/ParsedParameterGroup.hpp"
namespace ofxCloudLib
......@@ -23,6 +25,7 @@ class CropFilterParameterGroup : public ofxCloudLib::ParsedParameterGroup
add(enabled_.set("enable", false));
add(pos_.set("position", glm::vec3(-10), glm::vec3(-10), glm::vec3(10)));
add(dim_.set("dimension", glm::vec3(.01), glm::vec3(.01), glm::vec3(10)));
add(ease_dim_.set("ease dim", glm::vec3(.01), glm::vec3(.01), glm::vec3(10)));
add(slide_down_.set("filter (down)", .5, 0, 1));
add(capacity_.set("capacity", 200, 1, 5000));
add(count_.set("count", 0, 0, 1000));
......@@ -30,10 +33,18 @@ class CropFilterParameterGroup : public ofxCloudLib::ParsedParameterGroup
add(height_.set("height", 0, 0, 1));
add(thresh_.set("thresh", 0.06, 0.06, .5));
dim_.addListener(this, &CropFilterParameterGroup::ease);
add_to_string_mapping(&(ofAbstractParameter &)pos_);
add_to_string_mapping(&(ofAbstractParameter &)dim_);
}
auto ease(glm::vec3 &to) -> void
{
ease_dim_.ease(to);
}
void force_trigger(ofEvent<ofAbstractParameter> event)
{
ofNotifyEvent(event, pos_);
......@@ -43,7 +54,7 @@ class CropFilterParameterGroup : public ofxCloudLib::ParsedParameterGroup
void reset()
{
pos_ = glm::vec3(0, 0, .5);
dim_ = glm::vec3(.5, .5, 1);
dim_.set(glm::vec3(.5, .5, 1));
capacity_ = 200;
slide_down_ = .5;
count_ = 0;
......@@ -51,8 +62,9 @@ class CropFilterParameterGroup : public ofxCloudLib::ParsedParameterGroup
}
ofParameter<float> slide_down_;
ofParameter<glm::vec3> dim_;
ofEasingParameterVec3 ease_dim_;
ofParameter<glm::vec3> pos_;
ofParameter<glm::vec3> dim_;
ofParameter<bool> state_;
ofParameter<bool> newstate_;
ofParameter<float> thresh_;
......@@ -116,8 +128,8 @@ class CropFilter
// apply_rule from here
// perhaps only on param_changes? (setup_rules()?)
min_ = parameters_.pos_.get() - (parameters_.dim_.get() / 2);
max_ = parameters_.pos_.get() + (parameters_.dim_.get() / 2);
min_ = parameters_.pos_.get() - (parameters_.ease_dim_.get() / 2);
max_ = parameters_.pos_.get() + (parameters_.ease_dim_.get() / 2);
// end perhaps
for (int i = 0; i < input_cloud->size(); i++) {
......@@ -183,7 +195,7 @@ class CropBoxFilter : public CropFilter
void draw() override
{
glm::vec3 size = parameters_.dim_.get();
glm::vec3 size = parameters_.ease_dim_.get();
ofPushStyle();
ofEnableBlendMode(OF_BLENDMODE_ADD);
......@@ -199,7 +211,7 @@ class CropBoxFilter : public CropFilter
c.a = ofMap(get_fill(), 0, .25, 10, 50, true);
if (parameters_.count_ > 10) {
glm::vec3 fillsize = parameters_.dim_.get() * glm::vec3(1, get_fill(), 1);
glm::vec3 fillsize = parameters_.ease_dim_.get() * glm::vec3(1, get_fill(), 1);
glm::vec3 fillpos = parameters_.pos_.get() - glm::vec3(0, (size.y * (1.0 - get_fill())) / 2, 0);
ofSetColor(c);
ofDrawBox(fillpos, fillsize.x, fillsize.y, fillsize.z);
......@@ -244,7 +256,7 @@ class CropCylinderFilter : public CropFilter
void draw() override
{
glm::vec3 size = parameters_.dim_.get();
glm::vec3 size = parameters_.ease_dim_.get();
ofPushStyle();
ofEnableBlendMode(OF_BLENDMODE_ADD);
......@@ -261,7 +273,7 @@ class CropCylinderFilter : public CropFilter
if (parameters_.count_ > 0) {
glm::vec3 fillsize = parameters_.dim_.get() * glm::vec3(1, get_fill(), 1);
glm::vec3 fillsize = parameters_.ease_dim_.get() * glm::vec3(1, get_fill(), 1);
glm::vec3 fillpos = parameters_.pos_.get() - glm::vec3(0, (size.y * (1.0 - get_fill())) / 2, 0);
ofSetColor(c);
// ofDrawBox(fillpos, fillsize.x, fillsize.y, fillsize.z);
......@@ -339,6 +351,9 @@ class FilterManager
{
ofLogNotice("filter_manager") << "saving preset" << ofToString(num) << ".json";
zones_gui_.saveToFile("presets/zones/preset" + ofToString(num) + ".json");
ofJson json;
ofSerialize(json, parameters_);
ofSaveJson("presets/zones/preset" + ofToString(num) + "-group.json", json);
}
void load_preset_id(int num)
......@@ -406,7 +421,7 @@ class FilterManager
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));
filter->parameters_.dim_ = glm::vec3(m.getArgAsFloat(4), m.getArgAsFloat(5), m.getArgAsFloat(6));
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);
filter->parameters_.capacity_ = m.getArgAsInt(9);
......
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