List of usage examples for javax.media.j3d GeometryArray setNormals
public void setNormals(int index, Vector3f normals[])
From source file:CuboidTest.java
private GeometryArray processTriangles() { GeometryArray obj = null; int i;/*from w w w .j a v a 2 s. co m*/ int totalVerts = 0; for (i = 0; i < currPrimCnt; i++) { totalVerts += currPrimEndVertex[i] - currPrimStartVertex[i]; } if (debug >= 1) System.out.println("totalVerts " + totalVerts); if (((flags & GENERATE_NORMALS) != 0) && ((flags & GENERATE_TEXTURE_COORDS) != 0)) { obj = new TriangleArray(totalVerts, TriangleArray.COORDINATES | TriangleArray.NORMALS | TriangleArray.TEXTURE_COORDINATE_2); } else if (((flags & GENERATE_NORMALS) == 0) && ((flags & GENERATE_TEXTURE_COORDS) != 0)) { obj = new TriangleArray(totalVerts, TriangleArray.COORDINATES | TriangleArray.TEXTURE_COORDINATE_2); } else if (((flags & GENERATE_NORMALS) != 0) && ((flags & GENERATE_TEXTURE_COORDS) == 0)) { obj = new TriangleArray(totalVerts, TriangleArray.COORDINATES | TriangleArray.NORMALS); } else { obj = new TriangleArray(totalVerts, TriangleArray.COORDINATES); } Point3f[] newpts = new Point3f[totalVerts]; Vector3f[] newnormals = new Vector3f[totalVerts]; TexCoord2f[] newtcoords = new TexCoord2f[totalVerts]; int currVert = 0; for (i = 0; i < currPrimCnt; i++) { for (int j = currPrimStartVertex[i]; j < currPrimEndVertex[i] - 2; j += 3) { outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j + 1); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j + 2); numTris += 1; } } numVerts = currVert; obj.setCoordinates(0, newpts); if ((flags & GENERATE_NORMALS) != 0) obj.setNormals(0, newnormals); if ((flags & GENERATE_TEXTURE_COORDS) != 0) obj.setTextureCoordinates(0, 0, newtcoords); geometry = obj; return obj; }
From source file:CuboidTest.java
private GeometryArray processQuadStrips() { GeometryArray obj = null; int i;// www . j a va 2 s. c om int totalVerts = 0; for (i = 0; i < currPrimCnt; i++) { int numQuadStripVerts; numQuadStripVerts = currPrimEndVertex[i] - currPrimStartVertex[i]; totalVerts += (numQuadStripVerts / 2 - 1) * 4; } if (debug >= 1) System.out.println("totalVerts " + totalVerts); if (((flags & GENERATE_NORMALS) != 0) && ((flags & GENERATE_TEXTURE_COORDS) != 0)) { obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.NORMALS | QuadArray.TEXTURE_COORDINATE_2); } else if (((flags & GENERATE_NORMALS) == 0) && ((flags & GENERATE_TEXTURE_COORDS) != 0)) { obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.TEXTURE_COORDINATE_2); } else if (((flags & GENERATE_NORMALS) != 0) && ((flags & GENERATE_TEXTURE_COORDS) == 0)) { obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.NORMALS); } else { obj = new QuadArray(totalVerts, QuadArray.COORDINATES); } Point3f[] newpts = new Point3f[totalVerts]; Vector3f[] newnormals = new Vector3f[totalVerts]; TexCoord2f[] newtcoords = new TexCoord2f[totalVerts]; int currVert = 0; for (i = 0; i < currPrimCnt; i++) { for (int j = currPrimStartVertex[i] + 2; j < currPrimEndVertex[i]; j += 2) { outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j - 2); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j - 1); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j + 1); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j); numTris += 2; } } numVerts = currVert; obj.setCoordinates(0, newpts); if ((flags & GENERATE_NORMALS) != 0) obj.setNormals(0, newnormals); if ((flags & GENERATE_TEXTURE_COORDS) != 0) obj.setTextureCoordinates(0, 0, newtcoords); geometry = obj; return obj; }
From source file:CuboidTest.java
private GeometryArray processQuads() { GeometryArray obj = null; int i;/* w w w. j av a 2 s . com*/ int totalVerts = 0; for (i = 0; i < currPrimCnt; i++) { totalVerts += currPrimEndVertex[i] - currPrimStartVertex[i]; } if (debug >= 1) System.out.println("totalVerts " + totalVerts); if (((flags & GENERATE_NORMALS) != 0) && ((flags & GENERATE_TEXTURE_COORDS) != 0)) { obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.NORMALS | QuadArray.TEXTURE_COORDINATE_2); } else if (((flags & GENERATE_NORMALS) == 0) && ((flags & GENERATE_TEXTURE_COORDS) != 0)) { obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.TEXTURE_COORDINATE_2); } else if (((flags & GENERATE_NORMALS) != 0) && ((flags & GENERATE_TEXTURE_COORDS) == 0)) { obj = new QuadArray(totalVerts, QuadArray.COORDINATES | QuadArray.NORMALS); } else { obj = new QuadArray(totalVerts, QuadArray.COORDINATES); } Point3f[] newpts = new Point3f[totalVerts]; Vector3f[] newnormals = new Vector3f[totalVerts]; TexCoord2f[] newtcoords = new TexCoord2f[totalVerts]; int currVert = 0; if (debug > 1) System.out.println("total prims " + currPrimCnt); for (i = 0; i < currPrimCnt; i++) { if (debug > 1) System.out.println("start " + currPrimStartVertex[i] + " end " + currPrimEndVertex[i]); for (int j = currPrimStartVertex[i]; j < currPrimEndVertex[i] - 3; j += 4) { outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j + 1); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j + 2); outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j + 3); numTris += 2; } } numVerts = currVert; obj.setCoordinates(0, newpts); if ((flags & GENERATE_NORMALS) != 0) obj.setNormals(0, newnormals); if ((flags & GENERATE_TEXTURE_COORDS) != 0) obj.setTextureCoordinates(0, 0, newtcoords); geometry = obj; return obj; }