WaterRenderPass in Applet

I have ported the WaterRenderPass example used in TestQuadWater.java over to an SimpleJMEApplet.  My demo works when it is ran from Eclipse but I get an error when I try running it from a browser (Firefox and Epiphany).



java.lang.SecurityException: Unable to create temporary file
   at java.io.File.checkAndCreate(File.java:1701)
   at java.io.File.createTempFile(File.java:1793)
   at javax.imageio.stream.FileCacheImageInputStream.<init>(FileCacheImageInputStream.java:80)
   at com.sun.imageio.spi.InputStreamImageInputStreamSpi.createInputStreamInstance(InputStreamImageInputStreamSpi.java:51)
   at javax.imageio.ImageIO.createImageInputStream(ImageIO.java:331)
   at javax.imageio.ImageIO.read(ImageIO.java:1325)
   at com.jme.util.TextureManager.loadImage(Unknown Source)
   at com.jme.util.TextureManager.loadImage(Unknown Source)
   at com.jme.util.TextureManager.loadImage(Unknown Source)
   at com.jme.util.TextureManager.loadTexture(Unknown Source)
   at com.jme.util.TextureManager.loadTexture(Unknown Source)
   at com.jmex.effects.water.WaterRenderPass.initialize(Unknown Source)
   at com.jmex.effects.water.WaterRenderPass.<init>(Unknown Source)
   at myapp.www.client.MyGameApplet.simpleAppletSetup(MyGameApplet.java:85)
   at com.jmex.awt.applet.SimpleJMEApplet$SimpleAppletCanvasImplementor.simpleSetup(Unknown Source)
   at com.jmex.awt.SimpleCanvasImpl.doSetup(Unknown Source)
   at com.jmex.awt.lwjgl.LWJGLCanvas.paintGL(Unknown Source)
   at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:308)
   at org.lwjgl.opengl.AWTGLCanvas.update(AWTGLCanvas.java:339)
   at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239)
   at sun.awt.X11.XRepaintArea.updateComponent(XRepaintArea.java:43)
   at sun.awt.RepaintArea.paint(RepaintArea.java:216)
   at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:688)
   at java.awt.Component.dispatchEventImpl(Component.java:4577)
   at java.awt.Component.dispatchEvent(Component.java:4331)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
   at myapp.www.client.MyGameApplet.simpleAppletUpdate(MyGameApplet.java:154)
   at com.jmex.awt.applet.SimpleJMEApplet$SimpleAppletCanvasImplementor.simpleUpdate(Unknown Source)
   at com.jmex.awt.SimpleCanvasImpl.doUpdate(Unknown Source)
   at com.jmex.awt.lwjgl.LWJGLCanvas.paintGL(Unknown Source)
   at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:308)
   at org.lwjgl.opengl.AWTGLCanvas.update(AWTGLCanvas.java:339)
   at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239)
   at sun.awt.X11.XRepaintArea.updateComponent(XRepaintArea.java:43)
   at sun.awt.RepaintArea.paint(RepaintArea.java:216)
   at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:688)
   at java.awt.Component.dispatchEventImpl(Component.java:4577)
   at java.awt.Component.dispatchEvent(Component.java:4331)
   at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)



The applet work before I added WaterRenderPass feature to my applet.  All jars are signed.  It seems  to me that WaterRenderPass needs to create a temp file on the file system and the browser will not allow this. Any help is appreciated.

If this is Windows Vista, try using IE ('enhanced' security in Vista keeps some programs from being able to write files); to get Firefox to work properly you may have to run it as the Administrator.



(if this is not Windows Vista please post OS :))

I'm trying this on Ubuntu.  I tried on Windows XP with the same issue. Also, I have never got my applet to run in IE. It just stops at "INFO: LWJGL Display System created.".  Getting JME Applets to work really is a lot of work.

Maybe I should rephrase this into a more simple question.  Is WaterRenderPass compatible with applets?

I figured out my issue.  I didn't actually sign my jme-effects jar plus I needed to include jmetest.jar since the WaterRenderPass class uses some resources from it.  Also, for anyone who is interested you can port the code from the TestQuadWater class into your applet.  You need to change any calls like display.getRenderer() to just getRenderer() since SimpleJMEApplet is setup differently than a SimpleGame.  The hard part is adding the  BasicPassManager.  Just add a class level variable (Or whatever just needs to be accessible to the methods where its used):



    protected BasicPassManager pManager;


Initialize pManager on simpleAppletSetup().


    pManager=new BasicPassManager();


Add this to simpleAppletRender()


pManager.renderPasses(getRenderer());


Finally add this to your simpleAppletUpdate()


pManager.updatePasses(getTimePerFrame());


All the code from TestQuadWater should compile now and run.

Good info! I haven't delved into the murky world of jME applets yet but I'm looking forward to it already  XD

Run while you still can!  Web Starts are so much easier to get up and running.  Applets are such a pain because of permissions.