You should be able to access the coordinate data as an array of double
values in the following manner (the important bit is checking whether or not
the data is BY_REFERENCE before you request it):

GeometryArray ga = (GeometryArray)geometries.nextElement();
TriangleArray  ta = (TriangleArray)ga;

// Temporary variables for retrieving coordinates
int         nCoords             = 3 * ta.getVertexCount();
double []   coords              = null;

// Get the coordinates
if ((ta.getVertexFormat() & GeometryArray.BY_REFERENCE) != 0)
    coords = ta.getCoordRefDouble();
else
{
    coords = new double[nCoords];
    ta.getCoordinates(0, coords);
}

Hope this helps,
Ewan

----- Original Message -----
From: "Madeti, Henu S. (UMR-Student)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 06, 2003 2:24 AM
Subject: Re: [JAVA3D] getting polygon array for object file


> Thanks a lot Evan. The code worked and i am able to get the geometry
array. But there is a problem after that.
> Im trying to get the trianglearray set and modify the attributes to few
arrays. This is how im doing
>
> GeometryArray ga = (GeometryArray)geometries.nextElement();
> TriangleArray  count = (TriangleArray)ga;
> Point3f[] coordinates = new Point3f[count.getVertexCount()];
> count.getCoordinates(0, coordinates);
>
> But here i get the error
> java.lang.IllegalStateException: GeometryArray: cannot directly access
data in BY_REFERENCE mode.
>
> I know this is a bug in Java3D 1.3. Can someone tell me how I can overcome
this problem.
>
> Henu
>
>
>
> -----Original Message-----
> From: Ewan Borland [mailto:[EMAIL PROTECTED]
> Sent: Sun 10/5/2003 7:29 AM
> To: [EMAIL PROTECTED]
> Cc:
> Subject: Re: [JAVA3D] getting polygon array for object file
>
>
>
> Finding specific nodes in a loaded model is a common problem. I use this
> utility class (NodeFinder.java attached) to find the node I want. For your
> purpose something simliar to the example below should suffice.
>
> -Ewan
>
> // Load the model
> ObjectFile myLoader = new ObjectFile();
> Scene myScene = myLoader.load("your filename/url here");
>
> // Get the root of the scene
> Node myRootNode = myScene.getSceneGroup();
>
> // Temp enumerations for shapes and geometries
> Enumeration shapes = null;
> Enumeration geometries = null;
>
> // Find all of the Shape3D nodes that comprise this model
> try { shapes = NodeFinder.findNodes(myRootNode,
> "javax.media.j3d.Shape3D"); }
> catch(ClassNotFoundException e) { e.printStackTrace(); }
>
> // Handle each shape in turn
> while (shapes.hasMoreElements())
> {
>     // Retrieve all of the geometry node components from the shape
>     geometries = ((Shape3D)shapes.nextElement()).getAllGeometries();
>
>     // Handle each piece of geometry in turn
>     while (geometries.hasMoreElements())
>     {
>         // Recover the next geometry component
>         GeometryArray ga = (GeometryArray)geometries.nextElement();
>
>         ... now do whatever you like with the GeometryArray object
>     }
> }
>
>
> ----- Original Message -----
> From: "Madeti, Henu S. (UMR-Student)" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, October 05, 2003 1:51 AM
> Subject: [JAVA3D] getting polygon array for object file
>
>
> >
> >
> > Hi all,
> >
> > We have the objload.java loading a obj file. I wish to set different
> appearances for different polygons of the obj file. So can someone tell me
> how to get the polygon(geometry array) from the object file.
> >
> > thanks
> > Henu
> >
> >
>
>
===========================================================================
> 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