Exemple #1
0
int main(int argc, char *argv[]) {
  QApplication app(argc, argv) ;
  MainWindow window ;
  window.show() ;
  //window.showMaximized();
  window.showFullScreen() ;
  QTuio qTUIO(&window) ;
  QStringList args = app.arguments() ;
  if (args.size() > 1) {
    if (args[1] == "-h" || args[1] == "--help") {
      printf("Usage: %s [OPTION]\n\n", args[0].toLocal8Bit().data()) ;
      printf("Mandatory arguments to long options are mandatory for short options too.\n") ;
      printf("  -c, --calib MATRIX   specificy a 3x3 calibration matrix to fit [0,1] TUIO coordinates to screen coordinates\n") ;
      printf("  -h, --help           display this help and exit\n") ;
      exit(0) ;
    } else if (args[1] == "-c" || args[1] == "--calib") {
      if (args.size() < 11) {
	printf("Error! Calibration matrix requires 9 values.\n") ;
	exit(-1) ;
      } else {
	QMatrix3x3 calibration ;
	qreal *data = calibration.data() ;
	for (int i = 0; i < 9; ++i)
	  data[i] = args[i+2].toDouble() ;
	qTUIO.setTuioCalibration(calibration) ;
      }
    }
  }  
  qTUIO.run();
  return app.exec();
}
Exemple #2
0
int
main(int argc, char *argv[]) {
  QApplication app(argc, argv) ;
  QMainWindow *window = new QMainWindow ;
  Ui::overlayTest ui ;
  ui.setupUi(window) ;
  foreach (QWidget *widget, QApplication::allWidgets())
    widget->setAttribute(Qt::WA_AcceptTouchEvents) ;
  // --- add Overlay ---
  Overlay *overlay = new Overlay(window) ;  
  // --- Add qTUIO ---
  QTuio qTUIO(window) ;
  QStringList args = app.arguments() ;
  if (args.size() > 1) {
    if (args[1] == "-h" || args[1] == "--help") {
      printf("Usage: %s [OPTION]\n\n", args[0].toLocal8Bit().data()) ;
      printf("Mandatory arguments to long options are mandatory for short options too.\n") ;
      printf("  -c, --calib MATRIX   specificy a 3x3 calibration matrix to fit [0,1] TUIO coordinates to screen coordinates\n") ;
      printf("  -h, --help           display this help and exit\n") ;
      exit(0) ;
    } else if (args[1] == "-c" || args[1] == "--calib") {
      if (args.size() < 11) {
	printf("Error! Calibration matrix requires 9 values.\n") ;
	exit(-1) ;
      } else {
	QMatrix3x3 calibration ;
	qreal *data = calibration.data() ;
	for (int i = 0; i < 9; ++i)
	  data[i] = args[i+2].toDouble() ;
	qTUIO.setTuioCalibration(calibration) ;
      }
    }
  }
  qTUIO.run();
  // ---
  window->show() ;
  window->raise() ;
  return app.exec() ;
}
QMatrix3x3 CatmulRom::calculate_frame(QVector3D p0, QVector3D p1)
{
    QVector3D t0, t1, Q, B, N;
    t0 = p0 - p1;
    t1 = QVector3D(0, 0, 0) - p1;
    t0.normalize();
    t1.normalize();
    Q = t0 - t1;
    // This is the same frame, so we should return the previous frame translated...
    Q.normalize();
    B = QVector3D::crossProduct(Q, t0);
    N = QVector3D::crossProduct(t0, B);
    N.normalize();
    B.normalize();
    QMatrix3x3 orientation = QMatrix3x3();
    if (Q.x() == 0 && Q.y() == 0 && Q.z() == 0)
    {
        orientation.setToIdentity();
        return orientation;
    }
    float * o_mat = orientation.data();

    // Get frame orientation
    o_mat[0] = t0.x();
    o_mat[1] = B.x();
    o_mat[2] = N.x();

    o_mat[3] = t0.y();
    o_mat[4] = B.y();
    o_mat[5] = N.y();

    o_mat[6] = t0.z();
    o_mat[7] = B.z();
    o_mat[8] = N.z();
    return orientation;
}