/** * Fetch the currently shared singleton instance. * * @return The current instance */ public static NormalUtils getSharedInstance() { if(sharedInstance == null) sharedInstance = new NormalUtils(); return sharedInstance; }
/** * Clean up the internal cache and reduce it to zero. */ public void clearCachedObjects() { ecTriangulator.clearCachedObjects(); }
private void findNewRoots(int segnum) { SeidelSegment s = segments[segnum]; if(s.isInserted) return; s.root0 = locateEndpoint(s.v0, s.v1, s.root0); s.root0 = trapezoidList[s.root0].sink; s.root1 = locateEndpoint(s.v1, s.v0, s.root1); s.root1 = trapezoidList[s.root1].sink; }
private void constructTrapezoids(int nseg) { // Add the first segment and get the query structure and trapezoid // list initialised int root = initQueryStructure(chooseSegment()); for(int i = 1; i <= nseg; i++) segments[i].root0 = segments[i].root1 = root; int ls_n = logStarN(nseg); for(int h = 1; h <= ls_n; h++) { for(int i = nRatio(nseg, h - 1) + 1; i <= nRatio(nseg, h); i++) addSegment(chooseSegment()); /* Find a new root for each of the segment endpoints */ for(int i = 1; i <= nseg; i++) findNewRoots(i); } for(int i = nRatio(nseg, ls_n) + 1; i <= nseg; i++) addSegment(chooseSegment()); }
/** * Generate a new set of points for a triangle strip array. Each side is a * strip of two faces. * * @param data The data to patch the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void lineStrips(GeometryData data) throws InvalidArraySizeException { generateIndexedLineCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateIndexedLineNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateLineTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateLineTexture3D(data); if(data.stripCounts == null) data.stripCounts = new int[1]; else if(data.stripCounts.length < 1) throw new InvalidArraySizeException("Strip counts", data.stripCounts.length, 1); data.numStrips = 1; data.stripCounts[0] = facetCount + 1; }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to shape the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedQuads(GeometryData data) throws InvalidArraySizeException { generateUnindexedQuadCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedQuadNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to patch the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedLines(GeometryData data) throws InvalidArraySizeException { generateUnindexedLineCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedLineNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateLineTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateLineTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to base the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedQuads(GeometryData data) throws InvalidArraySizeException { generateUnindexedCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to base the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedTriangles(GeometryData data) throws InvalidArraySizeException { generateUnindexedTriCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateUnindexedTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to shape the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedTriangles(GeometryData data) throws InvalidArraySizeException { generateUnindexedTriCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedTriNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to base the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedTriangles(GeometryData data) throws InvalidArraySizeException { generateUnindexedTriCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedTriNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to base the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedQuads(GeometryData data) throws InvalidArraySizeException { generateUnindexedQuadCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedQuadNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to base the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedTriangles(GeometryData data) throws InvalidArraySizeException { generateUnindexedTriCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedTriNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateUnindexedTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to shape the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedQuads(GeometryData data) throws InvalidArraySizeException { generateUnindexedQuadCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedQuadNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to base the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedQuads(GeometryData data) throws InvalidArraySizeException { generateUnindexedQuadCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateUnindexedQuadTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to base the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedTriangles(GeometryData data) throws InvalidArraySizeException { generateUnindexedTriCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedTriNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Generate a new set of points for an unindexed quad array * * @param data The data to shape the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void unindexedTriangles(GeometryData data) throws InvalidArraySizeException { generateUnindexedTriCoordinates(data); if((data.geometryComponents & GeometryData.NORMAL_DATA) != 0) generateUnindexedTriNormals(data); if((data.geometryComponents & GeometryData.TEXTURE_2D_DATA) != 0) generateTriTexture2D(data); else if((data.geometryComponents & GeometryData.TEXTURE_3D_DATA) != 0) generateTriTexture3D(data); }
/** * Fetch the currently shared singleton instance. * * @return The current instance */ public static CoordinateUtils getSharedInstance() { if(sharedInstance == null) sharedInstance = new CoordinateUtils(); return sharedInstance; }
/** * Check to see if the trapezoid lies inside the polygon. * * @param t The trapezoid to test against the polygon * @return true if the trapezoid lies completely inside the polygon */ private boolean insidePolygon(SeidelTrapezoid t) { if((!t.valid) || ((t.leftSegment <= 0) || (t.rightSegment <= 0))) return false; if(((t.u0 <= 0) && (t.u1 <= 0)) || ((t.d0 <= 0) && (t.d1 <= 0))) { int rseg = t.rightSegment; return greaterThan(segments[rseg].v1, segments[rseg].v0); } return false; }
/** * Generate a new set of texCoords for a texCoord set of indexed points. * This must always be called after the coordinate generation. The * top texCoord of the cone is always perpendicular to the face. * * @param data The data to patch the calculations on * @throws InvalidArraySizeException The array is not big enough to contain * the requested geometry */ private void generateIndexedTexture2D(GeometryData data) throws InvalidArraySizeException { int vtx_cnt = data.vertexCount * 2; if(data.textureCoordinates == null) data.textureCoordinates = new float[vtx_cnt]; else if(data.textureCoordinates.length < vtx_cnt) throw new InvalidArraySizeException("Texcoords", data.textureCoordinates.length, vtx_cnt); }