Commit 7e6a3d38 authored by alexandre burton's avatar alexandre burton
Browse files

CropFIlter: retrait du artnet stuff

parent f86aac8b
......@@ -2,10 +2,9 @@
#ifndef CLOUDLIB_CROPFILTER_HPP_
#define CLOUDLIB_CROPFILTER_HPP_
#include "ofxArtnet.h"
#include "ofxCloudLib/ParsedParameterGroup.hpp"
#include "ofxOsc.h"
#include "ofxGui.h"
#include "ofxOsc.h"
namespace ofxCloudLib
{
......@@ -79,11 +78,21 @@ class CropFilter
return ofClamp(parameters_.count_.get() / parameters_.capacity_.get(), 0, 1);
}
void draw_floor(ofColor color, float size, std::string label)
{
ofPushStyle();
ofSetColor(color);
ofDrawBox(parameters_.pos_.get().x, 0, parameters_.pos_.get().z, size, .01, size);
ofSetColor(ofColor::white);
ofDrawBitmapString(label, parameters_.pos_.get().x, .25, parameters_.pos_.get().z);
ofPopStyle();
}
void draw()
{
glm::vec3 size = parameters_.dim_.get();
//,a 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);
glm::vec3 size = parameters_.dim_.get();
//,a 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);
ofPushStyle();
ofEnableBlendMode(OF_BLENDMODE_ADD);
ofDisableDepthTest();
......@@ -111,7 +120,6 @@ class CropFilter
if (parameters_.state_) {
ofSetColor(color_);
ofDrawBox(parameters_.pos_, size.x, .01, size.z);
}
} else {
......@@ -186,8 +194,6 @@ class CropFilter
ofColor color_;
size_t index_;
float distance_ = 10000;
// char * rgbw_[4];
};
class CropBoxFilter : public CropFilter
......@@ -220,10 +226,7 @@ class FilterManager
FilterManager(size_t num_filters, ofxOscSender *sender)
{
sender_ = sender;
rgbw_.allocate(num_filters * 4, 1, OF_IMAGE_COLOR_ALPHA);
my_artnet_ip_ = "10.6.41.105";
setup_artnet();
parameters_.setName("FilterManager");
parameters_.add(enabled_.set("enabled", true));
......@@ -233,34 +236,22 @@ class FilterManager
parameters_.add(filters_.back()->parameters_);
}
zones_gui_.setup(parameters_);
zones_gui_.setPosition(220,10);
zones_gui_.minimizeAll();
zones_gui_.setup(parameters_);
zones_gui_.setPosition(220, 10);
zones_gui_.minimizeAll();
}
void save_preset_id(int num) {
zones_gui_.saveToFile("presets/zones/preset"+ofToString(num)+".json");
}
void load_preset_id(int num) {
zones_gui_.loadFromFile("presets/zones/preset"+ofToString(num)+".json");
void save_preset_id(int num)
{
zones_gui_.saveToFile("presets/zones/preset" + ofToString(num) + ".json");
}
}
void setup_artnet()
void load_preset_id(int num)
{
std::cout << "setting up artnet on " << my_artnet_ip_ << std::endl;
// if (artnet_ != nullptr) {
// std::cout << "...(stopping previous instance)..." << my_artnet_ip_ << std::endl;
// artnet_->waitForThread();
// artnet_.release();
// }
artnet_ = make_unique<ofxArtnet>();
artnet_->setup(my_artnet_ip_.c_str(), 0, 0);
zones_gui_.loadFromFile("presets/zones/preset" + ofToString(num) + ".json");
}
void update(pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud)
{
ofxOscMessage m, m_height;
......@@ -284,33 +275,14 @@ void load_preset_id(int num) {
}
// m.addIntArg(filter->parameters_.count_);
m.addFloatArg(filter->get_fill());
m_height.addFloatArg(filter->parameters_.height_);
if (!filter->parameters_.state_) {
float amp = (sin(ofGetElapsedTimeMillis() / 1000.0f));
rgbw_.getPixels().getData()[filter->index_ * 4 + 0] = int(ofMap(amp, -1, 1, 0, 16, true));
rgbw_.getPixels().getData()[filter->index_ * 4 + 1] = int(ofMap(amp, -1, 1, 0, 16, true));
rgbw_.getPixels().getData()[filter->index_ * 4 + 2] = int(ofMap(amp, -1, 1, 10, 255, true));
rgbw_.getPixels().getData()[filter->index_ * 4 + 3] = int(ofMap(amp, -1, 1, 0, 32, true));
} else {
float amp = filter->parameters_.rms_;
rgbw_.getPixels().getData()[filter->index_ * 4 + 0] = int(ofMap(amp, 0, 1, 128, 255, true));
rgbw_.getPixels().getData()[filter->index_ * 4 + 1] = int(ofMap(amp, 0, 1, 128, 255, true));
rgbw_.getPixels().getData()[filter->index_ * 4 + 2] = int(ofMap(amp, 0, 1, 128, 255, true));
rgbw_.getPixels().getData()[filter->index_ * 4 + 3] = int(ofMap(amp, 0, 1, 0, 255, true));
}
sender_->sendMessage(m);
sender_->sendMessage(m_height);
}
// if (artnet_->sendDmx("192.168.94.244", 0, 0, rgbw_.getPixels().getData(), 16) == -3) {
// setup_artnet();
// }
sender_->sendMessage(m);
sender_->sendMessage(m_height);
}
void process_osc(ofxOscMessage &m)
{
if (m.getAddress() == "/filter_manager/filter/set") {
......@@ -345,26 +317,20 @@ void load_preset_id(int num) {
}
}
void draw_gui()
void draw_floor(size_t index, ofColor color, float size, std::string label)
{
zones_gui_.draw();
filters_[index]->draw_floor(color, size, label);
}
void draw_rgbw(int x, int y, int w, int h)
void draw_gui()
{
rgbw_.draw(x, y, w, h);
zones_gui_.draw();
}
ofParameterGroup parameters_;
ofParameter<bool> enabled_;
ofImage rgbw_;
ofxPanel zones_gui_;
private:
std::string my_artnet_ip_;
std::unique_ptr<ofxArtnet> artnet_;
std::vector<CropFilter *> filters_;
ofxOscSender *sender_;
};
......
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