Hi there,

I was trying out a simple example where I build a cube
and add two directional in front.


I noticed that while the front left side of the box is correctly lit, the
right side end is not. If you place a face towards the left light source,
then it starts shining, however if you place it towards the right light
source, then it gets black.
The effect is the opposite if you add the ligths to the tree
in the reverse order.


Am I doing something wrong? or is it just a problem of Java3D in
my machine?

I tried out the latest beta version and the result was the same.
If I use point lights instead, then it works o.k.

For reference, I am working on a PC under Windows 2000.

I attach an example where the behavior can be reproduced.

Thanks

---
Luis




-------- Example -------------

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.io.*;
import com.sun.j3d.utils.behaviors.mouse.*;
import com.sun.j3d.utils.geometry.Box;

public class Test extends Applet {

    public BranchGroup createSceneGraph() {
        // Create the root of the branch graph
        BranchGroup objRoot = new BranchGroup();

        // Create the transform group node and initialize it to the
        // identity.  Enable the TRANSFORM_WRITE capability so that
        // our behavior code can modify it at runtime.  Add it to the
        // root of the subgraph.
        TransformGroup objTrans = new TransformGroup();
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        objRoot.addChild(objTrans);


       // Create a new ColoringAttributes object for the shape's
        // appearance and make it writable at runtime.
        Appearance app = new Appearance ();
        Color3f black = new Color3f (0.0f, 0.0f, 0.0f);
        Color3f white = new Color3f (1.0f, 1.0f, 1.0f);
        Color3f objColor = new Color3f (0.8f, 0.0f, 0.0f);
        Material mat = new Material (objColor, black, objColor, white,
                                     80.0f);

        app.setMaterial (mat);
        Box box = new Box(0.2f, 0.2f, 0.2f, app);

        objTrans.addChild(box);

        BoundingSphere bounds =
          new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);



       // Create the rotate behavior node
        MouseRotate behavior = new MouseRotate();
        behavior.setTransformGroup(objTrans);
        objTrans.addChild(behavior);
        behavior.setSchedulingBounds(bounds);


        // Set up the background
        Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
        Background bgNode = new Background(bgColor);
        bgNode.setApplicationBounds(bounds);
        objRoot.addChild(bgNode);

        // Set up the ambient light
        Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
        AmbientLight ambientLightNode = new AmbientLight(ambientColor);
        ambientLightNode.setInfluencingBounds(bounds);
        objRoot.addChild(ambientLightNode);

        // Set up the directional lights
        Color3f lightColor = new Color3f(1.0f, 1.0f, 0.9f);
        Vector3f light1Direction  = new Vector3f ( 4.0f, -4.0f, -2.0f);
        Vector3f light2Direction  = new Vector3f (-4.0f, -4.0f, -2.0f);

        DirectionalLight light1
            = new DirectionalLight(lightColor, light1Direction);
        light1.setInfluencingBounds(bounds);
        objRoot.addChild(light1);

        DirectionalLight light2
            = new DirectionalLight(lightColor, light2Direction);
        light2.setInfluencingBounds(bounds);
        objRoot.addChild(light2);

        return objRoot;
    }
    public Test() {

        setLayout(new BorderLayout());
        GraphicsConfiguration config =
           SimpleUniverse.getPreferredConfiguration();

        Canvas3D c = new Canvas3D(config);
        add("Center", c);

        // Create a simple scene and attach it to the virtual universe
        BranchGroup scene = createSceneGraph();
        SimpleUniverse u = new SimpleUniverse(c);
        // This will move the ViewPlatform back a bit so the
        // objects in the scene can be viewed.
        u.getViewingPlatform().setNominalViewingTransform();
        u.addBranchGraph(scene);
    }

    //
    // The following allows Test to be run as an application
    // as well as an applet
    //
    public static void main(String[] args) {
        new MainFrame(new Test(), 700, 700);
    }
}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to