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(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, float h, float d) { 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(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); // 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(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); // 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(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); // 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(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); // 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(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(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); }