Thanks a lot Mark and Matthieu, I used the GeometryInfo and it's working
now.
Olivier.

----- Original Message -----
From: "Mark Hood" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 04, 2002 4:37 AM
Subject: Re: [JAVA3D] vertex of a shape3d


> > Date:         Wed, 3 Jul 2002 13:45:33 +0200
> > From: =?iso-8859-1?q?BEGHIN=20Matthieu?= <[EMAIL PROTECTED]>
> >
> > I had the same problem and posted it. My solution was to avoid getting
> > vertex coordinates.  I know this exception is only thrown with Java3D
1.3,
> > not with previous realeases.
> >
> > The problem is that loaders we are using creates GeometryArray in
> > BY_REFERENCE mode, which is a parameter of the constructor.  I'd like to
know
> > another way to get vertex coordinates in a TriangleStrip array.
> >
> >>   Olivier Tassy <[EMAIL PROTECTED]> a �crit : Hello,I am trying to
get
> >>   the position of every vertex of a shape3d in a live scene.I use the
> >>   following code:
> >>
> >>   Shape3D node1 = (Shape3D);
> >>   shapeTab.get(item1);
> >>   TriangleArray geom1 = (TriangleArray);
> >>   node1.getGeometry();
> >>   Point3d[] coordinates = new Point3d[geom1.getVertexCount()];
> >>
> >>   for(int n = 0; n < geom1.getVertexCount(); n++)
> >>       coordinates[n] = new Point3d();
> >>
> >>   geom1.getCoordinates(0, coordinates);
> >>
> >>   java.lang.IllegalStateException:
> >>   GeometryArray: cannot directly access data in BY_REFERENCE mode
> >>      at
javax.media.j3d.GeometryArray.getCoordinates(GeometryArray.java:2743)
>
> 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".
>

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