Transparency Issue

I'm trying to just apply the Monkey.jpg picture to a sphere, and the sphere just shows up as white.  Here's the code:


private void buildPlayer () {
      
      // Get a URL that points to the texture we're going to load
      URL monkeyLoc;
      monkeyLoc = Runner.class.getClassLoader().getResource(
            "/home/alex/Programming/Java3D/jme/bin/jmetest/data/images/Monkey.jpg");
 
      // Get a TextureState
      TextureState ts = display.getRenderer().createTextureState();
      // Use the TextureManager to load a texture
      Texture t = TextureManager.loadTexture(monkeyLoc,
            Texture.MinificationFilter.BilinearNearestMipMap,
            Texture.MagnificationFilter.Bilinear);
      // Assign the texture to the TextureState
      ts.setTexture(t);

      Sphere sphere = new Sphere ("Sphere", 10, 10, 1f);
      sphere.setModelBound (new BoundingSphere ());
      sphere.updateModelBound ();
      sphere.setRenderState (ts);
      player = new Node ("Player Node");
      player.setLocalTranslation (new Vector3f (100, 0, 100));
      rootNode.attachChild (player);
      player.attachChild (sphere);
      player.updateWorldBound ();      
   }



It's very simple code, most if it's copied directly from tutorials.  Does anyone see something I'm doing wrong?

Thanks!

Try calling:

sphere.updateRenderState();


after you set the render state.

Oh thank you, that worked!

Oi, new problem.  For some reason my box is partially transparent - when I'm right above it, I can see through the top (I'll post a picture).  Again, my code is pretty much copy and pasted from the Wiki -


protected void initGame() {
      Box temp = new Box ("Box", new Vector3f (0,0,0), new Vector3f (100, 10, 10));
 
      Node node = new Node ("Lower Root Node");
      
      node.attachChild (temp);
      // Get a MaterialState
      MaterialState ms = display.getRenderer().createMaterialState();
      // Give the MaterialState an emissive tint
      ms.setEmissive(new ColorRGBA(0f, .2f, 0f, 1f));
 
      // Create a point light
      PointLight l = new PointLight();
      // Give it a location
      l.setLocation(new Vector3f(0, 10, 5));
      // Make it a red light
      l.setDiffuse(ColorRGBA.red.clone());
      // Enable it
      l.setEnabled(true);
 
      // Create a LightState to put my light in
      LightState ls = display.getRenderer().createLightState();
      // Attach the light
      ls.attach(l);
      
      node.setRenderState (ls);
      node.setRenderState (ms);

      node.updateRenderState ();
      rootNode.attachChild (node);

      buildPlayer ();
      
      input = new RunnerInputHandler (player.getChild ("Sphere"),settings.getRenderer ());
      
      buildChaseCamera ();

   }



Here's the picture - http://yfrog.com/5ndarntransparencyp .  The red is the bottom, so of course you shouldn't be able to see that...

Thanks for the help!

maybe a missing ZBufferstate?

Err sorry but I'm not quite sure how I use ZBufferState.  Do you have any examples?

Have a look in the userguide:



http://www.jmonkeyengine.com/wiki/doku.php/zbufferstate



and dont forget to call


yourNode.updateRenderState();



afterwards

Awesome, that worked wonderfully!  :smiley: