If anyone is using X3D M6, you might be interested:

I've spent the better part of today trying to figure out why M6 was so much
slower than M5.  With M5 on one of my .x3d files (see attached), I was getting
a consistent 60 FPS on my machine.  When I upgraded to M6, the performance was
cut in HALF.  Could only manage roughly 30 FPS with M6.

I tried messing with the capabilities of the branchgroup returned from the X3D
loader, shutting collision off, etc.  No change.  Then I tried changing the
appearance of the Shape3D's to use a new Appearance object, thinking there was
something in there that was messing it up.  No change.  Tried serializing the
branchgroup, then reloading it using the serialization API on the com.sun
utilities.  No change.  Finally, I put code in that gets all of the Shape3D's,
extracts their geometryArrays, and runs the 'Stripifier' utility, then replaces
the Shape3D's geometry.  This DOUBLED the performance.

I'm now geting 60 FPS by simply stripifying the geometry returned by the X3D
loader.

Here is the relevant code.  Note that this is in the middle of a tree-treversal
routine:

if(sgo instanceof Shape3D)
{
    Shape3D s3d = (Shape3D)sgo;
    Geometry g = s3d.getGeometry();

    if(g instanceof GeometryArray)
    {
        GeometryArray ga = (GeometryArray)g;

        int vertexCount = ga.getVertexCount();
        float[] coords = new float[vertexCount];
        ga.getCoordinates(0, coords);

        GeometryInfo gInfo = new GeometryInfo(GeometryInfo.TRIANGLE_ARRAY);
        gInfo.setCoordinates(coords);

        NormalGenerator ng = new NormalGenerator();
        ng.generateNormals(gInfo);

        Stripifier st = new Stripifier();
        st.stripify(gInfo);

        s3d.setGeometry(gInfo.getGeometryArray());
    }

}

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