> Date:         Mon, 29 Jul 2002 15:52:21 +0200
> From: Cyril Zorman <[EMAIL PROTECTED]>
>
> does someone have any ideas of when the bug  4690609 will be fixe  and
> what to do for the moment
> because using the old method  need lot of changes in the code.
> I really need to use the by_REFERENCE bit to increase the performe of my
> work

The synopsis line of bug 4690609 is a little misleading.  The bug is actually
a bug in j3dfly; it tries to use getCoordinates() on a GeometryArray that was
created with BY_REFERENCE access semantics.

If your concern is not actually with j3dfly, then you can always get vertex
data from BY_REFERENCE geometry, but you have to use either the GeometryInfo
utility method getCoordinates() or the appropriate GeometryArray by-reference
accessors directly.

Here is some info I posted on the subject a while back:

------------------------------------------------------------------------------
You may be getting the geometry from ObjectFile, which for performance reasons
was revised in Java 3D 1.3 to use by-ref interleaved access semantics.

A quick fix is to modify ObjectFile.java at line 1230 from
        shape.setGeometry(gi.getGeometryArray(true, true, false));
to
        shape.setGeometry(gi.getGeometryArray(false, false, false));

Or you could create a new GeometryInfo with the constructor that takes a
GeometryArray as a parameter, and then use the getCoordinates() method of
GeometryInfo.  This is probably the best way to get what you want.

Otherwise, you would need to extract the by-ref data yourself by inspecting the
vertex format flags to see how the data is formatted.  Unfortunately, this is
can be quite complex -- see the source code for the private
processGeometryArray() method of GeometryInfoGenerator for hints.  By-ref
geometry is easy to construct but wasn't intended to be easily taken apart by
anything other than the native graphics API.

Basically you have three bits to look at in the vertex format of the
GeometryArray:

        boolean NIO = (vertexFormat & GeometryArray.USE_NIO_BUFFER) != 0 ;
        boolean byRef = (vertexFormat & GeometryArray.BY_REFERENCE) != 0 ;
        boolean interleaved = (vertexFormat & GeometryArray.INTERLEAVED) != 0 ;

If byRef is false, you have the normal by-copy access semantics of the Java 3D
1.2.  Otherwise, you have all the boolean combinations of interleaved and NIO
to consider:

If both NIO and interleaved are false, then you access coordinates with
getCoordRefFloat() and gotCoordRefDouble() to get the references to the float
and double arrays containing the vertex coordinates.  There isn't any way to
determine if it contains float or double arrays other than checking if the
returned reference is null.

If interleaved is true but NIO is false, then you get the interleaved float
array by calling getInterleavedVertices().  You have to examine the vertex
format to determine what's included in each vertex -- the texture data comes
first, followed by the color, then the normal, then the vertex coordinates.

If both interleaved and NIO are true, then you get the vertex data by calling
getInterleavedVertexBuffer() to get a reference to a J3DBuffer which wraps the
NIO contents.  This will always be of type BufferWrapper.TYPE_FLOAT, so you
create a FloatBufferWrapper object from the J3DBuffer and then use the get()
method on that object to retrieve the data.

If only NIO is true, then you call getCoordRefBuffer() to get the J3DBuffer.
This buffer can be of two types -- BufferWrapper.TYPE_FLOAT or
BufferWrapper.TYPE_DOUBLE.

-- Mark Hood

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