Deploying Textures in JWS

Hi,

I am trying to deploy my app using JWS
my app contains some simple shapes with textures.

I have been adding the textures using the following code:

Texture2D textureSphere = null;

TextureLoader tl = new TextureLoader();
textureSphere = (Texture2D)tl.getMinMapTexture("./DemoOBJ/skyboxs/sky_up.jpg");

Appearance a = new Appearance();
a.setTexture(textureSphere);

this works fine for local development
I realise that for JWS I should be using a URL - can anybody show me how to do this given the above code.

Cheers

rmdire

Ok
I know I can use :
ThisClass.class.getClassLoader().getResource(“sprites/mySprite.png”);

but textureloader functions for loading textures accepts a string not a URL.

please help anybody

cheers

Rmdire

Hi,

I have come up with the following function
I am not sure that this is the best way:

public Texture2D loadMyTexture(String MyTexturePath) {
TextureLoader tl = new TextureLoader();
Texture2D texture;
BufferedImage bufferedImage = null;
java.net.URL url = getClass().getResource(MyTexturePath);
try {
bufferedImage = javax.imageio.ImageIO.read(url);
} catch (Exception e)
{
e.printStackTrace();
}
return (Texture2D)tl.constructTexture(bufferedImage,“RGBA”,false,Texture.BASE_LEVEL,Texture.BASE_LEVEL_LINEAR,Texture.WRAP,false,0);

     }

can anybody tell me if there is a better way.

cheers

rmdire

this is a major PITA.

My current recommendation is to bundle the textures in their own .jar file (in the root directory of that .jar). In your code, use the TextureLoader and refer to the file names only (no path info). If you want to venture outside the root directory - still refer to the files only but register the “Jar Path” first. Reading the source code for TextureLoader is a good idea.

One day I will fully investigate this, and work out the best way to do it.

Will.

This will get the URL as a string.

getClass().getClassLoader().getResource(MyTexturePath).getPath();