From: Gerardo H. <ma...@us...> - 2007-02-26 19:35:59
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv30698/src/org/jrman/primitive Modified Files: BicubicPatch.java BilinearPatch.java Cone.java CubicCurve.java Cylinder.java DelayedReadArchive.java Disk.java Hyperboloid.java LinearCurve.java Paraboloid.java Point.java PointsPolygons.java Primitive.java Sphere.java SubdivisionMesh.java Torus.java Log Message: Check for Catmull Clark scheme before trying to instance a Subdivision Mesh. Started reformatting source code to fit in 80 columns, remove tabs and ugly formatting done by Eclipse. Index: Torus.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Torus.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Torus.java 25 Dec 2006 07:50:37 -0000 1.10 --- Torus.java 26 Feb 2007 19:35:52 -0000 1.11 *************** *** 50,62 **** private float thetaMax; ! public Torus( ! float majorRadius, ! float minorRadius, ! float phiMin, ! float phiMax, ! float thetaMin, ! float thetaMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.majorRadius = majorRadius; --- 50,61 ---- private float thetaMax; ! public Torus(float majorRadius, ! float minorRadius, ! float phiMin, ! float phiMax, ! float thetaMin, ! float thetaMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.majorRadius = majorRadius; *************** *** 132,176 **** if ((thetaMax - thetaMin) * majorRadius > (phiMax - phiMin) * minorRadius) { ! result[0] = ! new Torus( ! majorRadius, ! minorRadius, ! phiMin, ! phiMax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = ! new Torus( ! majorRadius, ! minorRadius, ! phiMin, ! phiMax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); } else { ! result[0] = ! new Torus( ! majorRadius, ! minorRadius, ! phiMin, ! (phiMin + phiMax) / 2f, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); ! result[1] = ! new Torus( ! majorRadius, ! minorRadius, ! (phiMin + phiMax) / 2f, ! phiMax, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); } return result; --- 131,171 ---- if ((thetaMax - thetaMin) * majorRadius > (phiMax - phiMin) * minorRadius) { ! result[0] = new Torus(majorRadius, ! minorRadius, ! phiMin, ! phiMax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! bilinearInterpolateParameters(0f, .5f, ! 0f, 1f), ! attributes); ! result[1] = new Torus(majorRadius, ! minorRadius, ! phiMin, ! phiMax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! bilinearInterpolateParameters(.5f, 1f, ! 0f, 1f), ! attributes); } else { ! result[0] = new Torus(majorRadius, ! minorRadius, ! phiMin, ! (phiMin + phiMax) / 2f, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, ! 0f, .5f), ! attributes); ! result[1] = new Torus(majorRadius, ! minorRadius, ! (phiMin + phiMax) / 2f, ! phiMax, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, ! .5f, 1f), ! attributes); } return result; Index: LinearCurve.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/LinearCurve.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LinearCurve.java 30 Dec 2006 16:32:23 -0000 1.6 --- LinearCurve.java 26 Feb 2007 19:35:51 -0000 1.7 *************** *** 288,305 **** } - /* - protected void dice_v(ShaderVariables shaderVariables) { - FloatGrid g = shaderVariables.v; - int vSize = Grid.getVSize(); - float vStep = 1f / (vSize - 1); - float v = 0; - for (int i = 0; i < vSize; i++) { - g.set(0, i, v); - g.set(1, i, v); - v += vStep; - } - } - */ - } --- 288,291 ---- Index: SubdivisionMesh.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/SubdivisionMesh.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SubdivisionMesh.java 26 Feb 2007 15:25:15 -0000 1.1 --- SubdivisionMesh.java 26 Feb 2007 19:35:52 -0000 1.2 *************** *** 47,52 **** VaryingScalarTuple3f points; ! public SubdivisionMesh(String scheme, ! int[] nvertices, int[] vertices, String[] tags, --- 47,51 ---- VaryingScalarTuple3f points; ! public SubdivisionMesh(int[] nvertices, int[] vertices, String[] tags, *************** *** 56,62 **** ParameterList parameters, Attributes attributes) { - if (!scheme.equals("catmull-clark")) - throw new IllegalArgumentException("Subdivison scheme " + scheme + - " not supported"); this.parameters = parameters; this.attributes = attributes; --- 55,58 ---- Index: PointsPolygons.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/PointsPolygons.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PointsPolygons.java 26 Feb 2007 15:25:15 -0000 1.7 --- PointsPolygons.java 26 Feb 2007 19:35:52 -0000 1.8 *************** *** 39,47 **** VaryingScalarTuple3f points; ! public PointsPolygons( ! int[] nVertices, ! int[] vertices, ! ParameterList parameters, ! Attributes attributes) { this.parameters = parameters; this.attributes = attributes; --- 39,46 ---- VaryingScalarTuple3f points; ! public PointsPolygons(int[] nVertices, ! int[] vertices, ! ParameterList parameters, ! Attributes attributes) { this.parameters = parameters; this.attributes = attributes; *************** *** 51,55 **** parameters.removeParameter("P"); } ! public BoundingVolume getBoundingVolume() { MutableBounds3f mb = new MutableBounds3f(); --- 50,54 ---- parameters.removeParameter("P"); } ! public BoundingVolume getBoundingVolume() { MutableBounds3f mb = new MutableBounds3f(); *************** *** 65,69 **** int offset = 0; for (int i = 0; i < nVertices.length; i++) { ! result[i] = new Polygon(i, nVertices[i], offset, parameters, attributes); offset += nVertices[i]; } --- 64,69 ---- int offset = 0; for (int i = 0; i < nVertices.length; i++) { ! result[i] = new Polygon(i, nVertices[i], offset, ! parameters, attributes); offset += nVertices[i]; } *************** *** 83,87 **** private int offset; ! Polygon(int pos, int n, int offset, ParameterList parameters, Attributes attributes) { this.pos = pos; this.n = n; --- 83,88 ---- private int offset; ! Polygon(int pos, int n, int offset, ParameterList parameters, ! Attributes attributes) { this.pos = pos; this.n = n; *************** *** 104,112 **** int[] posIndex = new int[1]; posIndex[0] = pos; ! 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(posIndex, indexes, indexes); pl.addParameter(points.selectValues(indexes)); result[i - 1] = new BilinearPatch(pl, attributes); --- 105,115 ---- int[] posIndex = new int[1]; posIndex[0] = pos; ! 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(posIndex, indexes, indexes); pl.addParameter(points.selectValues(indexes)); result[i - 1] = new BilinearPatch(pl, attributes); Index: Sphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Sphere.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Sphere.java 25 Dec 2006 07:50:37 -0000 1.23 --- Sphere.java 26 Feb 2007 19:35:52 -0000 1.24 *************** *** 44,55 **** private float thetaMax; ! public Sphere( ! float radius, ! float phiMin, ! float phiMax, ! float thetaMin, ! float thetaMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; --- 44,54 ---- private float thetaMax; ! public Sphere(float radius, ! float phiMin, ! float phiMax, ! float thetaMin, ! float thetaMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; *************** *** 123,163 **** Primitive[] result = new Primitive[2]; if (thetaMax - thetaMin > phiMax - phiMin) { ! result[0] = ! new Sphere( ! radius, ! phiMin, ! phiMax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = ! new Sphere( ! radius, ! phiMin, ! phiMax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); } else { ! result[0] = ! new Sphere( ! radius, ! phiMin, ! (phiMin + phiMax) / 2f, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); ! result[1] = ! new Sphere( ! radius, ! (phiMin + phiMax) / 2f, ! phiMax, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); } return result; --- 122,158 ---- Primitive[] result = new Primitive[2]; if (thetaMax - thetaMin > phiMax - phiMin) { ! result[0] = new Sphere(radius, ! phiMin, ! phiMax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! bilinearInterpolateParameters(0f, .5f, ! 0f, 1f), ! attributes); ! result[1] = new Sphere(radius, ! phiMin, ! phiMax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! bilinearInterpolateParameters(.5f, 1f, ! 0f, 1f), ! attributes); } else { ! result[0] = new Sphere(radius, ! phiMin, ! (phiMin + phiMax) / 2f, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, ! 0f, .5f), ! attributes); ! result[1] = new Sphere(radius, ! (phiMin + phiMax) / 2f, ! phiMax, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, ! .5f, 1f), ! attributes); } return result; Index: Hyperboloid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Hyperboloid.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Hyperboloid.java 25 Dec 2006 07:50:37 -0000 1.10 --- Hyperboloid.java 26 Feb 2007 19:35:51 -0000 1.11 *************** *** 33,198 **** public class Hyperboloid extends Quadric { ! private static Point3f tmp = new Point3f(); ! ! private static Vector3f vtmp = new Vector3f(); ! ! private static Point3f p1 = new Point3f(); ! ! private static Point3f p2 = new Point3f(); ! ! private static Vector3f v1 = new Vector3f(); ! ! private static Vector3f v2 = new Vector3f(); ! ! private float x1; ! ! private float y1; ! ! private float z1; ! ! private float x2; ! ! private float y2; ! ! private float z2; ! ! private float thetaMin; ! ! private float thetaMax; ! ! public Hyperboloid( ! float x1, ! float y1, ! float z1, ! float x2, ! float y2, ! float z2, ! float thetaMin, ! float thetaMax, ! ParameterList parameters, ! Attributes attributes) { ! super(parameters, attributes); ! this.x1 = x1; ! this.y1 = y1; ! this.z1 = z1; ! this.x2 = x2; ! this.y2 = y2; ! this.z2 = z2; ! this.thetaMin = thetaMin; ! this.thetaMax = thetaMax; ! } ! ! public BoundingVolume getBoundingVolume() { ! ! float cosTMin = (float) Math.cos(thetaMin); ! float sinTMin = (float) Math.sin(thetaMin); ! float cosTMax = (float) Math.cos(thetaMax); ! float sinTMax = (float) Math.sin(thetaMax); ! float x1Min = x1 * cosTMin - y1 * sinTMin; ! float y1Min = x1 * sinTMin + y1 * cosTMin; ! ! float gamma1Min = (float) Math.atan2(y1Min, x1Min); ! if (gamma1Min < 0) ! gamma1Min += (float) Math.PI * 2f; ! float gamma1Max = gamma1Min + (thetaMax - thetaMin); ! ! float r1 = (float) Math.sqrt((x1 * x1) + (y1 * y1)); ! float[] values1 = analizeAngleCase(r1, gamma1Min, gamma1Max); ! float x11Min = values1[0]; ! float x11Max = values1[1]; ! float y11Min = values1[2]; ! float y11Max = values1[3]; ! ! float x2Min = x2 * cosTMin - y2 * sinTMin; ! float y2Min = x2 * sinTMin + y2 * cosTMin; ! ! float gamma2Min = (float) Math.atan2(y2Min, x2Min); ! if (gamma2Min < 0) ! gamma2Min += (float) Math.PI * 2f; ! float gamma2Max = gamma2Min + (thetaMax - thetaMin); ! ! float r2 = (float) Math.sqrt((x2 * x2) + (y2 * y2)); ! float[] values2 = analizeAngleCase(r2, gamma2Min, gamma2Max); ! float x22Min = values2[0]; ! float x22Max = values2[1]; ! float y22Min = values2[2]; ! float y22Max = values2[3]; ! ! float xMin = Math.min(x11Min, x22Min); ! float xMax = Math.max(x11Max, x22Max); ! float yMin = Math.min(y11Min, y22Min); ! float yMax = Math.max(y11Max, y22Max); ! float zMin = Math.min(z1, z2); ! float zMax = Math.max(z1, z2); ! ! Bounds3f b3f = new Bounds3f(xMin, xMax, yMin, yMax, zMin, zMax); ! return b3f; ! } ! ! private boolean passAngle(float angle, float minAngle, float maxAngle) { ! return minAngle < angle && angle < maxAngle; ! } ! ! private float[] analizeAngleCase(float r, float gammaMin, ! float gammaMax) { ! ! float[] values = new float[4]; ! float cosGammaMin = (float) Math.cos(gammaMin); ! float sinGammaMin = (float) Math.sin(gammaMin); ! float cosGammaMax = (float) Math.cos(gammaMax); ! float sinGammaMax = (float) Math.sin(gammaMax); ! float xMin = Math.min(r * cosGammaMin, r * cosGammaMax); ! float xMax = Math.max(r * cosGammaMin, r * cosGammaMax); ! float yMin = Math.min(r * sinGammaMin, r * sinGammaMax); ! float yMax = Math.max(r * sinGammaMin, r * sinGammaMax); ! ! if (passAngle((float) Math.PI / 2f, gammaMin, gammaMax) ! || passAngle( ! (float) Math.PI / 2f + (float) Math.PI * 2f, ! gammaMin, ! gammaMax)) { ! yMax = r; ! } ! if (passAngle((float) Math.PI, gammaMin, gammaMax) ! || passAngle( ! (float) Math.PI + (float) Math.PI * 2f, ! gammaMin, ! gammaMax)) { ! xMin = -r; ! } ! if (passAngle((float) Math.PI * 3f / 2f, gammaMin, gammaMax) ! || passAngle( ! (float) Math.PI * 3f / 2f + (float) Math.PI * 2f, ! gammaMin, ! gammaMax)) { ! yMin = -r; ! } ! if (passAngle(0f, gammaMin, gammaMax) ! || passAngle( ! (float) Math.PI * 2f, gammaMin, gammaMax)) { ! xMax = r; ! } ! values[0] = xMin; ! values[1] = xMax; ! values[2] = yMin; ! values[3] = yMax; ! return values; ! } ! ! public Primitive[] split() { ! ! float r1 = (float) Math.sqrt((x1 * x1) + (y1 * y1)); ! float r2 = (float) Math.sqrt((x2 * x2) + (y2 * y2)); ! float r = ! (float) Math.sqrt( ! (x2 - x1) * (x2 - x1) ! + (y2 - y1) * (y2 - y1) ! + (z2 - z1) * (z2 - z1)); ! Primitive[] result = new Primitive[2]; ! if ((thetaMax - thetaMin) * (float) Math.max(r1, r2) > r) { ! result[0] = ! new Hyperboloid( ! x1, y1, z1, --- 33,187 ---- public class Hyperboloid extends Quadric { + + private static Point3f tmp = new Point3f(); + + private static Vector3f vtmp = new Vector3f(); + + private static Point3f p1 = new Point3f(); + + private static Point3f p2 = new Point3f(); + + private static Vector3f v1 = new Vector3f(); + + private static Vector3f v2 = new Vector3f(); + + private float x1; + + private float y1; + + private float z1; + + private float x2; + + private float y2; + + private float z2; + + private float thetaMin; + + private float thetaMax; + + public Hyperboloid(float x1, + float y1, + float z1, + float x2, + float y2, + float z2, + float thetaMin, + float thetaMax, + ParameterList parameters, + Attributes attributes) { + super(parameters, attributes); + this.x1 = x1; + this.y1 = y1; + this.z1 = z1; + this.x2 = x2; + this.y2 = y2; + this.z2 = z2; + this.thetaMin = thetaMin; + this.thetaMax = thetaMax; + } + + public BoundingVolume getBoundingVolume() { + float cosTMin = (float) Math.cos(thetaMin); + float sinTMin = (float) Math.sin(thetaMin); + float cosTMax = (float) Math.cos(thetaMax); + float sinTMax = (float) Math.sin(thetaMax); + float x1Min = x1 * cosTMin - y1 * sinTMin; + float y1Min = x1 * sinTMin + y1 * cosTMin; + + float gamma1Min = (float) Math.atan2(y1Min, x1Min); + if (gamma1Min < 0) + gamma1Min += (float) Math.PI * 2f; + float gamma1Max = gamma1Min + (thetaMax - thetaMin); + + float r1 = (float) Math.sqrt((x1 * x1) + (y1 * y1)); + float[] values1 = analizeAngleCase(r1, gamma1Min, gamma1Max); + float x11Min = values1[0]; + float x11Max = values1[1]; + float y11Min = values1[2]; + float y11Max = values1[3]; + + float x2Min = x2 * cosTMin - y2 * sinTMin; + float y2Min = x2 * sinTMin + y2 * cosTMin; ! float gamma2Min = (float) Math.atan2(y2Min, x2Min); ! if (gamma2Min < 0) ! gamma2Min += (float) Math.PI * 2f; ! float gamma2Max = gamma2Min + (thetaMax - thetaMin); ! ! float r2 = (float) Math.sqrt((x2 * x2) + (y2 * y2)); ! float[] values2 = analizeAngleCase(r2, gamma2Min, gamma2Max); ! float x22Min = values2[0]; ! float x22Max = values2[1]; ! float y22Min = values2[2]; ! float y22Max = values2[3]; ! ! float xMin = Math.min(x11Min, x22Min); ! float xMax = Math.max(x11Max, x22Max); ! float yMin = Math.min(y11Min, y22Min); ! float yMax = Math.max(y11Max, y22Max); ! float zMin = Math.min(z1, z2); ! float zMax = Math.max(z1, z2); ! ! Bounds3f b3f = new Bounds3f(xMin, xMax, yMin, yMax, zMin, zMax); ! return b3f; ! } ! ! private boolean passAngle(float angle, float minAngle, float maxAngle) { ! return minAngle < angle && angle < maxAngle; ! } ! ! private float[] analizeAngleCase(float r, float gammaMin, ! float gammaMax) { ! float[] values = new float[4]; ! float cosGammaMin = (float) Math.cos(gammaMin); ! float sinGammaMin = (float) Math.sin(gammaMin); ! float cosGammaMax = (float) Math.cos(gammaMax); ! float sinGammaMax = (float) Math.sin(gammaMax); ! float xMin = Math.min(r * cosGammaMin, r * cosGammaMax); ! float xMax = Math.max(r * cosGammaMin, r * cosGammaMax); ! float yMin = Math.min(r * sinGammaMin, r * sinGammaMax); ! float yMax = Math.max(r * sinGammaMin, r * sinGammaMax); ! ! if (passAngle((float) Math.PI / 2f, gammaMin, gammaMax) || ! passAngle((float) Math.PI / 2f + (float) Math.PI * 2f, ! gammaMin, ! gammaMax)) { ! yMax = r; ! } ! if (passAngle((float) Math.PI, gammaMin, gammaMax) || ! passAngle((float) Math.PI + (float) Math.PI * 2f, ! gammaMin, ! gammaMax)) { ! xMin = -r; ! } ! if (passAngle((float) Math.PI * 3f / 2f, gammaMin, gammaMax) || ! passAngle((float) Math.PI * 3f / 2f + (float) Math.PI * 2f, ! gammaMin, ! gammaMax)) { ! yMin = -r; ! } ! if (passAngle(0f, gammaMin, gammaMax) || ! passAngle((float) Math.PI * 2f, gammaMin, gammaMax)) { ! xMax = r; ! } ! values[0] = xMin; ! values[1] = xMax; ! values[2] = yMin; ! values[3] = yMax; ! return values; ! } ! ! public Primitive[] split() { ! float r1 = (float) Math.sqrt((x1 * x1) + (y1 * y1)); ! float r2 = (float) Math.sqrt((x2 * x2) + (y2 * y2)); ! float r = ! (float) Math.sqrt((x2 - x1) * (x2 - x1) ! + (y2 - y1) * (y2 - y1) ! + (z2 - z1) * (z2 - z1)); ! Primitive[] result = new Primitive[2]; ! if ((thetaMax - thetaMin) * (float) Math.max(r1, r2) > r) { ! result[0] = new Hyperboloid(x1, y1, z1, *************** *** 205,211 **** 0f, 1f), attributes); ! result[1] = ! new Hyperboloid( ! x1, y1, z1, --- 194,198 ---- 0f, 1f), attributes); ! result[1] = new Hyperboloid(x1, y1, z1, *************** *** 218,225 **** 0f, 1f), attributes); ! } else { ! result[0] = ! new Hyperboloid( ! x1, y1, z1, --- 205,210 ---- 0f, 1f), attributes); ! } else { ! result[0] = new Hyperboloid(x1, y1, z1, *************** *** 232,303 **** 0f, .5f), attributes); ! result[1] = ! new Hyperboloid( ! (x1 + x2) / 2f, ! (y1 + y2) / 2f, ! (z1 + z2) / 2f, ! x2, ! y2, ! z2, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), attributes); ! } ! return result; ! } ! ! protected void dice_P(ShaderVariables shaderVariables) { ! int uSize = Grid.getUSize(); ! int vSize = Grid.getVSize(); ! float thetaDelta = (thetaMax - thetaMin) / (uSize - 1); ! float vDelta = 1f / (vSize - 1); ! Point3fGrid P = shaderVariables.P; ! float theta = thetaMin; ! for (int u = 0; u < uSize; u++) { ! float cosTheta = (float) Math.cos(theta); ! float sinTheta = (float) Math.sin(theta); ! float nv = 0f; ! for (int v = 0; v < vSize; v++) { ! float xr = (1f - nv) * x1 + nv * x2; ! float yr = (1f - nv) * y1 + nv * y2; ! float zr = (1f - nv) * z1 + nv * z2; ! tmp.x = xr * cosTheta - yr * sinTheta; ! tmp.y = xr * sinTheta + yr * cosTheta; ! tmp.z = zr; ! P.set(u, v, tmp); ! nv += vDelta; ! } ! theta += thetaDelta; ! } ! } ! ! protected void dice_Ng(ShaderVariables shaderVariables) { ! int uSize = Grid.getUSize(); ! int vSize = Grid.getVSize(); ! float thetaDelta = (thetaMax - thetaMin) / (uSize - 1); ! Vector3fGrid Ng = shaderVariables.Ng; ! for (int u = 0; u < uSize; u++) { ! float theta = thetaMin + thetaDelta * u; ! float cosTheta = (float) Math.cos(theta); ! float sinTheta = (float) Math.sin(theta); ! float x11 = x1 * cosTheta - y1 * sinTheta; ! float x22 = x2 * cosTheta - y2 * sinTheta; ! float y11 = x1 * sinTheta + y1 * cosTheta; ! float y22 = x2 * sinTheta + y2 * cosTheta; ! p1.set(x11, y11, z1); ! p2.set(x22, y22, z2); ! v1.sub(p1, p2); ! for (int v = 0; v < vSize; v++) { ! float nv = (float) v / (vSize - 1); ! float xi = (1f - nv) * x11 + nv * x22; ! float yi = (1f - nv) * y11 + nv * y22; ! v2.set(-yi, xi, 0f); ! vtmp.cross(v1, v2); ! Ng.set(u, v, vtmp); ! } ! } ! } ! } --- 217,286 ---- 0f, .5f), attributes); ! result[1] = new Hyperboloid((x1 + x2) / 2f, ! (y1 + y2) / 2f, ! (z1 + z2) / 2f, ! x2, ! y2, ! z2, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), attributes); ! } ! return result; ! } ! ! protected void dice_P(ShaderVariables shaderVariables) { ! int uSize = Grid.getUSize(); ! int vSize = Grid.getVSize(); ! float thetaDelta = (thetaMax - thetaMin) / (uSize - 1); ! float vDelta = 1f / (vSize - 1); ! Point3fGrid P = shaderVariables.P; ! float theta = thetaMin; ! for (int u = 0; u < uSize; u++) { ! float cosTheta = (float) Math.cos(theta); ! float sinTheta = (float) Math.sin(theta); ! float nv = 0f; ! for (int v = 0; v < vSize; v++) { ! float xr = (1f - nv) * x1 + nv * x2; ! float yr = (1f - nv) * y1 + nv * y2; ! float zr = (1f - nv) * z1 + nv * z2; ! tmp.x = xr * cosTheta - yr * sinTheta; ! tmp.y = xr * sinTheta + yr * cosTheta; ! tmp.z = zr; ! P.set(u, v, tmp); ! nv += vDelta; ! } ! theta += thetaDelta; ! } ! } ! ! protected void dice_Ng(ShaderVariables shaderVariables) { ! int uSize = Grid.getUSize(); ! int vSize = Grid.getVSize(); ! float thetaDelta = (thetaMax - thetaMin) / (uSize - 1); ! Vector3fGrid Ng = shaderVariables.Ng; ! for (int u = 0; u < uSize; u++) { ! float theta = thetaMin + thetaDelta * u; ! float cosTheta = (float) Math.cos(theta); ! float sinTheta = (float) Math.sin(theta); ! float x11 = x1 * cosTheta - y1 * sinTheta; ! float x22 = x2 * cosTheta - y2 * sinTheta; ! float y11 = x1 * sinTheta + y1 * cosTheta; ! float y22 = x2 * sinTheta + y2 * cosTheta; ! p1.set(x11, y11, z1); ! p2.set(x22, y22, z2); ! v1.sub(p1, p2); ! for (int v = 0; v < vSize; v++) { ! float nv = (float) v / (vSize - 1); ! float xi = (1f - nv) * x11 + nv * x22; ! float yi = (1f - nv) * y11 + nv * y22; ! v2.set(-yi, xi, 0f); ! vtmp.cross(v1, v2); ! Ng.set(u, v, vtmp); ! } ! } ! } ! } Index: Disk.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Disk.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Disk.java 25 Dec 2006 07:50:37 -0000 1.11 --- Disk.java 26 Feb 2007 19:35:51 -0000 1.12 *************** *** 48,59 **** private float rMin; ! public Disk( ! float height, ! float thetaMin, ! float thetaMax, ! float rMin, ! float rMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.height = height; --- 48,58 ---- private float rMin; ! public Disk(float height, ! float thetaMin, ! float thetaMax, ! float rMin, ! float rMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.height = height; *************** *** 108,149 **** if ((thetaMax - thetaMin) * (rMax + rMin) / 2f > rMax - rMin) { ! result[0] = ! new Disk( ! height, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! rMin, ! rMax, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = ! new Disk( ! height, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! rMin, ! rMax, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); ! } ! else{ ! result[0] = ! new Disk( ! height, ! thetaMin, ! thetaMax, ! rMin, ! (rMax + rMin)/2f, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); ! result[1] = ! new Disk( ! height, ! thetaMin, ! thetaMax, ! (rMax + rMin)/2f, ! rMax, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); } return result; --- 107,139 ---- if ((thetaMax - thetaMin) * (rMax + rMin) / 2f > rMax - rMin) { ! result[0] = new Disk(height, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! rMin, ! rMax, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = new Disk(height, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! rMin, ! rMax, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); ! } else{ ! result[0] = new Disk(height, ! thetaMin, ! thetaMax, ! rMin, ! (rMax + rMin)/2f, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); ! result[1] = new Disk(height, ! thetaMin, ! thetaMax, ! (rMax + rMin)/2f, ! rMax, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); } return result; Index: CubicCurve.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/CubicCurve.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** CubicCurve.java 4 Feb 2007 06:27:13 -0000 1.7 --- CubicCurve.java 26 Feb 2007 19:35:51 -0000 1.8 *************** *** 465,482 **** } - /* - protected void dice_v(ShaderVariables shaderVariables) { - FloatGrid g = shaderVariables.v; - int vSize = Grid.getVSize(); - float vStep = 1f / (vSize - 1); - float v = 0; - for (int i = 0; i < vSize; i++) { - g.set(0, i, v); - g.set(1, i, v); - v += vStep; - } - } - */ - } --- 465,468 ---- Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Primitive.java 30 Dec 2006 13:49:22 -0000 1.40 --- Primitive.java 26 Feb 2007 19:35:52 -0000 1.41 *************** *** 252,256 **** } ! public static void setDefaultParameters(ParameterList parameters, Attributes attributes) { Parameter parameter = parameters.getParameter("u"); if (parameter == null) { --- 252,257 ---- } ! public static void setDefaultParameters(ParameterList parameters, ! Attributes attributes) { Parameter parameter = parameters.getParameter("u"); if (parameter == null) { *************** *** 276,280 **** (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { ! parameters.addParameter(stParam.extract(Global.getDeclaration("s"), 0)); } else { float[] s = new float[4]; --- 277,283 ---- (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { ! parameters.addParameter( ! stParam.extract(Global.getDeclaration("s"), ! 0)); } else { float[] s = new float[4]; *************** *** 291,295 **** s[3] = 1; } ! parameters.addParameter(new VaryingScalarFloat(Global.getDeclaration("s"), s)); } } --- 294,300 ---- s[3] = 1; } ! parameters.addParameter( ! new VaryingScalarFloat(Global.getDeclaration("s"), ! s)); } } *************** *** 299,303 **** (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { ! parameters.addParameter(stParam.extract(Global.getDeclaration("t"), 1)); } else { float[] t = new float[4]; --- 304,310 ---- (VaryingArrayFloat) parameters.getParameter("st"); if (stParam != null) { ! parameters.addParameter( ! stParam.extract(Global.getDeclaration("t"), ! 1)); } else { float[] t = new float[4]; *************** *** 314,318 **** t[3] = 1; } ! parameters.addParameter(new VaryingScalarFloat(Global.getDeclaration("t"), t)); } } --- 321,327 ---- t[3] = 1; } ! parameters.addParameter( ! new VaryingScalarFloat(Global.getDeclaration("t"), ! t)); } } *************** *** 324,332 **** } ! protected ParameterList bilinearInterpolateParameters( ! float uMin, ! float uMax, ! float vMin, ! float vMax) { return parameters.bilinearInterpolate(uMin, uMax, vMin, vMax); } --- 333,340 ---- } ! protected ParameterList bilinearInterpolateParameters(float uMin, ! float uMax, ! float vMin, ! float vMax) { return parameters.bilinearInterpolate(uMin, uMax, vMin, vMax); } *************** *** 335,339 **** float width = rasterBounds.getWidth() - screenDisplacementWidth; float height = rasterBounds.getHeight() - screenDisplacementHeight; ! boolean ready = width * height <= gridSize * attributes.getShadingRate(); if (!ready) return false; --- 343,348 ---- float width = rasterBounds.getWidth() - screenDisplacementWidth; float height = rasterBounds.getHeight() - screenDisplacementHeight; ! boolean ready = width * height <= ! gridSize * attributes.getShadingRate(); if (!ready) return false; Index: Point.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Point.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Point.java 24 Dec 2006 05:25:57 -0000 1.9 --- Point.java 26 Feb 2007 19:35:52 -0000 1.10 *************** *** 52,62 **** private float z; ! public Point( ! float width, ! float x, ! float y, ! float z, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.x = x; --- 52,61 ---- private float z; ! public Point(float width, ! float x, ! float y, ! float z, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.x = x; *************** *** 67,78 **** public BoundingVolume getBoundingVolume() { ! Bounds3f result = ! new Bounds3f( ! x - width / 2f, ! x + width / 2f, ! y - width / 2f, ! y + width / 2f, ! z - width / 2f, ! z + width / 2f); return result; } --- 66,75 ---- public BoundingVolume getBoundingVolume() { ! Bounds3f result = new Bounds3f(x - width / 2f, ! x + width / 2f, ! y - width / 2f, ! y + width / 2f, ! z - width / 2f, ! z + width / 2f); return result; } *************** *** 109,113 **** float twidth = v.length(); float halfWidth = twidth / 2f; ! float height = (float) (Math.sqrt(twidth * twidth - halfWidth * halfWidth)) / 2f; v.set(0f, 0f, -1f); Point3fGrid P = shaderVariables.P; --- 106,111 ---- float twidth = v.length(); float halfWidth = twidth / 2f; ! float height = (float) ! (Math.sqrt(twidth * twidth - halfWidth * halfWidth)) / 2f; v.set(0f, 0f, -1f); Point3fGrid P = shaderVariables.P; Index: Paraboloid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Paraboloid.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Paraboloid.java 25 Dec 2006 07:50:37 -0000 1.10 --- Paraboloid.java 26 Feb 2007 19:35:52 -0000 1.11 *************** *** 54,68 **** private float maxTheta; ! public Paraboloid( ! float radius, ! float zMin, ! float zMax, ! float thetaMin, ! float thetaMax, ! float minZ, ! float maxZ, ! float maxTheta, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; --- 54,67 ---- private float maxTheta; ! public Paraboloid(float radius, ! float zMin, ! float zMax, ! float thetaMin, ! float thetaMax, ! float minZ, ! float maxZ, ! float maxTheta, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; *************** *** 120,177 **** public Primitive[] split() { Primitive[] result = new Primitive[2]; ! float r = ! Math.max( ! radius * (float) Math.sqrt(zMin / maxZ), ! radius * (float) Math.sqrt(zMax / maxZ)); if ((thetaMax - thetaMin) * r > zMax - zMin) { ! result[0] = ! new Paraboloid( ! radius, ! zMin, ! zMax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = ! new Paraboloid( ! radius, ! zMin, ! zMax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); } else { ! result[0] = ! new Paraboloid( ! radius, ! zMin, ! (zMin + zMax) / 2f, ! thetaMin, ! thetaMax, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); ! result[1] = ! new Paraboloid( ! radius, ! (zMin + zMax) / 2f, ! zMax, ! thetaMin, ! thetaMax, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); } return result; --- 119,170 ---- public Primitive[] split() { Primitive[] result = new Primitive[2]; ! float r = Math.max(radius * (float) Math.sqrt(zMin / maxZ), ! radius * (float) Math.sqrt(zMax / maxZ)); if ((thetaMax - thetaMin) * r > zMax - zMin) { ! result[0] = new Paraboloid(radius, ! zMin, ! zMax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(0f, .5f, ! 0f, 1f), ! attributes); ! result[1] = new Paraboloid(radius, ! zMin, ! zMax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(.5f, 1f, ! 0f, 1f), ! attributes); } else { ! result[0] = new Paraboloid(radius, ! zMin, ! (zMin + zMax) / 2f, ! thetaMin, ! thetaMax, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(0f, 1f, ! 0f, .5f), ! attributes); ! result[1] = new Paraboloid(radius, ! (zMin + zMax) / 2f, ! zMax, ! thetaMin, ! thetaMax, ! minZ, ! maxZ, ! maxTheta, ! bilinearInterpolateParameters(0f, 1f, ! .5f, 1f), ! attributes); } return result; *************** *** 215,225 **** vtmp.x = r * cosTheta * dZ; vtmp.y = r * sinTheta * dZ; ! vtmp.z = ! -0.5f ! * radius ! * radius ! * dZ ! / maxZ ! * (sinTheta * sinTheta + cosTheta * cosTheta); Ng.set(u, v, vtmp); } --- 208,213 ---- vtmp.x = r * cosTheta * dZ; vtmp.y = r * sinTheta * dZ; ! vtmp.z = -0.5f * radius * radius * dZ / maxZ ! * (sinTheta * sinTheta + cosTheta * cosTheta); Ng.set(u, v, vtmp); } Index: Cone.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Cone.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Cone.java 25 Dec 2006 07:50:37 -0000 1.9 --- Cone.java 26 Feb 2007 19:35:51 -0000 1.10 *************** *** 50,62 **** private float height; ! public Cone( ! float radius, ! float zmin, ! float zmax, ! float thetaMin, ! float thetaMax, ! float height, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; --- 50,61 ---- private float height; ! public Cone(float radius, ! float zmin, ! float zmax, ! float thetaMin, ! float thetaMax, ! float height, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; *************** *** 115,159 **** radius * (1 - zmin / height)); if ((thetaMax - thetaMin) * r > zmax - zmin) { ! result[0] = ! new Cone( ! radius, ! zmin, ! zmax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! height, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = ! new Cone( ! radius, ! zmin, ! zmax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! height, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); } else { ! result[0] = ! new Cone( ! radius, ! zmin, ! (zmin + zmax) / 2f, ! thetaMin, ! thetaMax, ! height, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); ! result[1] = ! new Cone( ! radius, ! (zmin + zmax) / 2f, ! zmax, ! thetaMin, ! thetaMax, ! height, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); } return result; --- 114,150 ---- radius * (1 - zmin / height)); if ((thetaMax - thetaMin) * r > zmax - zmin) { ! result[0] = new Cone(radius, ! zmin, ! zmax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! height, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = new Cone(radius, ! zmin, ! zmax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! height, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); } else { ! result[0] = new Cone(radius, ! zmin, ! (zmin + zmax) / 2f, ! thetaMin, ! thetaMax, ! height, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); ! result[1] = new Cone(radius, ! (zmin + zmax) / 2f, ! zmax, ! thetaMin, ! thetaMax, ! height, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); } return result; Index: BilinearPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BilinearPatch.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** BilinearPatch.java 24 Dec 2006 05:25:57 -0000 1.10 --- BilinearPatch.java 26 Feb 2007 19:35:51 -0000 1.11 *************** *** 80,91 **** if (ul > vl) { result[0] = ! new BilinearPatch(bilinearInterpolateParameters(0f, .5f, 0f, 1f), attributes); result[1] = ! new BilinearPatch(bilinearInterpolateParameters(.5f, 1f, 0f, 1f), attributes); } else { result[0] = ! new BilinearPatch(bilinearInterpolateParameters(0f, 1f, 0f, .5f), attributes); result[1] = ! new BilinearPatch(bilinearInterpolateParameters(0f, 1f, .5f, 1f), attributes); } return result; --- 80,99 ---- if (ul > vl) { result[0] = ! new BilinearPatch(bilinearInterpolateParameters(0f, .5f, ! 0f, 1f), ! attributes); result[1] = ! new BilinearPatch(bilinearInterpolateParameters(.5f, 1f, ! 0f, 1f), ! attributes); } else { result[0] = ! new BilinearPatch(bilinearInterpolateParameters(0f, 1f, ! 0f, .5f), ! attributes); result[1] = ! new BilinearPatch(bilinearInterpolateParameters(0f, 1f, ! .5f, 1f), ! attributes); } return result; Index: Cylinder.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Cylinder.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Cylinder.java 25 Dec 2006 07:50:37 -0000 1.9 --- Cylinder.java 26 Feb 2007 19:35:51 -0000 1.10 *************** *** 48,59 **** float thetaMax; ! public Cylinder( ! float radius, ! float zmin, ! float zmax, ! float thetaMin, ! float thetaMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; --- 48,58 ---- float thetaMax; ! public Cylinder(float radius, ! float zmin, ! float zmax, ! float thetaMin, ! float thetaMax, ! ParameterList parameters, ! Attributes attributes) { super(parameters, attributes); this.radius = radius; *************** *** 99,139 **** Primitive[] result = new Primitive[2]; if ((thetaMax - thetaMin) * radius > zmax - zmin) { ! result[0] = ! new Cylinder( ! radius, ! zmin, ! zmax, ! thetaMin, ! (thetaMin + thetaMax) / 2f, ! bilinearInterpolateParameters(0f, .5f, 0f, 1f), ! attributes); ! result[1] = ! new Cylinder( ! radius, ! zmin, ! zmax, ! (thetaMin + thetaMax) / 2f, ! thetaMax, ! bilinearInterpolateParameters(.5f, 1f, 0f, 1f), ! attributes); } else { ! result[0] = ! new Cylinder( ! radius, ! zmin, ! (zmin + zmax) / 2f, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, 0f, .5f), ! attributes); ! result[1] = ! new Cylinder( ! radius, ! (zmin + zmax) / 2f, ! zmax, ! thetaMin, ! thetaMax, ! bilinearInterpolateParameters(0f, 1f, .5f, 1f), ! attributes); } return result; --- 98,134 ---- Primitive[] result = new Primitive[2]; if ((thetaMax - thetaMin) * radius > zmax - zmin) { ! result[0] = new Cylinder(radius, ! zmin, ! zmax, ! thetaMin, ! (thetaMin... [truncated message content] |