Examples of PickInfo


Examples of org.jdesktop.mtgame.PickInfo

    public InputManager.PickEventReturn pickMouseEventSwing (MouseEvent awtMouseEvent) {

  logger.info("Picker Swing: received awt event = " + awtMouseEvent);

  // Determine the destination pick info by performing a pick, considering grabs. etc.
  PickInfo hitPickInfo;
  DetermineDestPickInfoReturn ret = determineDestPickInfo(awtMouseEvent);
  if (ret == null) {
      destPickInfo = null;
      hitPickInfo = null;
  } else {
      destPickInfo = ret.destPickInfo;
      hitPickInfo = ret.hitPickInfo;
  }
  logger.fine("destPickInfo = " + destPickInfo);
   logger.fine("hitPickInfo = " + hitPickInfo);

  // Generate 3D enter/exit events associated with this mouse event
  int eventID = awtMouseEvent.getID();
  if (eventID == MouseEvent.MOUSE_MOVED ||
      eventID == MouseEvent.MOUSE_DRAGGED ||
      eventID == MouseEvent.MOUSE_ENTERED ||
      eventID == MouseEvent.MOUSE_EXITED) {
      generateEnterExitEvents(awtMouseEvent, destPickInfo);
  }

  // Check for pick miss
  if (destPickInfo == null || destPickInfo.size() <= 0) {
      // Pick miss. Send it to the event distributor without pick info.
      logger.finest("Picker: pick miss");
      logger.finest("Enqueue null pick info for 3D event");
      logger.finest("awtMouseEvent = " + awtMouseEvent);
      swingPickInfos.add(new PickInfoQueueEntry(null, awtMouseEvent));
      return null;
  }

  // Create the Wonderland event which corresponds to this AWT event
  // (and, for drag events, attach the raw hit pick info).
  MouseEvent3D event = (MouseEvent3D) createWonderlandEvent(awtMouseEvent);

  // Get the destination entity and move pick details into the event
  PickDetails pickDetails = destPickInfo.get(0);
        Entity entity = pickDetails.getEntity();
  logger.fine("Picker: pickDetails = " + pickDetails);
        logger.fine("Picker: entity = " + entity);
        event.setPickDetails(pickDetails);
        if (eventID == MouseEvent.MOUSE_DRAGGED && hitPickInfo != null) {
            MouseDraggedEvent3D de3d = (MouseDraggedEvent3D) event;
            if (hitPickInfo.size() > 0) {
                de3d.setHitPickDetails(hitPickInfo.get(0));
            }
        }

        if (isWindowSwingEntity(entity)) {
            logger.info("Hit window swing entity = " + entity);

            // Get the WindowSwing of the entity
            WindowSwingEventConsumer eventConsumer =
                (WindowSwingEventConsumer) entity.getComponent(WindowSwingEventConsumer.class);
           
            // Treat change control events as 3D events, regardless of control or focus
            EventAction eventAction =  eventConsumer.consumesEvent(event);
            logger.info("Event action = " + eventAction);

            switch (eventAction) {

            case CONSUME_3D:

                // We haven't hit an input sensitive WindowSwing so post the event to the
                // event distributor as a 3D event
                swingPickInfos.add(new PickInfoQueueEntry(hitPickInfo, awtMouseEvent));
                return null;

            case CONSUME_2D:

                // HACK: see doc for this method
                cleanupGrab(awtMouseEvent);

                // Return the event to Swing
                if (eventID == MouseEvent.MOUSE_DRAGGED && hitPickInfo != null &&
                    hitPickInfo.size() > 0) {
                    return new InputManager.PickEventReturn(entity, pickDetails, hitPickInfo.get(0));
                } else {
                    return new InputManager.PickEventReturn(entity, pickDetails, null);
                }

            case DISCARD:
View Full Code Here

Examples of org.jdesktop.mtgame.PickInfo

            // drag
            ((DropTargetDragEvent) dropEvent).acceptDrag(DnDConstants.ACTION_MOVE);
            location = ((DropTargetDragEvent) dropEvent).getLocation();
        }

        PickInfo pickInfo = null;
        if (location != null) {
            pickInfo = pickEventScreenPos(location.x, location.y);
        }

        // now that we have the current and previous pick infos, we can
View Full Code Here

Examples of org.jdesktop.mtgame.PickInfo

  // See if the WindowSwing has already determined a pickInfo for this event.
  // TODO: right now, button release events are never sent to createCoordinateHandler so they
  // never have pre-calculated pickInfos. I don't yet know if this is an Embedded Swing bug or
  // whether it is a feature.
  PickInfo swingHitPickInfo = null;
  if (swingPickInfos.peek() != null) {
      try {
    PickInfoQueueEntry entry = swingPickInfos.take();

    // TODO: for now, verify that this is the right pickInfo for this event
    // Only check certain fields. Other fields (such as absolute X and Y) are
    // expected to be different
    if (e.getID() == entry.mouseEvent.getID() &&
        e.getX() == entry.mouseEvent.getX() &&
        e.getY() == entry.mouseEvent.getY()) {
        swingHitPickInfo = entry.hitPickInfo;
    } else {
        logger.finest("Swing pickInfo event doesn't match 3D event. Repicking.");
        logger.finest("3D event = " + e);
        logger.finest("pickInfo event = " + entry.mouseEvent);
    }
      } catch (InterruptedException ex) {}
  }

  // Implement the click threshold. Allow click event to be passed along only
  if (e.getID() == MouseEvent.MOUSE_PRESSED) {
      buttonLastX = e.getX();
      buttonLastY = e.getY();
  } else if (e.getID() == MouseEvent.MOUSE_CLICKED) {
      if (!buttonWithinClickThreshold(e.getX(), e.getY())) {
    // Discard the event by returing a miss
    return null;
      }
  }

  // Handle button clicked events specially. The mouse clicked event
  // comes after the grab has terminated. So we do this in order to
  // force the clicked event to go to the same destination as the
  // pressed event
  if (e.getID() == MouseEvent.MOUSE_CLICKED) {
      return new DetermineDestPickInfoReturn(lastButtonPressedPickInfo, lastButtonPressedPickInfo);
  }

  // First perform the pick (the pick details in the info are ordered
  // from least to greatest eye distance.
        PickInfo hitPickInfo;
  if (swingHitPickInfo == null) {
      hitPickInfo = pickEventScreenPos(e.getX(), e.getY());
      logger.finest("Result of pickEventScreenPos = " + hitPickInfo);
      if (hitPickInfo != null) {
    logger.finest("hitPickInfo.size() = " + hitPickInfo.size());
      }
  } else {
      hitPickInfo = swingHitPickInfo;
  }

  /* For Debug
  int n = hitPickInfo.size();
  System.err.println("n = " + n);
  for (int i = 0; i < n; i++) {
      PickDetails pd = hitPickInfo.get(i);
      System.err.println("pd[" + i + "] = " + pd);
      Entity pickEntity = pd.getEntity();
      System.err.println("entity[" + i + "] = " + pickEntity);
  }
  */

  // Calculate how the grab state should change. If the a grab should activate, activate it.
  GrabChangeType grabChange = GrabChangeType.GRAB_NO_CHANGE;
        int eventID = e.getID();
  if (eventID == MouseEvent.MOUSE_PRESSED ||
      eventID == MouseEvent.MOUSE_RELEASED) {

      grabChange = evaluateButtonGrabStateChange(eventID, e);
      if (grabChange == GrabChangeType.GRAB_ACTIVATE) {
    grabIsActive = true;
    grabPickInfo = hitPickInfo;
    logger.finest("Grab activate, grabPickInfo = " + grabPickInfo);
    if (grabPickInfo != null) {
        logger.finest("grabPickInfo.size() = " + grabPickInfo.size());
        if (grabPickInfo.size() > 0) {
      PickDetails pd = grabPickInfo.get(0);
      logger.finest("Grab pickDetails[0] = " + pd);
      if (pd != null) {
          logPickDetailsEntity(pd);
          CollisionComponent cc = pd.getCollisionComponent();
          logger.finest("cc = " + cc);
          if (cc != null) {
        logger.finest("cc entity = " + cc.getEntity());
          }
      }
        }
    }
      }
  }

  // If a grab is active, the event destination pick info will be the grabbed pick info
  PickInfo destPickInfo;
  logger.finest("grabIsActive = " + grabIsActive);
  if (grabIsActive) {
      destPickInfo = grabPickInfo;
      logger.finest("Grab is active, grabPickInfo = " + grabPickInfo);
  } else {
View Full Code Here

Examples of org.jdesktop.mtgame.PickInfo

            Vector3f target = new Vector3f(tIn);
            target.addLocal(0, DEFAULT_OFFSET.y, 0);
            dir.subtractLocal(target).normalizeLocal();
           
            Ray ray = new Ray(target, dir);
            PickInfo info = collisionSys.pickAllWorldRay(ray, true, false,
                                                         false, cameraComp);
            for (int i = 0; i < info.size(); i++) {
                // find the next picked object
                PickDetails details = info.get(i);
               
                // if the distance is less than the minimum, try the next
                // info
                if (details.getDistance() < MIN_DISTANCE) {
                    continue;
View Full Code Here

Examples of org.jdesktop.mtgame.PickInfo

        heightRay.direction = new Vector3f(0.0f, -1.0f, 0.0f);

        // Use the given collision system to find where the ground is. If we
        // find one, then return the distance to the ground with respect to
        // the given view position.
        PickInfo pi = collision.pickAllWorldRay(heightRay, true, false);
        if (pi.size() != 0) {
            // Grab the first one
            PickDetails pd = pi.get(0);
            return pd.getDistance() - yDelta;
        }

        // Otherwise, if we did not find any ground, then return -1
        return -1;
View Full Code Here

Examples of org.jdesktop.mtgame.PickInfo

        logger.info("For collidable, origin=" + position + " look at " +
                lookAt);

        // Use the given collision system to find where the closest collidable
        // object is.
        PickInfo pi = collision.pickAllWorldRay(heightRay, true, false);
        if (pi.size() != 0) {
            // Grab the first one
            PickDetails pd = pi.get(0);
            return pd.getDistance();
        }

        // Otherwise, if we did not find any ground, then return -1
        return -1;
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.