Commit e2920269 authored by artificiel's avatar artificiel
Browse files

CropFilter: tweaks de couleurs et cylindre

parent 1481d555
......@@ -68,8 +68,8 @@ 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));
material_.setSpecularColor(ofColor(200,200,200));
material_.setAmbientColor(ofColor(20,20,20,0));
material_.setSpecularColor(ofColor(0,0,0,0));
}
float get_fill()
......@@ -116,7 +116,6 @@ class CropFilter
}
// end apply_rule
if (new_height > parameters_.height_) {
parameters_.height_ = new_height;
} else {
......@@ -174,6 +173,7 @@ class CropBoxFilter : public CropFilter
ofEnableBlendMode(OF_BLENDMODE_ADD);
ofDisableDepthTest();
if (parameters_.enabled_) {
ofSetColor(color_);
ofNoFill();
ofDrawBox(parameters_.pos_, size.x, size.y, size.z);
......@@ -182,26 +182,26 @@ class CropBoxFilter : public CropFilter
auto c = color_;
c.a = ofMap(get_fill(), 0, .25, 10, 50, true);
if (parameters_.count_ > 0) {
if (parameters_.count_ > 10) {
glm::vec3 fillsize = parameters_.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);
}
/*
if (parameters_.rms_ > 0) {
glm::vec3 fillsize = parameters_.dim_.get() * glm::vec3(1, parameters_.rms_, 1);
glm::vec3 fillpos = parameters_.pos_.get() - glm::vec3(0, (size.y * (1.0 - parameters_.rms_)) / 2, 0);
ofSetColor(255, 0, 0, ofMap(parameters_.rms_, 0, .25, 10, 150, true));
ofDrawBox(fillpos, fillsize.x, fillsize.y, fillsize.z);
}
*/
if (parameters_.state_) {
ofSetColor(color_);
c.a = 128;
} else {
auto c = color_;
c.a = 128;
ofSetColor(color_);
c.a = 64;
}
ofSetColor(c);
ofDrawBox(parameters_.pos_->x, 0, parameters_.pos_->z, size.x, .01, size.z);
......@@ -236,23 +236,31 @@ class CropCylinderFilter : public CropFilter
if (parameters_.enabled_) {
ofSetColor(color_);
ofNoFill();
ofDrawBox(parameters_.pos_, size.x, size.y, size.z);
ofFill();
// 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();
auto c = color_;
c.a = ofMap(get_fill(), 0, .25, 10, 50, true);
c.a = 128;//ofMap(get_fill(), 0, .1, 0, 1, true);
if (parameters_.count_ > 0) {
glm::vec3 fillsize = parameters_.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);
// ofDrawBox(fillpos, fillsize.x, fillsize.y, fillsize.z);
material_.setDiffuseColor(c);
material_.begin();
ofDrawCylinder(fillpos, fillsize.x * .707, fillsize.y);
material_.end();
}
if (parameters_.rms_ > 0) {
/*
glm::vec3 fillsize = parameters_.dim_.get() * glm::vec3(1, parameters_.rms_, 1);
glm::vec3 fillpos = parameters_.pos_.get() - glm::vec3(0, (size.y * (1.0 - parameters_.rms_)) / 2, 0);
ofSetColor(255, 0, 0, ofMap(parameters_.rms_, 0, .25, 10, 150, true));
ofDrawBox(fillpos, fillsize.x, fillsize.y, fillsize.z);
*/
}
if (parameters_.state_) {
ofSetColor(color_);
......@@ -262,18 +270,20 @@ class CropCylinderFilter : public CropFilter
auto c = color_;
c.a = 128;
ofSetColor(color_);
material_.setDiffuseColor(color_);
}
material_.setDiffuseColor(color_);
material_.begin();
ofDrawCylinder(parameters_.pos_->x, parameters_.pos_->y, parameters_.pos_->z, size.x, size.z);
ofDrawCylinder(parameters_.pos_->x, parameters_.pos_->y, parameters_.pos_->z, size.x*.707, size.y);
material_.end();
} else {
/*
// a mettre dans un debug quelconque?
ofSetColor(200, 200, 200, 128);
ofNoFill();
ofDrawBox(parameters_.pos_, size.x, size.y, size.z);
ofFill();
*/
}
ofPopStyle();
}
......@@ -300,7 +310,7 @@ class FilterManager
for (size_t i = 0; i < num_filters; i++) {
// TODO: figure out parametrisation of type (same type for all manager?)
filters_.push_back(new CropCylinderFilter(i));
filters_.push_back(new CropBoxFilter(i));
filters_.back()->parameters_.setName("Filter #" + ofToString(i));
parameters_.add(filters_.back()->parameters_);
}
......@@ -350,11 +360,11 @@ class FilterManager
// m.addIntArg(filter->parameters_.count_);
if (excitated_) {
m.addFloatArg(filter->get_fill());
m_height.addFloatArg(filter->parameters_.height_);
}
m.addFloatArg(filter->get_fill());
}
// sender_->sendMessage(m);
sender_->sendMessage(m);
// sender_->sendMessage(m_height);
TS_STOP("FilterManager::update()");
}
......@@ -383,23 +393,31 @@ class FilterManager
auto filter = filters_[i];
filter->parameters_.rms_ = 5 * (m.getArgAsFloat(i));
}
} else if (m.getAddress() == "/filter_manager/enable") {
enabled_ = m.getArgAsBool(0);
} else if (m.getAddress() == "/filter_manager/save") {
save_preset_id(m.getArgAsInt(1));
} else if (m.getAddress() == "/filter_manager/load") {
load_preset_id(m.getArgAsInt(1));
}
}
std::vector<CropFilter *> &get_filters() { return filters_; }
void draw()
{
ofPushMatrix();
ofPopStyle();
ofEnableLighting();
for (const auto &filter : filters_) {
filter->draw();
}
ofDisableLighting();
if (enabled_) {
ofPopStyle();
ofPopMatrix();
ofPushMatrix();
ofPopStyle();
ofEnableLighting();
for (const auto &filter : filters_) {
filter->draw();
}
ofDisableLighting();
ofPopStyle();
ofPopMatrix();
}
}
void draw_floor(size_t index, ofColor color, float size, std::string label)
......
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