• Visualizing normals and tangents using GL_LINES?
    1 replies, posted
What would be the best way to display this: [IMG]http://www.fabiensanglard.net/bumpMapping/normalVis.jpg[/IMG] I tried looking on Google but It's not explained anywhere, here's my object.h if that can help [code]#ifndef OBJECT_H_ #define OBJECT_H_ #include "MaterialsLibrary.h" #include "Common.h" #include "Vertex.h" class Object { public: struct Polygon { short a; short b; short c; }; struct MapCoord { float u; float v; }; Object(); ~Object(); int vertices_qty; int polygons_qty; Material* material; map<int,Vertex> vertex; map<int,Vertex> normal; map<int,Vertex> tangent; map<int,Vertex> bitangent; map<int,Polygon> polygon; map<int,MapCoord> mapcoord; void load(); private: void generateNormalsAndTangents(); }; #endif[/code]
Surely you can just loop through the vertecies, specifying first the vertex itself, then the vertex's position + its normal (you may want to multiply the normal by a scalar first so the line isn't tiny) with GL_LINES as the drawing type. I'm no GL expert but something like [code] glBegin(GL_LINE); for(int i = 0; i < vertexContainerSize; i++) { Vertex endpoint = vert[i] + (5 * norm[i]); glVertex3f(vert[i].x, vert[i].y, vert[i].z); glVertex3f(endpoint[i].x, endpoint[i].y, endpoint[i].z); } glEnd(); [/code] You should easily be able to work out how to do tangents too. Surely it's as simple as that? [b]Edit:[/b] Just saw you've already sort of done it in waywo
Sorry, you need to Log In to post a reply to this thread.