Update of /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv23425/src/net/sourceforge/bprocessor/model
Modified Files:
Camera.java Persistence.java
Log Message:
made several smaller fixes to the scalefactor for cameras, including saving of it and visualization in attribute view... This alongside with better feedback when altering the current cam and copying cameras...
Index: Persistence.java
===================================================================
RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/Persistence.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -d -r1.31 -r1.32
*** Persistence.java 6 Jan 2007 21:06:59 -0000 1.31
--- Persistence.java 20 Jan 2007 21:24:44 -0000 1.32
***************
*** 137,140 ****
--- 137,141 ----
TripletType up = ct.getRoll();
cam.setRoll(new double[]{up.getX(), up.getY(), up.getZ()});
+ cam.setFactor(ct.getScalefactor());
Collection clips = ct.getClipplanes();
Iterator clipit = clips.iterator();
***************
*** 727,730 ****
--- 728,732 ----
up.setZ(c.getRoll()[2]);
cam.setRoll(up);
+ cam.setScalefactor((int)c.getFactor());
Collection clips = c.getClipplanes();
Iterator clipit = clips.iterator();
Index: Camera.java
===================================================================
RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/Camera.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** Camera.java 12 Jan 2007 17:52:32 -0000 1.34
--- Camera.java 20 Jan 2007 21:24:44 -0000 1.35
***************
*** 7,10 ****
--- 7,11 ----
package net.sourceforge.bprocessor.model;
+ import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Collection;
***************
*** 40,43 ****
--- 41,47 ----
public static final int PERSPECTIVE = 6;
+ /** The standard window height */
+ public static final int CONVETIONAL_WINDOW_HEIGHT = 600;
+
/** The logger */
private static Logger log = Logger.getLogger(Camera.class);
***************
*** 123,128 ****
this.setCamera(new double[]{other.camera[0], other.camera[1], other.camera[2]});
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();
--- 127,132 ----
this.setCamera(new double[]{other.camera[0], other.camera[1], other.camera[2]});
this.setRoll(new double[]{other.roll[0], other.roll[1], other.roll[2]});
this.factor = other.factor;
+ this.setType(other.getType());
this.setFocalwidth(other.getFocalwidth());
Iterator clips = other.getClipplanes().iterator();
***************
*** 327,330 ****
--- 331,335 ----
} else {
factor /= 2;
+ invertFactor();
}
}
***************
*** 340,343 ****
--- 345,349 ----
} else {
factor *= 2;
+ invertFactor();
}
}
***************
*** 545,548 ****
--- 551,556 ----
} else if (a.getName().equals("FOW")) {
setFocalwidth(((Double)a.getValue()).doubleValue());
+ } else if (a.getName().equals("Scale factor")) {
+ setFactor(((Double)a.getValue()).intValue());
} else {
log.error("Wrong attribute for the object " + a);
***************
*** 561,565 ****
a.setEditable(false);
res.add(a);
!
ArrayList<Attribute> cam = new ArrayList<Attribute>(3);
cam.add(new Attribute("X", new Double(getCamera()[0])));
--- 569,575 ----
a.setEditable(false);
res.add(a);
! if (this.type == ORTHOGRAPHIC) {
! res.add(new Attribute("Scale factor", getFactor()));
! }
ArrayList<Attribute> cam = new ArrayList<Attribute>(3);
cam.add(new Attribute("X", new Double(getCamera()[0])));
***************
*** 676,679 ****
public void setFactor(double factor) {
this.factor = factor;
! }
}
--- 686,727 ----
public void setFactor(double factor) {
this.factor = factor;
! }
!
!
! /**
! * Calculate the 1 : factor ralationship with reality
! * @return The to reality factor for the camera
! */
! public double calcFactor() {
! Camera current = this;
! 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;
! return tal / windowheight;
! }
!
! /**
! * Calc position for the camera based on the given to reality factor
! */
! public void invertFactor() {
! Camera current = this;
! 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();
! }
}
|