Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15896/src/net/sourceforge/bprocessor/model
Modified Files:
Camera.java
Log Message:
implemented new way of correcting the minimal bounding sphere in viewEntireModel. Now works well at most angles
Index: Camera.java
===================================================================
RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Camera.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Camera.java 16 Jun 2006 09:45:17 -0000 1.17
--- Camera.java 7 Jul 2006 14:09:35 -0000 1.18
***************
*** 401,405 ****
Set allVertices = Project.getInstance().world().collect();
if (!allVertices.isEmpty()) {
! //Computing center and radius of the minimal covering sphere
Set notTested = new HashSet(allVertices);
double radius = 0;
--- 401,405 ----
Set allVertices = Project.getInstance().world().collect();
if (!allVertices.isEmpty()) {
! //Computing center and radius of the minimal bounding sphere
Set notTested = new HashSet(allVertices);
double radius = 0;
***************
*** 424,440 ****
modelCenter.scale(1.0 / 2.0);
modelCenter = modelCenter.add(p2);
!
! //Setting up camera
! double halfFocal;
! if (aspect < 1.0) {
! halfFocal = (this.getFocalwidth() * aspect) / 2.0;
! log.info("doing");
! } else {
! halfFocal = (this.getFocalwidth() / 2.0);
! }
double halfFocalVerTan = Math.tan(Math.toRadians(halfFocal));
! double halfFocalHorTan = halfFocalVerTan / aspect;
!
double width = Math.min(halfFocalHorTan, halfFocalVerTan);
double cameraDistance = radius / width;
--- 424,445 ----
modelCenter.scale(1.0 / 2.0);
modelCenter = modelCenter.add(p2);
! //expand sphere if needs
! it = allVertices.iterator();
! while (it.hasNext()) {
! Vertex v = (Vertex)it.next();
! Vertex dV = v.minus(modelCenter);
! double dist = dV.length();
! //if v is outside the sphere expand it to contain v.
! if (dist > radius) {
! radius = (dist + radius) / 2.0;
! dV.scale((dist - radius) / dist);
! modelCenter = modelCenter.add(dV);
! }
! }
+ //Setting up camera
+ double halfFocal = this.getFocalwidth() / 2.0;
double halfFocalVerTan = Math.tan(Math.toRadians(halfFocal));
! double halfFocalHorTan = halfFocalVerTan * aspect;
double width = Math.min(halfFocalHorTan, halfFocalVerTan);
double cameraDistance = radius / width;
|