NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: Java3D shapes to visad shapes? - solved

[Bill]
> did you also copy the colors (if they are non-null)
> and especially the stripVertexCounts?

That did it Bill, I hadn't been setting the individual strip vertex counts.

So for reference, here's how to create Spheres as VisAD shapes from Sun's built 
in ones (other shapes should be similar):

  /*
             import com.sun.j3d.utils.geometry.Sphere;
             import javax.media.j3d.Appearance;
             import javax.media.j3d.TriangleStripArray;
             */
            
            VisADTriangleStripArray sphere_visad = new 
VisADTriangleStripArray();
             
            Sphere sphere_j3d = new Sphere(0.1f, new Appearance());
            TriangleStripArray geom_j3d = 
(TriangleStripArray)sphere_j3d.getShape().getGeometry();

            sphere_visad.vertexCount = geom_j3d.getVertexCount();

            sphere_visad.coordinates = new float[3 * geom_j3d.getVertexCount()];
            geom_j3d.getCoordinates(0, sphere_visad.coordinates);

            sphere_visad.normals = new float[3 * geom_j3d.getVertexCount()];
            geom_j3d.getNormals(0, sphere_visad.normals);

            sphere_visad.vertexFormat = geom_j3d.getVertexFormat();

            sphere_visad.stripVertexCounts = new int[geom_j3d.getNumStrips()];
            geom_j3d.getStripVertexCounts(sphere_visad.stripVertexCounts);

    // Now use sphere_visad like any other VisAD shape, e.g. in 
ShapeControl.setShape()

Thanks for the help
Steve Harris
Programmer
National Center for Toxicological Research, FDA


  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: