Here is an example of scaling by running through the
scenegraph :

The scaling function is called as this:

            BranchGroup brGrp = (BranchGroup)switchGroup.getChild(i);
            System.out.println("nscale: Number of children of BranchGroup =
" + brGrp.numChildren());

            Enumeration enum = brGrp.getAllChildren();

            nodeLevel = 0;
            maxNodeLevel = 0;
            scaleOnLowestLevel(enum,0.5f);

This is the function that scales:

    public void scaleOnLowestLevel(Enumeration enum, float scale){
        nodeLevel++;
        System.out.println("scaleOnLowestLevel: nodeLevel = "+nodeLevel);
        while (enum.hasMoreElements()) {
            Object tmpObject = enum.nextElement();

            if (tmpObject instanceof Shape3D) {
                System.out.println("scaleOnLowestLevel: a shape3D");
            } else if (tmpObject instanceof TransformGroup) {
                if (nodeLevel > maxNodeLevel) maxNodeLevel = nodeLevel;
                System.out.println("scaleOnLowestLevel: deepest transform
level : " + maxNodeLevel);
                System.out.println("scaleOnLowestLevel: a transformgroup");
                TransformGroup tmptransformGroup =
(TransformGroup)tmpObject;

                Transform3D trans = new Transform3D();
                tmptransformGroup.getTransform(trans);
                System.out.println("scaleOnLowestLevel: originally transform
= " + trans);

                Transform3D transnew = new Transform3D();
                tmptransformGroup.setTransform(transnew);

                Enumeration nextenum = tmptransformGroup.getAllChildren();

                scaleOnLowestLevel(nextenum,scale);

                if (nodeLevel == maxNodeLevel) {
                    System.out.println("scaleOnLowestLevel: originally
transform = " + trans);
                    trans.setScale(0.5);
                    tmptransformGroup.setTransform(trans);
                    System.out.println("scaleOnLowestLevel: modified
transform = " + trans);
                } else {
                    tmptransformGroup.setTransform(trans);
                }

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

                Enumeration groupenum = tmpGroup.getAllChildren();

                scaleOnLowestLevel(groupenum,scale);
            } else {
                System.out.println("scaleOnLowestLevel: What is this
thing?");
            }
        }
        nodeLevel--;
    }


Hope it helps you out !

Ole Vilmann
Danish Maritime Institute


-----Original Message-----
From: Andreas Ebbert [mailto:[EMAIL PROTECTED]]
Sent: 6. november 2000 22:49
To: [EMAIL PROTECTED]
Subject: [JAVA3D] vrml again, sorry


Hi,

I know this has been said before, but I cannot find it in the archives
:-( There was a way to scale/translate the Shape3Ds, read via the vrml97
loader, to origin and fitting into the unit cube. Could you please tell
me how this was done?

Thank you so much!

Andreas

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