Commit 32ff3002 authored by artificiel's avatar artificiel
Browse files

ClientManager: retrait du Sticky et maintient de Mesh live vs recorded

parent ed930c17
......@@ -11,22 +11,22 @@ ClientsManager::ClientsManager()
ofAddListener(browser_.serviceNewE, this, &ClientsManager::service_new);
ofAddListener(browser_.serviceRemoveE, this, &ClientsManager::service_remove);
sticky_mesh_parameters_.setName("sticky_mesh");
sticky_mesh_parameters_.add(sticky_mesh_enable_.set("Enable", 1));
sticky_mesh_parameters_.add(sticky_mesh_input_prob_.set("Input prob", .01, 0, 1));
sticky_mesh_parameters_.add(sticky_mesh_attenuation_amnt_.set("Att amnt", .05, 0, .5));
sticky_mesh_parameters_.add(sticky_mesh_alpha_thresh_.set("Alpha thresh", .05, 0, .5));
sticky_mesh_parameters_.add(sticky_mesh_twinkle_prob_.set("Twinkle prob", .05, 0, .5));
sticky_mesh_parameters_.add(sticky_mesh_twinkle_amnt_.set("Twinkle amnt", .5, 0, 1));
sticky_mesh_parameters_.add(sticky_mesh_dither_amnt_.set("Dither amnt", 0, 0, .1));
sticky_mesh_parameters_.add(sticky_mesh_color_.set("Color", ofColor::yellow, ofColor::black, ofColor::white));
parameters_.add(sticky_mesh_parameters_);
// sticky_mesh_parameters_.setName("sticky_mesh");
// sticky_mesh_parameters_.add(sticky_mesh_enable_.set("Enable", 1));
// sticky_mesh_parameters_.add(sticky_mesh_input_prob_.set("Input prob", .01, 0, 1));
// sticky_mesh_parameters_.add(sticky_mesh_attenuation_amnt_.set("Att amnt", .05, 0, .5));
// sticky_mesh_parameters_.add(sticky_mesh_alpha_thresh_.set("Alpha thresh", .05, 0, .5));
// sticky_mesh_parameters_.add(sticky_mesh_twinkle_prob_.set("Twinkle prob", .05, 0, .5));
// sticky_mesh_parameters_.add(sticky_mesh_twinkle_amnt_.set("Twinkle amnt", .5, 0, 1));
// sticky_mesh_parameters_.add(sticky_mesh_dither_amnt_.set("Dither amnt", 0, 0, .1));
// sticky_mesh_parameters_.add(sticky_mesh_color_.set("Color", ofColor::yellow, ofColor::black, ofColor::white));
// parameters_.add(sticky_mesh_parameters_);
parameters_.add(crop_left_.set("crop_left", 0, -10, 10));
parameters_.add(crop_right_.set("crop_right", 0, -10, 10));
parameters_.add(crop_top_.set("crop_top", 0, -10, 10));
parameters_.add(crop_bottom_.set("crop_bottom", 0, -10, 10));
sticky_mesh_.setMode(OF_PRIMITIVE_POINTS);
// sticky_mesh_.setMode(OF_PRIMITIVE_POINTS);
parameters_.setName("ClientsManager");
gui_.setup();
......@@ -34,12 +34,14 @@ ClientsManager::ClientsManager()
gui_.setPosition(10, ofGetHeight() - gui_.getHeight());
}
void ClientsManager::add_player(std::string player_name)
std::shared_ptr<ofxCloudLib::ClientPlayer> ClientsManager::add_player(std::string player_name)
{
mutex_.lock();
client_connectors_[player_name] = std::make_shared<ofxCloudLib::ClientPlayer>(player_name, client_connectors_.size());
auto client = std::make_shared<ofxCloudLib::ClientPlayer>(player_name, client_connectors_.size());
client_connectors_[player_name] = client;
gui_.add(client_connectors_[player_name]->get_draw_gui().set(player_name, 0));
mutex_.unlock();
return client;
}
void ClientsManager::service_new(ofxAvahiService &s)
......@@ -104,63 +106,72 @@ bool ClientsManager::receive_mesh(ofMesh &mesh)
}
}
if (is_new) {
ofMesh tmp_mesh;
tmp_mesh.append(sticky_mesh_);
sticky_mesh_.clear();
// if (is_new) {
ofMesh tmp_mesh;
// tmp_mesh.append(sticky_mesh_);
// sticky_mesh_.clear();
recorded_mesh_.clear();
live_mesh_.clear();
mesh.clear();
mesh.setMode(OF_PRIMITIVE_POINTS);
mesh.clear();
mesh.setMode(OF_PRIMITIVE_POINTS);
for (const auto &client : client_connectors_) {
for (const auto &client : client_connectors_) {
if (client.second->enabled_) {
if (client.second->enabled_) {
// ofLogNotice("ClientManager") << "merging client " << client.second->client_name_ << " with " << client.second->get_mesh().getNumVertices() << " vertices";
// ofLogNotice("ClientManager") << "merging client " << client.second->client_name_ << " with " << client.second->get_mesh().getNumVertices() << " vertices";
int reject = 0;
for (const auto &v : client.second->get_mesh().getVertices()) {
int reject = 0;
for (const auto &v : client.second->get_mesh().getVertices()) {
if (v.x > crop_left_ && v.x < crop_right_) {
mesh.addVertex(v);
if (v.x > crop_left_ && v.x < crop_right_) {
mesh.addVertex(v);
if (ofRandom(1.0) < sticky_mesh_input_prob_) {
tmp_mesh.addVertex(v);
tmp_mesh.addColor(sticky_mesh_color_);
}
if (dynamic_cast<ClientConnector *>(client.second.get())) {
live_mesh_.addVertex(v);
} else {
reject++;
recorded_mesh_.addVertex(v);
}
}
ofLogNotice("ClientManager") << "rejected " << reject << "/" << client.second->get_mesh().getNumVertices() << " vertices (out-of-crop)";
}
}
for (unsigned int i = 0; i < tmp_mesh.getNumVertices(); i++) {
auto color = tmp_mesh.getColors()[i];
color.a = color.a * (1.0 - sticky_mesh_attenuation_amnt_);
if (color.a > sticky_mesh_alpha_thresh_) {
if (ofRandom(1.0) < sticky_mesh_twinkle_prob_) {
// fade-out
color.a = color.a + sticky_mesh_twinkle_amnt_;
}
auto v = tmp_mesh.getVertices()[i];
if (sticky_mesh_dither_amnt_ > 0 && v.y > 0.0) {
v.x += ofRandom(-sticky_mesh_dither_amnt_, sticky_mesh_dither_amnt_);
v.z += ofRandom(-sticky_mesh_dither_amnt_, sticky_mesh_dither_amnt_);
v.y += ofRandom(-sticky_mesh_dither_amnt_, 0);
if (v.y < 0.0) v.y = 0.0;
sticky_mesh_.addVertex(v);
// if (ofRandom(1.0) < sticky_mesh_input_prob_) {
// tmp_mesh.addVertex(v);
// tmp_mesh.addColor(sticky_mesh_color_);
// }
} else {
sticky_mesh_.addVertex(tmp_mesh.getVertices()[i]);
reject++;
}
sticky_mesh_.addColor(color);
}
// ofLogNotice("ClientManager") << "rejected " << reject << "/" << client.second->get_mesh().getNumVertices() << " vertices (out-of-crop)";
}
// ofLogNotice("ClientManager") << "build mesh with " << mesh.getNumVertices() << " vertices.";
}
// for (unsigned int i = 0; i < tmp_mesh.getNumVertices(); i++) {
// auto color = tmp_mesh.getColors()[i];
// color.a = color.a * (1.0 - sticky_mesh_attenuation_amnt_);
// if (color.a > sticky_mesh_alpha_thresh_) {
// if (ofRandom(1.0) < sticky_mesh_twinkle_prob_) {
// // fade-out
// color.a = color.a + sticky_mesh_twinkle_amnt_;
// }
// auto v = tmp_mesh.getVertices()[i];
// if (sticky_mesh_dither_amnt_ > 0 && v.y > 0.0) {
// v.x += ofRandom(-sticky_mesh_dither_amnt_, sticky_mesh_dither_amnt_);
// v.z += ofRandom(-sticky_mesh_dither_amnt_, sticky_mesh_dither_amnt_);
// v.y += ofRandom(-sticky_mesh_dither_amnt_, 0);
// if (v.y < 0.0) v.y = 0.0;
// sticky_mesh_.addVertex(v);
// } else {
// sticky_mesh_.addVertex(tmp_mesh.getVertices()[i]);
// }
// sticky_mesh_.addColor(color);
// }
// }
// ofLogNotice("ClientManager") << "build mesh with " << mesh.getNumVertices() << " vertices.";
///}}
return is_new;
}
......
......@@ -9,9 +9,12 @@
#include "ofxCloudLib.h"
#include "ofxPublishableParameterGroup.h"
namespace ofxCloudLib
{
class ClientPlayer;
class AbstractClient;
class ClientsManager
......@@ -26,7 +29,7 @@ class ClientsManager
void update();
bool is_xyz_new();
void service_remove(ofxAvahiService &s);
void add_player(std::string player_name);
std::shared_ptr<ofxCloudLib::ClientPlayer> add_player(std::string player_name);
PublishableParameterGroup parameters_;
ofParameterGroup sticky_mesh_parameters_;
......@@ -45,6 +48,8 @@ class ClientsManager
ofVboMesh sticky_mesh_;
ofMesh registered_mesh_;
ofMesh recorded_mesh_;
ofMesh live_mesh_;
ofxPanel gui_;
map<std::string, shared_ptr<AbstractClient>> client_connectors_;
......
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