/**
  * Sets the global mirror flag. This will set all current existing nodes' mirror state, and also
  * affect future created nodes. The default mirror flag is FALSE.
  *
  * @param theMirror New Mirror state.
  */
 public void mirror(boolean theMirror) {
   try {
     _myContext.setGlobalMirror(theMirror);
   } catch (StatusException e) {
     throw new CCOpenNIException(e);
   }
 }
 /** Stop all generators from generating data. */
 public void stop() {
   try {
     _myContext.stopGeneratingAll();
   } catch (StatusException e) {
     throw new CCOpenNIException(e);
   }
 }
 /**
  * Opens a recording file, adding all nodes in it to the context.
  *
  * @param theFile The file to open.
  * @return The created player node.
  */
 public CCOpenNIPlayer openFileRecording(String theFile) {
   try {
     return new CCOpenNIPlayer(_myContext.openFileRecordingEx(CCIOUtil.dataPath(theFile)));
   } catch (GeneralException e) {
     throw new CCOpenNIException(e);
   }
 }
 /** Make sure all generators are generating data. */
 public void start() {
   try {
     _myContext.startGeneratingAll();
     _myThread = new Thread(this);
     _myThread.start();
   } catch (StatusException e) {
     throw new CCOpenNIException(e);
   }
 }
  public CCOpenNI(CCApp theApp) {
    theApp.addUpdateListener(this);
    theApp.addDisposeListener(this);

    try {
      _myContext = new Context();
      License licence = new License("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4="); // vendor, key
      _myContext.addLicense(licence);
    } catch (GeneralException e) {
      throw new CCOpenNIException(e);
    }
  }
  @Override
  public void run() {
    myLastNanos = System.nanoTime();
    while (_myIsRunning) {
      try {
        _myContext.waitAndUpdateAll();
        long myNewNanos = System.nanoTime();
        long mySpentTime = myNewNanos - myLastNanos;
        myLastNanos = myNewNanos;
        _myIsUpdated = true;
      } catch (StatusException e) {

      }
    }
  }