/** Company: Shout3D LLC Project: Shout3D 2.0 Sample Code Class: ExaminePanel Date: April 3, 2000 Description: Class for ExaminePanel (C) Copyright Shout3D LLC. - 1997-2001 - All rights reserved */ package applets; import shout3d.core.*; import shout3d.*; /** * A SelectAPanoramaPanel. * * @author Dave Westwood * @author Paul Isaacs * @author Jim Stewartson */ public class SelectAPanoramaPanel extends ExaminePanel implements DeviceObserver { Panorama panorama; EnvironmentCubeMap envCubeMap; MultiMesh[] meshes; /** * Constructs me */ public SelectAPanoramaPanel(Shout3DApplet applet) { super(applet); } /** * Constructs me */ public SelectAPanoramaPanel(Shout3DApplet applet, int width, int height) { super(applet,width, height); } /** * Remove observers when done with the panel */ public void finalize()throws Throwable { applet.getDeviceListener().removeDeviceObserver(this, "DeviceInput"); applet.getRenderer().removeRenderObserver(this); // required so that ExaminePanel's finalize() . super.finalize(); } /** * Overrides Shout3DPanel.customInitialize() */ public void customInitialize() { // required to get super class ExaminePanel's full functionality super.customInitialize(); // register for device input applet.getDeviceListener().addDeviceObserver(this, "DeviceInput", null); // register for rendering notification applet.getRenderer().addRenderObserver(this, null); Searcher mySearcher = getNewSearcher(); // reference to Panorama mySearcher.setType("Panorama"); Node[] path = mySearcher.searchFirst(getScene()); if (path!=null && path.length>0) { panorama = (Panorama)path[path.length-1]; } // reference to EnvironmentCubeMap used in a Panorama mySearcher.setType("EnvironmentCubeMap"); path = mySearcher.searchFirst(getScene()); if (path!=null && path.length>0) { envCubeMap = (EnvironmentCubeMap)path[path.length-1]; } // reference to env mapped meshes mySearcher.setType("MultiMesh"); Node[][] paths = mySearcher.searchAll(getScene()); if (paths!=null && paths.length>0) { meshes = new MultiMesh[paths.length]; for (int i = 0; i < paths.length; i++) { meshes[i] = (MultiMesh)paths[i][paths[i].length-1]; } } // Turn off antialiasing so that the env map will change even if // camera is still mySearcher.setType("StillCamProgAntialias"); path = mySearcher.searchFirst(getScene()); if (path!=null && path.length>0) { StillCamProgAntialias aa = (StillCamProgAntialias)path[path.length-1]; aa.enabled.setValue(false); } } public boolean onDeviceInput(DeviceInput di, Object userData) { // required to get super class ExaminePanel's full functionality return super.onDeviceInput(di, userData); } ImageTexture itex; /** * Set the EnvironmentCubeMap textures and/or change bilinear filtering * if we are waiting to do so. * * Note that no onPreRender() method is implemented in this class, * even though it is required for all classes implementing RenderObserver. * This is because the super class implements RenderObserver fully * and onPreRender is inherited. * Hence this class needs only to override the onPostRender() method, * making sure to call super.onPostRender(r,userData) within the body * of the method. */ public void onPostRender(Renderer r, Object userData) { // required to get super class ExaminePanel's full functionality super.onPostRender(r, userData); if (envCubeMap!= null && set_envmap_urls) { itex = (ImageTexture) envCubeMap.frontTexture.getValue(); if (itex != null) itex.url.setValue(new String[]{frontmap}); itex = (ImageTexture) envCubeMap.rightTexture.getValue(); if (itex != null) itex.url.setValue(new String[]{rightmap}); itex = (ImageTexture) envCubeMap.backTexture.getValue(); if (itex != null) itex.url.setValue(new String[]{backmap}); itex = (ImageTexture) envCubeMap.leftTexture.getValue(); if (itex != null) itex.url.setValue(new String[]{leftmap}); itex = (ImageTexture) envCubeMap.upTexture.getValue(); if (itex != null) itex.url.setValue(new String[]{upmap}); itex = (ImageTexture) envCubeMap.downTexture.getValue(); if (itex != null) itex.url.setValue(new String[]{downmap}); set_envmap_urls = false; } if (envCubeMap != null && set_bilerp_enabled) { envCubeMap.bilinearFilteringEnabled.setValue(bilerp_enabled); panorama.bilinearFilteringEnabled.setValue(bilerp_enabled); set_bilerp_enabled = false; } } boolean set_envmap_urls = false; String frontmap, rightmap, backmap, leftmap, upmap, downmap; public void setEnvMaps(String _frontmap, String _rightmap, String _backmap, String _leftmap, String _upmap, String _downmap) { frontmap = _frontmap; rightmap = _rightmap; backmap = _backmap; leftmap = _leftmap; upmap = _upmap; downmap = _downmap; set_envmap_urls = true; } boolean set_bilerp_enabled = false; boolean bilerp_enabled = true; public void setBilerpEnabled(boolean _bilerp_enabled){ set_bilerp_enabled = true; bilerp_enabled = _bilerp_enabled; } }