Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view AbstractView.java,1.57,1.58 View.java,
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2005-11-17 18:14:08
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20173/src/net/sourceforge/bprocessor/gl/view Modified Files: AbstractView.java View.java View3D.java Log Message: - Changed initial camera position - Changed drawing of grid and coordinatesystem Index: AbstractView.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/AbstractView.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** AbstractView.java 17 Nov 2005 16:59:45 -0000 1.57 --- AbstractView.java 17 Nov 2005 18:14:00 -0000 1.58 *************** *** 243,247 **** AbstractView.aspect = AbstractView.width / AbstractView.height; ! gl.glClearColor(0.7f, 0.7f, 0.7f, 0.0f); gl.glViewport(0, 0, (int)width, (int)height); gl.glLineStipple(4, (short)0xAAAA); --- 243,247 ---- AbstractView.aspect = AbstractView.width / AbstractView.height; ! gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); gl.glViewport(0, 0, (int)width, (int)height); gl.glLineStipple(4, (short)0xAAAA); *************** *** 295,299 **** gl.glLineWidth(1.0f); grid(); ! gl.glLineWidth(2.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LESS); --- 295,299 ---- gl.glLineWidth(1.0f); grid(); ! gl.glLineWidth(1.0f); gl.glEnable(GL.GL_DEPTH_TEST); gl.glDepthFunc(GL.GL_LESS); *************** *** 620,623 **** --- 620,633 ---- } + /** + * Compare two doubles to see if they are close enough to + * be considered equal + * @param a A value + * @param b A value + * @return Do they compare? + */ + protected boolean cmp(double a, double b) { + return Math.abs(b - a) < 0.0000001; + } /** * Draw all the existing elements *************** *** 719,730 **** gl.glDisable(GL.GL_DEPTH_TEST); Vertex to = null; if (activeEdge != null) { to = activeEdge.getTo(); Vertex from = activeEdge.getFrom(); ! if (from.getY() == to.getY() && from.getZ() == to.getZ()) { gl.glColor3fv(X_AXIS_COLOR); ! } else if (from.getX() == to.getX() && from.getZ() == to.getZ()) { gl.glColor3fv(Y_AXIS_COLOR); ! } else if (from.getX() == to.getX() && from.getY() == to.getY()) { gl.glColor3fv(Z_AXIS_COLOR); } else { --- 729,741 ---- gl.glDisable(GL.GL_DEPTH_TEST); Vertex to = null; + if (activeEdge != null) { to = activeEdge.getTo(); Vertex from = activeEdge.getFrom(); ! if (cmp(from.getY(), to.getY()) && cmp(from.getZ(), to.getZ())) { gl.glColor3fv(X_AXIS_COLOR); ! } else if (cmp(from.getX(), to.getX()) && cmp(from.getZ(), to.getZ())) { gl.glColor3fv(Y_AXIS_COLOR); ! } else if (cmp(from.getX(), to.getX()) && cmp(from.getY(), to.getY())) { gl.glColor3fv(Z_AXIS_COLOR); } else { *************** *** 744,752 **** if (snapVertex != null && to != null) { boolean doDraw = true; ! if (snapVertex.getY() == to.getY() && snapVertex.getZ() == to.getZ()) { gl.glColor3fv(X_AXIS_COLOR); ! } else if (snapVertex.getX() == to.getX() && snapVertex.getZ() == to.getZ()) { gl.glColor3fv(Y_AXIS_COLOR); ! } else if (snapVertex.getX() == to.getX() && snapVertex.getY() == to.getY()) { gl.glColor3fv(Z_AXIS_COLOR); } else { --- 755,763 ---- if (snapVertex != null && to != null) { boolean doDraw = true; ! if (cmp(snapVertex.getY(), to.getY()) && cmp(snapVertex.getZ(), to.getZ())) { gl.glColor3fv(X_AXIS_COLOR); ! } else if (cmp(snapVertex.getX(), to.getX()) && cmp(snapVertex.getZ(), to.getZ())) { gl.glColor3fv(Y_AXIS_COLOR); ! } else if (cmp(snapVertex.getX(), to.getX()) && cmp(snapVertex.getY(), to.getY())) { gl.glColor3fv(Z_AXIS_COLOR); } else { Index: View3D.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View3D.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** View3D.java 17 Nov 2005 16:59:45 -0000 1.19 --- View3D.java 17 Nov 2005 18:14:00 -0000 1.20 *************** *** 40,46 **** super(glv); center = new double[]{.0, .0, .0}; ! camera = new double[]{25.0, 0.0, 0.0}; roll = new double[]{.0, .0, 1.0}; } /** --- 40,47 ---- super(glv); center = new double[]{.0, .0, .0}; ! camera = new double[]{16.0, -16, 9}; roll = new double[]{.0, .0, 1.0}; } + /** *************** *** 76,79 **** --- 77,81 ---- gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); + glu.gluLookAt(camera[0] * getZoomFactor(), camera[1] * getZoomFactor(), *************** *** 382,392 **** gl.glColor4fv(GRID_COLOR); gl.glBegin(GL.GL_LINES); for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x, -size, -0.01); ! gl.glVertex3d((double) x, size, -0.01); } for (int y = -(int)size; y <= (int)size; y++) { ! gl.glVertex3d(-size, (double) y, -0.01); ! gl.glVertex3d(size, (double) y, -0.01); } gl.glEnd(); --- 384,396 ---- gl.glColor4fv(GRID_COLOR); gl.glBegin(GL.GL_LINES); + size /= 2; + for (int x = -(int)size; x <= (int)size; x++) { ! gl.glVertex3d((double) x * 2, -size * 2, -0.01); ! gl.glVertex3d((double) x * 2, size * 2, -0.01); } for (int y = -(int)size; y <= (int)size; y++) { ! gl.glVertex3d(-size * 2, (double) y * 2, -0.01); ! gl.glVertex3d(size * 2, (double) y * 2, -0.01); } gl.glEnd(); *************** *** 397,410 **** */ protected void coords() { gl.glBegin(GL.GL_LINES); gl.glColor3fv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); ! gl.glVertex3d(10.0, 0.0, 0.0); gl.glColor3fv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); ! gl.glVertex3d(0.0, 10.0, 0.0); gl.glColor3fv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); ! gl.glVertex3d(0.0, 0.0, 10.0); gl.glEnd(); } --- 401,420 ---- */ protected void coords() { + double size = AbstractView.size; + if (aspect > 1) { + size *= aspect; + } else { + size /= aspect; + } gl.glBegin(GL.GL_LINES); gl.glColor3fv(X_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); ! gl.glVertex3d(size, 0.0, 0.0); gl.glColor3fv(Y_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); ! gl.glVertex3d(0.0, size, 0.0); gl.glColor3fv(Z_AXIS_COLOR); gl.glVertex3d(0.0, 0.0, 0.0); ! gl.glVertex3d(0.0, 0.0, size); gl.glEnd(); } Index: View.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/View.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** View.java 17 Nov 2005 16:59:45 -0000 1.20 --- View.java 17 Nov 2005 18:14:00 -0000 1.21 *************** *** 41,44 **** --- 41,47 ---- public static final float[] Z_AXIS_COLOR = new float[] {0.1f, 0.1f, 0.8f}; + /** the background color */ + public static final float[] BACKGROUND_COLOR = new float[] {1.0f, 1.0f, 1.0f}; + /** the std line color*/ public static final float[] STD_LINE_COLOR = new float[] {0.1f, 0.1f, 0.1f}; *************** *** 48,55 **** /** Used for the actual drawing line */ ! public static final float[] GRID_COLOR = new float[] {0.85f, 0.85f, 0.85f, 0.8f}; /** Surface color for all not selected surfaces */ ! public static final float[] SURFACE_COLOR = new float[] {0.93f, 0.93f, 0.93f}; /** Front color for surfaces */ --- 51,58 ---- /** Used for the actual drawing line */ ! public static final float[] GRID_COLOR = new float[] {0.80f, 0.80f, 0.80f, 0.8f}; /** Surface color for all not selected surfaces */ ! public static final float[] SURFACE_COLOR = new float[] {1.0f, 1.0f, 1.0f}; /** Front color for surfaces */ |