From: <ma...@us...> - 2003-04-09 01:12:49
|
Update of /cvsroot/jrman/drafts/src/org/jrman/parser In directory sc8-pr-cvs1:/tmp/cvs-serv2564/src/org/jrman/parser Modified Files: Transform.java Parser.java PerspectiveTransform.java AffineTransform.java Log Message: More improvements to implementation of transforms. Index: Transform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Transform.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Transform.java 8 Apr 2003 23:48:40 -0000 1.2 --- Transform.java 9 Apr 2003 01:12:46 -0000 1.3 *************** *** 27,30 **** --- 27,34 ---- public interface Transform { + Transform newTransform(); + + Transform newTransformConcat(Matrix4f matrix); + void transformPoint(Point3f point); Index: Parser.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/Parser.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Parser.java 9 Apr 2003 00:37:44 -0000 1.8 --- Parser.java 9 Apr 2003 01:12:46 -0000 1.9 *************** *** 209,215 **** Matrix4f rotation = new Matrix4f(); rotation.set(axisAngle); ! Matrix4f matrix = currentAttributes.getTransform().getMatrix(); ! matrix.mul(rotation); ! currentAttributes.setTransform(new AffineTransform(matrix)); } --- 209,213 ---- Matrix4f rotation = new Matrix4f(); rotation.set(axisAngle); ! concatTransform(rotation); } *************** *** 217,223 **** Matrix4f scale = new Matrix4f(sx, 0f, 0f, 0f, 0f, sy, 0f, 0f, 0f, 0f, sz, 0f, 0f, 0f, 0f, 1f); ! Matrix4f matrix = currentAttributes.getTransform().getMatrix(); ! matrix.mul(scale); ! currentAttributes.setTransform(new AffineTransform(matrix)); } --- 215,219 ---- Matrix4f scale = new Matrix4f(sx, 0f, 0f, 0f, 0f, sy, 0f, 0f, 0f, 0f, sz, 0f, 0f, 0f, 0f, 1f); ! concatTransform(scale); } *************** *** 225,231 **** Matrix4f translation = new Matrix4f(); translation.setTranslation(new Vector3f(dx, dy, dz)); ! Matrix4f matrix = currentAttributes.getTransform().getMatrix(); ! matrix.mul(translation); ! currentAttributes.setTransform(new AffineTransform(matrix)); } --- 221,225 ---- Matrix4f translation = new Matrix4f(); translation.setTranslation(new Vector3f(dx, dy, dz)); ! concatTransform(translation); } *************** *** 253,259 **** public void concatTransform(Matrix4f trans) { ! Matrix4f matrix = currentAttributes.getTransform().getMatrix(); ! matrix.mul(trans); ! currentAttributes.setTransform(new AffineTransform(matrix)); } --- 247,252 ---- public void concatTransform(Matrix4f trans) { ! currentAttributes.setTransform( ! currentAttributes.getTransform().newTransformConcat(trans)); } Index: PerspectiveTransform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/PerspectiveTransform.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PerspectiveTransform.java 8 Apr 2003 23:48:40 -0000 1.2 --- PerspectiveTransform.java 9 Apr 2003 01:12:46 -0000 1.3 *************** *** 23,26 **** --- 23,27 ---- import javax.vecmath.Point3f; import javax.vecmath.Point4f; + import javax.vecmath.Vector3f; public class PerspectiveTransform extends AffineTransform { *************** *** 29,32 **** --- 30,43 ---- super(matrix); } + + public Transform newTransform() { + return new PerspectiveTransform(getMatrix()); + } + + public Transform newTransformConcat(Matrix4f m){ + Matrix4f matrix = getMatrix(); + matrix.mul(m); + return new AffineTransform(matrix); + } public void transformPoint(Point3f point) { *************** *** 34,37 **** --- 45,52 ---- transformHPoint(hpoint); point.project(hpoint); + } + + public void transformVector(Vector3f vector) { + throw new UnsupportedOperationException(); } Index: AffineTransform.java =================================================================== RCS file: /cvsroot/jrman/drafts/src/org/jrman/parser/AffineTransform.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AffineTransform.java 9 Apr 2003 00:37:44 -0000 1.3 --- AffineTransform.java 9 Apr 2003 01:12:46 -0000 1.4 *************** *** 50,53 **** --- 50,63 ---- this(transform.getMatrix()); } + + public Transform newTransform(){ + return new AffineTransform(this); + } + + public Transform newTransformConcat(Matrix4f m){ + Matrix4f matrix = getMatrix(); + matrix.mul(m); + return new AffineTransform(matrix); + } public void transformPoint(Point3f point) { |