protected void drawToolTip( DrawContext dc, java.awt.Rectangle viewport, String text, int x, int y, ToolTipAttributes attributes) { java.awt.geom.Rectangle2D textBounds = this.computeTextBounds(dc, text, attributes.getFont()); java.awt.geom.Rectangle2D bgBounds = this.computeBackgroundBounds( dc, textBounds.getWidth(), textBounds.getHeight(), attributes.getInsets()); java.awt.Point screenPoint = this.adjustDrawPointToViewport(x, y, bgBounds, viewport); java.awt.geom.Point2D textTranslation = this.computeTextTranslation(dc, textBounds, attributes.getInsets()); GL2 gl = dc.getGL(); OGLStackHandler stackHandler = new OGLStackHandler(); stackHandler.pushModelview(gl); try { gl.glTranslated( screenPoint.getX() + bgBounds.getX(), screenPoint.getY() + bgBounds.getY(), 0); this.drawToolTipInterior(dc, bgBounds.getWidth(), bgBounds.getHeight(), attributes); this.drawToolTipOutline(dc, bgBounds.getWidth(), bgBounds.getHeight(), attributes); gl.glTranslated(textTranslation.getX(), textTranslation.getY(), 0); this.drawToolTipText(dc, text, 0, 0, attributes); } finally { stackHandler.pop(gl); } }
void drawPart(Part part, double x, double y, double z, double r) { gl.glPushMatrix(); gl.glTranslated(x, y, z); // TODO gl.glTranslated(0, part.h - part.w / 2, 0); gl.glRotated(r, 1, 0, 0); gl.glTranslated(0, part.w / 2 - part.h, 0); drawCuboid(part); gl.glPopMatrix(); }
/** * Draw the object and all of its descendants recursively. * * <p>TODO: Complete this method * * @param gl */ public void draw(GL2 gl) { // don't draw if it is not showing if (!amShowing) { return; } // TODO: draw the object and all its children recursively // setting the model transform appropriately // Call drawSelf() to draw the object itself gl.glMatrixMode(GL2.GL_MODELVIEW); { gl.glPushMatrix(); { gl.glTranslated(myTranslation[0], myTranslation[1], 0); gl.glScaled(myScale, myScale, 1); gl.glRotated(myRotation, 0, 0, 1); drawSelf(gl); for (GameObject child : myChildren) { child.draw(gl); } } gl.glPopMatrix(); } }
@Override public void draw(GL2 gl, Object obj) { if (!(Force.class.isAssignableFrom(obj.getClass()))) return; Force force = (Force) obj; gl.glLineWidth(2.5f); gl.glColor3f(1.0f, 0f, 0f); gl.glBegin(GL.GL_LINES); gl.glVertex3d( force.getPointApplication().getX(), force.getPointApplication().getY(), force.getPointApplication().getZ()); Vector3D finalPoint = force.getPointApplication().add(force.getForce()); gl.glVertex3d(finalPoint.getX(), finalPoint.getY(), finalPoint.getZ()); gl.glEnd(); gl.glTranslated( force.getPointApplication().getX(), force.getPointApplication().getY(), force.getPointApplication().getZ()); gl.glColor3f(1.0f, 0.0f, 0.0f); GLU glu = new GLU(); GLUquadric q = glu.gluNewQuadric(); glu.gluQuadricDrawStyle(q, GLU.GLU_FILL); glu.gluSphere(q, Force.originRadius, 5, 5); glu.gluDeleteQuadric(q); }
// Where the printing happens private void glPrint(GL2 gl, int x, int y, int set, String fmt) { // If There's No Text if (fmt == null) { return; } // Did User Choose An Invalid Character Set? if (set > 1) { // If So, Select Set 1 (Italic) set = 1; } gl.glEnable(GL.GL_TEXTURE_2D); // Enable Texture Mapping gl.glLoadIdentity(); // Reset The Modelview Matrix gl.glTranslated(x, y, 0); // Position The Text (0,0 - Top Left) gl.glListBase(base - 32 + (128 * set)); // Choose The Font Set (0 or 1) gl.glScalef(1.0f, 2.0f, 1.0f); // Make The Text 2X Taller if (stringBuffer.capacity() < fmt.length()) { stringBuffer = GLBuffers.newDirectByteBuffer(fmt.length()); } stringBuffer.clear(); stringBuffer.put(fmt.getBytes()); stringBuffer.flip(); // Write the text to the screen gl.glCallLists(fmt.length(), GL.GL_UNSIGNED_BYTE, stringBuffer); gl.glDisable(GL.GL_TEXTURE_2D); // Disable Texture Mapping }
private void buildFont(GL2 gl) { // Build Our Font Display List base = gl.glGenLists(256); // Creating 256 Display Lists for (int loop1 = 0; loop1 < 256; loop1++) { // Loop Through All 256 // Lists float cx = (float) (loop1 % 16) / 16.0f; // X Position Of Current // Character float cy = (float) (loop1 / 16) / 16.0f; // Y Position Of Current // Character gl.glNewList(base + loop1, GL2.GL_COMPILE); // Start Building A List gl.glBegin(GL2.GL_QUADS); // Use A Quad For Each Character gl.glTexCoord2f(cx, 1.0f - cy - 0.0625f); // Texture Coord (Bottom // Left) gl.glVertex2d(0, 16); // Vertex Coord (Bottom Left) gl.glTexCoord2f(cx + 0.0625f, 1.0f - cy - 0.0625f); // Texture Coord // (Bottom // Right) gl.glVertex2i(16, 16); // Vertex Coord (Bottom Right) gl.glTexCoord2f(cx + 0.0625f, 1.0f - cy - 0.001f); // Texture Coord // (Top Right) gl.glVertex2i(16, 0); // Vertex Coord (Top Right) gl.glTexCoord2f(cx, 1.0f - cy - 0.001f); // Texture Coord (Top Left) gl.glVertex2i(0, 0); // Vertex Coord (Top Left) gl.glEnd(); // Done Building Our Quad (Character) gl.glTranslated(14, 0, 0); // Move To The Right Of The Character gl.glEndList(); // Done Building The Display List } // Loop Until All 256 Are Built }
public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE, color, 0); gl.glRotated(rotateX.getValue(), 1, 0, 0); gl.glRotated(rotateY.getValue(), 0, 1, 0); gl.glRotated(rotateZ.getValue(), 0, 0, 1); gl.glPushMatrix(); gl.glTranslated(translateX.getValue(), translateY.getValue(), translateZ.getValue()); gl.glPushMatrix(); gl.glRotated(90, 1, 0, 0); gl.glTranslated(0, 0, -height / 2); glut.glutSolidCylinder(radius, height, 32, 2); gl.glPopMatrix(); super.display(drawable); gl.glPopMatrix(); }
public void render(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glPushMatrix(); gl.glTranslated( body.getPosition().get0(), body.getPosition().get1(), body.getPosition().get2()); GLUquadric bulletGeom = glu.gluNewQuadric(); glu.gluQuadricDrawStyle(bulletGeom, GLU.GLU_FILL); glu.gluQuadricNormals(bulletGeom, GLU.GLU_SMOOTH); glu.gluDisk(bulletGeom, 0.3, 0.4, 5, 5); gl.glPopMatrix(); }
@Override public void draw(int depth) { // only render the sphere if this node is at the given depth if (((depth < 0) && (Math.abs(depth) >= this.depth)) || depth == this.depth) { GL2 gl = GLContext.getCurrent().getGL().getGL2(); gl.glPushMatrix(); gl.glTranslated(center.x, center.y, center.z); JDraw3D.jDrawSphere(radius, 10, 10); gl.glPopMatrix(); } }
protected void applyBackground( DrawContext dc, WWIcon icon, Vec4 screenPoint, double width, double height, double pedestalSpacing, double pedestalScale) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. double backgroundScale; backgroundScale = icon.getBackgroundScale(); if (icon.getBackgroundTexture() != null) { if (icon.getBackgroundTexture().bind(dc)) { TextureCoords texCoords = icon.getBackgroundTexture().getTexCoords(); gl.glPushMatrix(); gl.glLoadIdentity(); double bgwidth = backgroundScale * width; double bgheight = backgroundScale * height; // Offset the background for the highlighted scale. // if (icon.isHighlighted()) // { // gl.glTranslated(0d, height * (icon.getHighlightScale() - 1) / 2, 0d); // } // Offset the background for the pedestal height. gl.glTranslated(0d, (pedestalScale * height) + pedestalSpacing, 0d); // Place the background centered behind the icon. gl.glTranslated(screenPoint.x - bgwidth / 2, screenPoint.y - (bgheight - height) / 2, 0d); // Scale to the background image dimension. gl.glScaled(bgwidth, bgheight, 1d); dc.drawUnitQuad(texCoords); gl.glPopMatrix(); } } }
public void draw(GL2 gl, GLU glu) { gl.glColor3f(1f, 0f, .25f); // Lamp Stem, cylindrical, a little smaller at the top. gl.glPushMatrix(); gl.glRotatef(-90f, 1f, 0f, 0f); // stand upright (Y) glu.gluCylinder(quadric, 1., 1, 3., 10, 1); gl.glPopMatrix(); // Table Top gl.glPushMatrix(); gl.glTranslated(0, 3, 0); gl.glRotatef(-90f, 100f, 0f, 0f); // stand upright (Y) glu.gluDisk(quadric, 0, 4., 15, 5); // also to be flipped gl.glPopMatrix(); }
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // to position the camera. gl.glTranslated(0, 0, -1); // Forgetting to clear the depth buffer can cause problems // such as empty black screens. gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); float matAmbAndDifR[] = {0.9f, 0.0f, 0.0f, 0.75f}; float matAmbAndDifG[] = {0.0f, 0.5f, 0.0f, 1.0f}; gl.glBegin(GL2.GL_TRIANGLES); { // One in drawn first and in front has alpha // gl.glColor4f(1f,0f,0f,1f); // CCW ordering of vertices double p0[] = {1, 0, -1}; double p1[] = {0, 1, -1}; double p2[] = {-1, 0, -1}; gl.glMaterialfv(GL2.GL_FRONT, GL2.GL_AMBIENT_AND_DIFFUSE, matAmbAndDifG, 0); // gl.glColor4f(0,1,0,1f); gl.glVertex3d(2, 0, -2); gl.glVertex3d(1, 1, -2); gl.glVertex3d(0, 0, -2); gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT_AND_DIFFUSE, matAmbAndDifR, 0); gl.glVertex3dv(p0, 0); gl.glVertex3dv(p1, 0); gl.glVertex3dv(p2, 0); } gl.glEnd(); gl.glPolygonMode(GL2.GL_FRONT_AND_BACK, GL2.GL_FILL); }
@Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); // Move camera back a little gl.glTranslated(0, 0, -1); // Forgetting to clear the depth buffer can cause problems // such as empty black screens. gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); gl.glBegin(GL2.GL_TRIANGLES); { // Need to draw transparent one last gl.glColor4f(1f, 0f, 0f, 0.75f); // try with 0.25 // CCW ordering of vertices double p0[] = {1, 0, -1}; double p1[] = {0, 1, -1}; double p2[] = {-1, 0, -1}; // Can pass in an array and an offset into the array gl.glVertex3dv(p0, 0); gl.glVertex3dv(p1, 0); gl.glVertex3dv(p2, 0); // Opaque one (at back) must be drawn before // transparent one in front gl.glColor4f(0, 1, 0, 1f); gl.glVertex3d(2, 0, -2); gl.glVertex3d(1, 1, -2); gl.glVertex3d(0, 0, -2); } gl.glEnd(); }
/** * Draws this robot on the screen. * * @param gl The instance of GL2 responsible for drawing the robot on the screen. * @param glut An instance of GLUT to optionally aid in drawing the robot body. * @param stickFigure If true, the robot must draw itself as a stick figure rather than a solid * body. * @param tAnim Time since the start of the animation in seconds. * @param lighting The Lighting instance responsible for calculating the lighting in this scene. * Can be used to set the color of bodies before drawing them. */ public void draw(GL2 gl, GLUT glut, boolean stickFigure, float tAnim, Lighting lighting) { lighting.setMaterial(gl, getMaterial()); gl.glPushMatrix(); { gl.glTranslated(position.x(), position.y(), position.z()); final double rotationDotY = direction.dot(Vector.Y) / (direction.length() * Vector.Y.length()); final double rotationDotX = direction.dot(Vector.X) / (direction.length() * Vector.X.length()); final double rotationAngle = Math.toDegrees(Math.acos(rotationDotY)); gl.glRotated( (rotationDotX > 0d) ? (-rotationAngle) : (rotationAngle), Vector.Z.x(), Vector.Z.y(), Vector.Z.z()); final double elevationDot = direction.dot(Vector.Z) / (direction.length() * Vector.Z.length()); final double elevationAngle = Math.toDegrees(Math.asin(elevationDot)); gl.glRotated(elevationAngle, Vector.X.x(), Vector.X.y(), Vector.X.z()); robotBody.draw(gl, glut, stickFigure, tAnim); } gl.glPopMatrix(); }
public void render(GL2 gl2) { int i; boolean draw_finger_star = false; boolean draw_base_star = false; boolean draw_shoulder_to_elbow = false; boolean draw_shoulder_star = false; boolean draw_elbow_star = false; boolean draw_wrist_star = false; boolean draw_stl = true; // RebuildShoulders(motion_now); gl2.glPushMatrix(); gl2.glTranslated(position.x, position.y, position.z); if (draw_stl) { // base gl2.glPushMatrix(); gl2.glColor3f(0, 0, 1); gl2.glTranslatef(0, 0, BASE_TO_SHOULDER_Z + 0.6f); gl2.glRotatef(90, 0, 0, 1); gl2.glRotatef(90, 1, 0, 0); modelBase.render(gl2); gl2.glPopMatrix(); // arms for (i = 0; i < 3; ++i) { gl2.glColor3f(1, 0, 1); gl2.glPushMatrix(); gl2.glTranslatef( motion_now.arms[i * 2 + 0].shoulder.x, motion_now.arms[i * 2 + 0].shoulder.y, motion_now.arms[i * 2 + 0].shoulder.z); gl2.glRotatef(120.0f * i, 0, 0, 1); gl2.glRotatef(90, 0, 1, 0); gl2.glRotatef(180 - motion_now.arms[i * 2 + 0].angle, 0, 0, 1); modelArm.render(gl2); gl2.glPopMatrix(); gl2.glColor3f(1, 1, 0); gl2.glPushMatrix(); gl2.glTranslatef( motion_now.arms[i * 2 + 1].shoulder.x, motion_now.arms[i * 2 + 1].shoulder.y, motion_now.arms[i * 2 + 1].shoulder.z); gl2.glRotatef(120.0f * i, 0, 0, 1); gl2.glRotatef(90, 0, 1, 0); gl2.glRotatef(+motion_now.arms[i * 2 + 1].angle, 0, 0, 1); modelArm.render(gl2); gl2.glPopMatrix(); } // top gl2.glPushMatrix(); gl2.glColor3f(0, 1, 0); gl2.glTranslatef(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z); gl2.glRotatef(motion_now.iku, 1, 0, 0); gl2.glRotatef(motion_now.ikv, 0, 1, 0); gl2.glRotatef(motion_now.ikw, 0, 0, 1); gl2.glRotatef(90, 0, 0, 1); gl2.glRotatef(180, 1, 0, 0); modelTop.render(gl2); gl2.glPopMatrix(); } // draw the forearms Cylinder tube = new Cylinder(); gl2.glColor3f(0.8f, 0.8f, 0.8f); tube.setRadius(0.15f); for (i = 0; i < 6; ++i) { // gl2.glBegin(GL2.GL_LINES); // gl2.glColor3f(1,0,0); // gl2.glVertex3f(motion_now.arms[i].wrist.x,motion_now.arms[i].wrist.y,motion_now.arms[i].wrist.z); // gl2.glColor3f(0,1,0); // gl2.glVertex3f(motion_now.arms[i].elbow.x,motion_now.arms[i].elbow.y,motion_now.arms[i].elbow.z); // gl2.glEnd(); tube.SetP1(motion_now.arms[i].wrist); tube.SetP2(motion_now.arms[i].elbow); PrimitiveSolids.drawCylinder(gl2, tube); } gl2.glDisable(GL2.GL_LIGHTING); // debug info gl2.glPushMatrix(); for (i = 0; i < 6; ++i) { gl2.glColor3f(1, 1, 1); if (draw_shoulder_star) PrimitiveSolids.drawStar(gl2, motion_now.arms[i].shoulder, 5); if (draw_elbow_star) PrimitiveSolids.drawStar(gl2, motion_now.arms[i].elbow, 3); if (draw_wrist_star) PrimitiveSolids.drawStar(gl2, motion_now.arms[i].wrist, 1); if (draw_shoulder_to_elbow) { gl2.glBegin(GL2.GL_LINES); gl2.glColor3f(0, 1, 0); gl2.glVertex3f( motion_now.arms[i].elbow.x, motion_now.arms[i].elbow.y, motion_now.arms[i].elbow.z); gl2.glColor3f(0, 0, 1); gl2.glVertex3f( motion_now.arms[i].shoulder.x, motion_now.arms[i].shoulder.y, motion_now.arms[i].shoulder.z); gl2.glEnd(); } } gl2.glPopMatrix(); if (draw_finger_star) { // draw finger orientation float s = 2; gl2.glBegin(GL2.GL_LINES); gl2.glColor3f(1, 1, 1); gl2.glVertex3f(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z); gl2.glVertex3f( motion_now.finger_tip.x + motion_now.finger_forward.x * s, motion_now.finger_tip.y + motion_now.finger_forward.y * s, motion_now.finger_tip.z + motion_now.finger_forward.z * s); gl2.glVertex3f(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z); gl2.glVertex3f( motion_now.finger_tip.x + motion_now.finger_up.x * s, motion_now.finger_tip.y + motion_now.finger_up.y * s, motion_now.finger_tip.z + motion_now.finger_up.z * s); gl2.glVertex3f(motion_now.finger_tip.x, motion_now.finger_tip.y, motion_now.finger_tip.z); gl2.glVertex3f( motion_now.finger_tip.x + motion_now.finger_left.x * s, motion_now.finger_tip.y + motion_now.finger_left.y * s, motion_now.finger_tip.z + motion_now.finger_left.z * s); gl2.glEnd(); } if (draw_base_star) { // draw finger orientation float s = 2; gl2.glDisable(GL2.GL_DEPTH_TEST); gl2.glBegin(GL2.GL_LINES); gl2.glColor3f(1, 0, 0); gl2.glVertex3f(motion_now.base.x, motion_now.base.y, motion_now.base.z); gl2.glVertex3f( motion_now.base.x + motion_now.base_forward.x * s, motion_now.base.y + motion_now.base_forward.y * s, motion_now.base.z + motion_now.base_forward.z * s); gl2.glColor3f(0, 1, 0); gl2.glVertex3f(motion_now.base.x, motion_now.base.y, motion_now.base.z); gl2.glVertex3f( motion_now.base.x + motion_now.base_up.x * s, motion_now.base.y + motion_now.base_up.y * s, motion_now.base.z + motion_now.base_up.z * s); gl2.glColor3f(0, 0, 1); gl2.glVertex3f(motion_now.base.x, motion_now.base.y, motion_now.base.z); gl2.glVertex3f( motion_now.base.x + motion_now.finger_left.x * s, motion_now.base.y + motion_now.finger_left.y * s, motion_now.base.z + motion_now.finger_left.z * s); gl2.glEnd(); gl2.glEnable(GL2.GL_DEPTH_TEST); } gl2.glEnable(GL2.GL_LIGHTING); gl2.glPopMatrix(); }
public void draw(GL2 gl, Camera camera, Perspective3D perspective3d) { Photo photo = this.photo; gl.glDisable(GL2.GL_DEPTH_TEST); gl.glColor4f( (float) 255 / 255, (float) 255 / 255, (float) 255 / 255, (float) photo.getTransparent()); // Enable Alpha Blending (disable alpha testing) gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA); gl.glEnable(GL2.GL_BLEND); gl.glDisable(GL2.GL_LIGHTING); gl.glEnable(GL2.GL_TEXTURE_2D); // XXX String textureName = photo.getPath(); TextureCoords tc = new TextureCoords(0, 0, 1, 1); if (textureName != null) { Texture texture = this.textureCacheService.getTexture(gl, textureName); // // switch to texture mode and push a new matrix on the stack // gl.glMatrixMode(GL2.GL_TEXTURE); // gl.glPushMatrix(); // // // check to see if the texture needs flipping // if (texture.getMustFlipVertically()) { // gl.glScaled(1, -1, 1); // gl.glTranslated(0, -1, 0); // } // // // switch to modelview matrix and push a new matrix on the stack // gl.glMatrixMode(GL2.GL_MODELVIEW); // gl.glPushMatrix(); // // // This is required to repeat textures // gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT); // gl.glTexParameteri(GL2.GL_TEXTURE_2D, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT); // enable, bind texture.enable(gl); texture.bind(gl); tc = texture.getImageTexCoords(); } gl.glBegin(GL2.GL_POLYGON); // gl.glColor3f((float)123/256, (float)111/256, (float)100/255); // gl.glColor3f((float) 255/255, (float)255/255, (float)255/255); LatLon ll = new LatLon(photo.getLat(), photo.getLon()); Projection proj = Main.getProjection(); EastNorth eastNorth = proj.latlon2eastNorth(ll); double x = perspective3d.calcX(eastNorth.east()); double y = photo.getHeight(); double z = -perspective3d.calcY(eastNorth.north()); Vector3d angle = photo.getRotate(); double distance = 500d; double width = distance * Math.sin(photo.getAngleWitht() / 2d); double height = distance * Math.sin(photo.getAngleHeigth() / 2d); Vector3d p1 = new Vector3d(distance, -height, -width); Vector3d p2 = new Vector3d(distance, -height, width); Vector3d p3 = new Vector3d(distance, height, width); Vector3d p4 = new Vector3d(distance, height, -width); p1 = transform(angle, p1); p2 = transform(angle, p2); p3 = transform(angle, p3); p4 = transform(angle, p4); Point3d c = camera.getPoint(); // gl.glColor4f((float) 255/255, (float)255/255, (float)255/255, (float) 128/255); gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_BLEND); gl.glTexCoord2d(tc.left(), tc.bottom()); gl.glVertex3d(p1.x + x, p1.y + y, p1.z + z); gl.glTexCoord2d(tc.right(), tc.bottom()); gl.glVertex3d(p2.x + x, p2.y + y, p2.z + z); gl.glTexCoord2d(tc.right(), tc.top()); gl.glVertex3d(p3.x + x, p3.y + y, p3.z + z); gl.glTexCoord2d(tc.left(), tc.top()); gl.glVertex3d(p4.x + x, p4.y + y, p4.z + z); gl.glEnd(); gl.glColor3f((float) 0 / 255, (float) 0 / 255, (float) 255 / 255); gl.glPushMatrix(); gl.glTranslated(x, 0.1, z); gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_MODULATE); DrawUtil.drawDotY(gl, 0.5, 12); gl.glPopMatrix(); if (textureName != null) { Texture texture = this.textureCacheService.getTexture(gl, textureName); Texture t = this.textureCacheService.getTexture(gl, textureName); // this.textures.get(mesh.materialID);// .get(mesh.materialID); if (t != null) { t.disable(gl); } gl.glMatrixMode(GL2.GL_TEXTURE); gl.glPopMatrix(); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glPopMatrix(); } gl.glDisable(GL2.GL_TEXTURE_2D); gl.glColor4f((float) 255 / 255, (float) 255 / 255, (float) 255 / 255, (float) 255 / 255); gl.glDisable(GL2.GL_BLEND); gl.glEnable(GL2.GL_DEPTH_TEST); }
protected Vec4 drawIcon(DrawContext dc, OrderedIcon uIcon) { if (uIcon.point == null) { String msg = Logging.getMessage("nullValue.PointIsNull"); Logging.logger().severe(msg); // Record feedback data for this WWIcon if feedback is enabled. if (uIcon.icon != null) this.recordFeedback(dc, uIcon.icon, null, null); return null; } WWIcon icon = uIcon.icon; if (dc.getView().getFrustumInModelCoordinates().getNear().distanceTo(uIcon.point) < 0) { // Record feedback data for this WWIcon if feedback is enabled. this.recordFeedback(dc, icon, uIcon.point, null); return null; } final Vec4 screenPoint = dc.getView().project(uIcon.point); if (screenPoint == null) { // Record feedback data for this WWIcon if feedback is enabled. this.recordFeedback(dc, icon, uIcon.point, null); return null; } double pedestalScale; double pedestalSpacing; if (this.pedestal != null) { pedestalScale = this.pedestal.getScale(); pedestalSpacing = pedestal.getSpacingPixels(); } else { pedestalScale = 0d; pedestalSpacing = 0d; } GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. this.setDepthFunc(dc, uIcon, screenPoint); gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); Dimension size = icon.getSize(); double width = size != null ? size.getWidth() : icon.getImageTexture().getWidth(dc); double height = size != null ? size.getHeight() : icon.getImageTexture().getHeight(dc); gl.glTranslated( screenPoint.x - width / 2, screenPoint.y + (pedestalScale * height) + pedestalSpacing, 0d); if (icon.isHighlighted()) { double heightDelta = this.pedestal != null ? 0 : height / 2; // expand only above the pedestal gl.glTranslated(width / 2, heightDelta, 0); gl.glScaled(icon.getHighlightScale(), icon.getHighlightScale(), icon.getHighlightScale()); gl.glTranslated(-width / 2, -heightDelta, 0); } Rectangle rect = new Rectangle( (int) (screenPoint.x - width / 2), (int) (screenPoint.y), (int) width, (int) (height + (pedestalScale * height) + pedestalSpacing)); if (dc.isPickingMode()) { // If in picking mode and pick clipping is enabled, check to see if the icon is within the // pick volume. if (this.isPickFrustumClippingEnabled() && !dc.getPickFrustums().intersectsAny(rect)) { // Record feedback data for this WWIcon if feedback is enabled. this.recordFeedback(dc, icon, uIcon.point, rect); return screenPoint; } else { java.awt.Color color = dc.getUniquePickColor(); int colorCode = color.getRGB(); this.pickSupport.addPickableObject(colorCode, icon, uIcon.getPosition(), false); gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); } } if (icon.getBackgroundTexture() != null) this.applyBackground(dc, icon, screenPoint, width, height, pedestalSpacing, pedestalScale); if (icon.getImageTexture().bind(dc)) { TextureCoords texCoords = icon.getImageTexture().getTexCoords(); gl.glScaled(width, height, 1d); dc.drawUnitQuad(texCoords); } if (this.pedestal != null && this.pedestal.getImageTexture() != null) { gl.glLoadIdentity(); gl.glTranslated(screenPoint.x - (pedestalScale * (width / 2)), screenPoint.y, 0d); gl.glScaled(width * pedestalScale, height * pedestalScale, 1d); if (this.pedestal.getImageTexture().bind(dc)) { TextureCoords texCoords = this.pedestal.getImageTexture().getTexCoords(); dc.drawUnitQuad(texCoords); } } // Record feedback data for this WWIcon if feedback is enabled. this.recordFeedback(dc, icon, uIcon.point, rect); return screenPoint; }