Update of /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29959/src/net/sourceforge/bprocessor/model
Modified Files:
Camera.java
Log Message:
added a orthographic factor to the camera
Index: Camera.java
===================================================================
RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/Camera.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** Camera.java 2 Jan 2007 18:30:33 -0000 1.32
--- Camera.java 12 Jan 2007 11:48:16 -0000 1.33
***************
*** 7,10 ****
--- 7,11 ----
package net.sourceforge.bprocessor.model;
+ import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Collection;
***************
*** 60,63 ****
--- 61,67 ----
/** The list of clipplanes to this camera*/
private ArrayList<ClippingPlane> clipplanes;
+
+ /** The to reality size factor for orthographic cameras */
+ private double factor;
/**
***************
*** 102,105 ****
--- 106,110 ----
this.setFocalwidth(c.getFocalwidth());
Iterator clips = c.getClipplanes().iterator();
+ c.factor = this.factor;
while (clips.hasNext()) {
ClippingPlane clip = (ClippingPlane)clips.next();
***************
*** 117,120 ****
--- 122,126 ----
this.setRoll(new double[]{other.roll[0], other.roll[1], other.roll[2]});
this.setType(other.getType());
+ this.factor = other.factor;
this.setFocalwidth(other.getFocalwidth());
Iterator clips = other.getClipplanes().iterator();
***************
*** 159,164 ****
*/
public void setType(int type) {
! if (type == PERSPECTIVE || type == ORTHOGRAPHIC) {
! this.type = type;
} else {
log.error("Wrong camera type should be either Camera.PERSPECTIVE or Camera.ORTHOGRAPIC");
--- 165,174 ----
*/
public void setType(int type) {
! if (type == PERSPECTIVE) {
! calcOrthoToPersp();
! this.type = type;
! } else if (type == ORTHOGRAPHIC) {
! calcPerspToOrtho();
! this.type = type;
} else {
log.error("Wrong camera type should be either Camera.PERSPECTIVE or Camera.ORTHOGRAPIC");
***************
*** 167,170 ****
--- 177,200 ----
/**
+ * Change the to reality factor from the camera settings
+ */
+ private void calcPerspToOrtho() {
+ 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 width = Math.tan(Math.toRadians(focalwidth)) * length;
+ factor = width * 100.0 * (96.0 / 100.0);
+ log.info("The factor is:" + factor + " for width " + width);
+ }
+
+ /**
+ * Change the camera to corrospond the reality factor
+ */
+ private void calcOrthoToPersp() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
* Getter for camera.type
* @return The camera type
***************
*** 309,316 ****
*/
public void zoomin(double[] target) {
! if (dist() >= 0.1) {
! camera[0] -= (camera[0] - target[0]) * 0.1;
! camera[1] -= (camera[1] - target[1]) * 0.1;
! camera[2] -= (camera[2] - target[2]) * 0.1;
}
}
--- 339,350 ----
*/
public void zoomin(double[] target) {
! if (type == PERSPECTIVE) {
! if (dist() >= 0.1) {
! camera[0] -= (camera[0] - target[0]) * 0.1;
! camera[1] -= (camera[1] - target[1]) * 0.1;
! camera[2] -= (camera[2] - target[2]) * 0.1;
! }
! } else {
! factor *= 2;
}
}
***************
*** 320,327 ****
*/
public void zoomout() {
! camera[0] += (camera[0] - center[0]) * 0.1;
! camera[1] += (camera[1] - center[1]) * 0.1;
! camera[2] += (camera[2] - center[2]) * 0.1;
! }
/**
--- 354,365 ----
*/
public void zoomout() {
! if (type == PERSPECTIVE) {
! camera[0] += (camera[0] - center[0]) * 0.1;
! camera[1] += (camera[1] - center[1]) * 0.1;
! camera[2] += (camera[2] - center[2]) * 0.1;
! } else {
! factor /= 2;
! }
! }
/**
***************
*** 642,645 ****
--- 680,699 ----
c.add(s);
currentCamera.zoomOn(c, 1.0);
+ }
+
+ /**
+ * Getter for the factor
+ * @return the factor
+ */
+ public double getFactor() {
+ return factor;
+ }
+
+ /**
+ * Setter for the factor
+ * @param factor the factor
+ */
+ public void setFactor(double factor) {
+ this.factor = factor;
}
}
|