Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv22122/src/net/sourceforge/bprocessor/gl/view
Modified Files:
View.java
Log Message:
made changes to the way factor is evaluated and the placement of the calcs. inserted a combobox with no functionallity yet...
Index: View.java
===================================================================
RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v
retrieving revision 1.170
retrieving revision 1.171
diff -C2 -d -r1.170 -r1.171
*** View.java 9 Jan 2007 10:12:06 -0000 1.170
--- View.java 12 Jan 2007 17:52:27 -0000 1.171
***************
*** 47,50 ****
--- 47,51 ----
import java.util.HashMap;
+ import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
***************
*** 75,78 ****
--- 76,84 ----
*/
public class View implements GLEventListener {
+ /**
+ *
+ */
+ private static final int CONVETIONAL_WINDOW_HEIGHT = 600;
+
/** The logger */
private static Logger log = Logger.getLogger(View.class);
***************
*** 577,581 ****
glu = new GLU();
! gl.glViewport(0, 0, (int)width, (int)height);
if (picking > 0) {
selectBuffer = BufferUtil.newIntBuffer(selectionLength);
--- 583,587 ----
glu = new GLU();
! //gl.glViewport(0, 0, (int)width, (int)height);
if (picking > 0) {
selectBuffer = BufferUtil.newIntBuffer(selectionLength);
***************
*** 729,733 ****
View.aspect = width / height;
! /** fetch the current camera */
Camera camera = Project.getInstance().getCurrentCamera();
double[] eye = camera.getCamera();
--- 735,739 ----
View.aspect = width / height;
! /* fetch the current camera */
Camera camera = Project.getInstance().getCurrentCamera();
double[] eye = camera.getCamera();
***************
*** 742,751 ****
far = far < 20 ? 20 : far;
double focalwidth = camera.getFocalwidth();
if (camera.getType() == Camera.ORTHOGRAPHIC) {
! double tal = Math.tan(Math.toRadians(focalwidth / 2)) * length;
gl.glOrtho(-tal * aspect, tal * aspect, -tal, tal, near, far);
} else if (camera.getType() == Camera.PERSPECTIVE) {
// fovy, aspect, near, far (relative to camera position)
! glu.gluPerspective(focalwidth, aspect, near, far);
}
--- 748,762 ----
far = far < 20 ? 20 : far;
double focalwidth = camera.getFocalwidth();
+ double d = View.height / CONVETIONAL_WINDOW_HEIGHT;
if (camera.getType() == Camera.ORTHOGRAPHIC) {
! int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
! double relation = 2.54;
! double dpm = (dpi / relation) * 100;
! double windowInMeters = 600 / dpm;
! double tal = d * camera.getFactor() * windowInMeters / 2;
gl.glOrtho(-tal * aspect, tal * aspect, -tal, tal, near, far);
} else if (camera.getType() == Camera.PERSPECTIVE) {
// fovy, aspect, near, far (relative to camera position)
! glu.gluPerspective(focalwidth * d, aspect, near, far);
}
***************
*** 1790,1793 ****
--- 1801,1805 ----
View.height = height;
View.aspect = View.width / View.height;
+ gld.getGL().glViewport(0, 0, width, height);
}
***************
*** 3347,3349 ****
--- 3359,3399 ----
this.glObjects3D.add(glo);
}
+
+ /**
+ * Calculate the 1 : factor ralationship with reality
+ * @return The to reality factor for the camera
+ */
+ public double calcFactor() {
+ Camera current = Project.getInstance().getCurrentCamera();
+ double[] camera = current.getCamera();
+ double[] center = current.getCenter();
+ double length = Math.sqrt((camera[0] - center[0]) * (camera[0] - center[0]) +
+ (camera[1] - center[1]) * (camera[1] - center[1]) +
+ (camera[2] - center[2]) * (camera[2] - center[2]));
+ double tal = Math.tan(Math.toRadians(current.getFocalwidth())) * length;
+ int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
+ double dpm = (dpi / 2.54) * 100;
+ double windowheight = CONVETIONAL_WINDOW_HEIGHT / dpm;
+ log.info("factor " + (tal / windowheight));
+ return tal / windowheight;
+ }
+
+ /**
+ * Calc position for the camera based on the given to reality factor
+ */
+ public void invertFactor() {
+ Camera current = Project.getInstance().getCurrentCamera();
+ int dpi = Toolkit.getDefaultToolkit().getScreenResolution();
+ double dpm = (dpi / 2.54) * 100;
+ double window = CONVETIONAL_WINDOW_HEIGHT / dpm;
+ double length = current.getFactor() * window;
+ length /= Math.tan(Math.toRadians(current.getFocalwidth()));
+ double[] camera = current.getCamera();
+ double[] center = current.getCenter();
+ Vertex back = new Vertex(camera).minus(new Vertex(center));
+ back.scale(length / back.length());
+ camera[0] = center[0] + back.getX();
+ camera[1] = center[1] + back.getY();
+ camera[2] = center[2] + back.getZ();
+ }
}
|