Last active
August 29, 2015 14:08
-
-
Save larsberg/ab03dfc1498c9b514ba3 to your computer and use it in GitHub Desktop.
Revisions
-
larsberg revised this gist
Nov 5, 2014 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ static void makeScreenQuad(ofMesh& m, float w=2, float h=2) m.addIndex(3); } static void makeBoxMesh(ofMesh& m, float w, float h, float d) { w *= .5, h *= .5, d *= .5; @@ -40,7 +40,7 @@ static void makeBoxMesh(ofMesh& m, float w=1, float h=1, float d=1) m.addVertex(ofVec3f( w, h,-d)); m.addVertex(ofVec3f( w,-h,-d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,0,-1))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); @@ -52,7 +52,7 @@ static void makeBoxMesh(ofMesh& m, float w=1, float h=1, float d=1) m.addVertex(ofVec3f(-w, h,-d)); m.addVertex(ofVec3f(-w,-h,-d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(-1,0,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); @@ -64,7 +64,7 @@ static void makeBoxMesh(ofMesh& m, float w=1, float h=1, float d=1) m.addVertex(ofVec3f(-w, h, d)); m.addVertex(ofVec3f(-w,-h, d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,0,1))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); @@ -76,7 +76,7 @@ static void makeBoxMesh(ofMesh& m, float w=1, float h=1, float d=1) m.addVertex(ofVec3f( w, h, d)); m.addVertex(ofVec3f( w,-h, d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(1,0,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); @@ -89,7 +89,7 @@ static void makeBoxMesh(ofMesh& m, float w=1, float h=1, float d=1) m.addVertex(ofVec3f(-w,-h, d)); m.addVertex(ofVec3f(-w,-h,-d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,-1,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); -
larsberg revised this gist
Nov 5, 2014 . 2 changed files with 108 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,108 @@ static void makeScreenQuad(ofMesh& m, float w=2, float h=2) { w *= .5; h *= .5; m.clear(); m.addVertex(ofVec3f(-w,-h,0)); m.addVertex(ofVec3f( w,-h,0)); m.addVertex(ofVec3f( w, h,0)); m.addVertex(ofVec3f(-w, h,0)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,0,-1))); m.addTexCoord(ofVec2f(0,1)); m.addTexCoord(ofVec2f(1,1)); m.addTexCoord(ofVec2f(1,0)); m.addTexCoord(ofVec2f(0,0)); m.addIndex(0); m.addIndex(1); m.addIndex(2); m.addIndex(0); m.addIndex(2); m.addIndex(3); } static void makeBoxMesh(ofMesh& m, float w=1, float h=1, float d=1) { w *= .5, h *= .5, d *= .5; m.clear(); int i0, i1, i2, i3; // back i0 = m.getVertices().size(), i1 = i0+1, i2 = i1+1, i3 = i2+1; m.addVertex(ofVec3f(-w,-h,-d)); m.addVertex(ofVec3f(-w, h,-d)); m.addVertex(ofVec3f( w, h,-d)); m.addVertex(ofVec3f( w,-h,-d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,1,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); // left i0 = m.getVertices().size(), i1 = i0+1, i2 = i1+1, i3 = i2+1; m.addVertex(ofVec3f(-w,-h, d)); m.addVertex(ofVec3f(-w, h, d)); m.addVertex(ofVec3f(-w, h,-d)); m.addVertex(ofVec3f(-w,-h,-d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,1,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); // front i0 = m.getVertices().size(), i1 = i0+1, i2 = i1+1, i3 = i2+1; m.addVertex(ofVec3f( w,-h, d)); m.addVertex(ofVec3f( w, h, d)); m.addVertex(ofVec3f(-w, h, d)); m.addVertex(ofVec3f(-w,-h, d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,1,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); // right i0 = m.getVertices().size(), i1 = i0+1, i2 = i1+1, i3 = i2+1; m.addVertex(ofVec3f( w,-h,-d)); m.addVertex(ofVec3f( w, h,-d)); m.addVertex(ofVec3f( w, h, d)); m.addVertex(ofVec3f( w,-h, d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,1,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); // top i0 = m.getVertices().size(), i1 = i0+1, i2 = i1+1, i3 = i2+1; m.addVertex(ofVec3f( w,-h,-d)); m.addVertex(ofVec3f( w,-h, d)); m.addVertex(ofVec3f(-w,-h, d)); m.addVertex(ofVec3f(-w,-h,-d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,1,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); // bottom i0 = m.getVertices().size(), i1 = i0+1, i2 = i1+1, i3 = i2+1; m.addVertex(ofVec3f( w, h, d)); m.addVertex(ofVec3f( w, h,-d)); m.addVertex(ofVec3f(-w, h,-d)); m.addVertex(ofVec3f(-w, h, d)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,1,0))); m.addTexCoord(ofVec2f(0,0)), m.addTexCoord(ofVec2f(0,1)), m.addTexCoord(ofVec2f(1,1)), m.addTexCoord(ofVec2f(1,0)); m.addIndex(i0), m.addIndex(i1), m.addIndex(i2), m.addIndex(i0), m.addIndex(i2), m.addIndex(i3); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,25 +0,0 @@ -
larsberg created this gist
Nov 5, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ static void createScreenQuad(ofMesh& m, float w=2, float h=2) { w *= .5; h *= .5; m.clear(); m.addVertex(ofVec3f(-w,-h,0)); m.addVertex(ofVec3f( w,-h,0)); m.addVertex(ofVec3f( w, h,0)); m.addVertex(ofVec3f(-w, h,0)); m.addNormals(vector<ofVec3f>(4, ofVec3f(0,0,-1))); m.addTexCoord(ofVec2f(0,1)); m.addTexCoord(ofVec2f(1,1)); m.addTexCoord(ofVec2f(1,0)); m.addTexCoord(ofVec2f(0,0)); m.addIndex(0); m.addIndex(1); m.addIndex(2); m.addIndex(0); m.addIndex(2); m.addIndex(3); }