/** * Creates a blank Background with the proper capabilities. * * @return The created Background. */ private static Background createBackground () { Background background = new Background(); background.setCapability(Background.ALLOW_COLOR_WRITE); background.setCapability(Background.ALLOW_IMAGE_WRITE); background.setCapability(Background.ALLOW_GEOMETRY_WRITE); background.setApplicationBounds(INFINITE_BOUNDS); return background; }
/** * Fixe la couleur du fond. */ public void setBackground(final Color _c) { background_.setColor(new Color3f(_c)); // getCanvas3D().waitForSwap(); }
private void buildFond(Color3f _c) { if (background_ == null) { background_ = _c == null ? new Background(0F, 0F, 0F) : new Background(_c); background_.setCapability(Background.ALLOW_COLOR_WRITE); background_.setCapability(Background.ALLOW_COLOR_READ); background_.setCapability(Background.ALLOW_APPLICATION_BOUNDS_READ); background_.setCapability(Background.ALLOW_APPLICATION_BOUNDS_WRITE); // background_.setApplicationBounds(new BoundingSphere(new Point3d(0, 0, 0), 1E12)); background_.setBoundsAutoCompute(true); final BranchGroup fond = new BranchGroup(); fond.addChild(background_); fond.setCapability(BranchGroup.ALLOW_DETACH); addBranchGraph(fond); } }
Background background = new Background(); background.setColor(0.285f, 0.285f, 0.3f); background.setApplicationBounds(bounds); objRoot.addChild(background);
/** * 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 updateFond(GrBoite _boite) { buildFond(null); if (_boite == null) return; double maxDist = Math.max(Math.max(_boite.getDeltaX(), _boite.getDeltaY()), _boite.getDeltaZ()); background_.setApplicationBounds(new BoundingSphere(new Point3d(_boite.getMidX(), _boite.getMidY(), _boite .getMidZ()), maxDist * 20)); }
/** * 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 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 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); }
/** * Creates a blank Background with the proper capabilities. * * @return The created Background. */ private static Background createBackground () { Background background = new Background(); background.setCapability(Background.ALLOW_COLOR_WRITE); background.setCapability(Background.ALLOW_IMAGE_WRITE); background.setCapability(Background.ALLOW_GEOMETRY_WRITE); background.setApplicationBounds(INFINITE_BOUNDS); return background; }
public void setImmediateBackground(final Color _c) { if (background_ == null) buildFond(new Color3f(_c)); else background_.setColor(new Color3f(_c)); }
/** * 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 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); } }