Package com.sun.j3d.utils.picking

Examples of com.sun.j3d.utils.picking.PickResult


    PickCanvas pickCanvas = new PickCanvas(canvas, scene.getBranchgroup());
      pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
      pickCanvas.setTolerance(2.0f);
      pickCanvas.setShapeLocation(posX, posY);
      PickResult result = pickCanvas.pickClosest();

      if (result!=null) {
      Node node = result.getObject();
            Object o = node.getUserData();
            if (o instanceof ActiveNode) {
              ((ActiveNode)o).highlight(true,result);
                lastPickSelection.add(o);
                // pass full info to the active node so it can find which point is
View Full Code Here


      pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
      pickCanvas.setTolerance(Math.max(dx,dy));
      pickCanvas.setShapeLocation(posX, posY);

      // TODO : don't do pick closest, loop on all results
      PickResult result = pickCanvas.pickClosest();
      if (result!=null) {
      Node node = result.getObject();
            Object o = node.getUserData();
            if (o instanceof ActiveNode) {
              ((ActiveNode)o).highlight(true,result);
                lastPickSelection.add(o);
                // pass full info to the active node so it can find which point is
View Full Code Here

        _pickY=y;
        PickCanvas pickCanvas = new PickCanvas(_canvas, this._universe.getLocale());
        pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
        pickCanvas.setTolerance(2.0f);
        pickCanvas.setShapeLocation(_pickX, _pickY);
        PickResult result = pickCanvas.pickClosest();
        if(result==null){
            select(add, new Node[0]);
        }
        else{
            select(add, result.getObject());
        }
    }
View Full Code Here

                }
                select(add, n);
            }
        }
        else{
            PickResult result = pickCanvas.pickClosest();
            if(result==null){
                select(add, new Node[0]);
            }
            else{
                select(add, result.getObject());
            }
        }
    }
View Full Code Here

    // When picking, the parameter is always a PickResult
    // When selecting from the JTree, the parameter is not a PickResult
    // => ignore the JTree selection of the whole shape in this example
    if (!(parameter instanceof PickResult)) return;

    PickResult result = (PickResult)parameter;
    result.setFirstIntersectOnly(true);
    PickIntersection pi = result.getIntersection(0);

    // indices of the picked triangle
    // should always be triangle at this point
    // Indices are set to vertex indices, as this is not an Index Geometry object
    int[] idx = pi.getPrimitiveColorIndices();
View Full Code Here

  //Specification of the action to be carried out when an object is picked.
  public void updateScene(int xpos, int ypos)
  {
    Primitive pickedShape = null;
    pickCanvas.setShapeLocation(xpos,ypos);
    PickResult pResult = pickCanvas.pickClosest();
    if (pResult != null)
    {
      pickedShape = (Primitive) pResult.getNode(PickResult.PRIMITIVE);
    }

    if (pickedShape != null)
    {
      System.out.println("The object "+pickedShape.getUserData()+" has been selected.");
View Full Code Here

  public void updateScene(int xpos, int ypos)
  {
    Primitive pickedShape = null;
    pickCanvas.setShapeLocation(xpos,ypos);
    PickResult pResult = pickCanvas.pickClosest();
    if (pResult != null)
    {
      pickedShape = (Primitive) pResult.getNode(PickResult.PRIMITIVE);
    }

    if (pickedShape != null)
    {
      if (pickedShape.getUserData()=="box")
View Full Code Here

      vp.setViewPlatformBehavior(orbit);  
    }
   
    public void mouseClicked(MouseEvent e) {
      pickCanvas.setShapeLocation(e);
      PickResult result = pickCanvas.pickClosest();
        if (result == null) {
          System.out.println("Nothing picked");
        } else {
          Primitive p = (Primitive)result.getNode(PickResult.PRIMITIVE);
          Shape3D s = (Shape3D)result.getNode(PickResult.SHAPE3D);
         
          //*******************************************************************************
          //   This code will get you a reference to the sphere clicked on
          //   notice that it now prints out which sphere you clicked on
          SceneGraphPath myPath = result.getSceneGraphPath();
         
          //System.out.println( myPath.nodeCount() );
        //System.out.println(myPath.getObject().getClass());
         
          if(myPath.getObject() instanceof Shape3D)
View Full Code Here

    TransformGroup tg = null;

    if (!mevent.isMetaDown() && !mevent.isAltDown() && mevent.isShiftDown()){

      pickCanvas.setShapeLocation(xpos, ypos);
      PickResult pr = pickCanvas.pickClosest();
      if ((pr != null) &&
          ((tg = (TransformGroup)pr.getNode(PickResult.TRANSFORM_GROUP))
              != null) &&
              (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) &&
              (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))){
        drag.setTransformGroup(tg);
        drag.wakeup();
View Full Code Here

        this.canvas = canvas;
    }
   
    public void updateScene(int xpos, int ypos) {
      System.err.println("update scene ");
        PickResult pickResult = null;
        Primitive shape = null;

        pickCanvas.setShapeLocation(xpos, ypos);
        pickResult = pickCanvas.pickClosest();
       
        if (pickResult != null) {
           
            shape = (Primitive) pickResult.getNode(PickResult.PRIMITIVE);
            if(shape != null) {
               
                firePropertyChange("PeakSelected",
                        oldShape,
                        shape);
View Full Code Here

TOP

Related Classes of com.sun.j3d.utils.picking.PickResult

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.