From: Gerardo H. <ma...@us...> - 2006-12-26 16:58:56
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17387/src/org/jrman/primitive Modified Files: LinearCurve.java Log Message: Implemented "N" twisting for linear curves. Index: LinearCurve.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/LinearCurve.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** LinearCurve.java 24 Dec 2006 05:25:57 -0000 1.1 --- LinearCurve.java 26 Dec 2006 16:58:47 -0000 1.2 *************** *** 122,128 **** static Point3f pb = new Point3f(); static Vector3f v3 = new Vector3f(); ! static Vector2f v2 = new Vector2f(); static float wa; --- 122,132 ---- static Point3f pb = new Point3f(); + static Point3f pTmp1 = new Point3f(); + + static Point3f pTmp2 = new Point3f(); + static Vector3f v3 = new Vector3f(); ! static Vector3f vTmp = new Vector3f(); static float wa; *************** *** 197,206 **** // dice_s(shaderVariables); // dice_t(shaderVariables); ! dice_PandNg(shaderVariables); dice_du(shaderVariables); dice_dv(shaderVariables); dice_dPdu(shaderVariables); dice_dPdv(shaderVariables); - dice_N(shaderVariables); dice_Cs(shaderVariables); dice_Os(shaderVariables); --- 201,209 ---- // dice_s(shaderVariables); // dice_t(shaderVariables); ! dice_N_Ng_P(shaderVariables); dice_du(shaderVariables); dice_dv(shaderVariables); dice_dPdu(shaderVariables); dice_dPdv(shaderVariables); dice_Cs(shaderVariables); dice_Os(shaderVariables); *************** *** 208,214 **** } ! protected void dice_PandNg(ShaderVariables shaderVariables) { v3.set(0f, 0f, -1f); shaderVariables.Ng.set(v3); extractPoints(); extractWidths(); --- 211,225 ---- } ! protected void dice_N_Ng_P(ShaderVariables shaderVariables) { ! boolean hasN = false; v3.set(0f, 0f, -1f); shaderVariables.Ng.set(v3); + VaryingScalarTuple3f param = + (VaryingScalarTuple3f) parameters.getParameter("N"); + if (param != null) { + param.linearDice(shaderVariables.N); + hasN = true; + } else + shaderVariables.N.set(shaderVariables.Ng); extractPoints(); extractWidths(); *************** *** 221,252 **** objectToCamera.transformVector(v3, v3); wb = v3.length() /2; ! v2.set(pb.x - pa.x, pb.y - pa.y); ! Calc.perp(v2, v2); ! v2.normalize(); ! float aax = pa.x - v2.x * wa; ! float aay = pa.y - v2.y * wa; ! float aaz = pa.z; ! float abx = pa.x + v2.x * wa; ! float aby = pa.y + v2.y * wa; ! float abz = pa.z; ! float bax = pb.x - v2.x * wb; ! float bay = pb.y - v2.y * wb; ! float baz = pb.z; ! float bbx = pb.x + v2.x * wb; ! float bby = pb.y + v2.y * wb; ! float bbz = pb.z; Point3fGrid P = shaderVariables.P; int vSize = Grid.getVSize(); float vStep = 1f / (vSize - 1); float v = 0; for (int i = 0; i < vSize; i++) { ! pa.x = Calc.interpolate(aax, bax, v); ! pa.y = Calc.interpolate(aay, bay, v); ! pa.z = Calc.interpolate(aaz, baz, v); ! pb.x = Calc.interpolate(abx, bbx, v); ! pb.y = Calc.interpolate(aby, bby, v); ! pb.z = Calc.interpolate(abz, bbz, v); ! P.set(0, i, pa); ! P.set(1, i, pb); v += vStep; } --- 232,257 ---- objectToCamera.transformVector(v3, v3); wb = v3.length() /2; ! pTmp1.set(pa); ! pTmp2.set(pb); ! if (!hasN) { ! pTmp1.z = 0; ! pTmp2.z = 0; ! } ! v3.sub(pTmp2, pTmp1); Point3fGrid P = shaderVariables.P; + Vector3fGrid N = shaderVariables.N; int vSize = Grid.getVSize(); float vStep = 1f / (vSize - 1); float v = 0; for (int i = 0; i < vSize; i++) { ! N.get(0, i, vTmp); ! vTmp.cross(v3, vTmp); ! vTmp.normalize(); ! Calc.interpolate(pa, pb, v, pTmp1); ! float w = Calc.interpolate(wa, wb, v); ! pTmp2.scaleAdd(w, vTmp, pTmp1); ! P.set(0, i, pTmp2); ! pTmp2.scaleAdd(-w, vTmp, pTmp1); ! P.set(1, i, pTmp2); v += vStep; } |