/**
* This example creates a Switch Node and conditionally displays some of the
* child Nodes using a logical mask, defined using a BitSet object.
*/ public class SwitchTest extends Java3dApplet { private static final int m_kWidth = 400;
if (bDisplayAll == false) {
java.util.BitSet visibleNodes = new java.util.BitSet(switchGroup
.numChildren());
// make the third, sixth and seventh nodes visible
visibleNodes.set(2);
visibleNodes.set(5);
visibleNodes.set(6);
switchGroup.setChildMask(visibleNodes);
}
// finally add the Switch Node
objRoot.addChild(switchGroup);
return objRoot;
}
// creates a Text2D label and scales it
// the method shifts each label created downwards.
// Note that the labels on adjacent lines will overlap
// so we can illustrate the function of the OrderedGroup
TransformGroup createLabel(String szText, double scale) {
Color3f colorText = new Color3f(); int nFontSizeText = 10;
Text2D label3D = new Text2D(szText, colorText, "SansSerif",
nFontSizeText, Font.PLAIN);
TransformGroup tg = new TransformGroup();
Transform3D t3d = new Transform3D();
public static void main(String[] args) {
SwitchTest SwitchTest = new SwitchTest();
SwitchTest.saveCommandLineArguments(args);
new MainFrame(SwitchTest, m_kWidth, m_kHeight);
}
}
/*******************************************************************************
* Copyright (C) 2001 Daniel Selman
*
* First distributed with the book "Java 3D Programming" by Daniel Selman and
* published by Manning Publications. http://manning.com/selman
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* The license can be found on the WWW at: http://www.fsf.org/copyleft/gpl.html
*
* Or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite
* 330, Boston, MA 02111-1307, USA.
*
* Authors can be contacted at: Daniel Selman:
This e-mail address is being protected from spam bots, you need JavaScript enabled to view it
*
* If you make changes you think others would like, please contact one of the
* authors or someone at the www.j3d.org web site.
******************************************************************************/
//*****************************************************************************
/**
* Java3dApplet
*
* Base class for defining a Java 3D applet. Contains some useful methods for
* defining views and scenegraphs etc.
*
* @author Daniel Selman
* @version 1.0
*/
//*****************************************************************************
abstract class Java3dApplet extends Applet { public static int m_kWidth = 300;
public TransformGroup[] getViewTransformGroupArray() {
TransformGroup[] tgArray = new TransformGroup[1];
tgArray[0] = new TransformGroup();
// move the camera BACK a little...
// note that we have to invert the matrix as
// we are moving the viewer
Transform3D t3d = new Transform3D();
t3d.setScale(getScale());
t3d.setTranslation(new Vector3d(0.0, 0.0, -20.0));
t3d.invert();
tgArray[0].setTransform(t3d);
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.