From: Gerardo H. <ma...@us...> - 2004-04-08 21:16:44
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11866/src/org/jrman/primitive Modified Files: Primitive.java PointsPolygons.java Log Message: Refactored parameter selection. Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Primitive.java 8 Apr 2004 17:34:38 -0000 1.29 --- Primitive.java 8 Apr 2004 21:03:32 -0000 1.30 *************** *** 21,26 **** import javax.vecmath.Color3f; - import javax.vecmath.Point3f; - import javax.vecmath.Vector3f; import org.jrman.attributes.Attributes; --- 21,24 ---- Index: PointsPolygons.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/PointsPolygons.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PointsPolygons.java 2 Feb 2004 19:30:05 -0000 1.1 --- PointsPolygons.java 8 Apr 2004 21:03:32 -0000 1.2 *************** *** 39,44 **** VaryingScalarTuple3f points; - VaryingScalarTuple3f normals; - public PointsPolygons( int[] nVertices, --- 39,42 ---- *************** *** 52,57 **** points = (VaryingScalarTuple3f) parameters.getParameter("P"); parameters.removeParameter("P"); - normals = (VaryingScalarTuple3f) parameters.getParameter("N"); - parameters.removeParameter("N"); } --- 50,53 ---- *************** *** 69,74 **** int offset = 0; for (int i = 0; i < nVertices.length; i++) { ! result[i] = ! new Polygon(nVertices[i], offset, parameters, attributes); offset += nVertices[i]; } --- 65,69 ---- int offset = 0; for (int i = 0; i < nVertices.length; i++) { ! result[i] = new Polygon(nVertices[i], offset, parameters, attributes); offset += nVertices[i]; } *************** *** 104,140 **** public Primitive[] split() { Primitive[] result = new Primitive[n - 3 + 1]; for (int i = 1; i < n - 1; i++) { ! VaryingScalarTuple3f npoints = ! new VaryingScalarTuple3f(points.getDeclaration(), new float[4 * 3]); ! VaryingScalarTuple3f nnormals = null; ! if (normals != null) ! nnormals = ! new VaryingScalarTuple3f(normals.getDeclaration(), new float[4 * 3]); ! ParameterList newParameters = new ParameterList(parameters); ! points.getValue(vertices[offset], tmpPoint); ! npoints.setValue(0, tmpPoint); ! points.getValue(vertices[offset + i], tmpPoint); ! npoints.setValue(1, tmpPoint); ! points.getValue(vertices[offset], tmpPoint); ! npoints.setValue(2, tmpPoint); ! points.getValue(vertices[offset + i + 1], tmpPoint); ! npoints.setValue(3, tmpPoint); ! if (normals != null) { ! normals.getValue(vertices[offset], tmpPoint); ! nnormals.setValue(0, tmpPoint); ! normals.getValue(vertices[offset + i], tmpPoint); ! nnormals.setValue(1, tmpPoint); ! normals.getValue(vertices[offset], tmpPoint); ! nnormals.setValue(2, tmpPoint); ! normals.getValue(vertices[offset + i + 1], tmpPoint); ! nnormals.setValue(3, tmpPoint); ! } ! newParameters.removeParameter(npoints.getDeclaration().getName()); ! newParameters.addParameter(npoints); ! if (normals != null) { ! newParameters.removeParameter(nnormals.getDeclaration().getName()); ! newParameters.addParameter(nnormals); ! } ! result[i - 1] = new BilinearPatch(newParameters, attributes); } return result; --- 99,109 ---- public Primitive[] split() { Primitive[] result = new Primitive[n - 3 + 1]; + int[] indexes = new int[] { vertices[offset], 0, vertices[offset], 0 }; for (int i = 1; i < n - 1; i++) { ! indexes[1] = vertices[offset + i]; ! indexes[3] = vertices[offset + i + 1]; ! ParameterList pl = parameters.selectValues(indexes); ! pl.addParameter(points.selectValues(indexes)); ! result[i - 1] = new BilinearPatch(pl, attributes); } return result; |