Skip to main content

Advice for load textures II

1 reply [Last post]
bein82
Offline
Joined: 2006-02-14

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 ? Maybe is the solution.

I have this code but always the program show me a mistake in PixelGrabber pixelGr

/*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();}
*/

My function texture:

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.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous

see here about garbage collection:
http://www.javadesktop.org/forums/thread.jspa?forumID=55&threadID=12123&...
hope it helps

p.s.:
why you posting same message twice? :-)