LineFieldRenderer::LineFieldRenderer(const Manifold& m, bool smooth, VertexAttributeVector<Vec3d>& lines, float _r): SimpleShaderRenderer(vss,fss), r(_r) { float noise_scale = 10.0f/r; float line_scale = 0.003f; GLint old_prog; glGetIntegerv(GL_CURRENT_PROGRAM, &old_prog); glUseProgram(prog); glUniform1fARB(glGetUniformLocationARB(prog, "scale_line"),line_scale*noise_scale); glUniform1fARB(glGetUniformLocationARB(prog, "noise_scale"),noise_scale); glUniform1iARB(glGetUniformLocationARB(prog, "noise_tex"),0); GLuint direction = glGetAttribLocation(prog, "direction"); glNewList(display_list,GL_COMPILE); for(FaceIDIterator f = m.faces_begin(); f != m.faces_end(); ++f) { if(!smooth) glNormal3dv(normal(m, *f).get()); if(no_edges(m, *f) == 3) glBegin(GL_TRIANGLES); else glBegin(GL_POLYGON); for(Walker w = m.walker(*f); !w.full_circle(); w = w.circulate_face_ccw()) { Vec3d n(normal(m, w.vertex())); if(smooth) glNormal3dv(n.get()); Vec3d d = lines[w.vertex()]; d = normalize(d-n*dot(n,d)); glVertexAttrib3dv(direction, d.get()); glVertex3dv(m.pos(w.vertex()).get()); } glEnd(); } glBindTexture(GL_TEXTURE_3D, 0); glEndList(); glUseProgram(old_prog); }