From: Gerardo H. <ma...@us...> - 2006-12-26 17:26:24
|
Update of /cvsroot/jrman/drafts/src/org/jrman/primitive In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv28305/src/org/jrman/primitive Modified Files: CubicCurve.java LinearCurve.java Log Message: Implemented "N" twisting for cubic curves. Index: CubicCurve.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/CubicCurve.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CubicCurve.java 25 Dec 2006 07:50:37 -0000 1.1 --- CubicCurve.java 26 Dec 2006 17:26:19 -0000 1.2 *************** *** 23,27 **** import javax.vecmath.Point3f; import javax.vecmath.Point4f; - import javax.vecmath.Vector2f; import javax.vecmath.Vector3f; --- 23,26 ---- *************** *** 153,157 **** static Vector3f v3 = new Vector3f(); ! static Vector2f v2 = new Vector2f(); static Point4f PV0 = new Point4f(); --- 152,156 ---- static Vector3f v3 = new Vector3f(); ! static Vector3f vTmp = new Vector3f(); static Point4f PV0 = new Point4f(); *************** *** 366,370 **** // dice_s(shaderVariables); // dice_t(shaderVariables); ! dice_PandNg(shaderVariables); dice_du(shaderVariables); dice_dv(shaderVariables); --- 365,369 ---- // dice_s(shaderVariables); // dice_t(shaderVariables); ! dice_Ng_N_P(shaderVariables); dice_du(shaderVariables); dice_dv(shaderVariables); *************** *** 377,383 **** } ! protected void dice_PandNg(ShaderVariables shaderVariables) { v3.set(0f, 0f, -1f); shaderVariables.Ng.set(v3); extractPoints(); objectToCamera.transformHPoint(pa, pa); --- 376,390 ---- } ! protected void dice_Ng_N_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(); objectToCamera.transformHPoint(pa, pa); *************** *** 402,405 **** --- 409,413 ---- objectToCamera.transformVector(v3, v3); wd = v3.length() /2; + Vector3fGrid N = shaderVariables.N; v = 0f; for (int i = 0; i < nv; i++) { *************** *** 408,421 **** if (i < nv - 1) { P.get(0, i + 1, p3fb); ! v2.set(p3fb.x - p3fa.x, p3fb.y - p3fa.y); ! Calc.perp(v2, v2); ! v2.normalize(); } ! p3fb.x = p3fa.x - v2.x * wv; ! p3fb.y = p3fa.y - v2.y * wv; ! p3fb.z = p3fa.z; P.set(0, i, p3fb); ! p3fb.x = p3fa.x + v2.x * wv; ! p3fb.y = p3fa.y + v2.y * wv; P.set(1, i, p3fb); v += vStep; --- 416,432 ---- if (i < nv - 1) { P.get(0, i + 1, p3fb); ! if (!hasN) { ! p3fa.z = 0f; ! p3fb.z = 0f; ! } ! v3.sub(p3fb, p3fa); } ! N.get(0, i, vTmp); ! vTmp.cross(v3, vTmp); ! vTmp.normalize(); ! P.get(0, i, p3fa); ! p3fb.scaleAdd(wv, vTmp, p3fa); P.set(0, i, p3fb); ! p3fb.scaleAdd(-wv, vTmp, p3fa); P.set(1, i, p3fb); v += vStep; Index: LinearCurve.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/primitive/LinearCurve.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LinearCurve.java 26 Dec 2006 16:58:47 -0000 1.2 --- LinearCurve.java 26 Dec 2006 17:26:19 -0000 1.3 *************** *** 21,25 **** import javax.vecmath.Point3f; - import javax.vecmath.Vector2f; import javax.vecmath.Vector3f; --- 21,24 ---- *************** *** 201,205 **** // dice_s(shaderVariables); // dice_t(shaderVariables); ! dice_N_Ng_P(shaderVariables); dice_du(shaderVariables); dice_dv(shaderVariables); --- 200,204 ---- // dice_s(shaderVariables); // dice_t(shaderVariables); ! dice_Ng_N_P(shaderVariables); dice_du(shaderVariables); dice_dv(shaderVariables); *************** *** 211,215 **** } ! protected void dice_N_Ng_P(ShaderVariables shaderVariables) { boolean hasN = false; v3.set(0f, 0f, -1f); --- 210,214 ---- } ! protected void dice_Ng_N_P(ShaderVariables shaderVariables) { boolean hasN = false; v3.set(0f, 0f, -1f); *************** *** 235,240 **** pTmp2.set(pb); if (!hasN) { ! pTmp1.z = 0; ! pTmp2.z = 0; } v3.sub(pTmp2, pTmp1); --- 234,239 ---- pTmp2.set(pb); if (!hasN) { ! pTmp1.z = 0f; ! pTmp2.z = 0f; } v3.sub(pTmp2, pTmp1); |