Ejemplo n.º 1
0
void run(){
  static FPSLimiter fps(pa("-maxfps"),10);
  
  gui["image"] = grabber.grab();
  gui["fps"].render();
  fps.wait();
}
Ejemplo n.º 2
0
void run()
{
  //delay the simulation for a second
  if(delay++ < fps.getMaxFPS()){
    scene.step(0.f);
  } else {
    scene.step();
  }
  gui["draw"].render();
  fps.wait();
}
Ejemplo n.º 3
0
void run(){
  static ButtonHandle mem = gui["mem"];
  static ButtonHandle add = gui["add"];
  static DrawHandle3D draw = gui["draw"];
  static FPSLimiter fpslimit(10,10);

  fpslimit.setMaxFPS(parse<int>(gui["maxFPS"].as<std::string>()));

  paper->setTextureVisible(gui["showTexture"]);
  paper->setCubesVisible(gui["showCubes"]);
  paper->setShowAllConstraints(gui["showLinks"]);

  static float lastMargin = -1;
  float currMargin = gui["cm"];
  if(lastMargin != currMargin){
    paper->getSoftBody()->getCollisionShape()->setMargin(icl2bullet(currMargin));
    lastMargin = currMargin;
  }

  if(mem.wasTriggered()){
    paper->memorizeDeformation();
  }
  static bool first = true;
  if(add.wasTriggered() || (first && pa("-a"))){
    first = false;
    add_clutter(&scene,&scene,30);
    //TODO CHECK THIS OUT add_clutter(&scene, &world, 1, 5, false);
  }
  remove_fallen_objects(&scene, &scene);


  static Time lastTime = Time::now();
  Time now = Time::now();
  double dt = (now-lastTime).toSecondsDouble();
  lastTime = now;
  if(gui["run"]){
    paper->applyAllForces(gui["attractorStreangth"],gui["vertexMoveFactor"]);
    scene.Scene::lock();
    paper->lock();
    scene.step( dt * 5, 1);
    paper->unlock();
    scene.Scene::unlock();
  }

  foldLine.visualize(**draw);
  draw.render();
  gui["fps"].render();

  if(capturer){
    capturer->capture();
  }
  fpslimit.wait();
}
Ejemplo n.º 4
0
void run(){
  bool c_arg = pa("-c");
  
  static FPSLimiter fpsLimit(30);
  fpsLimit.wait();

  const ImgBase *image = grabber.grab();
  DrawHandle draw = gui["draw"];
  ImageHandle cropped = gui["cropped"];

  draw = image;

  static RotateOp rot;
  if(c_arg){
    rot.setAngle(0);
  }else{
    rot.setAngle(parse<int>(gui["rot"]));
  }

  const ImgBase *cro = 0;
  if(c_arg || gui["rect"].as<bool>()){
    static Img8u roi;
    std::vector<utils::Rect> rs = mouse_2->getRects();
    ICLASSERT_THROW(rs.size() == 1, ICLException("expected exactly one rectangle"));
    lastRect = rs[0];
    mouse_2->visualize(**draw);
    SmartPtr<const ImgBase> tmp = image->shallowCopy(rs[0] & image->getImageRect());
    roi.setChannels(tmp->getChannels());
    roi.setFormat(tmp->getFormat());
    roi.setSize(tmp->getROISize());
    tmp->convertROI(&roi);
    cro = rot.apply(&roi);

    draw->color(0,255,0,255);
    draw->text(str(rs[0]), rs[0].x, rs[0].y);

  }else{
    draw->draw(mouse_1->vis());
    Size32f s(gui["s1"],gui["s2"]);
    Point32f ps[4] = { mouse_1->ps[0],  mouse_1->ps[1],  mouse_1->ps[2],  mouse_1->ps[3] };
    switch(image->getDepth()){
#define ICL_INSTANTIATE_DEPTH(D)                                \
      case depth##D:{                                           \
        static ImageRectification<icl##D> ir;                   \
        try{                                                    \
          cro = rot.apply(&ir.apply(ps,*image->as##D(),s));     \
        }catch(...){}                                           \
        break;                                                  \
      }
      ICL_INSTANTIATE_ALL_DEPTHS;
#undef ICL_INSTANTIATE_DEPTH
    }
  }
  if(cro){
    cropped = cro;
    currMutex.lock();
    cro->convert(&curr);
    currMutex.unlock();
  }

  gui["draw"].render();
  gui["fps"].render();
}