I'm having problems with picking imported .flt data.

My situation: I've imported some objects representing space objects (satellites, 
planets, etc.) with FullSail's openflt loader. One of these objects is a sphere with a 
texture that represents the stars in the sky. My ViewPlatform is always somewhere 
within this sphere.
When using a PickCanvas in PickTool.Bounds mode the only object I can pick is this 
'stars' object with PickCanvas.pickClosest(). Could this be because I'm always within 
the bounds of the the sphere?

I've tried to set the PickCanvas mode to PickTool.Geometry. The imported geometry 
capabilities are updated with a few methods I saw on this list (originally for VRML 
objects; see attached code) to at least set set the Geometry.ALLOW_INTERSECT 
capability.
When I want to pick an object I get a CapabilityNotSetException: Shape3D: no 
capability to allow intersect. Am I forgetting something/doing somethin completely 
wrong?

Thanks in advance,
Joost Verschuren

----------------

>Datum: Tue, 4 Mar 2003 08:32:49 +0000
>Van: Philip J Colbert <[EMAIL PROTECTED]>
>Antwoord naar: Discussion list for Java 3D API <JAVA3D->[EMAIL PROTECTED]>
>Naar: [EMAIL PROTECTED]
>Onderwerp: Re: [JAVA3D] Finding parent of a picked leaf node  Alle koppen
>Josh
>
>I think you have got the right idea I don't enable pick reporting on all my
>objects but I do have a couple of methods that may help you.  I use a Vrml
>loader and I have to set my capabilities on the run as it were!  so I use
>these two methods:

/*
*****************************************************************************
       Method to set the capabilites required on the Vrml shape

       @Param scene = the loaded scene from the loadVrml method
*****************************************************************************
*/
  public void setCapabilities(Scene scene)
  {
    Hashtable VRMLObjects = new Hashtable();
    VRMLObjects = scene.getNamedObjects();
    int numOfObjects = VRMLObjects.size();
    Enumeration eNumKey = VRMLObjects.keys() ;
    Enumeration eNumValue = VRMLObjects.elements();
    if (eNumValue != null)
    {
      while(eNumValue.hasMoreElements()!= false)
      {
        Object value = eNumValue.nextElement();
        Object key = eNumKey.nextElement();
        setCap((Node)value);
      }// End while(eNumValue.hasMoreElements()!= false)
    }// End if (eNumValue != null)
  }// End of method
/*
*****************************************************************************
       Recursive Method to set the capabilites required on the Vrml shape

       @Param = node the individual mode to set capabilities on.
*****************************************************************************
*/
  public void setCap(Node node)
  {
    if (node instanceof Group)
    {
      Enumeration en = ((Group)node).getAllChildren();
      while (en.hasMoreElements())
      {
        setCap((Node)en.nextElement());
      }// End of while (en.hasMoreElements())
    }// End of if (node instanceof Group)
    else if (node instanceof Link)
    {
      setCap(((Link)node).getSharedGroup());
    }// End of if (node instanceof Link)
    else if (node instanceof Shape3D)
    {
      node.setUserData(uData);
      //System.out.println("User Data added to imported Vrml shape = \n"
      //                   +node.getUserData());
      node.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
      node.setCapability(Shape3D.ALLOW_LOCAL_TO_VWORLD_READ);
      node.setCapability(Shape3D.ALLOW_PICKABLE_WRITE);
      node.setCapability(Shape3D.ALLOW_PICKABLE_READ);
      node.setCapability(Shape3D.ENABLE_PICK_REPORTING);
      node.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
      node.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
      Shape3D shape = (Shape3D)node;
      Enumeration en = shape.getAllGeometries();
      while (en.hasMoreElements())
      {
        Geometry geometry = (Geometry)en.nextElement();
        if (geometry instanceof TriangleArray)
        {
          TriangleArray TA = (TriangleArray)geometry;
          TA.setCapability(GeometryArray.ALLOW_FORMAT_READ);
          TA.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
          TA.setCapability(GeometryArray.ALLOW_COUNT_READ);
          TA.setCapability(GeometryArray.ALLOW_INTERSECT);
          TA.setCapability(GeometryArray.ALLOW_FORMAT_READ);
          TA.setCapability(GeometryArray.ALLOW_NORMAL_READ);
        }// End if (geometry instanceof TriangleArray)
        else //doSomethingWithGeometry(geometry);
        {
          if (geometry instanceof TriangleStripArray)
          {
            TriangleStripArray TA = (TriangleStripArray)geometry;
            TA.setCapability(GeometryArray.ALLOW_FORMAT_READ);
            TA.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
            TA.setCapability(GeometryArray.ALLOW_COUNT_READ);
            TA.setCapability(GeometryArray.ALLOW_INTERSECT);
            TA.setCapability(GeometryArray.ALLOW_FORMAT_READ);
            TA.setCapability(GeometryArray.ALLOW_NORMAL_READ);
          }// End if (geometry instanceof TriangleStripArray)
          else
          if(geometry instanceof QuadArray)
          {
            QuadArray TA = (QuadArray)geometry;
            TA.setCapability(QuadArray.ALLOW_FORMAT_READ);
            TA.setCapability(QuadArray.ALLOW_COORDINATE_READ);
            TA.setCapability(QuadArray.ALLOW_COUNT_READ);
            TA.setCapability(QuadArray.ALLOW_INTERSECT);
            TA.setCapability(QuadArray.ALLOW_FORMAT_READ);
            TA.setCapability(QuadArray.ALLOW_NORMAL_READ);
          }// End if(geometry instanceof QuadArray)
        }// End else
      }// End of while (en.hasMoreElements())
    }// End if (node instanceof Shape3D)
    else
    {
      // ignore the rest because you don't
      //know what it can be,behaviours, lights, or else...
    } //end else
  }//end of method// End of setCapabilities()

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to