Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform mat4 m;
- uniform mat4 v;
- uniform mat4 p;
- attribute vec3 pos;
- attribute vec2 normale;
- void main()
- {
- float linewidth = 4.0;
- mat4 mv = v * m;
- vec4 delta = vec4(linewidth * normale.x, linewidth * normale.y, 0.0,0.0);
- vec4 pos2 = mv * vec4(pos.xy, 0.0, 1.0) ;
- gl_Position = p * (pos2 + delta);
- }
- for (int i = 0, valuesLength = values.length; i < valuesLength; i++) {//todo do not allocate
- float value = (float) values[i] / maxValue; // make it [0:1]
- Vertex v1 = new Vertex();//todo rewrite without allocatinos
- Vertex v2 = new Vertex();//todo rewrite without allocatinos
- float x = i;
- float y = value;
- if (vertices.size() > 0) {
- // copy normale vecotrs from prev vertices
- Vertex t1 = new Vertex();
- Vertex t2 = new Vertex();
- t1.x = x;
- t1.y = y;
- t1.z = 1;
- t1.normale_x = vertices.get(vertices.size() - 2).normale_x;
- t1.normale_y = vertices.get(vertices.size() - 2).normale_y;
- t2.x = x;
- t2.y = y;
- t2.z = -1;
- t2.normale_x = vertices.get(vertices.size() - 1).normale_x;
- t2.normale_y = vertices.get(vertices.size() - 1).normale_y;
- vertices.add(t1);
- vertices.add(t2);
- }
- v1.x = x ;
- v1.y = y ;
- v1.z = 1;
- v2.x = x;
- v2.y = y;
- v2.z = -1;
- vertices.add(v1);
- vertices.add(v2);
- if (i == valuesLength - 1) {
- int j = i - 1;
- //todo last vertex
- } else {
- double nextValue = (float) values[i + 1] / column.maxValue;
- double dy = nextValue - value;
- double l = (float) Math.sqrt(1f + dy * dy);
- dy /= l;
- double dx = 1f / l;
- v1.normale_x = (float) -dy * 10;
- v1.normale_y = (float) dx;
- v2.normale_x = (float) dy * 10;
- v2.normale_y = (float) -dx;
- }
- }
- Matrix.orthoM(PROJ, 0, 0, w, 0, h, -1.0f, 1.0f);
- Matrix.setIdentityM(MODEL, 0);
- Matrix.scaleM(MODEL, 0, mywpx/(float)maxXValue, myhpx , 1.0f);
- Matrix.setIdentityM(VIEW, 0);
- Matrix.translateM(VIEW, 0, dxpx, dypx ,0);
- GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, vertices.size());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement