Hi Java3D:

I can get my program to run as an application.  But, when I try to run it as an

applet I get a null pointer exception in my ImageComponent2D.

I am a newbie so I do not know where I am going wrong.

What is it that I do not know?

Can I get a clue?

Michael Carter, student

----------------------- see below -----------------------

This methods gives a NullPointerException

  at Javax.media.j3d.ImageComponent2D<init>(ImageComponent2D.java:166)
 
 
 

   void getTextures()
   {
      System.out.println("attempt to load texture from file: " + "sky.jpg" );
      tex = new TextureLoader("sky.jpg", new String("RGB"), this);
      textureAppear = new Appearance[5] ;
      String[] filename = new String[6] ;
      filename[0] = new String("file:./computer.jpg") ;
      filename[1] = new String("file:./circuit.jpg") ;
      filename[2] = new String("file:./wall.jpg") ;
      filename[3] = new String("file:./wall2.jpg") ;
      filename[4] = new String("file:./ground.jpg") ;
      for( int i = 0; i < 5; i++)
      {
         System.out.println("attempt to load texture from file: "+filename[i]);
         TextureLoader loader = null ;
            try
            {
               loader = new TextureLoader( new URL( filename[i] ), this);
            }
            catch (java.net.MalformedURLException e)
            {
               System.out.println( e.getMessage() ) ;
               System.exit(1) ;
            }
         ImageComponent2D image = loader.getImage() ;
         Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGB,
                                         image.getWidth(), image.getHeight()) ;

         if(image == null)
            System.out.println("load failed for texture: "+filename[i]) ;
            texture.setImage(0, image);
            texture.setEnable(true);
            texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
            texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);
            textureAppear[i] = new Appearance() ;
            textureAppear[i].setTexture(texture) ;
      }
   }

 

Reply via email to