Skip to content

Instantly share code, notes, and snippets.

@timothyhahn
Created May 9, 2013 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothyhahn/5550144 to your computer and use it in GitHub Desktop.
Save timothyhahn/5550144 to your computer and use it in GitHub Desktop.
faces == the "fs"
for(unsigned int i = 0; i < faces.size(); i += 3){
int index = faces[i];
vec4 vertex = vertices[index - 1];
vec4 a = vertex;
out_vertices.push_back(vertex);
index = faces[i + 1];
vertex = vertices[index - 1];
vec4 b = vertex;
out_vertices.push_back(vertex);
index = faces[i + 2];
vertex = vertices[index - 1];
vec4 c = vertex;
out_vertices.push_back(vertex);
vec3 norm = normalize(cross(b - a, c - b));
normals.push_back(norm);
normals.push_back(norm);
normals.push_back(norm);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment