Hi,
I have been investigating why the Java3D examples do not work on the
Diamond Viper 550 (and other TNT based graphics adapters).
My investigation suggested the problem might be with the 
stripVertexCounts in TriangleStripArray (this routine is used by
Sphere, Cone etc which are used by the examples)
So I modified SphereMotion until I ended up with the attached program.
Run on a machine with an S3 graphics adapter, the program displays
part of two cubes. Three faces are visible on each cube.
Run on a machine with a Diamond Viper 550 and with the latest drivers,
only one face on each cube (the one facing you) is displayed. 
This is not what I expected but someone might now be able to
throw some light on the problem.
I plan to continue the investigation and hope to end up with a
'C' and OpenGL program which demonstrates the problem.
Regards
Don

Don Scales
Senior Systems Consultant
Schlumberger Geco-Prakla
Gatwick
UK
[EMAIL PROTECTED]

----------------------------------
/*
 * DiamondTest - test program for Diamond Viper 550 problem
 *               based on SphereMotion Java3D example from Sun
 */
import java.applet.Applet;
import java.awt.BorderLayout;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.util.Enumeration;

public class DiamondTest extends Applet {

  public BranchGroup createSceneGraph(SimpleUniverse u) {

    // normals
    Vector3f[] bn = {
      new Vector3f( 0.0f,  0.0f,  1.0f),
      new Vector3f( 0.0f,  0.0f,  1.0f),
      new Vector3f( 0.0f,  0.0f,  1.0f),
      new Vector3f( 0.0f,  0.0f,  1.0f),
      new Vector3f( 0.0f,  0.0f, -1.0f),
      new Vector3f( 0.0f,  0.0f, -1.0f),
      new Vector3f( 0.0f,  0.0f, -1.0f),
      new Vector3f( 0.0f,  0.0f, -1.0f),
      new Vector3f( 1.0f,  0.0f,  0.0f),
      new Vector3f( 1.0f,  0.0f,  0.0f),
      new Vector3f( 1.0f,  0.0f,  0.0f),
      new Vector3f( 1.0f,  0.0f,  0.0f),
      new Vector3f(-1.0f,  0.0f,  0.0f),
      new Vector3f(-1.0f,  0.0f,  0.0f),
      new Vector3f(-1.0f,  0.0f,  0.0f),
      new Vector3f(-1.0f,  0.0f,  0.0f),
      new Vector3f( 0.0f,  1.0f,  0.0f),
      new Vector3f( 0.0f,  1.0f,  0.0f),
      new Vector3f( 0.0f,  1.0f,  0.0f),
      new Vector3f( 0.0f,  1.0f,  0.0f),
      new Vector3f( 0.0f, -1.0f,  0.0f),
      new Vector3f( 0.0f, -1.0f,  0.0f),
      new Vector3f( 0.0f, -1.0f,  0.0f),
      new Vector3f( 0.0f, -1.0f,  0.0f)
    };
    // textures
    Point2f[] bt = {
      new Point2f(1.0f, 0.0f),
      new Point2f(1.0f, 1.0f),
      new Point2f(0.0f, 0.0f),
      new Point2f(0.0f, 1.0f),
      new Point2f(1.0f, 0.0f),
      new Point2f(1.0f, 1.0f),
      new Point2f(0.0f, 0.0f),
      new Point2f(0.0f, 1.0f),
      new Point2f(1.0f, 0.0f),
      new Point2f(1.0f, 1.0f),
      new Point2f(0.0f, 0.0f),
      new Point2f(0.0f, 1.0f),
      new Point2f(1.0f, 0.0f),
      new Point2f(1.0f, 1.0f),
      new Point2f(0.0f, 0.0f),
      new Point2f(0.0f, 1.0f),
      new Point2f(1.0f, 0.0f),
      new Point2f(1.0f, 1.0f),
      new Point2f(0.0f, 0.0f),
      new Point2f(0.0f, 1.0f),
      new Point2f(0.0f, 1.0f),
      new Point2f(0.0f, 0.0f),
      new Point2f(1.0f, 1.0f),
      new Point2f(1.0f, 0.0f)
    };
    // verts
    Point3f[] bv = {
      new Point3f( 1.0f, -1.0f,  1.0f),
      new Point3f( 1.0f,  1.0f,  1.0f),
      new Point3f(-1.0f, -1.0f,  1.0f),
      new Point3f(-1.0f,  1.0f,  1.0f),
      new Point3f(-1.0f, -1.0f, -1.0f),
      new Point3f(-1.0f,  1.0f, -1.0f),
      new Point3f( 1.0f, -1.0f, -1.0f),
      new Point3f( 1.0f,  1.0f, -1.0f),
      new Point3f( 1.0f, -1.0f, -1.0f),
      new Point3f( 1.0f,  1.0f, -1.0f),
      new Point3f( 1.0f, -1.0f,  1.0f),
      new Point3f( 1.0f,  1.0f,  1.0f),
      new Point3f(-1.0f, -1.0f,  1.0f),
      new Point3f(-1.0f,  1.0f,  1.0f),
      new Point3f(-1.0f, -1.0f, -1.0f),
      new Point3f(-1.0f,  1.0f, -1.0f),
      new Point3f( 1.0f,  1.0f,  1.0f),
      new Point3f( 1.0f,  1.0f, -1.0f),
      new Point3f(-1.0f,  1.0f,  1.0f),
      new Point3f(-1.0f,  1.0f, -1.0f),
      new Point3f(-1.0f, -1.0f,  1.0f),
      new Point3f(-1.0f, -1.0f, -1.0f),
      new Point3f( 1.0f, -1.0f,  1.0f),
      new Point3f( 1.0f, -1.0f, -1.0f)
    };
    // strip counts
    int[] stca = new int[1];
    stca[0] = 4;
    int[] stcb = {4,4,4,4,4,4};

    int i,j,k;

    Color3f eColor    = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f sColor    = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f objColor  = new Color3f(0.6f, 0.6f, 0.6f);
    Color3f lColor1   = new Color3f(1.0f, 0.0f, 0.0f);
    Color3f lColor2   = new Color3f(0.0f, 1.0f, 0.0f);
    Color3f lColor3   = new Color3f(0.0f, 0.0f, 1.0f);
    Color3f alColor   = new Color3f(0.2f, 0.2f, 0.2f);
    Color3f bgColor   = new Color3f(0.05f, 0.05f, 0.2f);

    Transform3D t;

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

    // Create a Transformgroup to scale all objects so they
    // appear in the scene.
    TransformGroup objScale = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(0.4);
    objScale.setTransform(t3d);
    objRoot.addChild(objScale);

    // Create a bounds for the background and lights
    BoundingSphere bounds =
      new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);

    // Set up the background
    Background bg = new Background(bgColor);
    bg.setApplicationBounds(bounds);
    objScale.addChild(bg);

    // Create first object, 
    // and add it into the scene graph.
    Material m = new Material(objColor, eColor, objColor, sColor, 100.0f);
    Appearance a = new Appearance();
    m.setLightingEnable(true);
    a.setMaterial(m);

    // Create transformations for first object
    t = new Transform3D();
    Vector3d lPos1 = new Vector3d(-2.0, 2.0, 0.0);
    t.set(lPos1);
    TransformGroup l1Trans = new TransformGroup(t);
    objScale.addChild(l1Trans);

    // Create Geometry for first object
    j = 0;
    for (i = 0;i < 6;i++) {
      GeometryArray goa = new TriangleStripArray(4,            
                              TriangleStripArray.COORDINATES |
                              TriangleStripArray.NORMALS |
                              TriangleStripArray.TEXTURE_COORDINATE_2,
                              stca);
      Point3f[]  bpts = new Point3f[4];
      Vector3f[] bnrm = new Vector3f[4];
      Point2f[]  bcrd = new Point2f[4];
      for (k = 0;k<4;k++) {
        bpts[k] = bv[j];      
        bnrm[k] = bn[j];
        bcrd[k] = bt[j];
        j++;
      };
      goa.setCoordinates(0,bpts);
      goa.setNormals(0,bnrm);
      goa.setTextureCoordinates(0,bcrd);
      Shape3D shp = new Shape3D(goa);
      shp.setAppearance(a);
      l1Trans.addChild(shp);
    };

    // Create transformations for second object
    t = new Transform3D();
    Vector3d lPos2 = new Vector3d(-2.0, -2.0, 0.0);
    t.set(lPos2);
    TransformGroup l2Trans = new TransformGroup(t);
    objScale.addChild(l2Trans);

    // Create Geometry for second object
    GeometryArray goa = new TriangleStripArray(24,            
                            TriangleStripArray.COORDINATES |
                            TriangleStripArray.NORMALS |
                            TriangleStripArray.TEXTURE_COORDINATE_2,
                            stcb);
    goa.setCoordinates(0,bv);
    goa.setNormals(0,bn);
    goa.setTextureCoordinates(0,bt);
    Shape3D shp = new Shape3D(goa);
    shp.setAppearance(a);
    l2Trans.addChild(shp);

    // Create transformations for the positional lights
    TransformGroup llRotTrans = new TransformGroup();
    llRotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objScale.addChild(llRotTrans);

    t = new Transform3D();
    Vector3d lPosl = new Vector3d(0.5, 0.8, 2.0);
    t.set(lPosl);
    TransformGroup llTrans = new TransformGroup(t);
    llRotTrans.addChild(llTrans);

    // Create Geometry for point lights
    ColoringAttributes caLl = new ColoringAttributes();
    caLl.setColor(lColor2);
    Appearance appLl = new Appearance();
    appLl.setColoringAttributes(caLl);

    // Create lights
    Light lgtl = null;

    Point3f lPoint  = new Point3f(0.0f, 0.0f, 0.0f);
    Point3f atten = new Point3f(1.0f, 0.0f, 0.0f);
    Vector3f lDirectl = new Vector3f(lPosl);
    lDirectl.negate();

    lgtl = new PointLight(lColor2, lPoint, atten);

    // Set the influencing bounds
    lgtl.setInfluencingBounds(bounds);

    // Add the lights into the scene graph
    llTrans.addChild(lgtl);

    // Let Java 3D perform optimizations on this scene graph.
    objRoot.compile();

    return objRoot;
  }

  public DiamondTest() {
    setLayout(new BorderLayout());
    Canvas3D c = new Canvas3D(null);
    add("Center", c);

    SimpleUniverse u = new SimpleUniverse(c);
    BranchGroup scene = createSceneGraph(u);

    // 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 DiamondTest to be run as an application
  // as well as an applet
  //
  public static void main(String[] args) {
    new MainFrame(new DiamondTest(), 700, 700);
  }
}
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to