You must transverse the scene graph and set the proper capability bit.
 I have some code about Scene object transverse. Test,debug and change to meet
your needs.

 Good Luck
Alessandro


//*************************************************
/**
 *  Transverse not compiled not live Scene, setting
 *  a CapabilityBit in all Shape3D in the Scene.
 * CapabilityBit <b>can not</b> be ORed or XORed. Apply one by one, in
sucessive calls to this method.
 * Valid CapabilityBit are:
 * <pre>
 * ALLOW_APPEARANCE_OVERRIDE_READ -  Specifies that this node allows reading
its appearance override enable flag.
 * ALLOW_APPEARANCE_OVERRIDE_WRITE - Specifies that this node allows writing
its appearance override enable flag.
 * ALLOW_APPEARANCE_READ -  Specifies that the node allows read access to its
appearance information.
 * ALLOW_APPEARANCE_WRITE - Specifies that the node allows write access to its
appearance information.
 * ALLOW_COLLISION_BOUNDS_READ  - Specifies that the node allows reading its
collision Bounds
 * ALLOW_COLLISION_BOUNDS_WRITE - Specifies the node allows writing its
collision Bounds
 * ALLOW_GEOMETRY_READ  - Specifies that the node allows read access to its
geometry information.
 * ALLOW_GEOMETRY_WRITE - Specifies that the node allows write access to its
geometry information.
 * </pre>
 *
 *  @param scene A loaded scene graph, not live and not compiled
 *  @param capBit the capability bit to be set
 *
 *  @throws
 *     CapabilityNotSetException - if the capaility is not one of the above
list
 **/
public void setCapabilityBitToShape3D(Scene scene, int capBit)
  {

         if (capBit != Shape3D.ALLOW_APPEARANCE_OVERRIDE_READ ||
             capBit != Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE ||
             capBit != Shape3D.ALLOW_APPEARANCE_READ ||
             capBit != Shape3D.ALLOW_APPEARANCE_WRITE||
             capBit != Shape3D.ALLOW_COLLISION_BOUNDS_WRITE ||
             capBit != Shape3D.ALLOW_COLLISION_BOUNDS_READ ||
             capBit != Shape3D.ALLOW_GEOMETRY_READ ||
             capBit != Shape3D.ALLOW_GEOMETRY_WRITE )
         {
                 new CapabilityNotSetException("This is not a valid CapabilityBit 
value for a
Shape3D");
         }

    Hashtable table=scene.getNamedObjects();
    // bug - transverse the same node several times

    Enumeration enum=table.elements();
    while (enum.hasMoreElements())
    {
      Object item= (Object)enum.nextElement();

      if (item instanceof Shape3D)
      {
        Shape3D shp= (Shape3D)item;
        shp.setCapability(capBit);
      }
      else
      if (item instanceof TransformGroup)
      {
        TransformGroup tgRoot= (TransformGroup)item;
        Vector vec=new Vector();

        getShape3D(vec, tgRoot);

        Enumeration en = vec.elements();
        while(en.hasMoreElements())
        {
          Shape3D shp = (Shape3D) en.nextElement();
          shp.setCapability(capBit);
        }

      }
    }
  }

 /**
  * recursively takes all Shape 3D from a a TG
 **/
  private void getShape3D(Vector vec, TransformGroup tg)
  {
    Enumeration enum=tg.getAllChildren();
    while (enum.hasMoreElements())
    {
      Object item= (Object)enum.nextElement();
      if (item instanceof Shape3D)
      {
        vec.add(item);
      }
      else if (item instanceof TransformGroup)
      {
        TransformGroup temp= (TransformGroup)item;
        getShape3D(vec, temp);
      }
    }
  }

/**
 *  Transverse not compiled not live Scene, setting
 *  a CapabilityBit in all Geometry objects in the Scene.
 *  CapabilityBit <b>can not</b> be ORed or XORed.
 *  Apply one by one, in sucessive calls to this method.
 *
 *  @param scene A loaded scene graph, not live and not compiled
 *  @param capBit the capability bit to be set
 **/

  public void setCapabilityBitToGeometries(Scene scene, int capBit)
    {

         if ()
         {
                 new CapabilityNotSetException("This is not a valid CapabilityBit 
value for
a Shape3D");
         }

      Hashtable table=scene.getNamedObjects();
      // bug - transverse the same node several times

      Enumeration enum=table.elements();
      while (enum.hasMoreElements())
      {
        Object item= (Object)enum.nextElement();

        if (item instanceof Shape3D)
        {
          Shape3D shp= (Shape3D)item;
          for (Enumeration e = shp.getAllGeometries(); e.hasMoreElements(); )
          {
                     ((Geometry)e.nextElement()).setCapability(capBit);
                  }
        }
        else
        if (item instanceof TransformGroup)
        {
          TransformGroup tgRoot= (TransformGroup)item;
          Vector vec=new Vector();

          getShape3D(vec, tgRoot);

          Enumeration en = vec.elements();
          while(en.hasMoreElements())
          {
            Shape3D shp = (Shape3D) en.nextElement();
                        for (Enumeration e = shp.getAllGeometries(); 
e.hasMoreElements(); )
                            {
                                   ((Geometry)e.nextElement()).setCapability(capBit);
                        }
          }

        }
      }
    }

// END CODE **********************************************************





 --- Rolf Gabler-Mieck <[EMAIL PROTECTED]> escreveu:
> Hi again,
>
>  there's another problem I got with geometry-picking....
> I load geometry from an OBJ-File (some polygones...)
> after the BranchGroup is filled up with the data from the file I'm doing
> this:
> public BranchGroup getLoadedFile(){
>   BranchGroup sceneRoot = new BranchGroup();
>   TransformGroup szeneScale = new TransformGroup();
>   sceneRoot.addChild(szeneScale);
>   TransformGroup szeneTrans = new TransformGroup();
>    szeneScale.addChild(szeneTrans);
>   //for all above read and write caps are set...
>
>  ...load the obj-file...
>
>    Enumeration e=loadedBG.getAllChildren();
>    setS3dCaps(e);
>    szeneTrans.addChild(loadedBG);
>    return sceneRoot;
> }
>
> public void setS3dCaps(Enumeration e){
>       while(e.hasMoreElements()){
>          Object o = e.nextElement();
>          if (o instanceof Shape3D){
>               Shape3D S = (Shape3D) o;
>               S.setCapability(Geometry.ALLOW_INTERSECT);
>          }
>          if (o instanceof Group) {
>              Group g = (Group) o;
>              g.setCapability(Group.ALLOW_CHILDREN_WRITE); //could not be
> needed ?
>              g.setCapability(Group.ALLOW_CHILDREN_READ); //could not be
> needed ?
>              g.setCapability(Geometry.ALLOW_INTERSECT);
>              this.setS3dCaps(g.getAllChildren());
>          }
>       }
>   }
> OK, then I add the loaded BG into my BranchGraph as a child of a BranchGroup
> which has also my PickiningBehavior as a child.
> The PickingBehavior know the "loaded BG" since the construction, where
> pickCanvas.setMode(PickTool.GEOMETRY);    is set.
>
> when I click to the Geometry the capabilityNotSet Error hit me, that
> Shape3D has no Capability of "allow intersect" but would not be
> recognized....
>
> if I generate some Text3D objects and
> gave them
> txt3d.setCapability(Geometry.ALLOW_INTERSECT);
> and  construct the PickingBehavior with the parent-BranchGroup of the text3D
> instead of  BG which is the loadedBG
> all is working fine without any errors.....
>
> has anybody an idea  in how to solve this???
>
>
>

>
> sad but true with the identical results...nothing is detectable...so if
> anybody find any weirdness in this code
> please let me know....
>
> best regards
> rolf
>
> --
> Rolf Gabler-Mieck
> c/o
> LGI-Geographisches Institut der CAU-Kiel
> Ludewig-Meyen Str. 14
> 24098 Kiel
> Tel: +49 431-880.2955
> FAX: +49 431-880.4658
> e-mail: [EMAIL PROTECTED]
>


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

===========================================================================
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