/** paint the portal using gl. */ public void paint(GL gl, GLDrawable glc) { if (fill != null) { setColor(gl, fill); gl.glDisable(GL.GL_TEXTURE_2D); } gl.glLineWidth(lineWidth()); gl.glBegin(GL.GL_LINES); // draw each wall for (int i = 0; i < pts2d.size(); i++) { Point2D p = (Point2D) (pts2d.get(i)); gl.glVertex2d(p.x, p.y); } gl.glEnd(); if (pts2d.size() == 4) { /* Connect mid point of the two line segments with dotted line*/ gl.glLineStipple(1, (short) 0x0F0F); gl.glEnable(GL.GL_LINE_STIPPLE); gl.glLineWidth(1); gl.glBegin(GL.GL_LINES); Point2D mid = pts2d.get(0).interp(pts2d.get(1), 0.5); gl.glVertex2d(mid.x, mid.y); mid = pts2d.get(2).interp(pts2d.get(3), 0.5); gl.glVertex2d(mid.x, mid.y); gl.glEnd(); gl.glDisable(GL.GL_LINE_STIPPLE); } }
private void renderOneside(Point2D a, Point2D b, GL gl, double d) { gl.glClear(0); Vector3D t = new Vector3D(b.x - a.x, 0, b.y - a.y); Vector3D n = new Vector3D(0, 1, 0); Vector3D cross = n.cross(t); gl.glNormal3d(cross.x, cross.y, cross.z); // Texture adjustment vars double length = scale * Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) / 100 + 0.1; double height = scale; // draw the 4 points of it gl.glBegin(GL.GL_POLYGON); gl.glTexCoord2d(0, 0); gl.glVertex3d(a.x, d, a.y); gl.glTexCoord2d(0, height); gl.glVertex3d(a.x, d + 100, a.y); gl.glTexCoord2d(length, height); gl.glVertex3d(b.x, d + 100, b.y); gl.glTexCoord2d(length, 0); gl.glVertex3d(b.x, d, b.y); gl.glEnd(); }