Hi Ali,

I have just done this.  I used the code from this mail -

http://swjscmail1.java.sun.com/cgi-bin/wa?A2=ind0207&L=java3d-interest&P=R47218

I have just seen that there is a PickTest example included in Java 3D,
see section "G.3.21 PickTest" on -

http://java.sun.com/products/java-media/3D/forDevelopers/J3D_1_3_API/j3dguide/Ap
pendixExamples.html

A couple of points that came up with my work, I do not know if they are
relavent to you -

I load my scene from a file (X3D), so I need to go through the whole
scene graph and make everything 'pickable'.  I set loads of
capabilities (see code below) but it could be that you only need
ENABLE_PICK_REPORTING of something (as in the PickTest from Sun).

My code is here -

    public static void setAllCapabilitys(Group sceneRoot)
    {
        int i = 0;
        for (Enumeration children = sceneRoot.getAllChildren();
children.hasMoreElements() ; i++)
        {
            Node child = (Node) children.nextElement();
            System.out.println("child " + i + " = " + child + " getPickable() =
" + child.getPickable());
            try
            {
                setAllCapabilitys((Group) child);
/*                for (Enumeration children2 = ((BranchGroup)
child).getAllChildren(); children2.hasMoreElements() ;)
                {
                    Node child2 = (Node) children2.nextElement();
                    System.out.println("child2 = " + child2 + " getPickable() =
" + child2.getPickable());
                } */
            } catch (java.lang.ClassCastException e)
            {
                try
                {
                    System.out.println("numGeometries = " + ((Shape3D)
child).numGeometries());
                    ((Shape3D)
child).setCapability(Shape3D.ALLOW_GEOMETRY_READ);
                    for(int j = 0; j < (((Shape3D) child).numGeometries()); ++j)
                    {
                        Geometry geometry = ((Shape3D) child).getGeometry(j);
                        try
                        {
                            IndexedGeometryArray array = ((IndexedGeometryArray)
geometry);
                            System.out.println("array = " + array);

array.setCapability(IndexedGeometryArray.ALLOW_COORDINATE_READ);

array.setCapability(IndexedGeometryArray.ALLOW_COUNT_READ);

array.setCapability(IndexedGeometryArray.ALLOW_FORMAT_READ);

array.setCapability(IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ);

array.setCapability(IndexedGeometryArray.ALLOW_COLOR_INDEX_READ );

array.setCapability(IndexedGeometryArray.ALLOW_COLOR_INDEX_WRITE );
//                            array.setCapability(GeometryArray.);
                        } catch (java.lang.ClassCastException exc)
                        {
                            e.printStackTrace();
                        }
                    }
                } catch (java.lang.ClassCastException ex)
                {
                    e.printStackTrace();
                }
            }

        }
    }

Hope this helps somewhat, let me know if I can be of anymore help, on or off
list,

Hugh

>Delivered-To: [EMAIL PROTECTED]
>MIME-Version: 1.0
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
>Subject: [JAVA3D] help needed about 'picking'
>To: [EMAIL PROTECTED]
>X-Razor-id: a1f2c3e6076028fec8e963d4fbcf1e2769d4628f
>
>Hi all,
>
>I created my scene which contains many Shape3D objects. I used VirtualUniverse
to create this.
>
>Now I want to pick the shapes in this scene by mouse clicks and by by mouse
windows (selecting the objects which fall into a window created by a mouse
dragging).
>
>However I need some example code to implement this. This is very important for
me as it is the final phase of my project.
>
>Can anybody help me about this.
>
>
>Ali Murat Tanyer
>University of Salford

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