/** * Sets the background color to the given color. * * @param color The color to set the background as. */ public static void setBackground (Color color) { if (!color.equals(bgColor)) { bgColor = color; rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); background.setColor(new Color3f(bgColor)); bgGroup.addChild(background); rootGroup.addChild(bgGroup); } }
private void setColor (Group g, Color c) { for (int i = 0; i < g.numChildren(); i++) { Node child = g.getChild(i); if (child instanceof Shape3D) { Shape3D shape = (Shape3D)child; Appearance ap = shape.getAppearance(); setColor(ap, c); } else if (child instanceof Primitive) { Primitive primitive = (Primitive)child; Appearance ap = primitive.getAppearance(); setColor(ap, c); } else if (child instanceof Group) { setColor((Group)child, c); } } }
private void importGroup( RenderableQualityModel result, Group j3dScene, Transform3D transformation, double[] lower, double[] upper ) { Enumeration<Node> en = j3dScene.getAllChildren(); LOG.debug( "importting a group." ); while ( en.hasMoreElements() ) {
/** * Sets the background image to the given filename, scaled to fit the window. * * @param imageURL The filename for the background image. */ public static void setBackground (String imageURL) { rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); BufferedImage bi = null; try { bi = ImageIO.read(new File(imageURL)); } catch (IOException ioe) {ioe.printStackTrace(); } if (bi == null) { try { ImageIO.read(new URL(imageURL)); } catch (Exception e) { e.printStackTrace(); } } ImageComponent2D imageComp = new ImageComponent2D(ImageComponent.FORMAT_RGB, bi); background.setImage(imageComp); background.setImageScaleMode(Background.SCALE_FIT_ALL); bgGroup.addChild(background); rootGroup.addChild(bgGroup); }
private void setColor (Group g, Color c) { for (int i = 0; i < g.numChildren(); i++) { Node child = g.getChild(i); if (child instanceof Shape3D) { Shape3D shape = (Shape3D)child; Appearance ap = shape.getAppearance(); setColor(ap, c); } else if (child instanceof Primitive) { Primitive primitive = (Primitive)child; Appearance ap = primitive.getAppearance(); setColor(ap, c); } else if (child instanceof Group) { setColor((Group)child, c); } } }
/** * Sets the background image to the given filename, scaled to fit the window. * * @param imageURL The filename for the background image. */ public static void setBackground (String imageURL) { rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); BufferedImage bi = null; try { bi = ImageIO.read(new File(imageURL)); } catch (IOException ioe) {ioe.printStackTrace(); } if (bi == null) { try { ImageIO.read(new URL(imageURL)); } catch (Exception e) { e.printStackTrace(); } } ImageComponent2D imageComp = new ImageComponent2D(ImageComponent.FORMAT_RGB, bi); background.setImage(imageComp); background.setImageScaleMode(Background.SCALE_FIT_ALL); bgGroup.addChild(background); rootGroup.addChild(bgGroup); }
/** * Sets the background color to the given color. * * @param color The color to set the background as. */ public static void setBackground (Color color) { if (!color.equals(bgColor)) { bgColor = color; rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); background.setColor(new Color3f(bgColor)); bgGroup.addChild(background); rootGroup.addChild(bgGroup); } }
/** * Sets the background to the given image file. The file gets * wrapped around as a spherical skybox. * * @param imageURL The background image to use. */ public static void setBackgroundSphere (String imageURL) { Sphere sphere = new Sphere(1.1f, Sphere.GENERATE_NORMALS | Sphere.GENERATE_NORMALS_INWARD | Sphere.GENERATE_TEXTURE_COORDS, numDivisions); Appearance ap = sphere.getAppearance(); Texture texture = createTexture(imageURL); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.REPLACE); ap.setTexture(texture); ap.setTextureAttributes(texAttr); sphere.setAppearance(ap); BranchGroup backGeoBranch = createBranchGroup(); backGeoBranch.addChild(sphere); rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); background.setGeometry(backGeoBranch); bgGroup.addChild(background); rootGroup.addChild(bgGroup); }
/** * Sets the background to the given image file. The file gets * wrapped around as a spherical skybox. * * @param imageURL The background image to use. */ public static void setBackgroundSphere (String imageURL) { Sphere sphere = new Sphere(1.1f, Sphere.GENERATE_NORMALS | Sphere.GENERATE_NORMALS_INWARD | Sphere.GENERATE_TEXTURE_COORDS, numDivisions); Appearance ap = sphere.getAppearance(); Texture texture = createTexture(imageURL); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.REPLACE); ap.setTexture(texture); ap.setTextureAttributes(texAttr); sphere.setAppearance(ap); BranchGroup backGeoBranch = createBranchGroup(); backGeoBranch.addChild(sphere); rootGroup.removeChild(bgGroup); bgGroup.removeChild(background); background = createBackground(); background.setGeometry(backGeoBranch); bgGroup.addChild(background); rootGroup.addChild(bgGroup); }