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()


Hope this helps;

C YA Phil :)

>===== Original Message From Discussion list for Java 3D API
<[EMAIL PROTECTED]> =====
>Thanks Kevin and Phil.
>
>Sticking a reference to the object I need in the user data is a good idea.
The only drawback is that I need to travers my scenegraph after having loaded
it and stick that reference in every node that can be picked - a bit of a
time-suck and space user for large scenes.
>
>I will try enabling pick reporting too. Perhaps if I enable pick reporting
for only the branch groups I'm interested in the scene graph path will contain
only those nodes... hmmm.. I'll give that a shot first.
>
>Josh
>
>>> [EMAIL PROTECTED] 03/03/03 09:34AM >>>
>Sure, data object isn't really a special term, I just mean an object to
>store your data. For instance, in my application I have a player who
>wanders round a world.
>
>For my player I have a J3D branch group called "Actor3D", actually actor
>3d represents any "actor" in the game (monsters, NPCs etc). The object I
>put in the user data is a set of data about which particular create the
>shape is representing. For instance, my player object knows what race it
>is (hence what model to use), what its wearing, and its name.
>
>In you case you could just have an object that "wraps" up all the data you
>want to store about the "thing" that the shape3d represents. So all you
>doubles/floats/strings get stuck inside this one object. When you pick the
>shape3d you pull out the user data and can just access the data without
>having to parse any strings (or such like).
>
>Its quite similar to a model/view standard OO pattern. The 3d world is
>just a view of the data that you are modelling.
>
>Obviously, just my view on things,
>
>Kev
>
>> Kevin
>>
>> Told you it may not be 100% accurate!  Could you tell me what you mean
>> by a data Object?  I have to store doubles, floats and strings in my
>> User data how would a data object benefit me?  Only been looking a t
>> Java for around a year now so new things are always poping up so a dta
>> Object must be one of them! any suggestions?
>>
>> C YA Phil :)
>>
>>
>>>===== Original Message From Discussion list for Java 3D API
>> <[EMAIL PROTECTED]> =====
>>> Hi Josh
>>>
>>> Not an expert on this but being as I have been doing a fair bit with
>>> picking lately I thought I mioght have a crack at helping you.  It is
>>> not possioble to get the parent of an object at runtime but I find
>>> two things are needed to solve you problem.  firstly if the
>>> scenegraph path objcet will only return objects that have the correct
>>> capability set (pick reporting I think!). Secondly carefully design
>>> the
>>> ".userData(Object obj)"  then user
>>> setUserData(obj);  and
>>> new oBj = getUserData()
>>>
>>> Then I use a string that I frmat and tokenise on reading it to get
>>> all the required data I need.  e.g Parents name, Translational
>>> vectors (needs casting back into double or floats after reading from
>>> the stringTokeniser()) and even if their are children attached.
>>>
>>>
>>>Just a slight addition. It might be nicer (and more efficent) if you
>>> store a specifically designed data object in the user data. Then you'd
>>> have all your data readily available and typed as soon as you got your
>>> picked node, instead of parsing the string.
>>>
>>> Hope this helps.
>>>
>>> C YA Phil :)
>>>
>>>
>>>
>>>>===== Original Message From Discussion list for Java 3D API
>>> <[EMAIL PROTECTED]> =====
>>>>Hi,
>>>>
>>>>I've been using the PickCanvas for some time now to pick 3D points in
>>>> my
>>> scene. Now I'd like to be able to distinguish which avatar was
>>> picked.. not just the Shape3D. I had the "bright" idea to extend
>>> BranchGroup with a class that includes a reference to the avatar
>>> object thinking that I could chase this parent up from the leaf that
>>> is picked. Of course when I tried this I get the restricted access
>>> exception.
>>>>
>>>>Is there an easy way to do this?
>>>>
>>>>I looked at the result returned  by getSceneGraphPath but it always
>>>> claims to
>>> have 0 nodes! (nodeCount() == 0).
>>>>
>>>>josh
>>>>
>>>>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".
>>>
>>> Philip J Colbert
>>> Software Engineer
>>> RCID, Bruce Building
>>> University of Newcastle Upon Tyne
>>> NE1 7RU
>>> Phone 0191-2225306
>>> Fax 0191-2225833
>>> This e-mail, including any attached files, may contain confidential
>>> and privileged information for the sole use of the intended
>>> recipient(s). If you are not the intended recipient, please note that
>>> any circulation or copying of this e-mail is strictly prohibited. If
>>> you have received this e-mail in error please contact the sender by
>>> reply e-mail and delete all copies of this message.
>>>
>>> The RCID makes every effort to ensure that this e-mail and any
>>> attachments are sent virus free. However it is the responsibility of
>>> the recipient to perform any checks they deem necessary.
>>>
>>>
===========================================================================
>>> 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".
>>>
>>>
>>>--
>>>Jose UML - http://www.newdawnsoftware.com/jose
>>>Pondering RPG - http://pondering.newdawnsoftware.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".
>>
>> Philip J Colbert
>> Software Engineer
>> RCID, Bruce Building
>> University of Newcastle Upon Tyne
>> NE1 7RU
>> Phone 0191-2225306
>> Fax 0191-2225833
>> This e-mail, including any attached files, may contain confidential and
>> privileged information for the sole use of the intended recipient(s). If
>> you are not the intended recipient, please note that any circulation or
>> copying of this e-mail is strictly prohibited. If you have received this
>> e-mail in error please contact the sender by reply e-mail and delete all
>> copies of this message.
>>
>> The RCID makes every effort to ensure that this e-mail and any
>> attachments are sent virus free. However it is the responsibility of the
>> recipient to perform any checks they deem necessary.
>>
>> ===========================================================================
>> 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".
>
>
>--
>Jose UML - http://www.newdawnsoftware.com/jose
>Pondering RPG - http://pondering.newdawnsoftware.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".
>
>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".

Philip J Colbert
Software Engineer
RCID, Bruce Building
University of Newcastle Upon Tyne
NE1 7RU
Phone 0191-2225306
Fax 0191-2225833
This e-mail, including any attached files, may contain confidential and privileged 
information for the sole use of the intended recipient(s). If you are not the intended 
recipient, please note that any circulation or copying of this e-mail is strictly 
prohibited. If you have received this e-mail in error please contact the sender by 
reply e-mail and delete all copies of this message.

The RCID makes every effort to ensure that this e-mail and any attachments are sent 
virus free. However it is the responsibility of the recipient to perform any checks 
they deem necessary.

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