Beispiel #1
0
extern "C" void
normal_keydown_callback(unsigned char k, int x, int y)
{
   GLUT_MANAGER *mgr = (GLUT_MANAGER *)FD_MANAGER::mgr(); assert(mgr);
   // XXX - Just block events to the blocking window, or all windows?
   //       Rightnow, we only use one window, so this is academic...
   if (mgr->get_blocker() == GLUT_WINSYS::window()) return;

   static bool debug = Config::get_var_bool("JOT_DEBUG_KEY_CALLBACKS",false,true);
   if (debug)
      err_msg("key pressed: %d", int(k));

   GLUT_KBD *kbd = GLUT_KBD::kbd();

   int w, h;
   kbd->winsys()->size(w, h);

   VIEWptr view = GLUT_WINSYS::window()->view();

   VIEWint_list::get(view)->handle_event(Evd(k));
   
   CXYpt curs(PIXEL(x, (double) h - y));

   kbd->update_mods(curs);
}
Beispiel #2
0
extern "C" void
normal_keyup_callback(unsigned char k, int x, int y)
{
   GLUT_MANAGER *mgr = (GLUT_MANAGER *)FD_MANAGER::mgr(); assert(mgr);
   // XXX - Just block events to the blocking window, or all windows?
   //       Rightnow, we only use one window, so this is academic...
   if (mgr->get_blocker() == GLUT_WINSYS::window()) return;

   GLUT_KBD *kbd = GLUT_KBD::kbd();
   VIEWptr view = GLUT_WINSYS::window()->view();

   VIEWint_list::get(view)->handle_event(Evd(k,KEYU));

   int w, h;
   kbd->winsys()->size(w, h);
   CXYpt curs(PIXEL(x, (double) h - y));

   kbd->update_mods(curs);
}
Beispiel #3
0
RAYhit &
LINE3D::intersect(
   RAYhit  &ray,
   CWtransf&,
   int 
   ) const
{
   // Find the intersection point, its distance, and some kind of normal
   double distance = -1, d_2d = -1;
   Wvec   surf_norm;
   Wpt    nearpt;

   for (int i=0; i<num()-1; i++) {

      // Find the nearest point on the ray to the segment.
      Wpt ray_pt = ray.line().intersect(Wline(point(i), point(i+1)));

      // Accept only if ray_pt is in front of the ray
      if ((ray_pt - ray.point()) * ray.vec() > 0 ) {

         // Ok if the ray passes within 10 pixels of the segment
         const double PIX_THRESH = 10.0;
         Wpt hit_pt = nearest_pt_to_line_seg(ray_pt, point(i), point(i+1)); 
         double screen_dist = PIXEL(hit_pt).dist(ray_pt);
         if ((screen_dist < PIX_THRESH) && (d_2d < 0 || screen_dist < d_2d)) {
            d_2d      = screen_dist;
            distance  = ray.point().dist(ray_pt);
            nearpt    = hit_pt;

            // XXX - What should be the "normal"?  For now,
            //       just the vector pointing back to the camera.
            surf_norm = -ray.vec().normalized();
         }
      } 
   }

   // Then call ray.check() passing it all this stuff
   if (distance >= 0)
      ray.check(distance, 1, 0, (GEL*)this, surf_norm, nearpt, nearpt,
                0, XYpt());
   return ray;
}