Package javax.media.j3d

Examples of javax.media.j3d.GeometryArray


/* 2548 */       this.texCoordSetCount = 1;
/* 2549 */       this.texCoordSetMap = new int[1];
/* 2550 */       this.texCoordSetMap[0] = 0;
/*      */     }
/*      */
/* 2554 */     GeometryArray ga = null;
/* 2555 */     switch (this.prim) {
/*      */     case 1:
/* 2557 */       TriangleArray ta = new TriangleArray(vertexCount, vertexFormat, this.texCoordSetCount, this.texCoordSetMap);
/*      */
/* 2559 */       ga = ta;
View Full Code Here


/*  646 */     return hits > 0;
/*      */   }
/*      */
/*      */   final boolean intersect(int geomIndex, boolean firstpick)
/*      */   {
/*  656 */     GeometryArray geom = this.geometryArrays[geomIndex];
/*  657 */     int numPts = geom.getVertexCount();
/*  658 */     double[] doubleData = null;
/*  659 */     float[] floatData = null;
/*  660 */     Point3d[] p3dData = null;
/*  661 */     Point3f[] p3fData = null;
/*  662 */     int vformat = geom.getVertexFormat();
/*      */
/*  664 */     boolean retFlag = false;
/*      */
/*  666 */     if ((vformat & 0x80) == 0) {
/*  667 */       doubleData = new double[numPts * 3];
/*  668 */       geom.getCoordinates(0, doubleData);
/*      */     }
/*  671 */     else if ((vformat & 0x100) == 0) {
/*  672 */       doubleData = geom.getCoordRefDouble();
/*      */
/*  674 */       if (doubleData == null) {
/*  675 */         floatData = geom.getCoordRefFloat();
/*  676 */         if (floatData == null) {
/*  677 */           p3fData = geom.getCoordRef3f();
/*  678 */           if (p3fData == null)
/*  679 */             p3dData = geom.getCoordRef3d();
/*      */         }
/*      */       }
/*      */     }
/*      */     else
/*      */     {
/*  685 */       floatData = geom.getInterleavedVertices();
/*      */     }
/*      */
/*  690 */     Point3d[] pnts = new Point3d[numPts];
/*      */
/*  700 */     if (debug) {
/*  701 */       System.out.println("localToVWorld = " + this.localToVWorld);
/*      */     }
/*  703 */     if ((vformat & 0x100) == 0) {
/*  704 */       if (doubleData != null) {
/*  705 */         int offset = 0;
/*  706 */         for (int i = 0; i < numPts; i++)
/*      */         {
/*  709 */           pnts[i] = getPoint3d();
/*  710 */           pnts[i].x = doubleData[(offset++)];
/*  711 */           pnts[i].y = doubleData[(offset++)];
/*  712 */           pnts[i].z = doubleData[(offset++)];
/*      */
/*  714 */           this.localToVWorld.transform(pnts[i]);
/*      */         }
/*      */       }
/*  717 */       else if (floatData != null) {
/*  718 */         int offset = 0;
/*  719 */         for (int i = 0; i < numPts; i++)
/*      */         {
/*  722 */           pnts[i] = getPoint3d();
/*  723 */           pnts[i].x = floatData[(offset++)];
/*  724 */           pnts[i].y = floatData[(offset++)];
/*  725 */           pnts[i].z = floatData[(offset++)];
/*      */
/*  727 */           this.localToVWorld.transform(pnts[i]);
/*      */         }
/*      */       }
/*  730 */       else if (p3fData != null) {
/*  731 */         for (int i = 0; i < numPts; i++)
/*      */         {
/*  734 */           pnts[i] = getPoint3d();
/*  735 */           pnts[i].set(p3fData[i]);
/*  736 */           this.localToVWorld.transform(pnts[i]);
/*      */         }
/*      */       }
/*      */       else {
/*  740 */         for (int i = 0; i < numPts; i++)
/*      */         {
/*  743 */           pnts[i] = getPoint3d();
/*  744 */           pnts[i].set(p3dData[i]);
/*  745 */           this.localToVWorld.transform(pnts[i]);
/*      */         }
/*      */       }
/*      */     }
/*      */     else
/*      */     {
/*  751 */       int offset = 0;
/*  752 */       if ((vformat & 0x4) == 4) {
/*  753 */         offset += 3;
/*      */       }
/*  755 */       else if ((vformat & 0xC) == 12) {
/*  756 */         offset += 4;
/*      */       }
/*  758 */       if ((vformat & 0x2) != 0)
/*  759 */         offset += 3;
/*  760 */       if ((vformat & 0x20) == 32) {
/*  761 */         offset += 2 * geom.getTexCoordSetCount();
/*      */       }
/*  763 */       else if ((vformat & 0x40) == 64) {
/*  764 */         offset += 3 * geom.getTexCoordSetCount();
/*      */       }
/*  766 */       int stride = offset + 3;
/*  767 */       for (int i = 0; i < numPts; i++)
/*      */       {
/*  770 */         pnts[i] = getPoint3d();
View Full Code Here

/* 139 */     this(numVerts, 1);
/*     */   }
/*     */
/*     */   GeometryArray getGeom(int format)
/*     */   {
/* 151 */     GeometryArray obj = null;
/* 152 */     this.flags = format;
/*     */
/* 154 */     this.numTris = 0;
/*     */
/* 157 */     switch (this.currPrimType[0]) {
/*     */     case 2:
/* 159 */       obj = processTriangles();
/* 160 */       break;
/*     */     case 4:
/* 162 */       obj = processQuads();
/* 163 */       break;
/*     */     case 1:
/*     */     case 32:
/* 166 */       obj = processQuadStrips();
/* 167 */       break;
/*     */     case 16:
/* 169 */       obj = processTriangleFan();
/*     */     }
/*     */
/* 172 */     if ((obj != null) && ((this.flags & 0x20) != 0)) {
/* 173 */       obj.setCapability(18);
/* 174 */       obj.setCapability(17);
/* 175 */       obj.setCapability(8);
/* 176 */       obj.setCapability(0);
/*     */     }
/* 178 */     return obj;
/*     */   }
View Full Code Here

/* 263 */     return this.numVerts;
/*     */   }
/*     */
/*     */   private GeometryArray processQuadStrips()
/*     */   {
/* 269 */     GeometryArray obj = null;
/*     */
/* 271 */     int totalVerts = 0;
/*     */
/* 274 */     int[] stripCounts = new int[this.currPrimCnt];
/* 275 */     for (int i = 0; i < this.currPrimCnt; i++) {
/* 276 */       stripCounts[i] = (this.currPrimEndVertex[i] - this.currPrimStartVertex[i]);
/* 277 */       totalVerts += stripCounts[i];
/*     */     }
/*     */
/* 282 */     int tsaFlags = 1;
/* 283 */     if ((this.flags & 0x1) != 0)
/* 284 */       tsaFlags |= 2;
/* 285 */     if ((this.flags & 0x2) != 0) {
/* 286 */       tsaFlags |= 32;
/*     */     }
/*     */
/* 289 */     obj = new TriangleStripArray(totalVerts, tsaFlags, 1, this.texCoordSetMap, stripCounts);
/*     */
/* 293 */     Point3f[] newpts = new Point3f[totalVerts];
/* 294 */     Vector3f[] newnormals = new Vector3f[totalVerts];
/* 295 */     TexCoord2f[] newtcoords = new TexCoord2f[totalVerts];
/* 296 */     int currVert = 0;
/*     */
/* 299 */     for (i = 0; i < this.currPrimCnt; i++)
/*     */     {
/* 301 */       for (int j = this.currPrimStartVertex[i]; j < this.currPrimEndVertex[i]; j++) {
/* 302 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j);
/*     */       }
/*     */
/*     */     }
/*     */
/* 308 */     this.numVerts = currVert;
/* 309 */     this.numTris += totalVerts - this.currPrimCnt * 2;
/*     */
/* 311 */     obj.setCoordinates(0, newpts);
/* 312 */     if ((this.flags & 0x1) != 0)
/* 313 */       obj.setNormals(0, newnormals);
/* 314 */     if ((this.flags & 0x2) != 0) {
/* 315 */       obj.setTextureCoordinates(0, 0, newtcoords);
/*     */     }
/* 317 */     this.geometry = obj;
/* 318 */     return obj;
/*     */   }
View Full Code Here

/*  469 */     return this.geom;
/*      */   }
/*      */
/*      */   public boolean geometryIsIndexed()
/*      */   {
/*  474 */     GeometryArray ga = getGeometryArray();
/*  475 */     if (this.iGeom != null) {
/*  476 */       return true;
/*      */     }
/*  478 */     return false;
/*      */   }
View Full Code Here

/*      */       default:
/*  247 */         throw new IllegalArgumentException("Improper level");
/*      */       }
/*  249 */       double[] weights = morph.getWeights();
/*  250 */       for (int i = 0; i < weights.length; i++) {
/*  251 */         GeometryArray ga = morph.getGeometryArray(i);
/*  252 */         setCapabilities(ga, level);
/*      */       }
/*  254 */     } else if ((node instanceof Shape3D)) {
/*  255 */       Shape3D shape = (Shape3D)node;
/*  256 */       switch (level)
View Full Code Here

/* 318 */     return obj;
/*     */   }
/*     */
/*     */   private GeometryArray processQuads()
/*     */   {
/* 323 */     GeometryArray obj = null;
/*     */
/* 325 */     int totalVerts = 0;
/*     */
/* 327 */     for (int i = 0; i < this.currPrimCnt; i++) {
/* 328 */       totalVerts += this.currPrimEndVertex[i] - this.currPrimStartVertex[i];
/*     */     }
/*     */
/* 333 */     if (((this.flags & 0x1) != 0) && ((this.flags & 0x2) != 0))
/*     */     {
/* 335 */       obj = new QuadArray(totalVerts, 35, 1, this.texCoordSetMap);
/*     */     }
/* 342 */     else if (((this.flags & 0x1) == 0) && ((this.flags & 0x2) != 0))
/*     */     {
/* 344 */       obj = new QuadArray(totalVerts, 33, 1, this.texCoordSetMap);
/*     */     }
/* 350 */     else if (((this.flags & 0x1) != 0) && ((this.flags & 0x2) == 0))
/*     */     {
/* 352 */       obj = new QuadArray(totalVerts, 3);
/*     */     }
/*     */     else
/*     */     {
/* 357 */       obj = new QuadArray(totalVerts, 1);
/*     */     }
/*     */
/* 361 */     Point3f[] newpts = new Point3f[totalVerts];
/* 362 */     Vector3f[] newnormals = new Vector3f[totalVerts];
/* 363 */     TexCoord2f[] newtcoords = new TexCoord2f[totalVerts];
/* 364 */     int currVert = 0;
/*     */
/* 368 */     for (i = 0; i < this.currPrimCnt; i++)
/*     */     {
/* 371 */       for (int j = this.currPrimStartVertex[i]; j < this.currPrimEndVertex[i] - 3; j += 4) {
/* 372 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j);
/*     */
/* 374 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j + 1);
/*     */
/* 376 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j + 2);
/*     */
/* 378 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j + 3);
/*     */
/* 380 */         this.numTris += 2;
/*     */       }
/*     */     }
/* 383 */     this.numVerts = currVert;
/*     */
/* 385 */     obj.setCoordinates(0, newpts);
/* 386 */     if ((this.flags & 0x1) != 0)
/* 387 */       obj.setNormals(0, newnormals);
/* 388 */     if ((this.flags & 0x2) != 0) {
/* 389 */       obj.setTextureCoordinates(0, 0, newtcoords);
/*     */     }
/* 391 */     this.geometry = obj;
/* 392 */     return obj;
/*     */   }
View Full Code Here

/* 392 */     return obj;
/*     */   }
/*     */
/*     */   private GeometryArray processTriangles()
/*     */   {
/* 397 */     GeometryArray obj = null;
/*     */
/* 399 */     int totalVerts = 0;
/*     */
/* 401 */     for (int i = 0; i < this.currPrimCnt; i++) {
/* 402 */       totalVerts += this.currPrimEndVertex[i] - this.currPrimStartVertex[i];
/*     */     }
/*     */
/* 407 */     if (((this.flags & 0x1) != 0) && ((this.flags & 0x2) != 0))
/*     */     {
/* 409 */       obj = new TriangleArray(totalVerts, 35, 1, this.texCoordSetMap);
/*     */     }
/* 416 */     else if (((this.flags & 0x1) == 0) && ((this.flags & 0x2) != 0))
/*     */     {
/* 418 */       obj = new TriangleArray(totalVerts, 33, 1, this.texCoordSetMap);
/*     */     }
/* 424 */     else if (((this.flags & 0x1) != 0) && ((this.flags & 0x2) == 0))
/*     */     {
/* 426 */       obj = new TriangleArray(totalVerts, 3);
/*     */     }
/*     */     else
/*     */     {
/* 431 */       obj = new TriangleArray(totalVerts, 1);
/*     */     }
/*     */
/* 435 */     Point3f[] newpts = new Point3f[totalVerts];
/* 436 */     Vector3f[] newnormals = new Vector3f[totalVerts];
/* 437 */     TexCoord2f[] newtcoords = new TexCoord2f[totalVerts];
/* 438 */     int currVert = 0;
/*     */
/* 440 */     for (i = 0; i < this.currPrimCnt; i++) {
/* 441 */       for (int j = this.currPrimStartVertex[i]; j < this.currPrimEndVertex[i] - 2; j += 3) {
/* 442 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j);
/*     */
/* 444 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j + 1);
/*     */
/* 446 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j + 2);
/*     */
/* 448 */         this.numTris += 1;
/*     */       }
/*     */     }
/* 451 */     this.numVerts = currVert;
/*     */
/* 453 */     obj.setCoordinates(0, newpts);
/* 454 */     if ((this.flags & 0x1) != 0)
/* 455 */       obj.setNormals(0, newnormals);
/* 456 */     if ((this.flags & 0x2) != 0) {
/* 457 */       obj.setTextureCoordinates(0, 0, newtcoords);
/*     */     }
/* 459 */     this.geometry = obj;
/* 460 */     return obj;
/*     */   }
View Full Code Here

/* 460 */     return obj;
/*     */   }
/*     */
/*     */   private GeometryArray processTriangleFan()
/*     */   {
/* 467 */     GeometryArray obj = null;
/*     */
/* 469 */     int totalVerts = 0;
/*     */
/* 471 */     int[] stripCounts = new int[this.currPrimCnt];
/*     */
/* 474 */     for (int i = 0; i < this.currPrimCnt; i++) {
/* 475 */       stripCounts[i] = (this.currPrimEndVertex[i] - this.currPrimStartVertex[i]);
/* 476 */       totalVerts += stripCounts[i];
/*     */     }
/*     */
/* 480 */     int tfFlags = 1;
/* 481 */     if ((this.flags & 0x1) != 0) {
/* 482 */       tfFlags |= 2;
/*     */     }
/* 484 */     if ((this.flags & 0x2) != 0) {
/* 485 */       tfFlags |= 32;
/*     */     }
/*     */
/* 489 */     obj = new TriangleFanArray(totalVerts, tfFlags, 1, this.texCoordSetMap, stripCounts);
/*     */
/* 493 */     Point3f[] newpts = new Point3f[totalVerts];
/* 494 */     Vector3f[] newnormals = new Vector3f[totalVerts];
/* 495 */     TexCoord2f[] newtcoords = new TexCoord2f[totalVerts];
/*     */
/* 497 */     int currVert = 0;
/*     */
/* 500 */     for (i = 0; i < this.currPrimCnt; i++) {
/* 501 */       for (int j = this.currPrimStartVertex[i]; j < this.currPrimEndVertex[i]; j++) {
/* 502 */         outVertex(newpts, newnormals, newtcoords, currVert++, this.pts, this.normals, this.tcoords, j);
/*     */       }
/*     */
/*     */     }
/*     */
/* 507 */     for (i = 0; i < newpts.length; i++);
/* 511 */     this.numVerts = currVert;
/* 512 */     this.numTris = (totalVerts - this.currPrimCnt * 2);
/*     */
/* 515 */     obj.setCoordinates(0, newpts);
/*     */
/* 518 */     if ((this.flags & 0x1) != 0) {
/* 519 */       obj.setNormals(0, newnormals);
/*     */     }
/* 521 */     if ((this.flags & 0x2) != 0) {
/* 522 */       obj.setTextureCoordinates(0, 0, newtcoords);
/*     */     }
/* 524 */     this.geometry = obj;
/* 525 */     return obj;
/*     */   }
View Full Code Here

/* 144 */       debugOutputLn(2, "surf = " + surf);
/*     */
/* 147 */       LwoTexture texture = surf.getTexture();
/*     */
/* 149 */       Appearance appearance = new Appearance();
/*     */       GeometryArray object;
/* 150 */       if (shape.facetSizes[0] == 1)
/*     */       {
/* 153 */         GeometryArray object = new PointArray(vertexCount, vertexFormat);
/*     */
/* 155 */         object.setCoordinates(0, shape.coordsArray);
/* 156 */         ColoringAttributes colorAtt = new ColoringAttributes(surf.getColor(), 0);
/*     */
/* 159 */         PointAttributes pointStyle = new PointAttributes();
/* 160 */         pointStyle.setPointSize(1.0F);
/*     */
/* 162 */         appearance.setColoringAttributes(colorAtt);
/* 163 */         appearance.setPointAttributes(pointStyle);
/*     */       }
/* 165 */       else if (shape.facetSizes[0] == 2)
/*     */       {
/* 168 */         debugOutputLn(8, "Creating IndexedLineArray");
/* 169 */         GeometryArray object = new LineArray(vertexCount, vertexFormat);
/*     */
/* 171 */         object.setCoordinates(0, shape.coordsArray);
/* 172 */         ColoringAttributes colorAtt = new ColoringAttributes(surf.getColor(), 0);
/*     */
/* 175 */         appearance.setColoringAttributes(colorAtt);
/*     */       }
/*     */       else
/*     */       {
/* 179 */         debugOutputLn(8, "Creating IndexedTriFanArray");
/*     */
/* 181 */         vertexFormat |= 2;
/*     */
/* 183 */         debugOutputLn(8, "about to process vertices/indices, facetIndices = " + shape.facetIndices);
/*     */
/* 185 */         if (shape.facetIndices != null) {
/* 186 */           float[] textureCoords = null;
/* 187 */           int[] textureIndices = null;
/*     */
/* 189 */           debugOutputLn(8, "setting vertexCount, normind = " + shape.normalIndices);
/*     */
/* 191 */           debugOutputLn(8, "vtxcount, format, indcount = " + vertexCount + ", " + vertexFormat + ", " + indexCount);
/*     */
/* 194 */           if (texture != null)
/*     */           {
/* 197 */             vertexFormat |= 32;
/* 198 */             textureCoords = new float[vertexCount * 2];
/* 199 */             textureIndices = new int[shape.facetIndices.length];
/* 200 */             calculateTextureCoords(texture, shape.coordsArray, shape.facetIndices, textureCoords, textureIndices);
/*     */
/* 203 */             debugOutputLn(8, "textureCoords:");
/* 204 */             debugOutputLn(8, "texture Coords, Indices.length = " + textureCoords.length + ", " + textureIndices.length);
/*     */           }
/* 206 */           debugOutputLn(8, "about to create GeometryInfo");
/*     */
/* 209 */           GeometryInfo gi = new GeometryInfo(3);
/*     */
/* 211 */           gi.setCoordinates(shape.coordsArray);
/* 212 */           gi.setCoordinateIndices(shape.facetIndices);
/* 213 */           gi.setStripCounts(shape.facetSizes);
/* 214 */           if (texture != null) {
/* 215 */             gi.setTextureCoordinateParams(1, 2);
/* 216 */             gi.setTextureCoordinates(0, textureCoords);
/* 217 */             gi.setTextureCoordinateIndices(0, textureIndices);
/*     */           }
/* 219 */           gi.recomputeIndices();
/* 220 */           NormalGenerator ng = new NormalGenerator(surf.getCreaseAngle());
/*     */
/* 222 */           ng.generateNormals(gi);
/* 223 */           Stripifier st = new Stripifier();
/* 224 */           st.stripify(gi);
/* 225 */           GeometryArray object = gi.getGeometryArray(true, true, false);
/* 226 */           debugOutputLn(8, "done.");
/*     */         }
/*     */         else
/*     */         {
/* 232 */           debugOutputLn(8, "about to create trifanarray with vertexCount, facetSizes.len = " + vertexCount + ", " + shape.facetSizes.length);
/*     */
/* 237 */           object = new TriangleFanArray(vertexCount, vertexFormat, shape.facetSizes);
/*     */
/* 241 */           object.setCoordinates(0, shape.coordsArray);
/* 242 */           object.setNormals(0, shape.normalCoords);
/* 243 */           debugOutputLn(2, "passed in normalCoords, length = " + shape.normalCoords.length);
/*     */         }
/*     */
/* 246 */         debugOutputLn(8, "created fan array");
/*     */
View Full Code Here

TOP

Related Classes of javax.media.j3d.GeometryArray

Copyright © 2018 www.massapicom. 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.