To do this you must set the capabilities before you add the
BG to the scenegraph.

I do it this way:

            Enumeration enum = sceneGroup.getAllChildren();
            setVRMLCapabilities(enum);
            switchGroup.addChild(sceneGroup);

The capablilties are set by the setVRMLCapabilities. This member functions
sets all the capabilities of all the nodes in the VRML scene graph before
adding to the scenegraph.

    public void setVRMLCapabilities(Enumeration enum){
        while (enum.hasMoreElements()) {
            Object tmpObject = enum.nextElement();

            if (tmpObject instanceof Shape3D) {
                System.out.println("setVRMLCapabilities: a shape3D");

((Shape3D)tmpObject).setCapability(Shape3D.ALLOW_APPEARANCE_READ);

((Shape3D)tmpObject).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);

                Appearance appear = ((Shape3D)tmpObject).getAppearance();


appear.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_READ);

appear.setCapability(Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE);
                appear.setCapability(Appearance.ALLOW_MATERIAL_READ);
                appear.setCapability(Appearance.ALLOW_MATERIAL_WRITE);

                Material mat = appear.getMaterial();
                mat.setCapability(Material.ALLOW_COMPONENT_READ);
                mat.setCapability(Material.ALLOW_COMPONENT_WRITE);

            } else if (tmpObject instanceof TransformGroup) {
                System.out.println("setVRMLCapabilities: a transformgroup");
                TransformGroup tmptransformGroup =
(TransformGroup)tmpObject;


tmptransformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);

tmptransformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_READ);

tmptransformGroup.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);

tmptransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

tmptransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

                Enumeration nextenum = tmptransformGroup.getAllChildren();

                setVRMLCapabilities(nextenum);
            } else if(tmpObject instanceof Group){
                System.out.println("setVRMLCapabilities: a group");
                Group tmpGroup = (Group)tmpObject;

                tmpGroup.setCapability(BranchGroup.ALLOW_DETACH);
                tmpGroup.setCapability(BranchGroup.ALLOW_BOUNDS_READ);
                tmpGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
                tmpGroup.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);

tmpGroup.setCapability(BranchGroup.ALLOW_LOCAL_TO_VWORLD_READ);

                Enumeration groupenum = tmpGroup.getAllChildren();

                setVRMLCapabilities(groupenum);
            } else {
                System.out.println("setVRMLCapabilities: What is this
thing?");
            }
        }
    }

Ole Vilmann
Danish Maritime Institute

-----Original Message-----
From: Tina Manoharan Valappil [mailto:[EMAIL PROTECTED]]
Sent: 23. november 2000 21:14
To: [EMAIL PROTECTED]
Subject: [JAVA3D] RestrictedAccessException - VRMLloader


        Dear all,

        this is a part of my scene graph

        TG
        |
        BG (ALLOW_CHILDREN_WRITE & ALLOW_CHILDREN_EXTEND)

        To this I am adding a scenegraph dynamically with VRMLloader.
        The new additions to it are

                BG (from VRMLloader)
        |               |
        BG1             BG2
        |               |
        Shape3D1        Shape3D2

        Now if I want to set the capability(ALLLOW_APPEARANCE_READ) to the
        Shape3D 1 & 2 . It is giving me RestrictedAccessException. So, I
        tried giving the BG1 & BG2 , ALLOW_CHILDREN_WRITE capability but it
also
        gave a RestrictedAccessException cannot set capability bits on a
live or
        compiled object. ( I knew that this wouldnt work but just a try)

        Can somebody please tell me as to how I can set the capability for
        the children shape3Ds which I am dynamically loading with a
VRMLloader.


        Thanks
        Tina

Tina Manoharan
PhD. Heriot Watt University
Ph: 07801 069485 / 07740 959483 (mobile)
Ph: 0131 449 5111 ext. 4191 (office)
Ph: 0131 449 5111 ext. 4197 (lab)

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

Reply via email to