Did not have time to dig deeply in the sources to find the problem; but something
minor and
with normally no incidence on your problem hit my eyes.
You don't have to load multiple files to have the mipmapping done. Just use
TextureLoader.getScaledInstance() to get a scaled down version of your image. this
way, you only have one
file on your hard drive, and you cut the initialisation time.
For the rest, i don't know.
At 06/02/2003 15:58:00, you wrote:
>Hi, all:
>
>I was trying MIPmapping on my tree texture mapping, hoping that the JVM
>will pickup the resolution for the tree rendering so that the scene will
>display certain degree of depth. I know many of you have done the MIPmap on
>the terrain. But I don't know this is feasible for tree objects. Now I am
>stuck here, got a NullPointerException at Appearance.setTexture(texture),
>see below error msg.
>
>java.lang.NullPointerException
> at
>javax.media.j3d.TextureRetained.checkSizes(TextureRetained.java:406)
> at javax.media.j3d.TextureRetained.setLive(TextureRetained.java:943)
> at
>javax.media.j3d.AppearanceRetained.setTexture(AppearanceRetained.java
>:166)
> at javax.media.j3d.Appearance.setTexture(Appearance.java:527)
> at TreeBranchGroup2D.treeTexureMapping(TreeBranchGroup2D.java:164)
> ... ...
>where TreeBranchGroup2D is my code. The texure, appear were not null. All
>the image files were loaded. I don't know how to trace down the error and
>about to quit. If anyone knows that this is not the way to go, please point
>it out. Thanks for any input!
>
>Lan
>
>
>The code I was using to setup the MIPmap is as follows>
>
> String textFile = System.getProperty( "user.dir"
>)+"/images/"+"pine1024.png";
> TextureLoader loader = new NewTextureLoader(textFile);
> ImageComponent2D image = loader.getImage();
> imageWidth = image.getWidth();
> imageHeight = image.getHeight();
>
> Texture2D texture = new Texture2D(Texture.MULTI_LEVEL_MIPMAP,
>Texture.RGBA,
> imageWidth, imageHeight);
> imageLevel = 0;
> texture.setImage(imageLevel, image);
> texture.setEnable(true);
>
> while (imageWidth > 1 || imageWidth > 1){
> imageLevel++;
> if (imageWidth > 1) imageWidth /= 2;
> if (imageHeight > 1) imageHeight /= 2;
>
> textFile = System.getProperty( "user.dir"
>)+"/images/"+"pine"+imageWidth+".png";
> loader = new NewTextureLoader(textFile);
> image = loader.getImage();
> texture.setImage(imageLevel, image);
> }
>
> texture.setMagFilter(Texture.BASE_LEVEL_POINT);
> texture.setMinFilter(Texture.MULTI_LEVEL_POINT);
>
>texture.setBoundaryModeS(Texture.CLAMP_TO_EDGE );
>texture.setBoundaryModeT(Texture.CLAMP_TO_EDGE ); // get the texture
>from the loader
>
> TextureAttributes texAttr = new TextureAttributes();
> texAttr.setTextureMode(TextureAttributes.REPLACE);
>
> for (int i=0; i<ConstRepository.TREE_SPECIES.length; i++)
> {
> if (texture ==null || appear[i]==null)
> System.out.println("null appear or texture");
>
> appear[i].setTexture(texture);
> RenderingAttributes renderAtt =
>appear[i].getRenderingAttributes();
>
>renderAtt.setCapability(RenderingAttributes.ALLOW_IGNORE_VERTEX_COLORS_WRITE);
>
> renderAtt.setIgnoreVertexColors(true);
>
> appear[i].setTextureAttributes(texAttr);
> appear[i].setTransparencyAttributes(
> new
>TransparencyAttributes(TransparencyAttributes.BLENDED, 0f));
> }
>
>
>
>Lan Wu-Cavener
>Dept. of Landscape Architecture
>
>===========================================================================
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff JAVA3D-INTEREST". For general help, send email to
>[EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".