addr(a),
local(false),
active(true),
- activity(0),
throttle(0)
{
in_addr ina;
void Host::add_activity(unsigned bytes)
{
- activity += bytes*0.06935;
+ activity.add_bytes(bytes);
}
float Host::send_packet()
{
float dt = td/Msp::Time::sec;
- activity *= pow(0.933f, dt);
+ activity.tick(td);
throttle -= dt;
if(throttle<0)
throttle = 0;
return;
const map<unsigned, Host *> &hosts = netvis.get_hosts();
- float fx = -pos.x*0.1;
- float fy = -pos.y*0.1;
+ float center_force = (local ? 0.5 : 0.1);
+ float fx = -pos.x*center_force;
+ float fy = -pos.y*center_force;
for(map<unsigned, Host *>::const_iterator i=hosts.begin(); i!=hosts.end(); ++i)
{
if(i->second!=this)
if(!active)
return;
- GL::push_matrix();
+ GL::PushMatrix push_;
GL::translate(static_cast<int>(pos.x), static_cast<int>(pos.y), 0);
- GL::Immediate imm((GL::COLOR4_UBYTE, GL::VERTEX2));
+ GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
imm.begin(GL::QUADS);
- imm.color(1.0f, 1.0f, 1.0f, max(min(static_cast<float>(activity/10000), 1.0f), 0.2f));
+ imm.color(1.0f, 1.0f, 1.0f, max(min(static_cast<float>(activity.get_average()/10000), 1.0f), 0.2f));
imm.vertex(-5, -5);
imm.vertex(5, -5);
imm.vertex(5, 5);
imm.vertex(-5, 5);
imm.end();
- GL::pop_matrix();
-}
-
-void Host::render_label() const
-{
- if(!active)
- return;
-
const GL::Font &font = netvis.get_font();
-
- GL::push_matrix();
- GL::translate(static_cast<int>(pos.x)-static_cast<int>(font.get_string_width(short_name)*5), static_cast<int>(pos.y)+6, 0);
+ GL::translate(-static_cast<int>(font.get_string_width(short_name)*5), 6, 0);
GL::scale_uniform(10);
- font.draw_string(short_name);
-
- GL::pop_matrix();
+ imm.color(1.0f, 1.0f, 1.0f);
+ font.draw_string(short_name, imm);
+ GL::Texture::unbind();
}