Thanks Ole,
            That worked out exactly how I wanted it to.  My problem was that
I was not cycling through the Branchroup to get to the Shape3D's.  Thanks!!


Shaun

----- Original Message -----
From: "Ole Vilmann" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 08, 2001 10:57 AM
Subject: Re: [JAVA3D] Extacting Shape3D's from the FltLoader


> I do the following: Running trough all children in all levels, i.e.
> through BranchGroups, TransformGroups etc. all the way to the button
> where I look for Shape3Ds. When you have a Shape3D you still dont
> know exactly what kind of geometry you've got. You have to test that !
>
> I have included a piece of code you maybe would like to modify !
>
>
> The following is the call of the method:
>
>             Enumeration enum = brGrp.getAllChildren();
>             MinMaxVal   minmax = new MinMaxVal();
>
>             getMinMaxVal(enum,minmax);
>
>
> Run trough to find Shape3Ds and extract geometry:
>
>     public void getMinMaxVal(Enumeration enum, MinMaxVal minMax){
>         while (enum.hasMoreElements()) {
>             Object tmpObject = enum.nextElement();
>
>             if (tmpObject instanceof Shape3D) {
>                 System.out.println("getMinMaxVal: a shape3D");
>                 Geometry geom = ((Shape3D)tmpObject).getGeometry();
>                 if (geom instanceof GeometryArray) {
>                     System.out.println("getMinMaxVal: Yes it is a
> GeometryArray !");
>
>                     if (geom instanceof GeometryStripArray) {
>                         System.out.println("getMinMaxVal: instance
> GeometryStripArray");
>                     } else if (geom instanceof IndexedGeometryArray) {
>                         System.out.println("getMinMaxVal: instance
> IndexedGeometryArray");
>                     } else if (geom instanceof QuadArray) {
>                         System.out.println("getMinMaxVal: instance
> QuadArray");
>                     } else if (geom instanceof TriangleArray) {
>                         System.out.println("getMinMaxVal: instance
> TriangleArray");
>                     } else {
>                         System.out.println("getMinMaxVal: instance NOT
> KNOWN");
>                     }
>
>                     int format = ((TriangleArray)geom).getVertexFormat();
>                     System.out.println("getMinMaxVal: format = "+format);
>                     System.out.println("getMinMaxVal: format of
coordinates
> = "+TriangleArray.COORDINATES);
>                     if (((TriangleArray)geom).getVertexFormat() ==
> TriangleArray.COORDINATES) {
>                         System.out.println("getMinMaxVal: format is
> COORDINATES");
>                     } else if (((TriangleArray)geom).getVertexFormat() ==
> TriangleArray.COLOR_3) {
>                         System.out.println("getMinMaxVal: format is
> COLOR_3");
>                     } else if (((TriangleArray)geom).getVertexFormat() ==
> TriangleArray.COLOR_4) {
>                         System.out.println("getMinMaxVal: format is
> COLOR_4");
>                     } else if (((TriangleArray)geom).getVertexFormat() ==
> TriangleArray.NORMALS) {
>                         System.out.println("getMinMaxVal: format is
> NORMALS");
>                     } else if (((TriangleArray)geom).getVertexFormat() ==
> TriangleArray.TEXTURE_COORDINATE_2) {
>                         System.out.println("getMinMaxVal: format is
> TEXTURE_COORDINATE_2");
>                     } else if (((TriangleArray)geom).getVertexFormat() ==
> TriangleArray.TEXTURE_COORDINATE_3) {
>                         System.out.println("getMinMaxVal: format is
> TEXTURE_COORDINATE_3");
>                     } else {
>                         System.out.println("getMinMaxVal: format not
> known");
>                     }
>
>                     int  count = ((TriangleArray)geom).getVertexCount();
>                     System.out.println("getMinMaxVal: count = "+count);
>                     double coordinates[] = new double[count*3];
>                     ((TriangleArray)geom).getCoordinates(0, coordinates);
>                     for (int i=0; i<count; i++) {
>                         if (coordinates[i*3] > minMax.max[0])
minMax.max[0]
> = (float)coordinates[i*3];
>                         if (coordinates[i*3] < minMax.min[0])
minMax.min[0]
> = (float)coordinates[i*3];
>                         if (coordinates[i*3+1] > minMax.max[1])
> minMax.max[1] = (float)coordinates[i*3+1];
>                         if (coordinates[i*3+1] < minMax.min[1])
> minMax.min[1] = (float)coordinates[i*3+1];
>                         if (coordinates[i*3+2] > minMax.max[2])
> minMax.max[2] = (float)coordinates[i*3+2];
>                         if (coordinates[i*3+2] < minMax.min[2])
> minMax.min[2] = (float)coordinates[i*3+2];
>                         System.out.println(" " + coordinates[i*3] + " " +
> coordinates[i*3+1] + " " + coordinates[i*3+2]);
>                     }
>
>                 } else if (geom instanceof CompressedGeometry) {
>                     System.out.println("getMinMaxVal: It is a
> CompressedGeometry !");
>
>                 }
>             } else if (tmpObject instanceof TransformGroup) {
>                 System.out.println("scaleOnLowestLevel: a
transformgroup");
>                 TransformGroup tmptransformGroup =
> (TransformGroup)tmpObject;
>                 Enumeration nextenum = tmptransformGroup.getAllChildren();
>
>                 getMinMaxVal(nextenum,minMax);
>             } else if(tmpObject instanceof Group){
>                 System.out.println("getMinMaxVal: a group");
>                 Group tmpGroup = (Group)tmpObject;
>
>                 Enumeration groupenum = tmpGroup.getAllChildren();
>
>                 getMinMaxVal(groupenum,minMax);
>             } else {
>                 System.out.println("getMinMaxVal: What is this thing?");
>             }
>         }
>     }
>
>
> -----Original Message-----
> From: Shaun Shepherd [mailto:[EMAIL PROTECTED]]
> Sent: 8. januar 2001 16:00
> To: [EMAIL PROTECTED]
> Subject: [JAVA3D] Extacting Shape3D's from the FltLoader
>
>
> Morning all,
>            I'm working with the fullsail fltloader and am trying to get
the
> gemoetries of the shapes in a scene.  The problem is, everytime I try to
get
> a shape3D from a scene it throws a classCastException.  I tried to use the
> method of getNamedObjects and the resulting hashtable's get method to
obtain
> the shape3D(casted btw).  I based this off of an obj. loader example I
saw,
> is the fltloader different or is there a better way? Thanks.
>
>
> Shaun
>
>
> /** Here's a snippet of my code ***/
>      Hashtable h = s.getNamedObjects();
>      System.out.println(h.toString());
>      System.out.println(h.keys().nextElement());
>      Enumeration en = h.keys();
>      while (en.hasMoreElements()) {
>
>      String str = (String)en.nextElement();
>      Node temp = (Node)h.get(str);
>      System.out.println("Temp: " + temp.toString());
>      if (temp instanceof Shape3D) {
>          Shape3D shape = (Shape3D) temp;
>          GeometryArray g = (GeometryArray)shape.getGeometry();
>          System.out.println("Vertex Count: " + g.getVertexCount());
>      }
> }
>
>
> /*** Error given ***/
> java.lang.ClassCastException: com.fullsail.j3d.loaders.flt.FLTgroup
>  at TriangleTest.createSceneGraph(TriangleTest.java:71)
>  at TriangleTest.<init>(TriangleTest.java:27)
>  at TriangleTest.main(TriangleTest.java:32)
>
>
===========================================================================
> 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".
>

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