Package com.sun.j3d.utils.picking

Source Code of com.sun.j3d.utils.picking.PickIntersection

/*      */ package com.sun.j3d.utils.picking;
/*      */
/*      */ import javax.media.j3d.GeometryArray;
/*      */ import javax.media.j3d.IndexedGeometryArray;
/*      */ import javax.vecmath.Color3b;
/*      */ import javax.vecmath.Color3f;
/*      */ import javax.vecmath.Color4b;
/*      */ import javax.vecmath.Color4f;
/*      */ import javax.vecmath.Point3d;
/*      */ import javax.vecmath.Point3f;
/*      */ import javax.vecmath.TexCoord2f;
/*      */ import javax.vecmath.TexCoord3f;
/*      */ import javax.vecmath.Vector3d;
/*      */ import javax.vecmath.Vector3f;
/*      */
/*      */ public class PickIntersection
/*      */ {
/*  119 */   PickResult pickResult = null;
/*      */
/*  123 */   double distance = -1.0D;
/*      */
/*  126 */   int geomIndex = 0;
/*      */
/*  129 */   int[] primitiveVertexIndices = null;
/*      */
/*  132 */   Point3d[] primitiveCoordinatesVW = null;
/*      */
/*  135 */   Point3d pointCoordinatesVW = null;
/*      */
/*  140 */   GeometryArray geom = null;
/*  141 */   IndexedGeometryArray iGeom = null;
/*  142 */   boolean hasNormals = false;
/*  143 */   boolean hasColors = false;
/*  144 */   boolean hasTexCoords = false;
/*      */   int[] primitiveCoordinateIndices;
/*      */   int[] primitiveNormalIndices;
/*      */   int[] primitiveColorIndices;
/*      */   int[] primitiveTexCoordIndices;
/*  155 */   Point3d[] primitiveCoordinates = null;
/*      */
/*  158 */   Vector3f[] primitiveNormals = null;
/*      */
/*  161 */   Color4f[] primitiveColors = null;
/*      */
/*  164 */   TexCoord3f[] primitiveTexCoords = null;
/*      */
/*  169 */   Point3d pointCoordinates = null;
/*      */
/*  172 */   Vector3f pointNormal = null;
/*      */
/*  175 */   Color4f pointColor = null;
/*      */
/*  178 */   TexCoord3f pointTexCoord = null;
/*      */
/*  182 */   int closestVertexIndex = -1;
/*      */
/*  185 */   Point3d closestVertexCoordinates = null;
/*      */
/*  188 */   Point3d closestVertexCoordinatesVW = null;
/*      */   double[] interpWeights;
/*      */   static final boolean debug = false;
/*      */   static final int X_AXIS = 1;
/*      */   static final int Y_AXIS = 2;
/*      */   static final int Z_AXIS = 3;
/*      */   static final double TOL = 1.E-005D;
/*      */
/*      */   PickIntersection(PickResult pr, GeometryArray geomArr)
/*      */   {
/*  213 */     this.pickResult = pr;
/*  214 */     this.geom = geomArr;
/*  215 */     if (this.geom == null) {
/*  216 */       GeometryArray[] ga = this.pickResult.getGeometryArrays();
/*  217 */       this.geom = ga[this.geomIndex];
/*      */     }
/*      */
/*  221 */     if ((this.geom instanceof IndexedGeometryArray)) {
/*  222 */       this.iGeom = ((IndexedGeometryArray)this.geom);
/*      */     }
/*  224 */     int vertexFormat = this.geom.getVertexFormat();
/*  225 */     this.hasColors = (0 != (vertexFormat & 0xC));
/*      */
/*  227 */     this.hasNormals = (0 != (vertexFormat & 0x2));
/*  228 */     this.hasTexCoords = (0 != (vertexFormat & 0x60));
/*      */   }
/*      */
/*      */   public String toString()
/*      */   {
/*  237 */     String rt = new String("PickIntersection: ");
/*  238 */     rt = rt + " pickResult = " + this.pickResult + "\n";
/*  239 */     rt = rt + " geomIndex = " + this.geomIndex + "\n";
/*  240 */     if (this.distance != -1.0D) rt = rt + " dist:" + this.distance + "\n";
/*  241 */     if (this.pointCoordinates != null) rt = rt + " pt:" + this.pointCoordinates + "\n";
/*  242 */     if (this.pointCoordinatesVW != null) rt = rt + " ptVW:" + this.pointCoordinatesVW + "\n";
/*      */
/*  244 */     if (this.primitiveCoordinateIndices != null) {
/*  245 */       rt = rt + " prim coordinate ind:\n";
/*  246 */       for (int i = 0; i < this.primitiveCoordinateIndices.length; i++) {
/*  247 */         rt = rt + " " + this.primitiveCoordinateIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  251 */     if (this.primitiveColorIndices != null) {
/*  252 */       rt = rt + " prim color ind:\n";
/*  253 */       for (int i = 0; i < this.primitiveColorIndices.length; i++) {
/*  254 */         rt = rt + " " + this.primitiveColorIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  258 */     if (this.primitiveNormalIndices != null) {
/*  259 */       rt = rt + " prim normal ind:\n";
/*  260 */       for (int i = 0; i < this.primitiveNormalIndices.length; i++) {
/*  261 */         rt = rt + " " + this.primitiveNormalIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  265 */     if (this.primitiveTexCoordIndices != null) {
/*  266 */       rt = rt + " prim texture ind:\n";
/*  267 */       for (int i = 0; i < this.primitiveTexCoordIndices.length; i++) {
/*  268 */         rt = rt + " " + this.primitiveTexCoordIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  272 */     if (this.closestVertexCoordinates != null) {
/*  273 */       rt = rt + " clos. vert:" + this.closestVertexCoordinates + "\n";
/*      */     }
/*      */
/*  276 */     if (this.closestVertexCoordinatesVW != null) {
/*  277 */       rt = rt + " clos. vert:" + this.closestVertexCoordinatesVW + "\n";
/*      */     }
/*      */
/*  280 */     if (this.closestVertexIndex != -1) {
/*  281 */       rt = rt + " clos. vert. ind.:" + this.closestVertexIndex + "\n";
/*      */     }
/*  283 */     return rt;
/*      */   }
/*      */
/*      */   String toString2()
/*      */   {
/*  288 */     String rt = new String("PickIntersection: ");
/*      */
/*  290 */     rt = rt + " geomIndex = " + this.geomIndex + "\n";
/*  291 */     if (this.distance != -1.0D) rt = rt + " dist:" + this.distance + "\n";
/*  292 */     if (this.pointCoordinates != null) rt = rt + " pt:" + this.pointCoordinates + "\n";
/*  293 */     if (this.pointCoordinatesVW != null) rt = rt + " ptVW:" + this.pointCoordinatesVW + "\n";
/*      */
/*  295 */     if (this.primitiveCoordinateIndices != null) {
/*  296 */       rt = rt + " prim coordinate ind:\n";
/*  297 */       for (int i = 0; i < this.primitiveCoordinateIndices.length; i++) {
/*  298 */         rt = rt + " " + this.primitiveCoordinateIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  302 */     if (this.primitiveColorIndices != null) {
/*  303 */       rt = rt + " prim color ind:\n";
/*  304 */       for (int i = 0; i < this.primitiveColorIndices.length; i++) {
/*  305 */         rt = rt + " " + this.primitiveColorIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  309 */     if (this.primitiveNormalIndices != null) {
/*  310 */       rt = rt + " prim normal ind:\n";
/*  311 */       for (int i = 0; i < this.primitiveNormalIndices.length; i++) {
/*  312 */         rt = rt + " " + this.primitiveNormalIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  316 */     if (this.primitiveTexCoordIndices != null) {
/*  317 */       rt = rt + " prim texture ind:\n";
/*  318 */       for (int i = 0; i < this.primitiveTexCoordIndices.length; i++) {
/*  319 */         rt = rt + " " + this.primitiveTexCoordIndices[i] + "\n";
/*      */       }
/*      */     }
/*      */
/*  323 */     if (this.closestVertexCoordinates != null) {
/*  324 */       rt = rt + " clos. vert:" + this.closestVertexCoordinates + "\n";
/*      */     }
/*      */
/*  327 */     if (this.closestVertexCoordinatesVW != null) {
/*  328 */       rt = rt + " clos. vert:" + this.closestVertexCoordinatesVW + "\n";
/*      */     }
/*      */
/*  331 */     if (this.closestVertexIndex != -1) {
/*  332 */       rt = rt + " clos. vert. ind.:" + this.closestVertexIndex + "\n";
/*      */     }
/*  334 */     return rt;
/*      */   }
/*      */
/*      */   PickResult getPickResult()
/*      */   {
/*  341 */     return this.pickResult;
/*      */   }
/*      */
/*      */   void setGeomIndex(int gi)
/*      */   {
/*  349 */     if (this.geomIndex != gi) {
/*  350 */       GeometryArray[] ga = this.pickResult.getGeometryArrays();
/*  351 */       this.geom = ga[gi];
/*      */
/*  353 */       if ((this.geom instanceof IndexedGeometryArray)) {
/*  354 */         this.iGeom = ((IndexedGeometryArray)this.geom);
/*      */       }
/*  356 */       int vertexFormat = this.geom.getVertexFormat();
/*  357 */       this.hasColors = (0 != (vertexFormat & 0xC));
/*      */
/*  359 */       this.hasNormals = (0 != (vertexFormat & 0x2));
/*  360 */       this.hasTexCoords = (0 != (vertexFormat & 0x60));
/*      */     }
/*      */
/*  365 */     this.geomIndex = gi;
/*      */   }
/*      */
/*      */   void setPointCoordinatesVW(Point3d pt)
/*      */   {
/*  373 */     if (this.pointCoordinatesVW == null) {
/*  374 */       this.pointCoordinatesVW = new Point3d();
/*      */     }
/*  376 */     this.pointCoordinatesVW.x = pt.x;
/*  377 */     this.pointCoordinatesVW.y = pt.y;
/*  378 */     this.pointCoordinatesVW.z = pt.z;
/*      */   }
/*      */
/*      */   public Point3d getPointCoordinatesVW()
/*      */   {
/*  387 */     return this.pointCoordinatesVW;
/*      */   }
/*      */
/*      */   public double getDistance()
/*      */   {
/*  396 */     return this.distance;
/*      */   }
/*      */
/*      */   void setDistance(double dist)
/*      */   {
/*  404 */     this.distance = dist;
/*      */   }
/*      */
/*      */   void setPrimitiveCoordinatesVW(Point3d[] coords)
/*      */   {
/*  412 */     this.primitiveCoordinatesVW = new Point3d[coords.length];
/*  413 */     System.arraycopy(coords, 0, this.primitiveCoordinatesVW, 0, coords.length);
/*      */   }
/*      */
/*      */   public Point3d[] getPrimitiveCoordinatesVW()
/*      */   {
/*  421 */     return this.primitiveCoordinatesVW;
/*      */   }
/*      */
/*      */   void setVertexIndices(int[] verts)
/*      */   {
/*  429 */     this.primitiveVertexIndices = new int[verts.length];
/*  430 */     System.arraycopy(verts, 0, this.primitiveVertexIndices, 0, verts.length);
/*      */   }
/*      */
/*      */   public int[] getPrimitiveVertexIndices()
/*      */   {
/*  438 */     return this.primitiveVertexIndices;
/*      */   }
/*      */
/*      */   public int getGeometryArrayIndex()
/*      */   {
/*  446 */     return this.geomIndex;
/*      */   }
/*      */
/*      */   public GeometryArray getGeometryArray()
/*      */   {
/*  455 */     if (this.geom == null) {
/*  456 */       GeometryArray[] ga = this.pickResult.getGeometryArrays();
/*  457 */       this.geom = ga[this.geomIndex];
/*  458 */       if ((this.geom instanceof IndexedGeometryArray)) {
/*  459 */         this.iGeom = ((IndexedGeometryArray)this.geom);
/*      */       }
/*  461 */       int vertexFormat = this.geom.getVertexFormat();
/*  462 */       this.hasColors = (0 != (vertexFormat & 0xC));
/*      */
/*  464 */       this.hasNormals = (0 != (vertexFormat & 0x2));
/*  465 */       this.hasTexCoords = (0 != (vertexFormat & 0x60));
/*      */     }
/*      */
/*  469 */     return this.geom;
/*      */   }
/*      */
/*      */   public boolean geometryIsIndexed()
/*      */   {
/*  474 */     GeometryArray ga = getGeometryArray();
/*  475 */     if (this.iGeom != null) {
/*  476 */       return true;
/*      */     }
/*  478 */     return false;
/*      */   }
/*      */
/*      */   public Point3d getClosestVertexCoordinates()
/*      */   {
/*  493 */     if (this.closestVertexCoordinates == null) {
/*  494 */       int vertexIndex = getClosestVertexIndex();
/*  495 */       int vformat = this.geom.getVertexFormat();
/*      */
/*  498 */       int[] indices = getPrimitiveCoordinateIndices();
/*  499 */       if ((vformat & 0x80) == 0) {
/*  500 */         this.closestVertexCoordinates = new Point3d();
/*  501 */         this.geom.getCoordinate(indices[vertexIndex], this.closestVertexCoordinates);
/*      */       }
/*  508 */       else if ((vformat & 0x100) == 0) {
/*  509 */         double[] doubleData = this.geom.getCoordRefDouble();
/*      */
/*  511 */         if (doubleData == null) {
/*  512 */           float[] floatData = this.geom.getCoordRefFloat();
/*  513 */           if (floatData == null) {
/*  514 */             Point3f[] p3fData = this.geom.getCoordRef3f();
/*  515 */             if (p3fData == null) {
/*  516 */               Point3d[] p3dData = this.geom.getCoordRef3d();
/*  517 */               this.closestVertexCoordinates = new Point3d(p3dData[indices[vertexIndex]].x, p3dData[indices[vertexIndex]].y, p3dData[indices[vertexIndex]].z);
/*      */             }
/*      */             else {
/*  520 */               this.closestVertexCoordinates = new Point3d(p3fData[indices[vertexIndex]].x, p3fData[indices[vertexIndex]].y, p3fData[indices[vertexIndex]].z);
/*      */             }
/*      */           }
/*      */           else {
/*  524 */             int val = indices[vertexIndex] * 3;
/*  525 */             this.closestVertexCoordinates = new Point3d(floatData[val], floatData[(val + 1)], floatData[(val + 2)]);
/*      */           }
/*      */         }
/*      */         else {
/*  529 */           int val = indices[vertexIndex] * 3;
/*  530 */           this.closestVertexCoordinates = new Point3d(doubleData[val], doubleData[(val + 1)], doubleData[(val + 2)]);
/*      */         }
/*      */       }
/*      */       else {
/*  534 */         float[] floatData = this.geom.getInterleavedVertices();
/*  535 */         int offset = getInterleavedVertexOffset(this.geom);
/*  536 */         int stride = offset + 3;
/*  537 */         int val = stride * indices[vertexIndex] + offset;
/*  538 */         this.closestVertexCoordinates = new Point3d(floatData[val], floatData[(val + 1)], floatData[(val + 2)]);
/*      */       }
/*      */
/*      */     }
/*      */
/*  543 */     return this.closestVertexCoordinates;
/*      */   }
/*      */
/*      */   public Point3d getClosestVertexCoordinatesVW()
/*      */   {
/*  551 */     if (this.closestVertexCoordinatesVW == null) {
/*  552 */       int vertexIndex = getClosestVertexIndex();
/*  553 */       Point3d[] coordinatesVW = getPrimitiveCoordinatesVW();
/*  554 */       this.closestVertexCoordinatesVW = coordinatesVW[vertexIndex];
/*      */     }
/*  556 */     return this.closestVertexCoordinatesVW;
/*      */   }
/*      */
/*      */   public int getClosestVertexIndex()
/*      */   {
/*  563 */     if (this.closestVertexIndex == -1) {
/*  564 */       storeClosestVertex();
/*      */     }
/*  566 */     return this.closestVertexIndex;
/*      */   }
/*      */
/*      */   void storeClosestVertex()
/*      */   {
/*  571 */     if (this.closestVertexIndex == -1) {
/*  572 */       double maxDist = 1.7976931348623157E+308D;
/*  573 */       double curDist = 1.7976931348623157E+308D;
/*  574 */       int closestIndex = -1;
/*      */
/*  578 */       for (int i = 0; i < this.primitiveCoordinatesVW.length; i++) {
/*  579 */         curDist = this.pointCoordinatesVW.distance(this.primitiveCoordinatesVW[i]);
/*      */
/*  585 */         if (curDist < maxDist) {
/*  586 */           closestIndex = i;
/*  587 */           maxDist = curDist;
/*      */         }
/*      */       }
/*  590 */       this.closestVertexIndex = closestIndex;
/*      */     }
/*      */   }
/*      */
/*      */   public int[] getPrimitiveCoordinateIndices()
/*      */   {
/*  605 */     if (this.primitiveCoordinateIndices == null) {
/*  606 */       if (geometryIsIndexed()) {
/*  607 */         this.primitiveCoordinateIndices = new int[this.primitiveVertexIndices.length];
/*      */
/*  609 */         for (int i = 0; i < this.primitiveVertexIndices.length; i++)
/*  610 */           this.primitiveCoordinateIndices[i] = this.iGeom.getCoordinateIndex(this.primitiveVertexIndices[i]);
/*      */       }
/*      */       else
/*      */       {
/*  614 */         this.primitiveCoordinateIndices = this.primitiveVertexIndices;
/*      */       }
/*      */     }
/*  617 */     return this.primitiveCoordinateIndices;
/*      */   }
/*      */
/*      */   public Point3d[] getPrimitiveCoordinates()
/*      */   {
/*  625 */     if (this.primitiveCoordinates == null) {
/*  626 */       this.primitiveCoordinates = new Point3d[this.primitiveVertexIndices.length];
/*  627 */       int[] indices = getPrimitiveCoordinateIndices();
/*  628 */       int vformat = this.geom.getVertexFormat();
/*      */
/*  632 */       if ((vformat & 0x80) == 0) {
/*  633 */         for (int i = 0; i < indices.length; i++) {
/*  634 */           this.primitiveCoordinates[i] = new Point3d();
/*      */
/*  636 */           this.geom.getCoordinate(indices[i], this.primitiveCoordinates[i]);
/*      */         }
/*      */
/*      */       }
/*  640 */       else if ((vformat & 0x100) == 0) {
/*  641 */         double[] doubleData = this.geom.getCoordRefDouble();
/*      */
/*  643 */         if (doubleData == null) {
/*  644 */           float[] floatData = this.geom.getCoordRefFloat();
/*  645 */           if (floatData == null) {
/*  646 */             Point3f[] p3fData = this.geom.getCoordRef3f();
/*  647 */             if (p3fData == null) {
/*  648 */               Point3d[] p3dData = this.geom.getCoordRef3d();
/*  649 */               for (int i = 0; i < indices.length; i++)
/*  650 */                 this.primitiveCoordinates[i] = new Point3d(p3dData[indices[i]].x, p3dData[indices[i]].y, p3dData[indices[i]].z);
/*      */             }
/*      */             else
/*      */             {
/*  654 */               for (int i = 0; i < indices.length; i++) {
/*  655 */                 this.primitiveCoordinates[i] = new Point3d(p3fData[indices[i]].x, p3fData[indices[i]].y, p3fData[indices[i]].z);
/*      */               }
/*      */             }
/*      */           }
/*      */           else
/*      */           {
/*  661 */             for (int i = 0; i < indices.length; i++) {
/*  662 */               int val = indices[i] * 3;
/*  663 */               this.primitiveCoordinates[i] = new Point3d(floatData[val], floatData[(val + 1)], floatData[(val + 2)]);
/*      */             }
/*      */           }
/*      */         }
/*      */         else {
/*  668 */           for (int i = 0; i < indices.length; i++) {
/*  669 */             int val = indices[i] * 3;
/*  670 */             this.primitiveCoordinates[i] = new Point3d(doubleData[val], doubleData[(val + 1)], doubleData[(val + 2)]);
/*      */           }
/*      */         }
/*      */       }
/*      */       else {
/*  675 */         float[] floatData = this.geom.getInterleavedVertices();
/*  676 */         int offset = getInterleavedVertexOffset(this.geom);
/*  677 */         int stride = offset + 3;
/*  678 */         for (int i = 0; i < indices.length; i++) {
/*  679 */           int val = stride * indices[i] + offset;
/*  680 */           this.primitiveCoordinates[i] = new Point3d(floatData[val], floatData[(val + 1)], floatData[(val + 2)]);
/*      */         }
/*      */       }
/*      */
/*      */     }
/*      */
/*  686 */     return this.primitiveCoordinates;
/*      */   }
/*      */
/*      */   int getInterleavedVertexOffset(GeometryArray geo) {
/*  690 */     int offset = 0;
/*  691 */     int vformat = geo.getVertexFormat();
/*  692 */     if ((vformat & 0x4) == 4)
/*  693 */       offset += 3;
/*  694 */     else if ((vformat & 0xC) == 12) {
/*  695 */       offset += 4;
/*      */     }
/*  697 */     if ((vformat & 0x2) != 0)
/*  698 */       offset += 3;
/*  699 */     if ((vformat & 0x20) == 32) {
/*  700 */       offset += 2 * geo.getTexCoordSetCount();
/*      */     }
/*  702 */     else if ((vformat & 0x40) == 64) {
/*  703 */       offset += 3 * geo.getTexCoordSetCount();
/*      */     }
/*      */
/*  706 */     return offset;
/*      */   }
/*      */
/*      */   int getInterleavedStride(GeometryArray geo) {
/*  710 */     int offset = 3;
/*  711 */     int vformat = geo.getVertexFormat();
/*  712 */     if ((vformat & 0x4) == 4)
/*  713 */       offset += 3;
/*  714 */     else if ((vformat & 0xC) == 12) {
/*  715 */       offset += 4;
/*      */     }
/*  717 */     if ((vformat & 0x2) != 0)
/*  718 */       offset += 3;
/*  719 */     if ((vformat & 0x20) == 32) {
/*  720 */       offset += 2 * geo.getTexCoordSetCount();
/*      */     }
/*  722 */     else if ((vformat & 0x40) == 64) {
/*  723 */       offset += 3 * geo.getTexCoordSetCount();
/*      */     }
/*      */
/*  726 */     return offset;
/*      */   }
/*      */
/*      */   int getInterleavedColorOffset(GeometryArray geo)
/*      */   {
/*  731 */     int offset = 0;
/*  732 */     int vformat = geo.getVertexFormat();
/*  733 */     if ((vformat & 0x20) == 32) {
/*  734 */       offset += 2 * geo.getTexCoordSetCount();
/*      */     }
/*  736 */     else if ((vformat & 0x40) == 64) {
/*  737 */       offset += 3 * geo.getTexCoordSetCount();
/*      */     }
/*      */
/*  740 */     return offset;
/*      */   }
/*      */
/*      */   int getInterleavedNormalOffset(GeometryArray geo)
/*      */   {
/*  745 */     int offset = 0;
/*  746 */     int vformat = geo.getVertexFormat();
/*  747 */     if ((vformat & 0x20) == 32) {
/*  748 */       offset += 2 * geo.getTexCoordSetCount();
/*      */     }
/*  750 */     else if ((vformat & 0x40) == 64) {
/*  751 */       offset += 3 * geo.getTexCoordSetCount();
/*      */     }
/*  753 */     if ((vformat & 0x4) == 4)
/*  754 */       offset += 3;
/*  755 */     else if ((vformat & 0xC) == 12) {
/*  756 */       offset += 4;
/*      */     }
/*  758 */     return offset;
/*      */   }
/*      */
/*      */   public int[] getPrimitiveNormalIndices()
/*      */   {
/*  771 */     if ((this.hasNormals) && (this.primitiveNormalIndices == null)) {
/*  772 */       if (geometryIsIndexed()) {
/*  773 */         this.primitiveNormalIndices = new int[this.primitiveVertexIndices.length];
/*      */
/*  775 */         for (int i = 0; i < this.primitiveVertexIndices.length; i++)
/*  776 */           this.primitiveNormalIndices[i] = this.iGeom.getNormalIndex(this.primitiveVertexIndices[i]);
/*      */       }
/*      */       else
/*      */       {
/*  780 */         this.primitiveNormalIndices = this.primitiveVertexIndices;
/*      */       }
/*      */     }
/*  783 */     return this.primitiveNormalIndices;
/*      */   }
/*      */
/*      */   public Vector3f[] getPrimitiveNormals()
/*      */   {
/*  792 */     if ((this.hasNormals) && (this.primitiveNormals == null)) {
/*  793 */       this.primitiveNormals = new Vector3f[this.primitiveVertexIndices.length];
/*  794 */       int[] indices = getPrimitiveNormalIndices();
/*  795 */       int vformat = this.geom.getVertexFormat();
/*      */
/*  798 */       if ((vformat & 0x80) == 0) {
/*  799 */         for (int i = 0; i < indices.length; i++) {
/*  800 */           this.primitiveNormals[i] = new Vector3f();
/*  801 */           this.geom.getNormal(indices[i], this.primitiveNormals[i]);
/*      */         }
/*      */
/*      */       }
/*  805 */       else if ((vformat & 0x100) == 0) {
/*  806 */         float[] floatNormals = this.geom.getNormalRefFloat();
/*  807 */         if (floatNormals != null) {
/*  808 */           for (int i = 0; i < indices.length; i++) {
/*  809 */             int val = indices[i] * 3;
/*  810 */             this.primitiveNormals[i] = new Vector3f(floatNormals[val], floatNormals[(val + 1)], floatNormals[(val + 2)]);
/*      */           }
/*      */         }
/*      */         else {
/*  814 */           Vector3f[] normal3f = this.geom.getNormalRef3f();
/*  815 */           for (int i = 0; i < indices.length; i++)
/*  816 */             this.primitiveNormals[i] = new Vector3f(normal3f[indices[i]].x, normal3f[indices[i]].y, normal3f[indices[i]].z);
/*      */         }
/*      */       }
/*      */       else
/*      */       {
/*  821 */         float[] floatData = this.geom.getInterleavedVertices();
/*  822 */         int offset = getInterleavedColorOffset(this.geom);
/*  823 */         int stride = getInterleavedStride(this.geom);
/*  824 */         for (int i = 0; i < indices.length; i++) {
/*  825 */           int val = stride * indices[i] + offset;
/*  826 */           this.primitiveNormals[i] = new Vector3f(floatData[val], floatData[(val + 1)], floatData[(val + 2)]);
/*      */         }
/*      */       }
/*      */
/*      */     }
/*      */
/*  832 */     return this.primitiveNormals;
/*      */   }
/*      */
/*      */   public int[] getPrimitiveColorIndices()
/*      */   {
/*  842 */     if ((this.hasColors) && (this.primitiveColorIndices == null)) {
/*  843 */       if (geometryIsIndexed()) {
/*  844 */         this.primitiveColorIndices = new int[this.primitiveVertexIndices.length];
/*      */
/*  846 */         for (int i = 0; i < this.primitiveVertexIndices.length; i++)
/*  847 */           this.primitiveColorIndices[i] = this.iGeom.getColorIndex(this.primitiveVertexIndices[i]);
/*      */       }
/*      */       else
/*      */       {
/*  851 */         this.primitiveColorIndices = this.primitiveVertexIndices;
/*      */       }
/*      */     }
/*  854 */     return this.primitiveColorIndices;
/*      */   }
/*      */
/*      */   public Color4f[] getPrimitiveColors()
/*      */   {
/*  864 */     if ((this.hasColors) && (this.primitiveColors == null)) {
/*  865 */       this.primitiveColors = new Color4f[this.primitiveVertexIndices.length];
/*  866 */       int[] indices = getPrimitiveColorIndices();
/*  867 */       int vformat = this.geom.getVertexFormat();
/*  868 */       if ((vformat & 0x80) == 0) {
/*  869 */         if ((vformat & 0xC) == 12)
/*      */         {
/*  871 */           for (int i = 0; i < indices.length; i++) {
/*  872 */             this.primitiveColors[i] = new Color4f();
/*  873 */             this.geom.getColor(indices[i], this.primitiveColors[i]);
/*      */           }
/*      */         } else {
/*  876 */           Color3f color = new Color3f();
/*  877 */           for (int i = 0; i < indices.length; i++) {
/*  878 */             this.primitiveColors[i] = new Color4f();
/*  879 */             this.geom.getColor(indices[i], color);
/*  880 */             this.primitiveColors[i].x = color.x;
/*  881 */             this.primitiveColors[i].y = color.y;
/*  882 */             this.primitiveColors[i].z = color.z;
/*  883 */             this.primitiveColors[i].w = 1.0F;
/*      */           }
/*      */         }
/*      */
/*      */       }
/*  888 */       else if ((vformat & 0x100) == 0) {
/*  889 */         float[] floatData = this.geom.getColorRefFloat();
/*      */
/*  891 */         if (floatData == null) {
/*  892 */           byte[] byteData = this.geom.getColorRefByte();
/*  893 */           if (byteData == null) {
/*  894 */             Color3f[] c3fData = this.geom.getColorRef3f();
/*  895 */             if (c3fData == null) {
/*  896 */               Color4f[] c4fData = this.geom.getColorRef4f();
/*  897 */               if (c4fData == null) {
/*  898 */                 Color3b[] c3bData = this.geom.getColorRef3b();
/*  899 */                 if (c3bData == null) {
/*  900 */                   Color4b[] c4bData = this.geom.getColorRef4b();
/*  901 */                   for (int i = 0; i < indices.length; i++) {
/*  902 */                     this.primitiveColors[i] = new Color4f(c4bData[indices[i]].x, c4bData[indices[i]].y, c4bData[indices[i]].z, c4bData[indices[i]].w);
/*      */                   }
/*      */                 }
/*      */                 else
/*      */                 {
/*  907 */                   for (int i = 0; i < indices.length; i++) {
/*  908 */                     this.primitiveColors[i] = new Color4f(c3bData[indices[i]].x, c3bData[indices[i]].y, c3bData[indices[i]].z, 1.0F);
/*      */                   }
/*      */                 }
/*      */               }
/*      */               else
/*      */               {
/*  914 */                 for (int i = 0; i < indices.length; i++)
/*  915 */                   this.primitiveColors[i] = new Color4f(c4fData[indices[i]].x, c4fData[indices[i]].y, c4fData[indices[i]].z, c4fData[indices[i]].w);
/*      */               }
/*      */             }
/*      */             else
/*      */             {
/*  920 */               for (int i = 0; i < indices.length; i++) {
/*  921 */                 this.primitiveColors[i] = new Color4f(c3fData[indices[i]].x, c3fData[indices[i]].y, c3fData[indices[i]].z, 1.0F);
/*      */               }
/*      */
/*      */             }
/*      */
/*      */           }
/*  929 */           else if ((vformat & 0xC) == 12)
/*      */           {
/*  931 */             for (int i = 0; i < indices.length; i++) {
/*  932 */               int val = indices[i] << 2;
/*  933 */               this.primitiveColors[i] = new Color4f(byteData[val], byteData[(val + 1)], byteData[(val + 2)], byteData[(val + 3)]);
/*      */             }
/*      */           }
/*      */           else
/*      */           {
/*  938 */             for (int i = 0; i < indices.length; i++) {
/*  939 */               int val = indices[i] * 3;
/*  940 */               this.primitiveColors[i] = new Color4f(byteData[val], byteData[(val + 1)], byteData[(val + 2)], 1.0F);
/*      */             }
/*      */
/*      */           }
/*      */
/*      */         }
/*  949 */         else if ((vformat & 0xC) == 12)
/*      */         {
/*  951 */           for (int i = 0; i < indices.length; i++) {
/*  952 */             int val = indices[i] << 2;
/*  953 */             this.primitiveColors[i] = new Color4f(floatData[val], floatData[(val + 1)], floatData[(val + 2)], floatData[(val + 3)]);
/*      */           }
/*      */         }
/*      */         else {
/*  957 */           for (int i = 0; i < indices.length; i++) {
/*  958 */             int val = indices[i] * 3;
/*  959 */             this.primitiveColors[i] = new Color4f(floatData[val], floatData[(val + 1)], floatData[(val + 2)], 1.0F);
/*      */           }
/*      */
/*      */         }
/*      */
/*      */       }
/*      */       else
/*      */       {
/*  967 */         float[] floatData = this.geom.getInterleavedVertices();
/*  968 */         int offset = getInterleavedColorOffset(this.geom);
/*  969 */         int stride = getInterleavedStride(this.geom);
/*  970 */         for (int i = 0; i < indices.length; i++) {
/*  971 */           int val = stride * indices[i] + offset;
/*  972 */           if ((vformat & 0xC) == 12)
/*      */           {
/*  974 */             this.primitiveColors[i] = new Color4f(floatData[val], floatData[(val + 1)], floatData[(val + 2)], floatData[(val + 3)]);
/*      */           }
/*      */           else {
/*  977 */             this.primitiveColors[i] = new Color4f(floatData[val], floatData[(val + 1)], floatData[(val + 2)], 1.0F);
/*      */           }
/*      */         }
/*      */       }
/*      */     }
/*      */
/*  983 */     return this.primitiveColors;
/*      */   }
/*      */
/*      */   public int[] getPrimitiveTexCoordIndices(int index)
/*      */   {
/*  995 */     if ((this.hasTexCoords) && (this.primitiveTexCoordIndices == null)) {
/*  996 */       if (geometryIsIndexed()) {
/*  997 */         this.primitiveTexCoordIndices = new int[this.primitiveVertexIndices.length];
/*      */
/*  999 */         for (int i = 0; i < this.primitiveVertexIndices.length; i++) {
/* 1000 */           this.primitiveTexCoordIndices[i] = this.iGeom.getTextureCoordinateIndex(index, this.primitiveVertexIndices[i]);
/*      */         }
/*      */       }
/*      */       else
/*      */       {
/* 1005 */         this.primitiveTexCoordIndices = this.primitiveVertexIndices;
/*      */       }
/*      */     }
/* 1008 */     return this.primitiveTexCoordIndices;
/*      */   }
/*      */
/*      */   public TexCoord3f[] getPrimitiveTexCoords(int index)
/*      */   {
/* 1021 */     if (this.primitiveTexCoords == null) {
/* 1022 */       this.primitiveTexCoords = new TexCoord3f[this.primitiveVertexIndices.length];
/* 1023 */       int[] indices = getPrimitiveTexCoordIndices(index);
/* 1024 */       int vformat = this.geom.getVertexFormat();
/* 1025 */       if ((vformat & 0x80) == 0) {
/* 1026 */         for (int i = 0; i < indices.length; i++) {
/* 1027 */           this.primitiveTexCoords[i] = new TexCoord3f();
/* 1028 */           this.geom.getTextureCoordinate(index, indices[i], this.primitiveTexCoords[i]);
/*      */         }
/*      */
/*      */       }
/* 1032 */       else if ((vformat & 0x100) == 0)
/*      */       {
/* 1034 */         float[] floatTexCoords = this.geom.getTexCoordRefFloat(index);
/* 1035 */         if (floatTexCoords != null) {
/* 1036 */           if ((vformat & 0x20) == 32) {
/* 1037 */             for (int i = 0; i < indices.length; i++) {
/* 1038 */               int val = indices[i] << 1;
/* 1039 */               this.primitiveTexCoords[i] = new TexCoord3f(floatTexCoords[val], floatTexCoords[(val + 1)], 0.0F);
/*      */             }
/*      */
/*      */           }
/*      */           else
/*      */           {
/* 1045 */             for (int i = 0; i < indices.length; i++) {
/* 1046 */               int val = indices[i] * 3;
/* 1047 */               this.primitiveTexCoords[i] = new TexCoord3f(floatTexCoords[val], floatTexCoords[(val + 1)], floatTexCoords[(val + 2)]);
/*      */             }
/*      */           }
/*      */
/*      */         }
/*      */         else
/*      */         {
/* 1054 */           TexCoord2f[] texCoord2f = this.geom.getTexCoordRef2f(index);
/* 1055 */           if (texCoord2f != null) {
/* 1056 */             for (int i = 0; i < indices.length; i++) {
/* 1057 */               this.primitiveTexCoords[i] = new TexCoord3f(texCoord2f[indices[i]].x, texCoord2f[indices[i]].y, 0.0F);
/*      */             }
/*      */
/*      */           }
/*      */           else
/*      */           {
/* 1063 */             TexCoord3f[] texCoord3f = this.geom.getTexCoordRef3f(index);
/* 1064 */             for (int i = 0; i < indices.length; i++) {
/* 1065 */               this.primitiveTexCoords[i] = new TexCoord3f(texCoord3f[indices[i]].x, texCoord3f[indices[i]].y, texCoord3f[indices[i]].z);
/*      */             }
/*      */           }
/*      */
/*      */         }
/*      */
/*      */       }
/*      */       else
/*      */       {
/* 1074 */         float[] floatData = this.geom.getInterleavedVertices();
/* 1075 */         int stride = getInterleavedStride(this.geom);
/*      */         int offset;
/*      */         int offset;
/* 1078 */         if ((vformat & 0x20) == 32)
/*      */         {
/* 1080 */           offset = index << 1;
/*      */         }
/*      */         else {
/* 1083 */           offset = index * 3;
/*      */         }
/* 1085 */         for (int i = 0; i < indices.length; i++) {
/* 1086 */           int val = stride * indices[i];
/* 1087 */           if ((vformat & 0x20) == 32)
/*      */           {
/* 1089 */             this.primitiveTexCoords[i] = new TexCoord3f(floatData[(val + offset)], floatData[(val + 1 + offset)], 0.0F);
/*      */           }
/*      */           else {
/* 1092 */             this.primitiveTexCoords[i] = new TexCoord3f(floatData[(val + offset)], floatData[(val + 1 + offset)], floatData[(val + 2 + offset)]);
/*      */           }
/*      */         }
/*      */       }
/*      */     }
/*      */
/* 1098 */     return this.primitiveTexCoords;
/*      */   }
/*      */
/*      */   public Point3d getPointCoordinates()
/*      */   {
/* 1114 */     if (this.pointCoordinates == null) {
/* 1115 */       double[] weights = getInterpWeights();
/* 1116 */       Point3d[] coords = getPrimitiveCoordinates();
/* 1117 */       this.pointCoordinates = new Point3d();
/* 1118 */       for (int i = 0; i < weights.length; i++) {
/* 1119 */         this.pointCoordinates.x += weights[i] * coords[i].x;
/* 1120 */         this.pointCoordinates.y += weights[i] * coords[i].y;
/* 1121 */         this.pointCoordinates.z += weights[i] * coords[i].z;
/*      */       }
/*      */     }
/* 1124 */     return this.pointCoordinates;
/*      */   }
/*      */
/*      */   public Vector3f getPointNormal()
/*      */   {
/* 1133 */     if ((this.hasNormals) && (this.pointNormal == null)) {
/* 1134 */       double[] weights = getInterpWeights();
/* 1135 */       Vector3f[] normals = getPrimitiveNormals();
/* 1136 */       this.pointNormal = new Vector3f();
/* 1137 */       for (int i = 0; i < weights.length; i++) {
/* 1138 */         this.pointNormal.x += (float)weights[i] * normals[i].x;
/* 1139 */         this.pointNormal.y += (float)weights[i] * normals[i].y;
/* 1140 */         this.pointNormal.z += (float)weights[i] * normals[i].z;
/*      */       }
/*      */     }
/* 1143 */     return this.pointNormal;
/*      */   }
/*      */
/*      */   public Color4f getPointColor()
/*      */   {
/* 1154 */     if ((this.hasColors) && (this.pointColor == null)) {
/* 1155 */       double[] weights = getInterpWeights();
/* 1156 */       Color4f[] colors = getPrimitiveColors();
/* 1157 */       this.pointColor = new Color4f();
/* 1158 */       for (int i = 0; i < weights.length; i++) {
/* 1159 */         this.pointColor.x += (float)weights[i] * colors[i].x;
/* 1160 */         this.pointColor.y += (float)weights[i] * colors[i].y;
/* 1161 */         this.pointColor.z += (float)weights[i] * colors[i].z;
/* 1162 */         this.pointColor.w += (float)weights[i] * colors[i].w;
/*      */       }
/*      */     }
/* 1165 */     return this.pointColor;
/*      */   }
/*      */
/*      */   public TexCoord3f getPointTextureCoordinate(int index)
/*      */   {
/* 1178 */     if ((this.hasTexCoords) && (this.pointTexCoord == null)) {
/* 1179 */       double[] weights = getInterpWeights();
/* 1180 */       TexCoord3f[] texCoords = getPrimitiveTexCoords(index);
/* 1181 */       this.pointTexCoord = new TexCoord3f();
/* 1182 */       for (int i = 0; i < weights.length; i++) {
/* 1183 */         this.pointTexCoord.x += (float)weights[i] * texCoords[i].x;
/* 1184 */         this.pointTexCoord.y += (float)weights[i] * texCoords[i].y;
/* 1185 */         this.pointTexCoord.z += (float)weights[i] * texCoords[i].z;
/*      */       }
/*      */     }
/* 1188 */     return this.pointTexCoord;
/*      */   }
/*      */
/*      */   double abs(double value)
/*      */   {
/* 1198 */     if (value < 0.0D) {
/* 1199 */       return -value;
/*      */     }
/* 1201 */     return value;
/*      */   }
/*      */
/*      */   int maxAxis(Vector3d delta)
/*      */   {
/* 1209 */     int axis = 1;
/* 1210 */     double max = abs(delta.x);
/* 1211 */     if (abs(delta.y) > max) {
/* 1212 */       axis = 2;
/* 1213 */       max = abs(delta.y);
/*      */     }
/* 1215 */     if (abs(delta.z) > max) {
/* 1216 */       axis = 3;
/*      */     }
/* 1218 */     return axis;
/*      */   }
/*      */
/*      */   boolean interpTriangle(int index0, int index1, int index2, Point3d[] coords, Point3d intPt)
/*      */   {
/* 1260 */     Vector3d delta0 = new Vector3d();
/* 1261 */     Vector3d delta1 = new Vector3d();
/* 1262 */     Vector3d delta2 = new Vector3d();
/* 1263 */     delta0.sub(coords[index1], coords[index0]);
/* 1264 */     delta1.sub(coords[index2], coords[index0]);
/* 1265 */     delta2.sub(coords[index2], coords[index1]);
/* 1266 */     double len0 = delta0.lengthSquared();
/* 1267 */     double len1 = delta1.lengthSquared();
/* 1268 */     double len2 = delta2.lengthSquared();
/* 1269 */     Vector3d longest = delta0;
/* 1270 */     double maxLen = len0;
/* 1271 */     if (len1 > maxLen) {
/* 1272 */       longest = delta1;
/* 1273 */       maxLen = len1;
/*      */     }
/* 1275 */     if (len2 > maxLen) {
/* 1276 */       longest = delta2;
/*      */     }
/* 1278 */     int mainAxis = maxAxis(longest);
/*      */
/* 1295 */     double[] factor = new double[3];
/*      */
/* 1297 */     factor[0] = getInterpFactorForBase(intPt, coords[index1], coords[index2], mainAxis);
/*      */
/* 1299 */     factor[1] = getInterpFactorForBase(intPt, coords[index2], coords[index0], mainAxis);
/*      */
/* 1301 */     factor[2] = getInterpFactorForBase(intPt, coords[index0], coords[index1], mainAxis);
/*      */     double leftFactor;
/*      */     int base;
/*      */     int right;
/*      */     int left;
/*      */     double rightFactor;
/*      */     double leftFactor;
/* 1327 */     if ((factor[0] < 0.0D) || (factor[0] > 1.0D)) {
/* 1328 */       int base = index0;
/* 1329 */       int right = index1;
/* 1330 */       int left = index2;
/* 1331 */       double rightFactor = factor[2];
/* 1332 */       leftFactor = 1.0D - factor[1];
/*      */     }
/*      */     else
/*      */     {
/*      */       double leftFactor;
/* 1337 */       if ((factor[1] < 0.0D) || (factor[1] > 1.0D)) {
/* 1338 */         int base = index1;
/* 1339 */         int right = index2;
/* 1340 */         int left = index0;
/* 1341 */         double rightFactor = factor[0];
/* 1342 */         leftFactor = 1.0D - factor[2];
/*      */       }
/*      */       else
/*      */       {
/* 1348 */         base = index2;
/* 1349 */         right = index0;
/* 1350 */         left = index1;
/* 1351 */         rightFactor = factor[1];
/* 1352 */         leftFactor = 1.0D - factor[0];
/*      */       }
/*      */
/*      */     }
/*      */
/* 1364 */     Point3d iLeft = new Point3d(leftFactor * coords[left].x + (1.0D - leftFactor) * coords[base].x, leftFactor * coords[left].y + (1.0D - leftFactor) * coords[base].y, leftFactor * coords[left].z + (1.0D - leftFactor) * coords[base].z);
/*      */
/* 1371 */     Point3d iRight = new Point3d(rightFactor * coords[right].x + (1.0D - rightFactor) * coords[base].x, rightFactor * coords[right].y + (1.0D - rightFactor) * coords[base].y, rightFactor * coords[right].z + (1.0D - rightFactor) * coords[base].z);
/*      */
/* 1384 */     delta0.sub(iLeft, iRight);
/* 1385 */     int midAxis = maxAxis(delta0);
/* 1386 */     double midFactor = getInterpFactor(intPt, iRight, iLeft, midAxis);
/*      */
/* 1403 */     if (midFactor < 0.0D)
/*      */     {
/* 1405 */       if (midFactor + 1.E-005D >= 0.0D)
/*      */       {
/* 1407 */         midFactor = 0.0D;
/*      */       }
/*      */       else
/*      */       {
/* 1411 */         return false;
/*      */       }
/*      */     }
/* 1414 */     else if (midFactor > 1.0D)
/*      */     {
/* 1416 */       if (midFactor - 1.E-005D <= 1.0D)
/*      */       {
/* 1418 */         midFactor = 1.0D;
/*      */       }
/*      */       else
/*      */       {
/* 1422 */         return false;
/*      */       }
/*      */
/*      */     }
/*      */
/* 1427 */     this.interpWeights[base] = (1.0D - midFactor * leftFactor - rightFactor + midFactor * rightFactor);
/*      */
/* 1429 */     this.interpWeights[left] = (midFactor * leftFactor);
/* 1430 */     this.interpWeights[right] = (rightFactor - midFactor * rightFactor);
/* 1431 */     return true;
/*      */   }
/*      */
/*      */   double[] getInterpWeights()
/*      */   {
/* 1440 */     Point3d pt = getPointCoordinatesVW();
/* 1441 */     Point3d[] coordinates = getPrimitiveCoordinatesVW();
/*      */
/* 1445 */     if (this.interpWeights != null) {
/* 1446 */       return this.interpWeights;
/*      */     }
/*      */
/* 1449 */     this.interpWeights = new double[coordinates.length];
/*      */
/* 1452 */     switch (coordinates.length)
/*      */     {
/*      */     case 1:
/* 1455 */       this.interpWeights[0] = 1.0D;
/* 1456 */       break;
/*      */     case 2:
/* 1458 */       Vector3d delta = new Vector3d();
/* 1459 */       delta.sub(coordinates[1], coordinates[0]);
/* 1460 */       int axis = maxAxis(delta);
/* 1461 */       double factor = getInterpFactor(pt, coordinates[1], coordinates[0], axis);
/* 1462 */       this.interpWeights[0] = factor;
/* 1463 */       this.interpWeights[1] = (1.0D - factor);
/* 1464 */       break;
/*      */     case 3:
/* 1466 */       if (!interpTriangle(0, 1, 2, coordinates, pt)) {
/* 1467 */         throw new RuntimeException("Interp point outside triangle");
/*      */       }
/*      */       break;
/*      */     case 4:
/* 1471 */       if ((!interpTriangle(0, 1, 2, coordinates, pt)) &&
/* 1472 */         (!interpTriangle(0, 2, 3, coordinates, pt))) {
/* 1473 */         throw new RuntimeException("Interp point outside quad");
/*      */       }
/*      */
/*      */       break;
/*      */     default:
/* 1478 */       throw new RuntimeException("Unexpected number of points.");
/*      */     }
/* 1480 */     return this.interpWeights;
/*      */   }
/*      */
/*      */   private static float getInterpFactor(Point3d p, Point3d p1, Point3d p2, int axis)
/*      */   {
/*      */     float t;
/*      */     float t;
/*      */     float t;
/* 1492 */     switch (axis)
/*      */     {
/*      */     case 1:
/*      */       float t;
/* 1494 */       if (p1.x == p2.x)
/*      */       {
/* 1496 */         t = 0.0F;
/*      */       }
/* 1498 */       else t = (float)((p1.x - p.x) / (p1.x - p2.x));
/* 1499 */       break;
/*      */     case 2:
/* 1501 */       if (p1.y == p2.y)
/*      */       {
/* 1503 */         t = 0.0F;
/*      */       }
/* 1505 */       else t = (float)((p1.y - p.y) / (p1.y - p2.y));
/* 1506 */       break;
/*      */     case 3:
/* 1508 */       if (p1.z == p2.z)
/*      */       {
/* 1510 */         t = 0.0F;
/*      */       }
/* 1512 */       else t = (float)((p1.z - p.z) / (p1.z - p2.z));
/* 1513 */       break;
/*      */     default:
/* 1515 */       throw new RuntimeException("invalid axis parameter " + axis + " (must be 0-2)");
/*      */     }
/* 1517 */     return t;
/*      */   }
/*      */
/*      */   private static float getInterpFactorForBase(Point3d p, Point3d p1, Point3d p2, int axis)
/*      */   {
/*      */     float t;
/*      */     float t;
/*      */     float t;
/* 1530 */     switch (axis)
/*      */     {
/*      */     case 1:
/*      */       float t;
/* 1532 */       if (p1.x == p2.x)
/* 1533 */         t = 3.4028235E+38F;
/*      */       else
/* 1535 */         t = (float)((p1.x - p.x) / (p1.x - p2.x));
/* 1536 */       break;
/*      */     case 2:
/* 1538 */       if (p1.y == p2.y)
/* 1539 */         t = 3.4028235E+38F;
/*      */       else
/* 1541 */         t = (float)((p1.y - p.y) / (p1.y - p2.y));
/* 1542 */       break;
/*      */     case 3:
/* 1544 */       if (p1.z == p2.z)
/* 1545 */         t = 3.4028235E+38F;
/*      */       else
/* 1547 */         t = (float)((p1.z - p.z) / (p1.z - p2.z));
/* 1548 */       break;
/*      */     default:
/* 1550 */       throw new RuntimeException("invalid axis parameter " + axis + " (must be 0-2)");
/*      */     }
/* 1552 */     return t;
/*      */   }
/*      */ }

/* Location:           Z:\System\Library\Java\Extensions\j3dutils.jar
* Qualified Name:     com.sun.j3d.utils.picking.PickIntersection
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of com.sun.j3d.utils.picking.PickIntersection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.