Skip to main content

Advice for load textures

2 replies [Last post]
bein82
Offline
Joined: 2006-02-14
Points: 0

I wish know the method more effective for load textures
quickly , I load around 40 objects each one whit a different texture, but this is very slow,I use objects of the class Texture Loader .

Send me the response to my email please : bein82@hotmail.com

Thank you

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
pepe
Offline
Joined: 2003-06-10
Points: 0

hello.
are you sure it's texture loading that takes time? how did you do to make sure it is?
What is the uncompressed size of your textures? do they have a chance to all fit in the memory of your graphics board?

bein82
Offline
Joined: 2006-02-14
Points: 0

Thank you for to answer my message. Well , I build many cubes which are scaled for to get different figures: for example tables, walls, pictures, etc. In this figures for each face correspond a different texture, I use the class Geometry Info for generate this figures.

I have a scene which there are four bedrooms, when I load this escene for firs time the process for put all textures is a little slow, but the next times this process become very slow and afterwards the program show me the following message:

java.lang.OutOfMemoryError
Error loading Image duela.jpg
java.lang.NullPointerException
at javax.media.j3d.ImageComponent2D.(ImageComponent2D.java:166)
at com.sun.j3d.utils.image.TextureLoader.getImage(TextureLoader.java:525

I need know the manner which I can put all my textures in the bedrooms quickly and without the former message. My textures are of 256*256 , format jpg

Do you have some example using the temporary memory Buffer ? [u]Maybe is the solution. [/u]

I have this code but always the program show me a mistake in [i]PixelGrabber pixelGr[/i]

/*BufferedImage buffImage= new BufferedImage(256,256,BufferedImage.TYPE_INT_ARGB);
ImageComponent2D image =new ImageComponent2D(ImageComponent2D.FORMAT_RGBA,buffImage);
int []imageData=((DataBufferInt)buffImage.getRaster().getDataBuffer()).getData();
PixelGrabber pixelGr = new PixelGrabber(image,0,0,256,256,imageData,0,256);
try {pixelGr.grabPixels();}
catch (InterruptedException e) {
e.printStackTrace();}
*/

[b]My function texture:[/b]

public void textura(Appearance ap,String string){
String filename = string;
TextureLoader loader = new TextureLoader(filename,new String("RGBA"),TextureLoader.GENERATE_MIPMAP, this);
ImageComponent2D image = loader.getImage();

Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA,image.getWidth(), image.getHeight());
texture.setImage(0, image);
texture.setEnable(true);

TextureAttributes textAttr = new TextureAttributes();
textAttr.setTextureMode(TextureAttributes.DECAL);
textAttr.setPerspectiveCorrectionMode(TextureAttributes.NICEST );
Transform3D rotate=new Transform3D();
rotate.rotZ(Math.PI);
textAttr.setTextureTransform(rotate);//rotando las texturas pa q esten derechas

ap.setTextureAttributes(textAttr);
texture.setBoundaryModeT(Texture.WRAP);
texture.setBoundaryModeS(Texture.WRAP);
texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);
texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
ap.setTexture(texture);
}

I hope your answer. Thank you.