/** * 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); }