Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view View.java, 1.104, 1.105
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-07-13 13:35:05
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10787/src/net/sourceforge/bprocessor/gl/view Modified Files: View.java Log Message: Changed the initcamera method so that pers. and ortho cameras are placed and aligned equal, that is same visible area, fixed the inverting of the ortho camera as well. Implemented it so that as gluPerspective the FOW is in the height, so that extending the width will make the visible area bigger. Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** View.java 12 Jul 2006 14:35:11 -0000 1.104 --- View.java 13 Jul 2006 13:35:00 -0000 1.105 *************** *** 13,16 **** --- 13,17 ---- import net.sourceforge.bprocessor.model.ClippingPlane; + import net.sourceforge.bprocessor.model.Constructor; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Defaults; *************** *** 610,628 **** far = far < 20 ? far = 20 : far; double focalwidth = camera.getFocalwidth(); ! if (aspect < 1.0) { ! if (camera.getType() == Camera.ORTHOGRAPHIC) { ! double tal = Math.tan(focalwidth) * length; ! glu.gluOrtho2D(tal, -tal, tal, -tal); //TODO find the best pararms ! } else if (camera.getType() == Camera.PERSPECTIVE) { ! // fovy, aspect, near, far (relative to camera position) ! glu.gluPerspective(focalwidth, aspect, near, far); ! } ! } else { ! if (camera.getType() == Camera.ORTHOGRAPHIC) { ! double tal = Math.tan(focalwidth) * length; ! gl.glOrtho(tal, -tal, tal, -tal, near, far); ! } else if (camera.getType() == Camera.PERSPECTIVE) { ! glu.gluPerspective(focalwidth, aspect, near, far); ! } } --- 611,620 ---- far = far < 20 ? far = 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); } *************** *** 920,945 **** Collection cons = active.getConstructors(); Iterator iter = cons.iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof net.sourceforge.bprocessor.model.Point) { ! drawConstructorPoint(((net.sourceforge.bprocessor.model.Point)o).getOrigin()); } else if (o instanceof Line) { Line l = (Line)o; ! drawConstructorPoint(l.getOrigin()); ! drawConstructorVector(l.getOrigin(), l.getDirection()); } else if (o instanceof Plane) { Plane p = (Plane)o; ! drawConstructorPoint(p.getOrigin()); ! drawConstructorVector(p.getOrigin(), p.getI()); ! drawConstructorVector(p.getOrigin(), p.getJ()); } else if (o instanceof CoordinateSystem) { CoordinateSystem cs = (CoordinateSystem)o; ! drawConstructorPoint(cs.getOrigin()); Vertex i = cs.getI(); Vertex j = cs.getJ(); Vertex n = cs.getN(); ! drawConstructorVector(cs.getOrigin(), i); ! drawConstructorVector(cs.getOrigin(), j); ! drawConstructorVector(cs.getOrigin(), n); } } --- 912,945 ---- Collection cons = active.getConstructors(); Iterator iter = cons.iterator(); + Camera current = Project.getInstance().getCurrentCamera(); + Vertex v = new Vertex(current.getCamera()); + double scale = scale = current.getFocalwidth() / 65; + double dist = v.minus(new Vertex(current.getCenter())).length() * scale; while (iter.hasNext()) { Object o = iter.next(); + Constructor c = (Constructor)o; + if (current.getType() == Camera.PERSPECTIVE) { + dist = (c.getOrigin().minus(v)).length() * scale; + } if (o instanceof net.sourceforge.bprocessor.model.Point) { ! drawConstructorPoint(((net.sourceforge.bprocessor.model.Point)o).getOrigin(), dist); } else if (o instanceof Line) { Line l = (Line)o; ! drawConstructorPoint(l.getOrigin(), dist); ! drawConstructorVector(l.getOrigin(), l.getDirection(), dist); } else if (o instanceof Plane) { Plane p = (Plane)o; ! drawConstructorPoint(p.getOrigin(), dist); ! drawConstructorVector(p.getOrigin(), p.getI(), dist); ! drawConstructorVector(p.getOrigin(), p.getJ(), dist); } else if (o instanceof CoordinateSystem) { CoordinateSystem cs = (CoordinateSystem)o; ! drawConstructorPoint(cs.getOrigin(), dist); Vertex i = cs.getI(); Vertex j = cs.getJ(); Vertex n = cs.getN(); ! drawConstructorVector(cs.getOrigin(), i, dist); ! drawConstructorVector(cs.getOrigin(), j, dist); ! drawConstructorVector(cs.getOrigin(), n, dist); } } *************** *** 954,959 **** * Draw a point in the location of center * @param center The location for the point */ ! private void drawConstructorPoint(Vertex center) { gl.glPointSize(8); gl.glColor3fv(CONSTRUCTOR_COLOR); --- 954,960 ---- * Draw a point in the location of center * @param center The location for the point + * @param dist the distance from the cam */ ! private void drawConstructorPoint(Vertex center, double dist) { gl.glPointSize(8); gl.glColor3fv(CONSTRUCTOR_COLOR); *************** *** 967,989 **** * @param from the initial vertex * @param dir the direction vector */ ! private void drawConstructorVector(Vertex from, Vertex dir) { ! gl.glPointSize(8); ! gl.glColor3fv(CONSTRUCTOR_COLOR); ! gl.glBegin(GL.GL_POINTS); ! gl.glVertex3d(from.getX(), from.getY(), from.getZ()); ! gl.glEnd(); gl.glLineWidth(2); gl.glBegin(GL.GL_LINES); gl.glVertex3d(from.getX(), from.getY(), from.getZ()); ! gl.glVertex3d(dir.getX() + from.getX(), dir.getY() + from.getY(), dir.getZ() + from.getZ()); gl.glEnd(); GLUquadric quad = glu.gluNewQuadric(); gl.glPushMatrix(); ! gl.glTranslated(dir.getX() + from.getX(), dir.getY() + from.getY(), dir.getZ() + from.getZ()); gl.glRotated(Math.toDegrees(Geometry.degreesAboutZ(dir)), 0, 0, 1); gl.glRotated(-Math.toDegrees(Geometry.degreesAboutY(dir)), 0, 1, 0); gl.glRotated(90, 0, 1, 0); ! glu.gluCylinder(quad, 0.15, 0, 0.5, 10, 10); gl.glPopMatrix(); } --- 968,989 ---- * @param from the initial vertex * @param dir the direction vector + * @param dist the distance from the cam */ ! private void drawConstructorVector(Vertex from, Vertex dir, double dist) { gl.glLineWidth(2); + double scale = 500 / height; + dir.scale(scale * dist / 16); + Vertex to = from.add(dir); gl.glBegin(GL.GL_LINES); gl.glVertex3d(from.getX(), from.getY(), from.getZ()); ! gl.glVertex3d(to.getX(), to.getY(), to.getZ()); gl.glEnd(); GLUquadric quad = glu.gluNewQuadric(); gl.glPushMatrix(); ! gl.glTranslated(to.getX(), to.getY(), to.getZ()); gl.glRotated(Math.toDegrees(Geometry.degreesAboutZ(dir)), 0, 0, 1); gl.glRotated(-Math.toDegrees(Geometry.degreesAboutY(dir)), 0, 1, 0); gl.glRotated(90, 0, 1, 0); ! glu.gluCylinder(quad, (dist / 90) * scale, 0, (dist / 20) * scale, 10, 10); gl.glPopMatrix(); } |