Package org.mt4j.input.inputData

Examples of org.mt4j.input.inputData.AbstractCursorInputEvt


    logger.debug("Sending INPUT_ENDED events to the last scene, Active motions: " + ActiveCursorPool.getInstance().getActiveCursorCount());
    InputCursor[] activeCursors = ActiveCursorPool.getInstance().getActiveCursors();
    for (int i = 0; i < activeCursors.length; i++) {
      InputCursor inputCursor = activeCursors[i];
      if (inputCursor.getCurrentEvent() != null){
        AbstractCursorInputEvt lastEvt = inputCursor.getCurrentEvent();
        if (lastEvt.getId() != AbstractCursorInputEvt.INPUT_ENDED){
          try {
            AbstractCursorInputEvt endedEvt = (AbstractCursorInputEvt) lastEvt.clone();
            endedEvt.setId(AbstractCursorInputEvt.INPUT_ENDED);
            endedEvt.preFire();
           
            this.sendEvtToSceneProcessors(lastScene, endedEvt);
            logger.debug("Sending INPUT_ENDED evt to scene: " + lastScene.getName() + " Cursor: " + endedEvt.getCursor());
          } catch (CloneNotSupportedException e) {
            e.printStackTrace();
          }
        }
      }
View Full Code Here


      if (inputCursor.getCurrentEvent() != null){
        //PROBLEM: if in lastscene last event in cursor was input_started enqueued
        //but not added to cursor yet,
        //shall we send it again in new scene? -> will input_started be sent twice?
        //- what if input started was enqueued during transition and not sent to any scene
        AbstractCursorInputEvt lastEvt = inputCursor.getCurrentEvent();
        /*
        if (//lastEvt.getId() != AbstractCursorInputEvt.INPUT_DETECTED
            true
          ){
        */
          try {
            AbstractCursorInputEvt startedEvt = (AbstractCursorInputEvt) lastEvt.clone();
            startedEvt.setId(AbstractCursorInputEvt.INPUT_DETECTED);
            startedEvt.preFire();
           
            this.sendEvtToSceneProcessors(newScene, startedEvt);
            logger.debug("Sending INPUT_DETECTED evt to scene: " + newScene.getName() + " Cursor: " + startedEvt.getCursor());
          } catch (CloneNotSupportedException e) {
            e.printStackTrace();
          }
//        }
      }
View Full Code Here

       
        this.getCanvas().addInputListener(new IMTInputEventListener() {
          //@Override
          public boolean processInputEvent(MTInputEvent inEvt){
            if(inEvt instanceof AbstractCursorInputEvt){
              AbstractCursorInputEvt posEvt = (AbstractCursorInputEvt)inEvt;
              if (posEvt.hasTarget() && posEvt.getTargetComponent().equals(getCanvas())){
                InputCursor m = posEvt.getCursor();
                AbstractCursorInputEvt prev = m.getPreviousEventOf(posEvt);
                if (prev == null)
                  prev = posEvt;

                Vector3D pos = new Vector3D(posEvt.getPosX(), posEvt.getPosY(), 0);
                Vector3D prevPos = new Vector3D(prev.getPosX(), prev.getPosY(), 0);

                //System.out.println("Pos: " + pos);
                float mouseNormX = pos.x * invWidth;
                float mouseNormY = pos.y * invHeight;
                //System.out.println("MouseNormPosX: " + mouseNormX + "," + mouseNormY);
View Full Code Here

  }


  public void processInputEvtImpl(MTInputEvent inputEvent) {
    if (inputEvent instanceof AbstractCursorInputEvt) {
      AbstractCursorInputEvt posEvt = (AbstractCursorInputEvt) inputEvent;
      InputCursor m = posEvt.getCursor();
     
      switch (posEvt.getId()) {
      case AbstractCursorInputEvt.INPUT_DETECTED:{
//        logger.debug("Finger DOWN-> " + " ID:" + posEvt.getId() + "; X:" + posEvt.getPosX() + " Y:" + posEvt.getPosY() + "; Source: " + posEvt.getSource());
//        System.out.println("Finger DOWN-> " + " ID:" + posEvt.getId() + "; X:" + posEvt.getPosX() + " Y:" + posEvt.getPosY() + "; Source: " + posEvt.getSource()+  " CursorID: " + m.getId() + " appInfoProv: " + appInfoProvider);
        //Check if there is an object under the cursor and save it to a hashtable with the event if so
        IMTComponent3D obj = appInfoProvider.getComponentAt(posEvt.getPosX(), posEvt.getPosY());
        if (obj != null){
          motionToObjectMap.put(m, obj);
          posEvt.setTargetComponent(obj);
          this.fireInputEvent(posEvt);
        }
      }
      break;
      case AbstractCursorInputEvt.INPUT_UPDATED:{
//        logger.debug("Finger UPDATE-> " + " ID:" + posEvt.getId() + "; X:" + posEvt.getPositionX() + " Y:" + posEvt.getPositionY() + "; Source: " + posEvt.getSource());
        IMTComponent3D associatedObj = motionToObjectMap.get(m);
        if (associatedObj != null){
          posEvt.setTargetComponent(associatedObj);
          this.fireInputEvent(posEvt);
        }
      }
      break;
      case AbstractCursorInputEvt.INPUT_ENDED:{
//        logger.debug("Finger UP-> " + " ID:" + posEvt.getId() + "; X:" + posEvt.getPositionX() + " Y:" + posEvt.getPositionY() + "; Source: " + posEvt.getSource());
//        IMTComponent3D associatedObj = motionToObjectMap.get(m);
        IMTComponent3D associatedObj = motionToObjectMap.remove(m);
        if (associatedObj != null){
          posEvt.setTargetComponent(associatedObj);
          this.fireInputEvent(posEvt);
//          motionToObjectMap.remove(m);
        }
      }
      break;
View Full Code Here

   * @see org.mt4j.input.inputProcessors.globalProcessors.AbstractGlobalInputProcessor#processInputEvtImpl(org.mt4j.input.inputData.MTInputEvent)
   */
  @Override
  public void processInputEvtImpl(MTInputEvent inputEvent) {
    if (inputEvent instanceof AbstractCursorInputEvt) {
      AbstractCursorInputEvt cursorEvt = (AbstractCursorInputEvt)inputEvent;
      InputCursor c = ((AbstractCursorInputEvt)inputEvent).getCursor();
      Vector3D position = new Vector3D(cursorEvt.getPosX(), cursorEvt.getPosY());

      AbstractShape displayShape = null;
      switch (cursorEvt.getId()) {
      case AbstractCursorInputEvt.INPUT_DETECTED:
        displayShape = createDisplayComponent(app, position);
        cursorIDToDisplayShape.put(c, displayShape);
        overlayGroup.addChild(displayShape);
       
View Full Code Here

  @Override
  public boolean processInputEvent(MTInputEvent inEvt) {
    //We have to retarget inputevents for this component to the windowed scene
    if (inEvt instanceof AbstractCursorInputEvt){
      AbstractCursorInputEvt posEvt = (AbstractCursorInputEvt)inEvt;
      float x = posEvt.getPosX();
      float y = posEvt.getPosY();
     
      float newX = 0;
      float newY = 0;
      //Check intersection with infinite plane, this rect lies in
      Vector3D interSP = p.getIntersectionLocal(this.globalToLocal(Tools3D.getCameraPickRay(app, this, x, y)));
      if (interSP != null){
        //System.out.println(interSP);
        newX = interSP.x;
        newY = interSP.y;
      }
     
      AbstractCursorInputEvt newEvt = null;
      switch (posEvt.getId())
      {
      case AbstractCursorInputEvt.INPUT_DETECTED:{
        InputCursor newCursor = new InputCursor();
        try {
          newEvt = (AbstractCursorInputEvt) posEvt.clone();
          newEvt.setPositionX(newX);
          newEvt.setPositionY(newY);
//          newCursor.addEvent(newEvt);
          newEvt.setCursor(newCursor);
          newEvt.preFire();
          //Note: We dont set a target for the event! this can be
          //handled newly in the wondowed scenes InputRetargeter processor
        } catch (CloneNotSupportedException e) {
          e.printStackTrace();
        }
        this.oldCursorToNewCursor.put(posEvt.getCursor(), newCursor);
        //TODO checken ob cursor bereits events enth�lt - �berhaupt m�glich?..
        //ELSE -> CLONE AND ADD ALL OLD EVENTS TO THE NEW CURSOR!
      }break;
      case AbstractCursorInputEvt.INPUT_UPDATED:{
        InputCursor newCursor = this.oldCursorToNewCursor.get(posEvt.getCursor());
        if (newCursor != null){
          try {
            newEvt = (AbstractCursorInputEvt) posEvt.clone();
            newEvt.setPositionX(newX);
            newEvt.setPositionY(newY);
//            newCursor.addEvent(newEvt);
            newEvt.setCursor(newCursor);
            newEvt.preFire();
          } catch (CloneNotSupportedException e) {
            e.printStackTrace();
          }
        }else{
          System.err.println("Couldnt find new cursor!");
        }
      }break;
      case AbstractCursorInputEvt.INPUT_ENDED:{
        InputCursor newCursor = this.oldCursorToNewCursor.remove(posEvt.getCursor());
        if (newCursor != null){
          try {
            newEvt = (AbstractCursorInputEvt) posEvt.clone();
            newEvt.setPositionX(newX);
            newEvt.setPositionY(newY);
//            newCursor.addEvent(newEvt);
            newEvt.setCursor(newCursor);
            newEvt.preFire();
          } catch (CloneNotSupportedException e) {
            e.printStackTrace();
          }
        }else{
          System.err.println("Couldnt find new cursor!");
        }
      }break;
      default:
        break;
      }
     
      AbstractCursorInputEvt evtToFire = (newEvt != null) ?
          newEvt :
          posEvt;
     
      //Send similar event to the windowed scenes global input processors
      AbstractGlobalInputProcessor[] globalAnalyzer = app.getInputManager().getGlobalInputProcessors(scene);
View Full Code Here

    this.cursorToLastDrawnPoint = new HashMap<InputCursor, Vector3D>();
   
    this.getCanvas().addInputListener(new IMTInputEventListener() {
      public boolean processInputEvent(MTInputEvent inEvt){
        if(inEvt instanceof AbstractCursorInputEvt){
          final AbstractCursorInputEvt posEvt = (AbstractCursorInputEvt)inEvt;
          final InputCursor m = posEvt.getCursor();
//          System.out.println("PrevPos: " + prevPos);
//          System.out.println("Pos: " + pos);

          if (posEvt.getId() != AbstractCursorInputEvt.INPUT_ENDED){
            registerPreDrawAction(new IPreDrawAction() {
              public void processAction() {
                boolean firstPoint = false;
                Vector3D lastDrawnPoint = cursorToLastDrawnPoint.get(m);
                Vector3D pos = new Vector3D(posEvt.getPosX(), posEvt.getPosY(), 0);

                if (lastDrawnPoint == null){
                  lastDrawnPoint = new Vector3D(pos);
                  cursorToLastDrawnPoint.put(m, lastDrawnPoint);
                  firstPoint = true;
View Full Code Here

TOP

Related Classes of org.mt4j.input.inputData.AbstractCursorInputEvt

Copyright © 2018 www.massapicom. 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.