Examples of MTFiducialInputEvt


Examples of org.mt4j.input.inputData.MTFiducialInputEvt

  }

  //Global input processor listener implementation (IMTInputEventListener)
  public boolean processInputEvent(MTInputEvent inEvt) {
    if (inEvt instanceof MTFiducialInputEvt) {
      MTFiducialInputEvt fEvt = (MTFiducialInputEvt)inEvt;
      int fID = fEvt.getFiducialId();
      Vector3D position = fEvt.getPosition();

      AbstractShape comp;
      switch (fEvt.getId()) {
      case MTFiducialInputEvt.INPUT_DETECTED:
        //Create a new component for the fiducial
        AbstractShape newComp = createComponent(fID, position);
        fiducialIDToComp.put(fID, newComp); //Map id to component
        //Move component to fiducial position
        newComp.setPositionGlobal(position);
        //Save the absolute rotation angle in the component for late
        newComp.setUserData("angle", fEvt.getAngle());
        //Rotate the component
        newComp.rotateZ(newComp.getCenterPointRelativeToParent(), MTApplication.degrees(fEvt.getAngle()));
        //Add the component to the canvas to draw it
        getCanvas().addChild(newComp)
        break;
      case MTFiducialInputEvt.INPUT_UPDATED:
        //Retrieve the corresponding component for the fiducial ID from the map
        comp = fiducialIDToComp.get(fID);
        if (comp != null){
          //Set the new position
          comp.setPositionGlobal(position);
          //Set the rotation (we have to do a little more here because
          //mt4j does incremental rotations instead of specifying an absolute angle)
          float oldAngle = (Float)comp.getUserData("angle"); //retrieve the "old" angle
          float newAngle = fEvt.getAngle();
          if (oldAngle != newAngle){
            float diff = newAngle-oldAngle;
            comp.setUserData("angle", newAngle);
            diff = MTApplication.degrees(diff); //our rotation expects degrees (not radians)
            comp.rotateZ(comp.getCenterPointRelativeToParent(), diff);
View Full Code Here

Examples of org.mt4j.input.inputData.MTFiducialInputEvt

   * @see org.mt4j.input.inputProcessors.globalProcessors.AbstractGlobalInputProcessor#processInputEvtImpl(org.mt4j.input.inputData.MTInputEvent)
   */
  @Override
  public void processInputEvtImpl(MTInputEvent inputEvent) {
    if (inputEvent instanceof MTFiducialInputEvt){
      MTFiducialInputEvt fEvt = (MTFiducialInputEvt)inputEvent;
//      InputCursor motion = fEvt.getCursor();
      this.fireInputEvent(fEvt);
      /*
      switch (fEvt.getId()) {
      case MTFiducialInputEvt.INPUT_DETECTED:{
View Full Code Here

Examples of org.mt4j.input.inputData.MTFiducialInputEvt

    float absoluteX =  tuioObject.getX() * windowWidth;
    float abosulteY =  tuioObject.getY() * windowHeight;
//    logger.info("Added TuioObj tuio object-> sessionID: " + session_id + " fiducialID: " + fiducial_id + " xpos:" + tuioObject.getX() + " ypos:" + tuioObject.getY() + " angle:" + angle + " x_speed:" + x_speed + " y_speed:" + y_speed + " r_speed:" + r_speed + " m_accel:" + m_accel + " r_accel:" + r_accel);
   
    InputCursor c = new InputCursor();
    MTFiducialInputEvt fiducialEvt = new MTFiducialInputEvt(this, absoluteX, abosulteY, MTFiducialInputEvt.INPUT_DETECTED, c, fiducial_id, angle, x_speed, y_speed, r_speed, m_accel, r_accel);
    long cursorID = c.getId(); //TODO do implicitly somehow
    ActiveCursorPool.getInstance().putActiveCursor(cursorID, c);
    tuioFiducialIDMap.put(session_id, cursorID);
    this.enqueueInputEvent(fiducialEvt);
  }
View Full Code Here

Examples of org.mt4j.input.inputData.MTFiducialInputEvt

   
    Long tuioID = (Long)tuioFiducialIDMap.get(session_id) ;
    if (tuioID != null ){
      InputCursor c = ActiveCursorPool.getInstance().getActiveCursorByID(tuioID);
      if (c != null){
        MTFiducialInputEvt fiducialEvt = new MTFiducialInputEvt(this, absoluteX, abosulteY, MTFiducialInputEvt.INPUT_UPDATED, c, fiducial_id, angle, x_speed, y_speed, r_speed, m_accel, r_accel);
        this.enqueueInputEvent(fiducialEvt);
      }
    }
  }
View Full Code Here

Examples of org.mt4j.input.inputData.MTFiducialInputEvt

    Long cursorIDL = tuioFiducialIDMap.get(session_id);
    if (cursorIDL != null){
      long cursorID = (long)cursorIDL;
      InputCursor c = ActiveCursorPool.getInstance().getActiveCursorByID(cursorID);
      if (c != null){
        MTFiducialInputEvt te;
        if (c.getCurrentEvent() != null)
          te = new MTFiducialInputEvt(this, c.getCurrentEvent().getPosX(), c.getCurrentEvent().getPosY(), MTFiducialInputEvt.INPUT_ENDED, c, fiducial_id);
        else
          te = new MTFiducialInputEvt(this, 0,0, MTFiducialInputEvt.INPUT_ENDED, c, fiducial_id);

        tuioFiducialIDMap.remove(session_id);
        ActiveCursorPool.getInstance().removeCursor(cursorID);
        this.enqueueInputEvent(te);
      }else{
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.