Hi All,
I’m quiet new to java3D…but I’ve been trying my best to learn some of the main things. One thing I can’t seem to get to work, not matter what I seem to change is the Alpha value…I’ve loaded a texture and applied it to a shape, but wnat to set it to 20% transparent…or partially transparent so I can see through it.
I’ve set the shape3d appearance to use a transparencyAttribute, but I’m not sure if it has to be done in a specific order, or if something else in the code has to be set up…do I have to force the texture to be a texture2d?..any ideas or snippets or anything to fix this would be great.
I’ve put my main code below that does the shape texture and alpha values together before adding them to the child list.
Thanks,
Ben
//Load and set texture if the object is textured
Appearance app = null;
{
System.out.println("tex filename: " + m_fullTexPathName);
app = new Appearance();
TextureLoader loader = new TextureLoader(m_fullTexPathName, null);
//TextureLoader loader = new TextureLoader(m_fullTexPathName,Texture.RGBA, null);
Texture texture = loader.getTexture();
app.setTexture(texture);
TextureAttributes texatt = new TextureAttributes();
texatt.setTextureMode(TextureAttributes.REPLACE);
app.setTextureAttributes(texatt);
}
TransparencyAttributes ta;
ta = new TransparencyAttributes();
ta.setTransparencyMode(TransparencyAttributes.BLENDED);
ta.setTransparency(0.15f);
app.setTransparencyAttributes(ta);
Shape3D shape = new Shape3D(m_triangleArray, app);
m_tg.addChild(shape);
m_tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);