public void testEquality() { OrbitViewLighting sl0 = new OrbitViewLighting(); OrbitViewLighting sl1 = new OrbitViewLighting(); assertEquals(sl0,sl1); sl1.setPosition(1,new float[] { 2.0f, 0.0f, 0.0f }); assertNotEquals(sl0,sl1); sl1 = new OrbitViewLighting(); sl1.setAmbient(1, RED); assertNotEquals(sl0,sl1); sl1 = new OrbitViewLighting(); sl1.setDiffuse(1, RED); assertNotEquals(sl0,sl1); sl1 = new OrbitViewLighting(); sl1.setSpecular(1, RED); assertNotEquals(sl0,sl1); sl1 = new OrbitViewLighting(); sl1.setLightSourceType(1, lp); assertNotEquals(sl0,sl1); sl1 = new OrbitViewLighting(); sl1.setAmbientAndDiffuse(RED); sl0.setAmbientAndDiffuse(RED); assertEquals(sl0,sl1); }
/** * 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"); }
public void testLightToggle() { OrbitViewLighting l = new OrbitViewLighting(); assertTrue(l.isLightOn()); l.toggleLight(0); assertFalse(l.isLightOn()); l.toggleLight(0); assertTrue(l.isLightOn()); }
/** * 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"); }
/** * To maintain functionality with the legacy l in the JTK, the * default l should have: * 1. Single directional light source at (-0.1,-0.1,1.0) * 2. Ambient light set to (0,0,0,1) * 3. Diffuse light set to (1,1,1,1) * 4. Specular light set to (1,1,1,1) */ public void testDefaultParameters() { OrbitViewLighting l = new OrbitViewLighting(); assertEquals(l.getLightSourceType(0), ld); assertArrayEquals(l.getAmbient(0), BLACK,0); assertArrayEquals(l.getSpecular(0), WHITE,0); assertArrayEquals(l.getDiffuse(0), WHITE,0); assertArrayEquals(l.getPosition(0), POS, 0); assertTrue(l.isLightOn(0)); assertEquals(l.getLightSourceType(1), ld); assertArrayEquals(l.getAmbient(1), BLACK,0); assertArrayEquals(l.getSpecular(1), WHITE,0); assertArrayEquals(l.getDiffuse(1), WHITE,0); assertArrayEquals(l.getPosition(1), POS, 0); assertFalse(l.isLightOn(1)); assertEquals(l.getLightSourceType(2), ld); assertArrayEquals(l.getAmbient(2), BLACK,0); assertArrayEquals(l.getSpecular(2), WHITE,0); assertArrayEquals(l.getDiffuse(2), WHITE,0); assertArrayEquals(l.getPosition(2), POS, 0); assertFalse(l.isLightOn(2)); }
OrbitViewLighting l = new OrbitViewLighting(); float[] newpos = new float[] { 5.0f, 5.0f, 5.0f };