Java3D shading with texture

I hava a problem with shading a textured object. Here is my code..

public void createGlobe(BranchGroup BG)
[blue]TextureLoader loader = new TextureLoader("../images/world.jpg", this);
ImageComponent2D image = loader.getImage();
Texture2D tex = new Texture2D(Texture.BASE_LEVEL,
tex.setImage(0, image);

mat = new Material(new Color3f(0, .1f, 0),[green] // ambient[blue]
new Color3f(0, 0, 0), [green]// emissive[blue]
new Color3f(0, .7f, 0), [green] // diffuse[blue]
new Color3f(.3f, .3f, .3f), [green]// specular[blue]
50); [green]// shininess[blue]

TextureAttributes texAtt = new TextureAttributes();
Appearance [b]Earth[/b] = new Appearance();

BG.addChild(new Sphere(1, Primitive.GENERATE_TEXTURE_COORDS, [b]Earth[/b]));

DirectionalLight light = new DirectionalLight(new Color3f(1, 1, 1),new Vector3f(1, 0, 0));
light.setInfluencingBounds(new BoundingSphere(new Point3d(), 100));

It renders a fully bright sphere with a picture of the world on it. excellent. But there's no shading. It's equally bright at all points.

If i remove the lines "Earth.setTexture(tex)" and "Earth.setTextureAttributes(texAtt)" and remove "Primitive.GENERATE_TEXTURE_COORDINATES" from the constructor of the Sphere, i get a nicely shaded green Sphere.

If anyone is familiar with Java3D could they please help



What does God need with a starship?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!