At 04:31 PM 9/22/99 -0400, Daniel Selman wrote:
>I have been developing a Java 3D scenegraph viewer for my book "Java 3D
>Programming". I have put quite a bit of time and effort into the tool
>[Java3DTree] and I feel that it will be generally useful to the Java 3D
>community.

For those of us who can't wait, I've attached the low-tech version;
first a sample of its output (no JPG required:)).  This grows in a
bugwise way - i.e. every time I have a hairy bug and need to poke
around the scene graph, I have to add a bit more formatting.
===================================================================
class javax.media.j3d.BranchGroup
.class javax.media.j3d.BranchGroup
..class ca.antarcti.Porcelain
...class javax.media.j3d.TransformGroup x=3999672.0 y=0.0 z=523559.0
....class javax.media.j3d.Shape3D G=class javax.media.j3d.IndexedQuadArray
....class javax.media.j3d.Shape3D G=class javax.media.j3d.TriangleArray
....class javax.media.j3d.DistanceLOD
....class javax.media.j3d.Switch
.....class javax.media.j3d.TransformGroup x=0.0 y=0.0 z=0.0
......class javax.media.j3d.TransformGroup x=0.0 y=0.0 z=0.0
.......class javax.media.j3d.Shape3D G=class javax.media.j3d.Text3D
......class javax.media.j3d.Billboard
.....class javax.media.j3d.Group
..class ca.antarcti.Porcelain
...class javax.media.j3d.TransformGroup x=3999972.0 y=0.0 z=523623.0
....class javax.media.j3d.Shape3D G=class javax.media.j3d.IndexedQuadArray
....class javax.media.j3d.Shape3D G=class javax.media.j3d.TriangleArray
....class javax.media.j3d.DistanceLOD
....class javax.media.j3d.Switch
.....class javax.media.j3d.TransformGroup x=0.0 y=0.0 z=0.0
......class javax.media.j3d.TransformGroup x=0.0 y=0.0 z=0.0
.......class javax.media.j3d.Shape3D G=class javax.media.j3d.Text3D
......class javax.media.j3d.Billboard
.....class javax.media.j3d.Group
..class javax.media.j3d.Shape3D G=class javax.media.j3d.QuadArray
..class javax.media.j3d.Shape3D G=class javax.media.j3d.LineArray
..class ca.antarcti.Quadrant
..class ca.antarcti.Quadrant
..class ca.antarcti.Quadrant
..class ca.antarcti.Quadrant
=========================================================
Here's the code
=========================================================
package ca.antarcti;

import javax.media.j3d.*;
import java.util.*;
import javax.vecmath.*;
import java.io.PrintStream;

public class DumpSceneGraph
{
  public static void dump(Node n, PrintStream out)
  {
    dump1(n, 0, out);
  }

  public static void dumpTG(TransformGroup tg, PrintStream out)
  {
    Transform3D t = new Transform3D();
    Vector3d v = new Vector3d();
    tg.getTransform(t);
    t.get(v);
    out.print(" x="+v.x+" y="+v.y+" z="+v.z);
  }

  private static void dumpBB(BoundingBox bb, PrintStream out)
  {
    Point3d p = new Point3d();
    bb.getLower(p);
    out.print(" l="+p);
    bb.getUpper(p);
    out.print(" u="+p);
  }

  private static void dump1(Node n, int depth, PrintStream out)
  {
    int i;
    for (i = 0; i < depth; i++)
      out.print('.');

    out.print(n.getClass());

    if (n instanceof TransformGroup)
      dumpTG((TransformGroup) n, out);
    else if (n instanceof Shape3D)
      out.print(" G="+((Shape3D)n).getGeometry().getClass());
    out.println();

    if (n instanceof Group)
    {
      Enumeration children = ((Group) n).getAllChildren();

      while (children.hasMoreElements())
      {
        Object child = children.nextElement();
        if (child instanceof Node)
          dump1((Node) child, depth + 1, out);
      }
    }
  }
}


===========================================================================
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