Package com.sun.j3d.utils.geometry

Examples of com.sun.j3d.utils.geometry.GeometryInfo


/*  911 */       String curname = (String)e.next();
/*  912 */       ArrayList triList = (ArrayList)this.triSgroups.get(curname);
/*      */
/*  915 */       if (triList.size() > 0)
/*      */       {
/*  917 */         GeometryInfo gi = new GeometryInfo(1);
/*      */
/*  919 */         gi.setCoordinateIndices(groupIndices(this.coordIdxList, triList));
/*  920 */         gi.setCoordinates(this.coordArray);
/*      */
/*  922 */         if (curname.equals("0")) ng0.generateNormals(gi); else {
/*  923 */           ng.generateNormals(gi);
/*      */         }
/*      */
/*  926 */         Vector3f[] genNorms = gi.getNormals();
/*  927 */         int[] genNormIndices = gi.getNormalIndices();
/*      */
/*  934 */         int normIdx = 0;
/*      */
/*  936 */         for (int i = 0; i < triList.size(); i++)
/*      */         {
View Full Code Here


/*  994 */     ArrayList newCoordIdxList = null;
/*  995 */     ArrayList newTexIdxList = null;
/*  996 */     ArrayList newNormIdxList = null;
/*      */
/*  998 */     if (triangulate) {
/*  999 */       GeometryInfo gi = new GeometryInfo(5);
/* 1000 */       gi.setStripCounts(objectToIntArray(this.stripCounts));
/* 1001 */       gi.setCoordinates(this.coordArray);
/* 1002 */       gi.setCoordinateIndices(objectToIntArray(this.coordIdxList));
/* 1003 */       if (textures) {
/* 1004 */         gi.setTextureCoordinateParams(1, 2);
/* 1005 */         gi.setTextureCoordinates(0, this.texArray);
/* 1006 */         gi.setTextureCoordinateIndices(0, objectToIntArray(this.texIdxList));
/*      */       }
/* 1008 */       if (normals) {
/* 1009 */         gi.setNormals(this.normArray);
/* 1010 */         gi.setNormalIndices(objectToIntArray(this.normIdxList));
/*      */       }
/* 1012 */       gi.convertToIndexedTriangles();
/*      */
/* 1017 */       int[] coordIndicesArray = gi.getCoordinateIndices();
/*      */
/* 1021 */       int tris = 0;
/* 1022 */       for (int i = 0; i < numFaces; i++) {
/* 1023 */         tris += ((Integer)this.stripCounts.get(i)).intValue() - 2;
/*      */       }
/* 1025 */       if (coordIndicesArray.length != tris * 3)
/*      */       {
/* 1028 */         triangulate = false;
/*      */       }
/*      */       else {
/* 1031 */         int[] texIndicesArray = gi.getTextureCoordinateIndices();
/* 1032 */         int[] normIndicesArray = gi.getNormalIndices();
/*      */
/* 1035 */         this.coordIdxList.clear();
/* 1036 */         this.texIdxList.clear();
/* 1037 */         this.normIdxList.clear();
/* 1038 */         for (int i = 0; i < coordIndicesArray.length; i++) {
View Full Code Here

/* 1186 */       String curname = (String)e.next();
/* 1187 */       ArrayList triList = (ArrayList)this.triGroups.get(curname);
/*      */
/* 1190 */       if (triList.size() > 0)
/*      */       {
/* 1192 */         GeometryInfo gi = new GeometryInfo(1);
/*      */
/* 1194 */         gi.setCoordinateIndices(groupIndices(this.coordIdxList, triList));
/* 1195 */         gi.setCoordinates(this.coordArray);
/*      */
/* 1197 */         if (do_tex) {
/* 1198 */           gi.setTextureCoordinateParams(1, 2);
/* 1199 */           gi.setTextureCoordinates(0, this.texArray);
/* 1200 */           gi.setTextureCoordinateIndices(0, groupIndices(this.texIdxList, triList));
/*      */         }
/*      */
/* 1204 */         if (gen_norms) {
/* 1205 */           if ((this.flags & 0x100) != 0) gi.reverse();
/* 1206 */           ng.generateNormals(gi);
/*      */         }
/*      */         else
/*      */         {
/* 1213 */           gi.setNormalIndices(groupIndices(this.normIdxList, triList));
/* 1214 */           gi.setNormals(this.normArray);
/* 1215 */           if ((this.flags & 0x100) != 0) gi.reverse();
/*      */         }
/*      */
/* 1218 */         if ((this.flags & 0x200) != 0) {
/* 1219 */           strippy.stripify(gi);
/*      */         }
/*      */
/* 1228 */         Shape3D shape = new Shape3D();
/*      */
/* 1230 */         shape.setGeometry(gi.getGeometryArray(true, true, false));
/*      */
/* 1232 */         String matName = (String)this.groupMaterials.get(curname);
/* 1233 */         this.materials.assignMaterial(matName, shape);
/*      */
/* 1235 */         group.addChild(shape);
View Full Code Here

/* 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);
View Full Code Here

/*  199 */       int flag = -1; int numContours = 0; int numPoints = 0; int num = 0;
/*  200 */       UnorderList coords = new UnorderList(100, Point3f.class);
/*  201 */       float[] tmpCoords = new float[6];
/*  202 */       float lastX = 0.0F; float lastY = 0.0F;
/*  203 */       float firstPntx = 3.4028235E+38F; float firstPnty = 3.4028235E+38F;
/*  204 */       GeometryInfo gi = null;
/*  205 */       NormalGenerator ng = new NormalGenerator();
/*  206 */       FastVector contours = new FastVector(10);
/*  207 */       float maxY = -3.402824E+038F;
/*  208 */       int maxYIndex = 0; int beginIdx = 0; int endIdx = 0; int start = 0;
/*      */
/*  210 */       boolean setMaxY = false;
/*      */
/*  213 */       while (!pIt.isDone()) {
/*  214 */         Point3f vertex = new Point3f();
/*  215 */         flag = pIt.currentSegment(tmpCoords);
/*  216 */         if (flag == 4) {
/*  217 */           if (num > 0) {
/*  218 */             if (setMaxY)
/*      */             {
/*  220 */               beginIdx = start;
/*  221 */               endIdx = numPoints - 1;
/*      */             }
/*  223 */             contours.addElement(num);
/*  224 */             num = 0;
/*  225 */             numContours++;
/*      */           }
/*      */         } else { if (flag == 0) {
/*  228 */             vertex.x = tmpCoords[0];
/*  229 */             vertex.y = tmpCoords[1];
/*  230 */             lastX = vertex.x;
/*  231 */             lastY = vertex.y;
/*      */
/*  233 */             if ((lastX == firstPntx) && (lastY == firstPnty)) {
/*  234 */               pIt.next();
/*  235 */               continue;
/*      */             }
/*  237 */             setMaxY = false;
/*  238 */             coords.add(vertex);
/*  239 */             firstPntx = lastX;
/*  240 */             firstPnty = lastY;
/*  241 */             if (num > 0) {
/*  242 */               contours.addElement(num);
/*  243 */               num = 0;
/*  244 */               numContours++;
/*      */             }
/*  246 */             num++;
/*  247 */             numPoints++;
/*      */
/*  250 */             start = numPoints; break label525;
/*  251 */           }if (flag == 1) {
/*  252 */             vertex.x = tmpCoords[0];
/*  253 */             vertex.y = tmpCoords[1];
/*      */
/*  258 */             if ((vertex.x == lastX) && (vertex.y == lastY)) {
/*  259 */               pIt.next();
/*  260 */               continue;
/*      */             }
/*  262 */             if (vertex.y > maxY) {
/*  263 */               maxY = vertex.y;
/*  264 */               maxYIndex = numPoints;
/*  265 */               setMaxY = true;
/*      */             }
/*  267 */             lastX = vertex.x;
/*  268 */             lastY = vertex.y;
/*  269 */             coords.add(vertex);
/*  270 */             num++;
/*  271 */             numPoints++;
/*      */           } }
/*  273 */         label525: pIt.next();
/*      */       }
/*      */
/*  278 */       if (numPoints == 0) {
/*  279 */         return null;
/*      */       }
/*      */
/*  285 */       Point3f p1 = new Point3f(); Point3f p2 = new Point3f(); Point3f p3 = new Point3f();
/*  286 */       boolean flip_side_orient = true;
/*  287 */       Point3f[] vertices = (Point3f[])coords.toArray(false);
/*      */
/*  289 */       if (endIdx - beginIdx > 0)
/*      */       {
/*  294 */         if (maxYIndex == beginIdx)
/*  295 */           p1.set(vertices[endIdx]);
/*      */         else {
/*  297 */           p1.set(vertices[(maxYIndex - 1)]);
/*      */         }
/*  299 */         p2.set(vertices[maxYIndex]);
/*  300 */         if (maxYIndex == endIdx)
/*  301 */           p3.set(vertices[beginIdx]);
/*      */         else {
/*  303 */           p3.set(vertices[(maxYIndex + 1)]);
/*      */         }
/*      */
/*  306 */         if (p3.x != p2.x) {
/*  307 */           if (p1.x != p2.x)
/*      */           {
/*  309 */             if (Math.abs((p2.y - p1.y) / (p2.x - p1.x)) > Math.abs((p3.y - p2.y) / (p3.x - p2.x)))
/*      */             {
/*  311 */               flip_side_orient = p3.x > p2.x;
/*      */             }
/*  313 */             else flip_side_orient = p2.x > p1.x;
/*      */           }
/*      */           else {
/*  316 */             flip_side_orient = p3.x > p2.x;
/*      */           }
/*      */
/*      */         }
/*      */         else
/*      */         {
/*  323 */           flip_side_orient = p2.x > p1.x;
/*      */         }
/*      */
/*      */       }
/*      */
/*  328 */       int startIdx = 0;
/*  329 */       IslandsNode islandsTree = new IslandsNode(-1, -1);
/*  330 */       int[] contourCounts = contours.getData();
/*      */
/*  333 */       for (int i = 0; i < contours.getSize(); i++) {
/*  334 */         endIdx = startIdx + contourCounts[i];
/*  335 */         islandsTree.insert(new IslandsNode(startIdx, endIdx), vertices);
/*  336 */         startIdx = endIdx;
/*      */       }
/*      */
/*  339 */       coords = null;
/*  340 */       contours = null;
/*  341 */       contourCounts = null;
/*      */
/*  344 */       UnorderList islandsList = new UnorderList(10, IslandsNode.class);
/*  345 */       islandsTree.collectOddLevelNode(islandsList, 0);
/*  346 */       IslandsNode[] nodes = (IslandsNode[])islandsList.toArray(false);
/*  347 */       int[][] islandCounts = new int[islandsList.arraySize()][];
/*  348 */       Point3f[][] outVerts = new Point3f[islandCounts.length][];
/*      */
/*  352 */       for (i = 0; i < islandCounts.length; i++) {
/*  353 */         IslandsNode node = nodes[i];
/*  354 */         int nchild = node.numChild();
/*  355 */         islandCounts[i] = new int[nchild + 1];
/*  356 */         islandCounts[i][0] = node.numVertices();
/*  357 */         int sum = 0;
/*  358 */         sum += islandCounts[i][0];
/*  359 */         for (int j = 0; j < nchild; j++) {
/*  360 */           islandCounts[i][(j + 1)] = node.getChild(j).numVertices();
/*  361 */           sum += islandCounts[i][(j + 1)];
/*      */         }
/*  363 */         outVerts[i] = new Point3f[sum];
/*  364 */         startIdx = 0;
/*  365 */         for (int k = node.startIdx; k < node.endIdx; k++) {
/*  366 */           outVerts[i][(startIdx++)] = vertices[k];
/*      */         }
/*      */
/*  369 */         for (j = 0; j < nchild; j++) {
/*  370 */           endIdx = node.getChild(j).endIdx;
/*  371 */           for (k = node.getChild(j).startIdx; k < endIdx; k++) {
/*  372 */             outVerts[i][(startIdx++)] = vertices[k];
/*      */           }
/*      */
/*      */         }
/*      */
/*      */       }
/*      */
/*  379 */       islandsTree = null;
/*  380 */       islandsList = null;
/*  381 */       vertices = null;
/*      */
/*  383 */       contourCounts = new int[1];
/*  384 */       int currCoordIndex = 0; int vertOffset = 0;
/*  385 */       ArrayList triangData = new ArrayList();
/*      */
/*  387 */       Point3f q1 = new Point3f(); Point3f q2 = new Point3f(); Point3f q3 = new Point3f();
/*  388 */       Vector3f n1 = new Vector3f(); Vector3f n2 = new Vector3f();
/*  389 */       numPoints = 0;
/*      */
/*  392 */       for (i = 0; i < islandCounts.length; i++)
/*      */       {
/*  394 */         contourCounts[0] = islandCounts[i].length;
/*  395 */         numPoints += outVerts[i].length;
/*  396 */         gi = new GeometryInfo(5);
/*  397 */         gi.setCoordinates(outVerts[i]);
/*  398 */         gi.setStripCounts(islandCounts[i]);
/*  399 */         gi.setContourCounts(contourCounts);
/*  400 */         ng.generateNormals(gi);
/*      */
/*  402 */         GeometryArray ga = gi.getGeometryArray(false, false, false);
/*  403 */         vertOffset += ga.getVertexCount();
/*      */
/*  405 */         triangData.add(ga);
/*      */       }
/*      */       int vertCnt;
View Full Code Here

TOP

Related Classes of com.sun.j3d.utils.geometry.GeometryInfo

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.