Commit 72a06ce8 authored by gllm's avatar gllm
Browse files
parents cde815be b555d074
ofxFontStash
ofxOsc
ofxInputField
ofxCameraSaveLoad
ofxAssimpModelLoader
ofxGui
......
......@@ -2,6 +2,7 @@
#define ABSTRACTCLIENT_HPP
#include "ofMain.h"
//#include "ofxInputField.h"
namespace ofxCloudLib
{
......@@ -27,7 +28,7 @@ class AbstractClient
gui_.add(etiquette_field_.setup("nom", "nom"));
menu_is_ready_ = true;
auto parameter_string = (ofParameter<string> &)etiquette_field_.getParameter();
auto parameter_string = etiquette_field_.getParameter().cast<string>();
parameter_string.addListener(this, &AbstractClient::update_gui_name);
};
......@@ -58,7 +59,7 @@ class AbstractClient
bool dead_client_ = false;
ofMesh mesh_;
bool menu_is_ready_ = false;
ofxTextField etiquette_field_;
ofxInputField<std::string> etiquette_field_;
private:
};
......
......@@ -44,8 +44,11 @@ void ClientConnector::threadedFunction()
fresh_mesh.clear();
cloud_counter_++;
xyz_receiver_.receive(fresh_mesh);
fresh_mesh.removeVertex(0);
aggregated_.send(std::move(fresh_mesh));
if (fresh_mesh.getNumVertices()) {
fresh_mesh.removeVertex(0);
aggregated_.send(std::move(fresh_mesh));
}
// std::cout << "NEW CLOUD IN THREAD " << client_name_ << "#" << cloud_counter_ << std::endl;
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(10));
......
......@@ -136,7 +136,8 @@ class CloudPlayerThread : public ofThread
cloudfile.close();
struct stat st;
int ierr = stat(filename_to_decode, &st);
// int ierr = stat(filename_to_decode, &st);
stat(filename_to_decode, &st);
uint64_t status_ms = st.st_ctime * 1000 + st.st_ctim.tv_nsec / 1000000;
if (previousCloudTimestamp == 0) {
......
......@@ -66,7 +66,7 @@ class ClusterTracker
(*clusterMesh)->min[1] - cluster_halo))) {
// overlap X+Y
std::cout << "OVERLAP 1 " << std::endl;
// std::cout << "OVERLAP 1 " << std::endl;
(*clusterMesh)->smartCloud = *newCloud;
(*clusterMesh)->setupMesh();
(*clusterMesh)->lostTime = 0;
......@@ -121,13 +121,13 @@ class ClusterTracker
if ((((*c)->min[1] < (*clusterMesh)->max[1] + cluster_halo) && ((*c)->max[1] >
(*clusterMesh)->min[1] - cluster_halo))) {
// overlap X+Y
std::cout << "OVERLAP 2 avec tolérance" << cluster_halo << std::endl;
// std::cout << "OVERLAP 2 avec tolérance" << cluster_halo << std::endl;
(*clusterMesh)->smartCloud = *c;
(*clusterMesh)->setupMesh();
(*clusterMesh)->lostTime = 0;
(*clusterMesh)->lost = false;
(*clusterMesh)->activeSpree = 0;
std::cout << "delete cloud " << std::endl;
// std::cout << "delete cloud " << std::endl;
c = candidateClouds->erase(c);
reborn = true;
break;
......@@ -138,7 +138,7 @@ class ClusterTracker
if (!reborn) {
(*clusterMesh)->lostTime++;
if ((*clusterMesh)->lostTime > 2) {
std::cout << "delete clustermesh " << std::endl;
// std::cout << "delete clustermesh " << std::endl;
clusterMeshBin.push_back(*clusterMesh);
clusterMesh = clusterMeshes.erase(clusterMesh);
}
......@@ -162,7 +162,7 @@ class ClusterTracker
vector<shared_ptr<SmartCloud>>::iterator newCloud;
for (newCloud = candidateClouds->begin(); newCloud != candidateClouds->end(); newCloud++) {
std::cout << "new a clusterMesh" << std::endl;
// std::cout << "new a clusterMesh" << std::endl;
if (clusterMeshBin.size() > 0) {
shared_ptr<ClusterMesh> revived = clusterMeshBin.back();
......
......@@ -5,6 +5,7 @@
#include "ofxArtnet.h"
#include "ofxCloudLib/ParsedParameterGroup.hpp"
#include "ofxOsc.h"
#include "ofxGui.h"
namespace ofxCloudLib
{
......@@ -66,7 +67,7 @@ class CropFilter
index_ = i;
result_.reset(new pcl::PointCloud<pcl::PointXYZ>);
color_.setHsb((i/16.0)*255, 255, 128, 100);
color_.setHsb((i / 16.0) * 255, 255, 128, 100);
}
void setup()
......@@ -81,8 +82,8 @@ class CropFilter
void draw()
{
glm::vec3 size = parameters_.dim_.get();
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);
//,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();
......@@ -92,9 +93,9 @@ class CropFilter
ofDrawBox(parameters_.pos_, size.x, size.y, size.z);
ofFill();
auto c = color_;
c.a = ofMap(get_fill(), 0, .25, 10, 50, true);
auto c = color_;
c.a = ofMap(get_fill(), 0, .25, 10, 50, 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);
......@@ -107,6 +108,12 @@ class CropFilter
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_);
ofDrawBox(parameters_.pos_, size.x, .01, size.z);
}
} else {
ofSetColor(200, 200, 200, 128);
ofNoFill();
......@@ -144,13 +151,12 @@ class CropFilter
parameters_.height_ * (1.0 - parameters_.slide_down_);
}
if (!parameters_.state_) {
if (get_fill() > parameters_.thresh_ + .05) {
if (get_fill() > parameters_.thresh_ + .03) {
parameters_.newstate_ = true;
}
} else {
if (get_fill() < parameters_.thresh_ - .05) {
if (get_fill() < parameters_.thresh_ - .03) {
parameters_.newstate_ = false;
parameters_.height_ = 0;
}
......@@ -179,6 +185,7 @@ class CropFilter
glm::vec3 min_, max_;
ofColor color_;
size_t index_;
float distance_ = 10000;
// char * rgbw_[4];
};
......@@ -215,8 +222,8 @@ class FilterManager
sender_ = sender;
rgbw_.allocate(num_filters * 4, 1, OF_IMAGE_COLOR_ALPHA);
my_artnet_ip_= "192.168.94.62";
setup_artnet();
my_artnet_ip_ = "10.6.41.105";
setup_artnet();
parameters_.setName("FilterManager");
parameters_.add(enabled_.set("enabled", true));
......@@ -225,17 +232,33 @@ class FilterManager
filters_.back()->parameters_.setName("Filter #" + ofToString(i));
parameters_.add(filters_.back()->parameters_);
}
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 setup_artnet() {
}
void setup_artnet()
{
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);
// 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);
}
void update(pcl::PointCloud<pcl::PointXYZ>::Ptr input_cloud)
......@@ -253,6 +276,11 @@ class FilterManager
m2.addIntArg(filter->parameters_.newstate_);
sender_->sendMessage(m2);
filter->parameters_.state_ = filter->parameters_.newstate_;
// // exception hard-codee: si une zone ext est released avant la int, releasera la int
// if (filter->index_ > =8 && filter->parameters_.state_ == false) {
// filters_[filter->index_-1].newstate_ = false;
// }
}
// m.addIntArg(filter->parameters_.count_);
......@@ -275,9 +303,9 @@ class FilterManager
rgbw_.getPixels().getData()[filter->index_ * 4 + 3] = int(ofMap(amp, 0, 1, 0, 255, true));
}
}
if (artnet_->sendDmx("192.168.94.244", 0, 0, rgbw_.getPixels().getData(), 16) == -3) {
setup_artnet();
}
// if (artnet_->sendDmx("192.168.94.244", 0, 0, rgbw_.getPixels().getData(), 16) == -3) {
// setup_artnet();
// }
sender_->sendMessage(m);
sender_->sendMessage(m_height);
......@@ -292,7 +320,8 @@ class FilterManager
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_.slide_down_ = m.getArgAsFloat(7);
filter->parameters_.capacity_ = m.getArgAsInt(8);
filter->parameters_.thresh_ = m.getArgAsFloat(8);
filter->parameters_.capacity_ = m.getArgAsInt(9);
}
} else if (m.getAddress() == "/filter_manager/filter/enable") {
int filter_num = m.getArgAsInt(0);
......@@ -316,6 +345,12 @@ class FilterManager
}
}
void draw_gui()
{
zones_gui_.draw();
}
void draw_rgbw(int x, int y, int w, int h)
{
rgbw_.draw(x, y, w, h);
......@@ -324,6 +359,7 @@ class FilterManager
ofParameterGroup parameters_;
ofParameter<bool> enabled_;
ofImage rgbw_;
ofxPanel zones_gui_;
private:
std::string my_artnet_ip_;
......
......@@ -126,10 +126,10 @@ class Merger
ofPushStyle();
ofPushMatrix();
ofSetColor(255, 255, 255, 100);
ofRotateDeg(-180, 1, 0, 0); // ceci aaligne le modele avec le cloud
ofRotateYDeg(90); // ceci aaligne le modele avec le cloud
//git pu ofRotateXDeg(180); // ceci aaligne le modele avec le cloud
ofScale(250);
ofRotateDeg(180, 1, 0, 0);
ofScale(1000);
if (wireframe_models_) {
scene_model_.drawWireframe();
......@@ -147,14 +147,18 @@ class Merger
}
if (draw_marqueurs_) {
ofEnableLighting();
light_jardin_.enable();
light_court_.enable();
// ofEnableLighting();
// light_jardin_.enable();
// light_court_.enable();
ofPushStyle();
ofPushMatrix();
ofSetColor(50, 50, 50, 150);
ofScale(100);
if (wireframe_models_) {
ofSetColor(100, 100, 100, 150);
ofRotateDeg(180, 1, 0, 0);
ofScale(1000);
if (wireframe_models_) {
marqueurs_model_.drawWireframe();
} else {
model_material_.begin();
......@@ -163,13 +167,13 @@ class Merger
}
ofPopStyle();
ofPopMatrix();
light_jardin_.disable();
light_court_.disable();
// light_jardin_.disable();
// light_court_.disable();
// ofDisableLighting();
ofSetColor(255, 255, 255, 150);
ofEnableBlendMode(OF_BLENDMODE_ADD);
marqueurs_model_.drawWireframe();
ofDisableLighting();
}
// if (draw_lights_) {
......
......@@ -124,7 +124,7 @@ class ofCloudServerApp : public ofBaseApp
if (key == 'c') merger_.draw_cam_colors_ = !merger_.draw_cam_colors_;
if (key == 's') draw_clusters_ = !draw_clusters_;
key_pressed(key);
key_pressed(key); // passe aux subclasses?
}
void keyReleased(int key) { key_released(key); }
......@@ -138,17 +138,19 @@ class ofCloudServerApp : public ofBaseApp
void gotMessage(ofMessage msg) {}
void dragEvent(ofDragInfo dragInfo) {}
void exit() { save_gui_params_to_file(0); }
void exit() {
save_gui_params_to_file(0);
}
void save_gui_params_to_file(int i)
{
gui_.saveToFile("presets/cloudserver_" + ofToString(i) + ".xml");
gui_.saveToFile("presets/cloudserver_" + ofToString(i) + ".json");
ofxSaveCamera(cam_, "cameras/current.txt");
}
void load_gui_params_from_file(int i)
{
gui_.loadFromFile("presets/cloudserver_" + ofToString(i) + ".xml");
gui_.loadFromFile("presets/cloudserver_" + ofToString(i) + ".json");
ofxLoadCamera(cam_, "cameras/current.txt");
save_gui_params_to_file(0);
}
......
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