Hi

As you load your VRML scene you get at branche group. With this in
your hand you can run down through your scenegraph and pick the
Shape3D nodes. From these nodes you can get your "vectors and indexes"
as you call it.

I have included an example of change of color of an object. In my
example a object is located below a switch group such that I only change
the color of one object. I think you can easily modify the code to
accomplish your task.

Ole Vilmann
Danish Maritime Institute


// Call the iterative color change function by this

            Enumeration enum = brGrp.getAllChildren();

            Color3f color = new Color3f(1.0f,0.0f,0.0f);

            changeColor(enum,color);

// The iterative color change is like this
    public void changeColor(Enumeration enum, Color3f color){
        while (enum.hasMoreElements()) {
            Object tmpObject = enum.nextElement();

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

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

                // Material
                Material mat = appear.getMaterial();

                System.out.println("color: the original material : "+mat);
                mat.setDiffuseColor(color);

                Color3f color1 = new Color3f(0.5f, 0.5f, 0.5f);
                mat.setSpecularColor(color1);

                Color3f color2 = new Color3f(0.0f, 0.0f, 0.0f);
                mat.setEmissiveColor(color2);

                Color3f color3 = new Color3f();
                color3 = color;
                color3.x *= 0.2;
                color3.y *= 0.2;
                color3.z *= 0.2;
                mat.setAmbientColor(color3);

                appear.setMaterial(mat);

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

                Enumeration nextenum = tmptransformGroup.getAllChildren();

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

                Enumeration groupenum = tmpGroup.getAllChildren();

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



-----Original Message-----
From: Vlad Valica [mailto:[EMAIL PROTECTED]]
Sent: 22. august 2000 16:13
To: [EMAIL PROTECTED]
Subject: [JAVA3D] VRML97 problem


Hi!

I have a big problem with the package (com.sun.j3d.loaders.*) that can
browse the VRML97 models.
I made a little application to browse the models (wrl) and now I really
need to have the structures of models (the vector with points, the vector
with index). The wrl model is loaded somewhere but I don't know how can I
find this structures.
I will be very very happy if you can help me.
Thanks a lot,

Vlad Valica

*********************************************
*                                           *
* Vlad Valica                               *
*                                           *
* tel:  bureau: 01.60.76.47.02              *
*               01.60.76.44.37              *
*       maison: 01.60.76.64.47              *
*                                           *
*                                           *
*********************************************

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