package applets.picker; import shout3d.*; import shout3d.core.*; public class Picker3Panel extends Shout3DPanel implements DeviceObserver { Picker myPicker; Node[] pathToPick; Material activeMat; float[] on = {.5f, .5f, .5f}; float[] off = {0f, 0f, 0f}; public Picker3Panel(Shout3DApplet applet) { super(applet); } public void customInitialize() { myPicker = getNewPicker(); addDeviceObserver(this, "MouseInput", null); } protected void finalize() { removeDeviceObserver(this, "MouseInput"); } public boolean onDeviceInput(DeviceInput di, Object userData) { MouseInput mi = (MouseInput) di; if (mi.which == MouseInput.MOVE){ pathToPick = myPicker.pickClosest(mi.x,mi.y); //if something intersected if (pathToPick != null) { Shape s = (Shape) pathToPick[pathToPick.length-2]; Appearance ap = (Appearance) s.appearance.getValue()[0]; activeMat = (Material) ap.material.getValue(); activeMat.emissiveColor.setValue(on); } //if nothing intersected else { if (activeMat!= null) { activeMat.emissiveColor.setValue(off); activeMat = null; } } return true; } return false; } }