void * tachyon_init_spaceball(SceneHandle scene, char * port) {
  sbHandle * bh;

  bh = (sbHandle *) malloc(sizeof(sbHandle));

  if (bh != NULL) {
    memset(bh, 0, sizeof(sbHandle));

    bh->sball = sball_open(port);
    if (bh->sball == NULL) {
      free(bh);
      return NULL;
    } 
  }

  rt_get_camera_position(scene, &bh->orig_camcent, &bh->orig_camviewvec, &bh->orig_camupvec, &bh->orig_camrightvec);

  bh->camcent = bh->orig_camcent;
  bh->camviewvec = bh->orig_camviewvec;
  bh->camupvec = bh->orig_camupvec;

  trackball(bh->curquat, 0.0, 0.0, 0.0, 0.0);

  return bh;
}
Exemplo n.º 2
0
// constructor
Spaceball::Spaceball(VMDApp *vmdapp)
	: UIObject(vmdapp) {

#if defined(VMDTDCONNEXION) && defined(__APPLE__)
  // Enable input from MacOS X 3DConnexion API
  tdx_clear();
  if (tdx_enable() == 0)
    msgInfo << "3DConnexion SpaceNavigator enabled." << sendmsg;
#endif

#if defined(VMDLIBSBALL) && !defined(VMDSPACEWARE)
  sball=NULL; // zero it out to begin with
  if (getenv("VMDSPACEBALLPORT") != NULL) {
    msgInfo << "Opening Spaceball (direct I/O) on port: " 
            << getenv("VMDSPACEBALLPORT") << sendmsg;
    sball = sball_open(getenv("VMDSPACEBALLPORT"));
    if (sball == NULL) 
      msgErr << "Failed to open Spaceball direct I/O serial port, device disabled." 
             << sendmsg; 
  }
#endif

  buttonDown = 0;

  reset();
}
Exemplo n.º 3
0
int SpaceballTracker::do_start(const SensorConfig *config) {
#if defined(VMDLIBSBALL)
  if (sball) return FALSE;
#endif
  if (!config->require_local()) return 0;
  if (!config->have_one_sensor()) return 0;

  char *myUSL = stringdup(config->getname());

  if (!strupcmp(myUSL, "VMDLOCAL")) {
    msgInfo << "Opening VMD console Spaceball device (tracker)." << sendmsg;
    uselocal=1; // Use the main VMD spaceball for input

    // set the default translation and rotation increments
    // these really need to be made user modifiable at runtime
    transInc = 1.0f;
      rotInc = 1.0f;
    scaleInc = 1.0f;
  } else {
#if defined(VMDLIBSBALL)
    msgInfo << "Opening Spaceball tracker (direct I/O) on port: " << myUSL << sendmsg;
    sball = sball_open(myUSL);
    if (sball == NULL) 
      msgErr << "Failed to open Spaceball serial port, tracker disabled" 
             << sendmsg; 

    // set the default translation and rotation increments
    // these really need to be made user modifiable at runtime
    transInc = 1.0f / 6000.0f;
      rotInc = 1.0f /   50.0f;
    scaleInc = 1.0f / 6000.0f;
#else
    msgErr << "Cannot open Spaceball with direct I/O, not compiled with "
              "LIBSBALL option" << sendmsg;
#endif
  }


  // reset the position
  moveto(0,0,0);
  orient->identity();

  delete [] myUSL;

  return TRUE;
}