Commit 3f0dc33c authored by artificiel's avatar artificiel
Browse files

CropFilter: ajustements OSC

parent d5c0369f
......@@ -68,13 +68,15 @@ class CropFilter
index_ = i;
result_.reset(new pcl::PointCloud<pcl::PointXYZ>);
color_.setHsb((float(i) / float(total)) * 255, 255, 128, 200);
material_.setAmbientColor(ofColor(20,20,20,0));
material_.setSpecularColor(ofColor(0,0,0,0));
material_.setAmbientColor(ofColor(20, 20, 20, 0));
material_.setSpecularColor(ofColor(0, 0, 0, 0));
}
float get_fill()
{
return ofClamp(parameters_.count_.get() / parameters_.capacity_.get(), 0, 1);
auto fill = ofClamp(parameters_.count_.get() / parameters_.capacity_.get(), 0, 1);
if (fill > .02) return fill;
return 0;
}
void draw_floor(ofColor color, float size, std::string label)
......@@ -237,11 +239,11 @@ class CropCylinderFilter : public CropFilter
ofSetColor(color_);
ofNoFill();
// ofDrawBox(parameters_.pos_, size.x, size.y, size.z);
ofDrawCylinder(parameters_.pos_->x, parameters_.pos_->y, parameters_.pos_->z, size.x*.707, size.y);
ofFill();
ofDrawCylinder(parameters_.pos_->x, parameters_.pos_->y, parameters_.pos_->z, size.x * .707, size.y);
ofFill();
auto c = color_;
c.a = 128;//ofMap(get_fill(), 0, .1, 0, 1, true);
c.a = 128; //ofMap(get_fill(), 0, .1, 0, 1, true);
if (parameters_.count_ > 0) {
......@@ -273,7 +275,7 @@ class CropCylinderFilter : public CropFilter
}
material_.setDiffuseColor(color_);
material_.begin();
ofDrawCylinder(parameters_.pos_->x, parameters_.pos_->y, parameters_.pos_->z, size.x*.707, size.y);
ofDrawCylinder(parameters_.pos_->x, parameters_.pos_->y, parameters_.pos_->z, size.x * .707, size.y);
material_.end();
} else {
......@@ -322,15 +324,16 @@ class FilterManager
void save_preset_id(int num)
{
ofLogNotice("filter_manager") << "saving preset" << ofToString(num) << ".json";
zones_gui_.saveToFile("presets/zones/preset" + ofToString(num) + ".json");
}
void load_preset_id(int num)
{
ofLogNotice("filter_manager") << "loading preset" << ofToString(num) << ".json";
zones_gui_.loadFromFile("presets/zones/preset" + ofToString(num) + ".json");
}
void update(pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud)
{
......@@ -384,21 +387,27 @@ class FilterManager
}
} else if (m.getAddress() == "/filter_manager/filter/enable") {
int filter_num = m.getArgAsInt(0);
if (filter_num >= 0 && filter_num < filters_.size()) {
auto filter = filters_[filter_num];
filter->parameters_.enabled_ = m.getArgAsBool(1);
}
} else if (m.getAddress() == "/filter_manager/rms") {
for (int i = 0; i < 4; i++) {
auto filter = filters_[i];
filter->parameters_.rms_ = 5 * (m.getArgAsFloat(i));
}
} else if (m.getAddress() == "/filter_manager/enable") {
enabled_ = m.getArgAsBool(0);
ofLogNotice("crop_manager") << "filter enable";
enabled_ = m.getArgAsInt(0);
} else if (m.getAddress() == "/filter_manager/save") {
save_preset_id(m.getArgAsInt(1));
save_preset_id(m.getArgAsInt(0));
} else if (m.getAddress() == "/filter_manager/load") {
load_preset_id(m.getArgAsInt(1));
load_preset_id(m.getArgAsInt(0));
}
}
std::vector<CropFilter *> &get_filters() { return filters_; }
......
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