tags:

views:

36

answers:

1

Hi I have a scene that has a white ball(3d graphics) and the scene is on my frame also the north of my frame there is a panel which has a button and by clicking on the button the ball will be red.how can I do that?please help me thanks

this is the code that creates a white sphere:

  protected void floatingWhiteSphere() {

    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f specular = new Color3f(0.9f, 0.9f, 0.9f);

    Material blueMat = new Material(white, black, white, specular, 25.0f);
    // sets ambient, emissive, diffuse, specular, shininess
    blueMat.setLightingEnable(true);

    Appearance blueApp = new Appearance();
    blueApp.setMaterial(blueMat);

    // position the sphere
    Transform3D t3d = new Transform3D();
    t3d.set(new Vector3f(0, 1, -5));
    TransformGroup tg = new TransformGroup(t3d);
    tg.addChild(new Sphere(1.0f, blueApp));   // set its radius and appearance

    sceneBG.addChild(tg);

}
A: 

I think by setting a second material, loading the second material to the object and repainting the frame when the button is clicked should do the trick. I'm not very familiar with painting procedures to get into details so sorry...

Santeron