/** * Render the arrow as a line and a _head. * * @param gl OpenGL Context */ public void render(GL2 gl) { // save Light Attributes and remove lighting to get "full" RGB colors // gl.glPushAttrib( GL2.GL_LIGHTING_BIT ); gl.glPushAttrib(GL2.GL_ENABLE_BIT); gl.glDisable(GL2.GL_LIGHTING); if (_fg_verb) { System.out.println( "Arrow pos=" + _pos.toString() + " angZ1=" + _angZ1 + " angY2=" + _angY2 + " length=" + _length); _fg_verb = false; } // save transformation matrix, then translate and scale. gl.glPushMatrix(); gl.glTranslatef(_pos.x, _pos.y, _pos.z); gl.glRotatef(Matrix.rad2Deg(_angZ1), 0, 0, 1); // rotation around 0z gl.glRotatef(Matrix.rad2Deg(_angY2), 0, 1, 0); // rotation around 0y // draw line gl.glColor4f(_color_fg.x, _color_fg.y, _color_fg.z, _color_fg.w); gl.glLineWidth(1.0f); gl.glBegin(GL.GL_LINES); { gl.glVertex3f(0, 0, 0); gl.glVertex3f(_length, 0, 0); } gl.glEnd(); // draw head gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL); gl.glTranslatef(_length, 0, 0); gl.glBegin(GL.GL_TRIANGLES); { for (float[] face : _head_faces) { gl.glVertex3f(face[0], face[1], face[2]); gl.glVertex3f(face[3], face[4], face[5]); gl.glVertex3f(face[6], face[7], face[8]); } } gl.glEnd(); // restore transformation matrix gl.glPopMatrix(); // restore attributes gl.glPopAttrib(); }
@Override public Image run(Image input, int imageType) { ImageData inData = input.getImageData(); // Die echten Bilddaten sind hier drin // RGB zu YUV Umwandlungsmatrix // double[] linear_conversion = { // 0.2126, 0.7152, 0.0722, // -0.09991, -0.33609, 0.436, // 0.615, -0.55861, -0.05639 // }; double[] linear_conversion = {0.299, 0.587, 0.114, -0.147, -0.289, 0.436, 0.615, -0.515, -0.1}; Matrix m = new Matrix(3, 3, linear_conversion); // YUV zu RGB Umwandlungmatrix (das Inverse) // double[] inv_linear_conversion = { // 1.0000, 0.0000, 1.28033, // 1.0000, -0.21482, -0.38059, // 1.0000, 2.12798, -0.0005 // }; double[] inv_linear_conversion = { 1.0000, 0.0000, 1.1398, 1.0000, -0.3946, -0.5805, 1.0000, 2.0320, -0.0005 }; Matrix minv = new Matrix(3, 3, inv_linear_conversion); for (int v = 0; v < inData.height; v++) { for (int u = 0; u < inData.width; u++) { int pixel = inData.getPixel(u, v); RGB rgb = inData.palette.getRGB(pixel); // Variante mit Farbwerte U und V von YUV auf 0 setzen Vector r = new Vector(rgb.red, rgb.green, rgb.blue); double[] y = m.times(r).getV(); y[2] = 0; y[1] = 0; r = minv.times(new Vector(y)); rgb.red = (int) r.x(1); rgb.green = (int) r.x(2); rgb.blue = (int) r.x(3); if (rgb.red < 0) rgb.red = 0; else if (rgb.red > 255) rgb.red = 255; if (rgb.green < 0) rgb.green = 0; else if (rgb.green > 255) rgb.green = 255; if (rgb.blue < 0) rgb.blue = 0; else if (rgb.blue > 255) rgb.blue = 255; // Variante mit der Sättigung auf 0 gesetzt (schlechter) // float[] hsb = inData.palette.getRGB(pixel).getHSB(); // // hsb[1] = 0; //Sättigung auf 0 setzen // // Color c = new Color(Color.HSBtoRGB(hsb[0],hsb[1],hsb[2])); // RGB rgb = new RGB(0,0,0); // rgb.red = c.getRed(); // rgb.green = c.getGreen(); // rgb.blue = c.getBlue(); inData.setPixel(u, v, inData.palette.getPixel(rgb)); } } return new Image(input.getDevice(), inData); }
/** Set Arrow to match given vector */ public void setup(Vector3f vec) { float ang[] = Matrix.angleFromVec(vec); _angZ1 = ang[0]; _angY2 = ang[1]; _length = vec.length(); }