/** * Demos re-positioning the light source to the top-right corner. */ private static void demo1() { Sphere sphere = new Sphere(); StateSet states = StateSet.forTwoSidedShinySurface(Color.WHITE); sphere.setStates(states); World world = new World(); world.addChild(sphere); SimpleFrame sf = new SimpleFrame(world); OrbitViewLighting ovl = new OrbitViewLighting(); ovl.setPosition(0,1.0f,1.0f,0.0f); ovl.setLightSourceType(LightSourceType.DIRECTIONAL); sf.getOrbitView().setOrbitViewLighting(ovl); sf.setTitle("OrbitViewLighting Demo: Re-positioned primary light"); }
/** * Demos activating all three lights and assigning colors. */ private static void demo2() { Sphere sphere = new Sphere(); StateSet states = StateSet.forTwoSidedShinySurface(Color.WHITE); sphere.setStates(states); World world = new World(); world.addChild(sphere); SimpleFrame sf = new SimpleFrame(world); OrbitViewLighting ovl = new OrbitViewLighting(); ovl.setPosition(0,-2.0f, 2.0f,0.0f); ovl.setPosition(1, 2.0f, 2.0f,0.0f); ovl.setPosition(2, 0.0f,-2.0f,0.0f); ovl.setLightSourceType(0, LightSourceType.POSITIONAL); ovl.setLightSourceType(1, LightSourceType.POSITIONAL); ovl.setLightSourceType(2, LightSourceType.POSITIONAL); ovl.setDiffuse(0,RED); ovl.setDiffuse(1,GREEN); ovl.setDiffuse(2,BLUE); ovl.toggleLight(1); ovl.toggleLight(2); sf.getOrbitView().setOrbitViewLighting(ovl); sf.setTitle("OrbitViewLighting Demo: Three Lights"); }