From: <ma...@us...> - 2003-11-25 16:34:13
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs1:/tmp/cvs-serv29833/src/org/jrman/primitive Modified Files: Cone.java Hyperboloid.java Paraboloid.java Torus.java Primitive.java Sphere.java Point.java BilinearPatch.java BicubicPatch.java Disk.java Cylinder.java Quadric.java Log Message: Reimplemented primitive parameter lists to improve the API and use less memory. NOTE: Polygons are disabled, need to be fixed.... Index: Cone.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Cone.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Cone.java 22 May 2003 04:50:14 -0000 1.5 --- Cone.java 25 Nov 2003 16:34:08 -0000 1.6 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 31,34 **** --- 29,33 ---- import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; + import org.jrman.parameters.ParameterList; import org.jrman.render.ShaderVariables; *************** *** 58,62 **** float thetaMax, float height, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 57,61 ---- float thetaMax, float height, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); Index: Hyperboloid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Hyperboloid.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Hyperboloid.java 13 Aug 2003 03:59:38 -0000 1.6 --- Hyperboloid.java 25 Nov 2003 16:34:08 -0000 1.7 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 31,34 **** --- 29,33 ---- import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; + import org.jrman.parameters.ParameterList; import org.jrman.render.ShaderVariables; *************** *** 72,76 **** float thetaMin, float thetaMax, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 71,75 ---- float thetaMin, float thetaMax, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); Index: Paraboloid.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Paraboloid.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Paraboloid.java 25 Jul 2003 13:56:50 -0000 1.6 --- Paraboloid.java 25 Nov 2003 16:34:08 -0000 1.7 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 31,34 **** --- 29,33 ---- import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; + import org.jrman.parameters.ParameterList; import org.jrman.render.ShaderVariables; *************** *** 64,68 **** float maxZ, float maxTheta, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 63,67 ---- float maxZ, float maxTheta, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); Index: Torus.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Torus.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Torus.java 22 May 2003 04:50:14 -0000 1.6 --- Torus.java 25 Nov 2003 16:34:08 -0000 1.7 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 31,34 **** --- 29,33 ---- import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; + import org.jrman.parameters.ParameterList; import org.jrman.render.ShaderVariables; *************** *** 58,62 **** float thetaMin, float thetaMax, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 57,61 ---- float thetaMin, float thetaMax, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); Index: Primitive.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Primitive.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Primitive.java 9 Sep 2003 03:01:04 -0000 1.19 --- Primitive.java 25 Nov 2003 16:34:08 -0000 1.20 *************** *** 20,31 **** package org.jrman.primitive; - import java.util.HashMap; - import java.util.Iterator; - import java.util.Map; - import javax.vecmath.Color3f; - import javax.vecmath.Matrix4f; import javax.vecmath.Point3f; - import javax.vecmath.Point4f; import javax.vecmath.Vector3f; --- 20,25 ---- *************** *** 40,45 **** import org.jrman.grid.Vector3fGrid; import org.jrman.parameters.Declaration; import org.jrman.parser.Global; - import org.jrman.parser.Parameter; import org.jrman.render.ShaderVariables; import org.jrman.util.Calc; --- 34,42 ---- import org.jrman.grid.Vector3fGrid; import org.jrman.parameters.Declaration; + import org.jrman.parameters.NParameter; + import org.jrman.parameters.ParameterList; + import org.jrman.parameters.VaryingScalarFloat; + import org.jrman.parameters.VaryingScalarTuple3f; import org.jrman.parser.Global; import org.jrman.render.ShaderVariables; import org.jrman.util.Calc; *************** *** 51,55 **** private static Declaration V_DECL = new Declaration("v", "vertex float"); ! protected Map parameters; protected Attributes attributes; --- 48,76 ---- private static Declaration V_DECL = new Declaration("v", "vertex float"); ! private static Point3f p0 = new Point3f(); ! ! private static Point3f p1 = new Point3f(); ! ! private static Point3f p2 = new Point3f(); ! ! private static Point3f p3 = new Point3f(); ! ! private static Vector3f v0 = new Vector3f(); ! ! private static Vector3f v1 = new Vector3f(); ! ! private static Vector3f v2 = new Vector3f(); ! ! private static Vector3f v3 = new Vector3f(); ! ! private static Color3f c0 = new Color3f(); ! ! private static Color3f c1 = new Color3f(); ! ! private static Color3f c2 = new Color3f(); ! ! private static Color3f c3 = new Color3f(); ! ! protected ParameterList parameters; protected Attributes attributes; *************** *** 63,67 **** protected float distance; ! protected Primitive(Map parameters, Attributes attributes) { this.parameters = parameters; this.attributes = attributes; --- 84,88 ---- protected float distance; ! protected Primitive(ParameterList parameters, Attributes attributes) { this.parameters = parameters; this.attributes = attributes; *************** *** 151,158 **** protected void dice_N(ShaderVariables shaderVariables) { ! Parameter parameter = (Parameter) parameters.get("N"); ! if (parameter != null) { ! Vector3f[][] data = (Vector3f[][]) parameter.getData(); ! diceVector3f(shaderVariables.N, data[0][0], data[1][0], data[2][0], data[3][0]); } else shaderVariables.N.set(shaderVariables.Ng); --- 172,182 ---- protected void dice_N(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("N"); ! if (param != null) { ! param.getValue(0, v0); ! param.getValue(1, v1); ! param.getValue(2, v2); ! param.getValue(3, v3); ! diceVector3f(shaderVariables.N, v0, v1, v2, v3); } else shaderVariables.N.set(shaderVariables.Ng); *************** *** 160,167 **** protected void dice_Cs(ShaderVariables shaderVariables) { ! Parameter parameter = (Parameter) parameters.get("Cs"); ! if (parameter != null) { ! Color3f[][] data = (Color3f[][]) parameter.getData(); ! diceColor3f(shaderVariables.Cs, data[0][0], data[1][0], data[2][0], data[3][0]); } else shaderVariables.Cs.set(attributes.getColor()); --- 184,199 ---- protected void dice_Cs(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("Cs"); ! if (param != null) { ! if (param.getCount() == 4) { ! param.getValue(0, c0); ! param.getValue(1, c1); ! param.getValue(2, c2); ! param.getValue(3, c3); ! diceColor3f(shaderVariables.Cs, c0, c1, c2, c3); ! } else { ! param.getValue(0, c0); ! shaderVariables.Cs.set(c0); ! } } else shaderVariables.Cs.set(attributes.getColor()); *************** *** 169,176 **** protected void dice_Os(ShaderVariables shaderVariables) { ! Parameter parameter = (Parameter) parameters.get("Os"); ! if (parameter != null) { ! Color3f[][] data = (Color3f[][]) parameter.getData(); ! diceColor3f(shaderVariables.Os, data[0][0], data[1][0], data[2][0], data[3][0]); } else shaderVariables.Os.set(attributes.getOpacity()); --- 201,216 ---- protected void dice_Os(ShaderVariables shaderVariables) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("Os"); ! if (param != null) { ! if (param.getCount() == 4) { ! param.getValue(0, c0); ! param.getValue(1, c1); ! param.getValue(2, c2); ! param.getValue(3, c3); ! diceColor3f(shaderVariables.Os, c0, c1, c2, c3); ! } else { ! param.getValue(0, c0); ! shaderVariables.Os.set(c0); ! } } else shaderVariables.Os.set(attributes.getOpacity()); *************** *** 178,202 **** protected void dice_u(ShaderVariables shaderVariables) { ! Parameter parameter = (Parameter) parameters.get("u"); ! float[][] data = (float[][]) parameter.getData(); ! diceFloat(shaderVariables.u, data[0][0], data[1][0], data[2][0], data[3][0]); } protected void dice_v(ShaderVariables shaderVariables) { ! Parameter parameter = (Parameter) parameters.get("v"); ! float[][] data = (float[][]) parameter.getData(); ! diceFloat(shaderVariables.v, data[0][0], data[1][0], data[2][0], data[3][0]); } protected void dice_s(ShaderVariables shaderVariables) { ! Parameter parameter = (Parameter) parameters.get("s"); ! float[][] data = (float[][]) parameter.getData(); ! diceFloat(shaderVariables.s, data[0][0], data[1][0], data[2][0], data[3][0]); } protected void dice_t(ShaderVariables shaderVariables) { ! Parameter parameter = (Parameter) parameters.get("t"); ! float[][] data = (float[][]) parameter.getData(); ! diceFloat(shaderVariables.t, data[0][0], data[1][0], data[2][0], data[3][0]); } --- 218,258 ---- protected void dice_u(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("u"); ! diceFloat( ! shaderVariables.u, ! param.getValue(0), ! param.getValue(1), ! param.getValue(2), ! param.getValue(3)); } protected void dice_v(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("v"); ! diceFloat( ! shaderVariables.v, ! param.getValue(0), ! param.getValue(1), ! param.getValue(2), ! param.getValue(3)); } protected void dice_s(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("s"); ! diceFloat( ! shaderVariables.s, ! param.getValue(0), ! param.getValue(1), ! param.getValue(2), ! param.getValue(3)); } protected void dice_t(ShaderVariables shaderVariables) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameters.getParameter("t"); ! diceFloat( ! shaderVariables.t, ! param.getValue(0), ! param.getValue(1), ! param.getValue(2), ! param.getValue(3)); } *************** *** 302,499 **** protected void setDefaultParameters() { ! Parameter parameter = (Parameter) parameters.get("u"); if (parameter == null) { ! float[][] u = new float[4][]; ! u[0] = new float[1]; ! u[1] = new float[1]; ! u[2] = new float[1]; ! u[3] = new float[1]; ! u[0][0] = 0f; ! u[1][0] = 1f; ! u[2][0] = 0f; ! u[3][0] = 1f; ! parameters.put("u", new Parameter(U_DECL, u)); } ! parameter = (Parameter) parameters.get("v"); if (parameter == null) { ! float[][] v = new float[4][]; ! v[0] = new float[1]; ! v[1] = new float[1]; ! v[2] = new float[1]; ! v[3] = new float[1]; ! v[0][0] = 0f; ! v[1][0] = 0f; ! v[2][0] = 1f; ! v[3][0] = 1f; ! parameters.put("v", new Parameter(V_DECL, v)); } ! parameter = (Parameter) parameters.get("s"); if (parameter == null) { ! float[][] s = new float[4][]; ! s[0] = new float[1]; ! s[1] = new float[1]; ! s[2] = new float[1]; ! s[3] = new float[1]; ! Parameter uParam = (Parameter) parameters.get("u"); ! float[][] u = (float[][]) uParam.getData(); ! s[0][0] = u[0][0]; ! s[1][0] = u[1][0]; ! s[2][0] = u[2][0]; ! s[3][0] = u[3][0]; ! parameters.put("s", new Parameter(Global.getDeclaration("s"), s)); } ! parameter = (Parameter) parameters.get("t"); if (parameter == null) { ! float[][] t = new float[4][]; ! t[0] = new float[1]; ! t[1] = new float[1]; ! t[2] = new float[1]; ! t[3] = new float[1]; ! Parameter vParam = (Parameter) parameters.get("v"); ! float[][] v = (float[][]) vParam.getData(); ! t[0][0] = v[0][0]; ! t[1][0] = v[1][0]; ! t[2][0] = v[2][0]; ! t[3][0] = v[3][0]; ! parameters.put("t", new Parameter(Global.getDeclaration("t"), t)); } } ! protected Map linearInterpolateParameters( float uMin, float uMax, float vMin, float vMax) { ! Map result = new HashMap(); ! for (Iterator iter = parameters.keySet().iterator(); iter.hasNext();) { ! String name = (String) iter.next(); ! Parameter parameter = (Parameter) parameters.get(name); Declaration declaration = parameter.getDeclaration(); Declaration.StorageClass storageClass = declaration.getStorageClass(); if (storageClass == Declaration.StorageClass.CONSTANT || storageClass == Declaration.StorageClass.UNIFORM) { ! result.put(name, parameter); continue; } Declaration.Type type = declaration.getType(); if (type == Declaration.Type.INTEGER || type == Declaration.Type.STRING) { ! result.put(name, parameter); continue; } ! if (type == Declaration.Type.FLOAT) { ! float[][] param = (float[][]) parameter.getData(); ! float[][] sparam = new float[4][]; ! int count = declaration.getCount(); ! sparam[0] = new float[count]; ! sparam[1] = new float[count]; ! sparam[2] = new float[count]; ! sparam[3] = new float[count]; ! for (int i = 0; i < count; i++) { ! float uv00 = param[0][i]; ! float uv10 = param[1][i]; ! float uv01 = param[2][i]; ! float uv11 = param[3][i]; ! sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); ! sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); ! sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); ! sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); ! } ! result.put(name, new Parameter(declaration, sparam)); ! } else if (type == Declaration.Type.POINT) { ! Point3f[][] param = (Point3f[][]) parameter.getData(); ! Point3f[][] sparam = new Point3f[4][]; ! int count = declaration.getCount(); ! sparam[0] = new Point3f[count]; ! sparam[1] = new Point3f[count]; ! sparam[2] = new Point3f[count]; ! sparam[3] = new Point3f[count]; ! for (int i = 0; i < count; i++) { ! Point3f uv00 = param[0][i]; ! Point3f uv10 = param[1][i]; ! Point3f uv01 = param[2][i]; ! Point3f uv11 = param[3][i]; ! sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); ! sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); ! sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); ! sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); ! } ! result.put(name, new Parameter(declaration, sparam)); } else if (type == Declaration.Type.COLOR) { ! Color3f[][] param = (Color3f[][]) parameter.getData(); ! Color3f[][] sparam = new Color3f[4][]; ! int count = declaration.getCount(); ! sparam[0] = new Color3f[count]; ! sparam[1] = new Color3f[count]; ! sparam[2] = new Color3f[count]; ! sparam[3] = new Color3f[count]; ! for (int i = 0; i < count; i++) { ! Color3f uv00 = param[0][i]; ! Color3f uv10 = param[1][i]; ! Color3f uv01 = param[2][i]; ! Color3f uv11 = param[3][i]; ! sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); ! sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); ! sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); ! sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); ! } ! result.put(name, new Parameter(declaration, sparam)); } else if (type == Declaration.Type.VECTOR || type == Declaration.Type.NORMAL) { ! Vector3f[][] param = (Vector3f[][]) parameter.getData(); ! Vector3f[][] sparam = new Vector3f[4][]; ! int count = declaration.getCount(); ! sparam[0] = new Vector3f[count]; ! sparam[1] = new Vector3f[count]; ! sparam[2] = new Vector3f[count]; ! sparam[3] = new Vector3f[count]; ! for (int i = 0; i < count; i++) { ! Vector3f uv00 = param[0][i]; ! Vector3f uv10 = param[1][i]; ! Vector3f uv01 = param[2][i]; ! Vector3f uv11 = param[3][i]; ! sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); ! sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); ! sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); ! sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); ! } ! result.put(name, new Parameter(declaration, sparam)); ! } else if (type == Declaration.Type.HPOINT) { ! Point4f[][] param = (Point4f[][]) parameter.getData(); ! Point4f[][] sparam = new Point4f[4][]; ! int count = declaration.getCount(); ! sparam[0] = new Point4f[count]; ! sparam[1] = new Point4f[count]; ! sparam[2] = new Point4f[count]; ! sparam[3] = new Point4f[count]; ! for (int i = 0; i < count; i++) { ! Point4f uv00 = param[0][i]; ! Point4f uv10 = param[1][i]; ! Point4f uv01 = param[2][i]; ! Point4f uv11 = param[3][i]; ! sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); ! sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); ! sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); ! sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); ! } ! result.put(name, new Parameter(declaration, sparam)); ! } else if (type == Declaration.Type.MATRIX) { ! Matrix4f[][] param = (Matrix4f[][]) parameter.getData(); ! Matrix4f[][] sparam = new Matrix4f[4][]; ! int count = declaration.getCount(); ! sparam[0] = new Matrix4f[count]; ! sparam[1] = new Matrix4f[count]; ! sparam[2] = new Matrix4f[count]; ! sparam[3] = new Matrix4f[count]; ! for (int i = 0; i < count; i++) { ! Matrix4f uv00 = param[0][i]; ! Matrix4f uv10 = param[1][i]; ! Matrix4f uv01 = param[2][i]; ! Matrix4f uv11 = param[3][i]; ! sparam[0][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); ! sparam[1][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); ! sparam[2][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); ! sparam[3][i] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); ! } ! result.put(name, new Parameter(declaration, sparam)); ! } } return result; --- 358,486 ---- protected void setDefaultParameters() { ! NParameter parameter = parameters.getParameter("u"); if (parameter == null) { ! float[] u = new float[4]; ! u[0] = 0f; ! u[1] = 1f; ! u[2] = 0f; ! u[3] = 1f; ! parameters.addParameter(new VaryingScalarFloat(U_DECL, u)); } ! parameter = parameters.getParameter("v"); if (parameter == null) { ! float[] v = new float[4]; ! v[0] = 0f; ! v[1] = 0f; ! v[2] = 1f; ! v[3] = 1f; ! parameters.addParameter(new VaryingScalarFloat(V_DECL, v)); } ! parameter = parameters.getParameter("s"); if (parameter == null) { ! float[] s = new float[4]; ! VaryingScalarFloat uParam = (VaryingScalarFloat) parameters.getParameter("u"); ! s[0] = uParam.getValue(0); ! s[1] = uParam.getValue(1); ! s[2] = uParam.getValue(2); ! s[3] = uParam.getValue(3); ! parameters.addParameter(new VaryingScalarFloat(Global.getDeclaration("s"), s)); } ! parameter = parameters.getParameter("t"); if (parameter == null) { ! float[] t = new float[4]; ! VaryingScalarFloat vParam = (VaryingScalarFloat) parameters.getParameter("v"); ! t[0] = vParam.getValue(0); ! t[1] = vParam.getValue(1); ! t[2] = vParam.getValue(2); ! t[3] = vParam.getValue(3); ! parameters.addParameter(new VaryingScalarFloat(Global.getDeclaration("t"), t)); } } ! protected ParameterList linearInterpolateParameters( float uMin, float uMax, float vMin, float vMax) { ! ParameterList result = new ParameterList(); ! for (int i = 0; i < parameters.getParameterCount(); i++) { ! NParameter parameter = parameters.getParameter(i); Declaration declaration = parameter.getDeclaration(); Declaration.StorageClass storageClass = declaration.getStorageClass(); if (storageClass == Declaration.StorageClass.CONSTANT || storageClass == Declaration.StorageClass.UNIFORM) { ! result.addParameter(parameter); continue; } Declaration.Type type = declaration.getType(); if (type == Declaration.Type.INTEGER || type == Declaration.Type.STRING) { ! result.addParameter(parameter); continue; } ! if (type == Declaration.Type.FLOAT && declaration.getCount() == 1) { ! VaryingScalarFloat param = (VaryingScalarFloat) parameter; ! float[] sparam = new float[4]; ! float uv00 = param.getValue(0); ! float uv10 = param.getValue(1); ! float uv01 = param.getValue(2); ! float uv11 = param.getValue(3); ! sparam[0] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin); ! sparam[1] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin); ! sparam[2] = Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax); ! sparam[3] = Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax); ! result.addParameter(new VaryingScalarFloat(declaration, sparam)); ! } else if (type == Declaration.Type.POINT && declaration.getCount() == 1) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameter; ! VaryingScalarTuple3f sparam = ! new VaryingScalarTuple3f(declaration, new float[4 * 3]); ! param.getValue(0, p0); ! param.getValue(1, p1); ! param.getValue(2, p2); ! param.getValue(3, p3); ! Point3f uv00 = p0; ! Point3f uv10 = p1; ! Point3f uv01 = p2; ! Point3f uv11 = p3; ! sparam.setValue(0, Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin)); ! sparam.setValue(1, Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin)); ! sparam.setValue(2, Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax)); ! sparam.setValue(3, Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax)); ! result.addParameter(sparam); } else if (type == Declaration.Type.COLOR) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameter; ! VaryingScalarTuple3f sparam = ! new VaryingScalarTuple3f(declaration, new float[4 * 3]); ! param.getValue(0, c0); ! param.getValue(1, c1); ! param.getValue(2, c2); ! param.getValue(3, c3); ! Color3f uv00 = c0; ! Color3f uv10 = c1; ! Color3f uv01 = c2; ! Color3f uv11 = c3; ! sparam.setValue(0, Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin)); ! sparam.setValue(1, Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin)); ! sparam.setValue(2, Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax)); ! sparam.setValue(3, Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax)); ! result.addParameter(sparam); } else if (type == Declaration.Type.VECTOR || type == Declaration.Type.NORMAL) { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameter; ! VaryingScalarTuple3f sparam = ! new VaryingScalarTuple3f(declaration, new float[4 * 3]); ! param.getValue(0, v0); ! param.getValue(1, v1); ! param.getValue(2, v2); ! param.getValue(3, v3); ! Vector3f uv00 = v0; ! Vector3f uv10 = v1; ! Vector3f uv01 = v2; ! Vector3f uv11 = v3; ! sparam.setValue(0, Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMin)); ! sparam.setValue(1, Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMin)); ! sparam.setValue(2, Calc.interpolate(uv00, uv10, uv01, uv11, uMin, vMax)); ! sparam.setValue(3, Calc.interpolate(uv00, uv10, uv01, uv11, uMax, vMax)); ! result.addParameter(sparam); ! } else ! throw new UnsupportedOperationException("Can't interpolate: " + declaration); } return result; Index: Sphere.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Sphere.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Sphere.java 22 May 2003 04:50:14 -0000 1.19 --- Sphere.java 25 Nov 2003 16:34:08 -0000 1.20 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; --- 20,23 ---- *************** *** 29,32 **** --- 27,31 ---- import org.jrman.grid.Grid; import org.jrman.grid.Point3fGrid; + import org.jrman.parameters.ParameterList; import org.jrman.render.ShaderVariables; *************** *** 51,55 **** float thetaMin, float thetaMax, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 50,54 ---- float thetaMin, float thetaMax, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); Index: Point.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Point.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Point.java 18 May 2003 20:10:50 -0000 1.3 --- Point.java 25 Nov 2003 16:34:08 -0000 1.4 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Color3f; import javax.vecmath.Point3f; --- 20,23 ---- *************** *** 33,36 **** --- 31,36 ---- import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; + import org.jrman.parameters.ParameterList; + import org.jrman.parameters.VaryingScalarTuple3f; import org.jrman.parser.Parameter; import org.jrman.render.ShaderVariables; *************** *** 43,46 **** --- 43,48 ---- private static Vector3f v = new Vector3f(); + + private static Color3f color = new Color3f(); private float width; *************** *** 57,61 **** float y, float z, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 59,63 ---- float y, float z, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); *************** *** 86,99 **** dice_PandNg(sv, worldToCamera); sv.N.set(sv.Ng); ! Parameter csParam = (Parameter) parameters.get("Cs"); if (csParam != null) { ! Color3f[][] Cs = (Color3f[][]) csParam.getData(); ! sv.Cs.set(Cs[0][0]); } else sv.Cs.set(attributes.getColor()); ! Parameter osParam = (Parameter) parameters.get("Os"); if (osParam != null) { ! Color3f[][] Os = (Color3f[][]) osParam.getData(); ! sv.Os.set(Os[0][0]); } else sv.Os.set(attributes.getOpacity()); --- 88,101 ---- dice_PandNg(sv, worldToCamera); sv.N.set(sv.Ng); ! VaryingScalarTuple3f csParam = (VaryingScalarTuple3f) parameters.getParameter("Cs"); if (csParam != null) { ! csParam.getValue(0, color); ! sv.Cs.set(color); } else sv.Cs.set(attributes.getColor()); ! VaryingScalarTuple3f osParam = (VaryingScalarTuple3f) parameters.getParameter("Os"); if (osParam != null) { ! osParam.getValue(0, color); ! sv.Os.set(color); } else sv.Os.set(attributes.getOpacity()); Index: BilinearPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BilinearPatch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BilinearPatch.java 22 May 2003 04:50:14 -0000 1.1 --- BilinearPatch.java 25 Nov 2003 16:34:08 -0000 1.2 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 28,57 **** import org.jrman.geom.BoundingVolume; import org.jrman.geom.MutableBounds3f; ! import org.jrman.parser.Parameter; import org.jrman.render.ShaderVariables; public class BilinearPatch extends Primitive { ! ! private static Point3f P00; ! ! private static Point3f P10; ! ! private static Point3f P01; ! ! private static Point3f P11; ! private static Vector3f vtmp = new Vector3f(); ! ! public BilinearPatch(Map parameters, Attributes attributes) { super(parameters, attributes); } ! private void extractPoints() { ! Parameter param = (Parameter) parameters.get("P"); ! Point3f[][] P = (Point3f[][]) param.getData(); ! P00 = P[0][0]; ! P10 = P[1][0]; ! P01 = P[2][0]; ! P11 = P[3][0]; } --- 26,55 ---- import org.jrman.geom.BoundingVolume; import org.jrman.geom.MutableBounds3f; ! import org.jrman.parameters.ParameterList; ! import org.jrman.parameters.VaryingScalarTuple3f; import org.jrman.render.ShaderVariables; public class BilinearPatch extends Primitive { ! ! private static Point3f P00 = new Point3f(); ! ! private static Point3f P10 = new Point3f(); ! ! private static Point3f P01 = new Point3f(); ! ! private static Point3f P11 = new Point3f(); ! private static Vector3f vtmp = new Vector3f(); ! ! public BilinearPatch(ParameterList parameters, Attributes attributes) { super(parameters, attributes); } ! private void extractPoints() { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("P"); ! param.getValue(0, P00); ! param.getValue(1, P10); ! param.getValue(2, P01); ! param.getValue(3, P11); } *************** *** 80,100 **** float vl = (l1 + l2) / 2f; if (ul > vl) { ! result[0] = new BilinearPatch(linearInterpolateParameters(0f, .5f, 0f, 1f), attributes); ! result[1] = new BilinearPatch(linearInterpolateParameters(.5f, 1f, 0f , 1f), attributes); } else { ! result[0] = new BilinearPatch(linearInterpolateParameters(0f, 1f, 0f, .5f), attributes); ! result[1] = new BilinearPatch(linearInterpolateParameters(0f, 1f, .5f , 1f), attributes); } return result; } ! protected void dice_P(ShaderVariables sv) { extractPoints(); dicePoint3f(sv.P, P00, P10, P01, P11); } ! protected void dice_Ng(ShaderVariables sv) { sv.Ng.cross(sv.dPdu, sv.dPdv); } ! } --- 78,102 ---- float vl = (l1 + l2) / 2f; if (ul > vl) { ! result[0] = ! new BilinearPatch(linearInterpolateParameters(0f, .5f, 0f, 1f), attributes); ! result[1] = ! new BilinearPatch(linearInterpolateParameters(.5f, 1f, 0f, 1f), attributes); } else { ! result[0] = ! new BilinearPatch(linearInterpolateParameters(0f, 1f, 0f, .5f), attributes); ! result[1] = ! new BilinearPatch(linearInterpolateParameters(0f, 1f, .5f, 1f), attributes); } return result; } ! protected void dice_P(ShaderVariables sv) { extractPoints(); dicePoint3f(sv.P, P00, P10, P01, P11); } ! protected void dice_Ng(ShaderVariables sv) { sv.Ng.cross(sv.dPdu, sv.dPdv); } ! } Index: BicubicPatch.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/BicubicPatch.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BicubicPatch.java 9 Sep 2003 03:01:04 -0000 1.3 --- BicubicPatch.java 25 Nov 2003 16:34:08 -0000 1.4 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 30,34 **** import org.jrman.grid.Grid; import org.jrman.parameters.Declaration; ! import org.jrman.parser.Parameter; import org.jrman.render.ShaderVariables; import org.jrman.util.Calc; --- 28,33 ---- import org.jrman.grid.Grid; import org.jrman.parameters.Declaration; ! import org.jrman.parameters.ParameterList; ! import org.jrman.parameters.VaryingScalarTuple3f; import org.jrman.render.ShaderVariables; import org.jrman.util.Calc; *************** *** 36,96 **** public class BicubicPatch extends Primitive { ! private static Point3f P00; ! private static Point3f P10; ! private static Point3f P20; ! private static Point3f P30; ! private static Point3f P01; ! private static Point3f P11; ! private static Point3f P21; ! private static Point3f P31; ! private static Point3f P02; ! private static Point3f P12; ! private static Point3f P22; ! private static Point3f P32; ! private static Point3f P03; ! private static Point3f P13; ! private static Point3f P23; ! private static Point3f P33; private static Vector3f vtmp = new Vector3f(); ! public BicubicPatch(Map parameters, Attributes attributes) { super(parameters, attributes); } private void extractPoints() { ! Parameter param = (Parameter) parameters.get("P"); ! Point3f[][] P = (Point3f[][]) param.getData(); ! P00 = P[0][0]; ! P10 = P[1][0]; ! P20 = P[2][0]; ! P30 = P[3][0]; ! P01 = P[4][0]; ! P11 = P[5][0]; ! P21 = P[6][0]; ! P31 = P[7][0]; ! P02 = P[8][0]; ! P12 = P[9][0]; ! P22 = P[10][0]; ! P32 = P[11][0]; ! P03 = P[12][0]; ! P13 = P[13][0]; ! P23 = P[14][0]; ! P33 = P[15][0]; } --- 35,94 ---- public class BicubicPatch extends Primitive { ! private static Point3f P00 = new Point3f(); ! private static Point3f P10 = new Point3f(); ! private static Point3f P20 = new Point3f(); ! private static Point3f P30 = new Point3f(); ! private static Point3f P01 = new Point3f(); ! private static Point3f P11 = new Point3f(); ! private static Point3f P21 = new Point3f(); ! private static Point3f P31 = new Point3f(); ! private static Point3f P02 = new Point3f(); ! private static Point3f P12 = new Point3f(); ! private static Point3f P22 = new Point3f(); ! private static Point3f P32 = new Point3f(); ! private static Point3f P03 = new Point3f(); ! private static Point3f P13 = new Point3f(); ! private static Point3f P23 = new Point3f(); ! private static Point3f P33 = new Point3f(); private static Vector3f vtmp = new Vector3f(); ! public BicubicPatch(ParameterList parameters, Attributes attributes) { super(parameters, attributes); } private void extractPoints() { ! VaryingScalarTuple3f param = (VaryingScalarTuple3f) parameters.getParameter("P"); ! param.getValue(0, P00); ! param.getValue(1, P10); ! param.getValue(2, P20); ! param.getValue(3, P30); ! param.getValue(4, P01); ! param.getValue(5, P11); ! param.getValue(6, P21); ! param.getValue(7, P31); ! param.getValue(8, P02); ! param.getValue(9, P12); ! param.getValue(10, P22); ! param.getValue(11, P32); ! param.getValue(12, P03); ! param.getValue(13, P13); ! param.getValue(14, P23); ! param.getValue(15, P33); } *************** *** 144,177 **** } ! protected Map bezierInterpolateParameters( float uv00, float uv10, float uv01, float uv11) { ! Map result = linearInterpolateParameters(uv00, uv10, uv01, uv11); ! result.remove("u"); ! result.remove("v"); extractPoints(); ! Point3f[][] p = new Point3f[16][]; ! for (int i = 0; i < 16; i++) { ! p[i] = new Point3f[1]; ! p[i][0] = new Point3f(); ! } ! Point3f PS00 = p[0][0]; ! Point3f PS10 = p[1][0]; ! Point3f PS20 = p[2][0]; ! Point3f PS30 = p[3][0]; ! Point3f PS01 = p[4][0]; ! Point3f PS11 = p[5][0]; ! Point3f PS21 = p[6][0]; ! Point3f PS31 = p[7][0]; ! Point3f PS02 = p[8][0]; ! Point3f PS12 = p[9][0]; ! Point3f PS22 = p[10][0]; ! Point3f PS32 = p[11][0]; ! Point3f PS03 = p[12][0]; ! Point3f PS13 = p[13][0]; ! Point3f PS23 = p[14][0]; ! Point3f PS33 = p[15][0]; if (uv00 == .5f) { splitUpper(P00, P10, P20, P30, PS00, PS10, PS20, PS30); --- 142,172 ---- } ! protected ParameterList bezierInterpolateParameters( float uv00, float uv10, float uv01, float uv11) { ! ParameterList result = linearInterpolateParameters(uv00, uv10, uv01, uv11); ! result.removeParameter("u"); ! result.removeParameter("v"); extractPoints(); ! VaryingScalarTuple3f sparam = ! new VaryingScalarTuple3f(new Declaration("P", "vertex point"), new float[16 * 3]); ! Point3f PS00 = new Point3f(); ! Point3f PS10 = new Point3f(); ! Point3f PS20 = new Point3f(); ! Point3f PS30 = new Point3f(); ! Point3f PS01 = new Point3f(); ! Point3f PS11 = new Point3f(); ! Point3f PS21 = new Point3f(); ! Point3f PS31 = new Point3f(); ! Point3f PS02 = new Point3f(); ! Point3f PS12 = new Point3f(); ! Point3f PS22 = new Point3f(); ! Point3f PS32 = new Point3f(); ! Point3f PS03 = new Point3f(); ! Point3f PS13 = new Point3f(); ! Point3f PS23 = new Point3f(); ! Point3f PS33 = new Point3f(); if (uv00 == .5f) { splitUpper(P00, P10, P20, P30, PS00, PS10, PS20, PS30); *************** *** 195,199 **** splitLower(P30, P31, P32, P33, PS30, PS31, PS32, PS33); } ! result.put("P", new Parameter(new Declaration("P", "vertex point"), p)); return result; } --- 190,210 ---- splitLower(P30, P31, P32, P33, PS30, PS31, PS32, PS33); } ! sparam.setValue(0, PS00); ! sparam.setValue(1, PS10); ! sparam.setValue(2, PS20); ! sparam.setValue(3, PS30); ! sparam.setValue(4, PS01); ! sparam.setValue(5, PS11); ! sparam.setValue(6, PS21); ! sparam.setValue(7, PS31); ! sparam.setValue(8, PS02); ! sparam.setValue(9, PS12); ! sparam.setValue(10, PS22); ! sparam.setValue(11, PS32); ! sparam.setValue(12, PS03); ! sparam.setValue(13, PS13); ! sparam.setValue(14, PS23); ! sparam.setValue(15, PS33); ! result.addParameter(sparam); return result; } *************** *** 208,224 **** Point3f out2, Point3f out3) { ! out0.set(in0); ! out1.add(in0, in1); ! out1.scale(.5f); ! out2.set(in1); ! out2.scale(2f); ! out2.add(in0); ! out2.add(in2); ! out2.scale(.25f); ! out3.add(in1, in2); ! out3.scale(3f); ! out3.add(in0); ! out3.add(in3); ! out3.scale(.125f); } --- 219,235 ---- Point3f out2, Point3f out3) { ! out0.set(in0); ! out1.add(in0, in1); ! out1.scale(.5f); ! out2.set(in1); ! out2.scale(2f); ! out2.add(in0); ! out2.add(in2); ! out2.scale(.25f); ! out3.add(in1, in2); ! out3.scale(3f); ! out3.add(in0); ! out3.add(in3); ! out3.scale(.125f); } *************** *** 232,248 **** Point3f out2, Point3f out3) { ! out3.set(in3); ! out2.add(in3, in2); ! out2.scale(.5f); ! out1.set(in2); ! out1.scale(2f); ! out1.add(in3); ! out1.add(in1); ! out1.scale(.25f); ! out0.add(in2, in1); ! out0.scale(3f); ! out0.add(in3); ! out0.add(in0); ! out0.scale(.125f); } --- 243,259 ---- Point3f out2, Point3f out3) { ! out3.set(in3); ! out2.add(in3, in2); ! out2.scale(.5f); ! out1.set(in2); ! out1.scale(2f); ! out1.add(in3); ! out1.add(in1); ! out1.scale(.25f); ! out0.add(in2, in1); ! out0.scale(3f); ! out0.add(in3); ! out0.add(in0); ! out0.scale(.125f); } Index: Disk.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Disk.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Disk.java 22 May 2003 04:50:14 -0000 1.6 --- Disk.java 25 Nov 2003 16:34:08 -0000 1.7 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 31,34 **** --- 29,33 ---- import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; + import org.jrman.parameters.ParameterList; import org.jrman.render.ShaderVariables; *************** *** 55,59 **** float rMin, float rMax, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 54,58 ---- float rMin, float rMax, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); Index: Cylinder.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Cylinder.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Cylinder.java 22 May 2003 04:50:14 -0000 1.5 --- Cylinder.java 25 Nov 2003 16:34:08 -0000 1.6 *************** *** 20,25 **** package org.jrman.primitive; - import java.util.Map; - import javax.vecmath.Point3f; import javax.vecmath.Vector3f; --- 20,23 ---- *************** *** 31,34 **** --- 29,33 ---- import org.jrman.grid.Point3fGrid; import org.jrman.grid.Vector3fGrid; + import org.jrman.parameters.ParameterList; import org.jrman.render.ShaderVariables; *************** *** 55,59 **** float thetaMin, float thetaMax, ! Map parameters, Attributes attributes) { super(parameters, attributes); --- 54,58 ---- float thetaMin, float thetaMax, ! ParameterList parameters, Attributes attributes) { super(parameters, attributes); Index: Quadric.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/Quadric.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Quadric.java 22 May 2003 04:50:14 -0000 1.13 --- Quadric.java 25 Nov 2003 16:34:08 -0000 1.14 *************** *** 20,30 **** package org.jrman.primitive; - import java.util.Map; - import org.jrman.attributes.Attributes; public abstract class Quadric extends Primitive { ! public Quadric(Map parameters, Attributes attributes) { super(parameters, attributes); } --- 20,29 ---- package org.jrman.primitive; import org.jrman.attributes.Attributes; + import org.jrman.parameters.ParameterList; public abstract class Quadric extends Primitive { ! public Quadric(ParameterList parameters, Attributes attributes) { super(parameters, attributes); } |