From: <ha...@us...> - 2009-08-07 07:35:32
|
Revision: 11305 http://jmol.svn.sourceforge.net/jmol/?rev=11305&view=rev Author: hansonr Date: 2009-08-07 07:35:26 +0000 (Fri, 07 Aug 2009) Log Message: ----------- version=11.8.RC5_dev # new feature: preliminary VERY COMPACT IDTF export (for U3D conversion) Modified Paths: -------------- trunk/Jmol/src/org/jmol/export/_IdtfExporter.java trunk/Jmol/src/org/jmol/util/Quaternion.java Modified: trunk/Jmol/src/org/jmol/export/_IdtfExporter.java =================================================================== --- trunk/Jmol/src/org/jmol/export/_IdtfExporter.java 2009-08-06 06:27:41 UTC (rev 11304) +++ trunk/Jmol/src/org/jmol/export/_IdtfExporter.java 2009-08-07 07:35:26 UTC (rev 11305) @@ -105,14 +105,12 @@ getViewpointPosition(ptAtom); adjustViewpointPosition(ptAtom); viewer.getAxisAngle(viewpoint); + Quaternion q0 = new Quaternion(viewpoint); + Quaternion q = new Quaternion(new Point4f(0.5258319f, -0.3542887f, -0.43182528f, 0.6414883f)); + q = q.mul(q0); + viewpoint.set(q.getMatrix()); if (viewpoint.angle == 0) - viewpoint.y = 1; - Matrix3f m3 = new Matrix3f(); - m3.set(viewpoint); - Quaternion q = new Quaternion(new Point4f(0.48537543f, -0.38002273f, -0.4436077f, 0.6505426f)); - Quaternion q2 = new Quaternion(m3); - q2 = q.mul(q2); - viewpoint.set(q2.getMatrix()); + viewpoint.z = 1; m.set(viewpoint); ptAtom.set(center); ptAtom.scale(-1); @@ -813,55 +811,14 @@ } public void plotText(int x, int y, int z, short colix, String text, Font3D font3d) { + // trick here is that we use Jmol's standard g3d package to construct + // the bitmap, but then output to jmolRenderer, which returns control + // here via drawPixel. if (z < 3) { viewer.transformPoint(center, pt); z = (int)pt.z; } -/* String useFontStyle = font3d.fontStyle.toUpperCase(); - String preFontFace = font3d.fontFace.toUpperCase(); - String useFontFace = (preFontFace.equals("MONOSPACED") ? "TYPEWRITER" - : preFontFace.equals("SERIF") ? "SERIF" : "SANS"); - output("<Transform translation='"); - pt.set(x, y, z); - viewer.unTransformPoint(pt, ptAtom); - output(ptAtom); - output("'>"); - // These x y z are 3D coordinates of echo or the atom the label is attached - // to. - output("<Billboard "); - String child = getDef("T" + colix + useFontFace + useFontStyle + "_" + text); - if (child.charAt(0) == '_') { - output("DEF='" + child + "' axisOfRotation='0 0 0'>" - + "<Transform translation='0.0 0.0 0.0'>" - + "<Shape>"); - outputAppearance(colix, true); - output("<Text string=" + Escape.escape(text) + ">"); - output("<FontStyle "); - String fontstyle = getDef("F" + useFontFace + useFontStyle); - if (fontstyle.charAt(0) == '_') { - output("DEF='" + fontstyle + "' size='0.4' family='" + useFontFace - + "' style='" + useFontStyle + "'/>"); - } else { - output(fontstyle + "/>"); - } - output("</Text>"); - output("</Shape>"); - output("</Transform>"); - } else { - output(child + ">"); - } - output("</Billboard>\n"); - output("</Transform>\n"); -*/ - /* - * Unsolved issues: # Non-label texts: echos, measurements :: need to get - * space coordinates, not screen coord. # Font size: not implemented; 0.4A - * is hardcoded (resizes with zoom) Java VRML font3d.fontSize = 13.0 size - * (numeric), but in angstroms, not pixels font3d.fontSizeNominal = 13.0 # - * Label offsets: not implemented; hardcoded to 0.25A in each x,y,z # - * Multi-line labels: only the first line is received # Sub/superscripts not - * interpreted - */ + g3d.plotText(x, y, z, g3d.getColixArgb(colix), text, font3d, jmolRenderer); } public void startShapeBuffer(int iShape) { @@ -955,7 +912,7 @@ pt.set(x, y, z); viewer.unTransformPoint(pt, ptAtom); short colix = Graphics3D.getColix(argb); - outputSphere(ptAtom, 0.01f, colix); + outputSphere(ptAtom, 0.02f, colix); } public void plotImage(int x, int y, int z, Image image, short bgcolix, Modified: trunk/Jmol/src/org/jmol/util/Quaternion.java =================================================================== --- trunk/Jmol/src/org/jmol/util/Quaternion.java 2009-08-06 06:27:41 UTC (rev 11304) +++ trunk/Jmol/src/org/jmol/util/Quaternion.java 2009-08-07 07:35:26 UTC (rev 11305) @@ -55,43 +55,44 @@ public class Quaternion { public float q0, q1, q2, q3; - public Matrix3f mat; + private final static Point4f qZero = new Point4f(); + private final static Quaternion qTemp = new Quaternion(0, 0, 0, 0); + public Quaternion() { q0 = 1; } public Quaternion(Quaternion q) { - q0 = q.q0; - q1 = q.q1; - q2 = q.q2; - q3 = q.q3; + set(q); } - public void setRef(Quaternion qref) { - if (qref == null) { - fixQ(this); - return; - } - if (this.dot(qref) >= 0) - return; - q0 *= -1; - q1 *= -1; - q2 *= -1; - q3 *= -1; + public Quaternion(Tuple3f pt, float theta) { + set(pt, theta); } + public Quaternion(Matrix3f mat) { + set(mat); + } + + public Quaternion(AxisAngle4f a) { + set(a); + } + + public Quaternion(Point4f pt) { + set(pt); + } + // create a new object with the given components - private Quaternion(float q0, float q1, float q2, float q3) { + public Quaternion(float q0, float q1, float q2, float q3) { this.q0 = q0; this.q1 = q1; this.q2 = q2; this.q3 = q3; } - private final static Point4f qZero = new Point4f(); - public Quaternion(Point4f pt) { + private void set(Point4f pt) { float factor = (pt == null ? 0 : pt.distance(qZero)); if (factor == 0) { q0 = 1; @@ -103,7 +104,7 @@ q3 = pt.z / factor; } - public Quaternion(Tuple3f pt, float theta) { + public void set(Tuple3f pt, float theta) { if (pt.x == 0 && pt.y == 0 && pt.z == 0) { q0 = 1; return; @@ -116,7 +117,7 @@ q3 = (float) (pt.z * fact); } - public Quaternion(Matrix3f mat) { + public void set(Matrix3f mat) { /* * Changed 7/16/2008 to double precision for 11.5.48. @@ -254,9 +255,37 @@ } */ + } + public void set(AxisAngle4f a) { + AxisAngle4f aa = new AxisAngle4f(a); + if (aa.angle == 0) + aa.y = 1; + Matrix3f m3 = new Matrix3f(); + m3.set(aa); + set(m3); } + public void set(Quaternion q) { + q0 = q.q0; + q1 = q.q1; + q2 = q.q2; + q3 = q.q3; + } + + public void setRef(Quaternion qref) { + if (qref == null) { + fixQ(this); + return; + } + if (this.dot(qref) >= 0) + return; + q0 *= -1; + q1 *= -1; + q2 *= -1; + q3 *= -1; + } + public static final Quaternion getQuaternionFrame(Point3f center, Point3f x, Point3f xy) { Vector3f vA = new Vector3f(x); vA.sub(center); @@ -344,9 +373,8 @@ public Quaternion mul(float x) { // UNIT multiplication - if (x == 1) - return new Quaternion(q0, q1, q2, q3); - return new Quaternion(getNormal(), getTheta() * x); + return (x == 1 ? new Quaternion(q0, q1, q2, q3) : + new Quaternion(getNormal(), getTheta() * x)); } public Quaternion mul(Quaternion p) { @@ -386,8 +414,6 @@ qNew.q3 = q3 * f; } - private final static Quaternion qTemp = new Quaternion(0, 0, 0, 0); - public String toString() { return "{" + q1 + " " + q2 + " " + q3 + " " + q0 + "}"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |