Skip to content

Instantly share code, notes, and snippets.

@benben
Created July 10, 2012 15:39

Revisions

  1. Benjamin Knofe created this gist Jul 10, 2012.
    35 changes: 35 additions & 0 deletions Quad.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    class Quad : public ofNode {
    public:
    Quad(float x, float y, float z, float width, float height, float depth) {
    myMesh.addVertex(ofVec3f(x+width,y,z));
    myMesh.addVertex(ofVec3f(x+width,y,z-depth));
    myMesh.addVertex(ofVec3f(x,y,z-depth));
    myMesh.addVertex(ofVec3f(x,y,z));
    myMesh.addVertex(ofVec3f(x+width,y+height,z));
    myMesh.addVertex(ofVec3f(x+width,y+height,z-depth));
    myMesh.addVertex(ofVec3f(x,y+height,z-depth));
    myMesh.addVertex(ofVec3f(x,y+height,z));

    myMesh.addTriangle(0, 1, 2);
    myMesh.addTriangle(2, 3, 0);
    myMesh.addTriangle(4, 5, 6);
    myMesh.addTriangle(6, 7, 4);
    myMesh.addTriangle(0, 4, 5);
    myMesh.addTriangle(0, 1, 5);
    myMesh.addTriangle(1, 5, 6);
    myMesh.addTriangle(1, 2, 6);
    myMesh.addTriangle(2, 3, 6);
    myMesh.addTriangle(3, 6, 7);
    myMesh.addTriangle(3, 0, 4);
    myMesh.addTriangle(3, 7, 4);
    }

    void customDraw() {
    //myMesh.drawWireframe();
    ofFill();
    //not working
    myMesh.drawFaces();
    }
    private:
    ofMesh myMesh;
    };