Problem with applet

Hi

I cannot display an applet

It's clearly a permission error but I cannot solve it


SEVERE: Exception in game loop
java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
   at java.security.AccessControlContext.checkPermission(Unknown Source)
   at java.security.AccessController.checkPermission(Unknown Source)
   at java.lang.SecurityManager.checkPermission(Unknown Source)
   at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
   at java.lang.System.getProperty(Unknown Source)
   at java.io.Win32FileSystem.getUserPath(Unknown Source)
   at java.io.Win32FileSystem.resolve(Unknown Source)
   at java.io.File.getAbsolutePath(Unknown Source)
   at java.io.File.getAbsoluteFile(Unknown Source)
   at java.io.File.toURI(Unknown Source)
   at it.F1Viewer3D.ModelLoader.load3ds(ModelLoader.java:65)
   at it.F1Viewer3D.ModelLoader.load3ds(ModelLoader.java:37)
   at it.F1Viewer3D.Car.build(Car.java:94)
   at it.F1Viewer3D.Car.<init>(Car.java:88)
   at it.F1Viewer3D.Applet.buildCar(Applet.java:469)
   at it.F1Viewer3D.Applet.initGame(Applet.java:366)
   at com.jmex.awt.applet.BetterBaseJMEApplet.gameLoop(BetterBaseJMEApplet.java:125)
   at com.jmex.awt.applet.BetterBaseJMEApplet$1.run(BetterBaseJMEApplet.java:97)
27-giu-2009 14.00.46 com.jmex.awt.applet.BetterBaseJMEApplet$1 run
INFO: Application ending.



http://www.mediterrando.net/pauroleague/f1/f1viewer3d/

I don't know how to solve it (all my jars are signed)

bye

you've got multiple certificates there, they don't really work too well with applets, best to delete all the certificates in the jars and sign everything again with a single certificate.

faust said:

you've got multiple certificates there, they don't really work too well with applets, best to delete all the certificates in the jars and sign everything again with a single certificate.


but the problem happens when I try to read a file out of the jar (a 3ds file)
are you sure?

you better sign that jar as well

I've signed all

But now I cannot find 3ds models that I have to import

I thought was a file extension problem sue to provider (so I changed extension in .zip)

But…





java.io.FileNotFoundException: mediabox.3ds.zip (Impossibile trovare il percorso specificato)

at java.io.FileInputStream.open(Native Method)

at java.io.FileInputStream.<init>(Unknown Source)

at java.io.FileInputStream.<init>(Unknown Source)

at it.F1Viewer3D.ModelLoader.load3ds(ModelLoader.java:70)

at it.F1Viewer3D.ModelLoader.load3ds(ModelLoader.java:37)

at it.F1Viewer3D.BuildCircuito.getTerrainElement(BuildCircuito.java:666)

at it.F1Viewer3D.BuildCircuito.drawPista(BuildCircuito.java:640)

at it.F1Viewer3D.BuildCircuito.save(BuildCircuito.java:146)

at it.F1Viewer3D.BuildCircuito.initGui(BuildCircuito.java:324)

at it.F1Viewer3D.BuildCircuito.<init>(BuildCircuito.java:319)

at it.F1Viewer3D.Applet.buildTrack(Applet.java:701)

at it.F1Viewer3D.Applet.initGame(Applet.java:355)

at com.jmex.awt.applet.BetterBaseJMEApplet.gameLoop(BetterBaseJMEApplet.java:125)

at com.jmex.awt.applet.BetterBaseJMEApplet$1.run(BetterBaseJMEApplet.java:97)

File not found at: media/box.3ds.zip

27-giu-2009 17.14.43 class it.F1Viewer3D.Applet start()

GRAVE: Exception in game loop

java.lang.NullPointerException

at it.F1Viewer3D.ModelLoader.load3ds(ModelLoader.java:97)

at it.F1Viewer3D.ModelLoader.load3ds(ModelLoader.java:37)

at it.F1Viewer3D.BuildCircuito.getTerrainElement(BuildCircuito.java:666)

at it.F1Viewer3D.BuildCircuito.drawPista(BuildCircuito.java:640)

at it.F1Viewer3D.BuildCircuito.save(BuildCircuito.java:146)

at it.F1Viewer3D.BuildCircuito.initGui(BuildCircuito.java:324)

at it.F1Viewer3D.BuildCircuito.<init>(BuildCircuito.java:319)

at it.F1Viewer3D.Applet.buildTrack(Applet.java:701)

at it.F1Viewer3D.Applet.initGame(Applet.java:355)

at com.jmex.awt.applet.BetterBaseJMEApplet.gameLoop(BetterBaseJMEApplet.java:125)

at com.jmex.awt.applet.BetterBaseJMEApplet$1.run(BetterBaseJMEApplet.java:97)

27-giu-2009 17.14.43 com.jmex.awt.applet.BetterBaseJMEApplet$1 run

INFO: Application ending.



media folder is a subfolder of main directory

any idea?



thanks

bye

:smiley:

Is the media folder inside a JAR?

Haladria said:

Is the media folder inside a JAR?


no
where should I put it?
truman said:

no
where should I put it?


put it into a jar :)
Core-Dump said:

truman said:

no
where should I put it?


put it into a jar :)


thanks, it works !!!!
but now I have another problem: applet can't find textures from 3ds models (jpg are in the same folder)
this is my modelloader:


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
 
 
import com.jme.bounding.BoundingBox;
import com.jme.scene.Spatial;
import com.jme.util.export.binary.BinaryImporter;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.model.converters.FormatConverter;
import com.jmex.model.converters.MaxToJme; //.3ds
 
 
public class ModelLoader {
 
   static final FormatConverter CONVERTER_3DS = new MaxToJme();
 
   /**
    * Imports a .3ds model from file system. Like the 2-argument method
    * with a null textureDir. The texture file(s) are assumed to be in the
    * same directory as the model file.
    * @param modelPath the path to the model file.
    * Can be relative to the project directory.
    * @return a Spatial containing the model geometry
    * (with provided texture, if any) that can be attached to
    *  the scenegraph, or null instead if unable to load geometry.
    */
   public static Spatial load3ds(String modelPath) {
      return load3ds(modelPath, null);
   }
 
   /**
    * Imports a .3ds model from file system.
    * @param modelPath the path to the model file.
    * Can be relative to the project directory.
    * @param textureDir the path to the directory with the model's
    *  textures. If null, this will attempt to infer textureDir from
    *  modelPath, which assumes that the texture file(s) are in the same
    *  directory as the model file.
    * @return a Spatial containing the model geometry
    * (with provided texture, if any) that can be attached to
    *  the scenegraph, or null instead if unable to load geometry.
    */
   public static Spatial load3ds(String modelPath, String textureDir) {
      Spatial output = null; // the geometry will go here.
      final ByteArrayOutputStream outStream =
         new ByteArrayOutputStream(); // byte array streams don't have to be closed
      try {
         final File textures;
         if(textureDir != null) { // set textureDir location
            textures = new File( textureDir );
         } else {// try to infer textureDir from modelPath.
            textures = new File(
                  modelPath.substring(0, modelPath.lastIndexOf('/')) );
         }   // Add texture URL to auto-locator
         final SimpleResourceLocator location =
            new SimpleResourceLocator(textures.toURI().toURL());
            ResourceLocatorTool.addResourceLocator(
                  ResourceLocatorTool.TYPE_TEXTURE, location );
 
         // read .3ds file into memory & convert it to a jME usable format.
         final FileInputStream rawIn = new FileInputStream(modelPath);
         CONVERTER_3DS.convert(rawIn, outStream);
         rawIn.close(); // FileInputStream s must be explicitly closed.
 
         // prepare outStream for loading.
         final ByteArrayInputStream convertedIn =
            new ByteArrayInputStream(outStream.toByteArray());
 
         // import the converted stream to jME as a Spatial
         output = (Spatial) BinaryImporter.getInstance().load(convertedIn);
      } catch (FileNotFoundException e) {
         e.printStackTrace();
         System.err.println("File not found at: " + modelPath);
      } catch (IOException e) {
         e.printStackTrace();
         System.err.println("Unable read model at: " + modelPath);
      } catch (URISyntaxException e) {
         e.printStackTrace();
         System.err.println("Invalid texture location at:" + textureDir);
      }   /*
      * The bounding box is an important optimization.
      * There is no point in rendering geometry outside of the camera's
      * field of view. However, testing whether each individual triangle
      * is visible is nearly as expensive as actually rendering it. So you
      * don't test every triangle. Instead, you just test the bounding box.
      * If the box isn't in view, don't bother looking for triangles inside.
         */
      output.setModelBound(new BoundingBox());
      output.updateModelBound();
      return output;
   }
}



how can I say to it to look for textures in my jar?
thanks bye

Set up the ResourceLocator correctly.

It needs to point to the Folder containing the textures (don't forget the trailing slash)

new SimpleResourceLocator(your/package/data/textures/);

Core-Dump said:

Set up the ResourceLocator correctly.
It needs to point to the Folder containing the textures (don't forget the trailing slash)

new SimpleResourceLocator(your/package/data/textures/);




I need an url
I wrote


 location = new SimpleResourceLocator(getClass().getResource( "./media/" ) );
 


but I get

java.lang.NullPointerException: baseDir can not be null.
at com.jme.util.resource.SimpleResourceLocator.<init>(SimpleResourceLocator.java:61)
at it.F1Viewer3D.ModelLoader.load3ds(ModelLoader.java:77)


don't think you need the ./ bit

tried


   
URL texturesUrl =getClass().getResource( "it/F1Viewer3D/media/" );
location = new SimpleResourceLocator(texturesUrl);
              ResourceLocatorTool.addResourceLocator(
                     ResourceLocatorTool.TYPE_TEXTURE, location );



no luck

Is there any way to relink textures after loading models?

Textures are applied with TextureStates to Nodes. :slight_smile:

Don