Skip to content

Instantly share code, notes, and snippets.

@patrickFuerst
Created April 8, 2015 09:59
Show Gist options
  • Save patrickFuerst/9a9b6aa432893a0608ae to your computer and use it in GitHub Desktop.
Save patrickFuerst/9a9b6aa432893a0608ae to your computer and use it in GitHub Desktop.
#pragma once
#include "ofMain.h"
class ofApp : public ofBaseApp{
ofVboMesh testMesh;
ofEasyCam mCam1;
public:
void setup(){
ofBoxPrimitive box = ofBoxPrimitive(10, 10, 10, 1, 1, 1);
box.setSideColor(ofBoxPrimitive::BoxSides::SIDE_TOP, ofColor::green );
box.setSideColor(ofBoxPrimitive::BoxSides::SIDE_BOTTOM, ofColor::purple);
testMesh = box.getMesh();
mCam1.setupPerspective(false, 60, 0.1, 5000);
mCam1.setDistance(25);
};
void draw(){
ofBackground(ofColor::black);
mCam1.begin();
ofSetColor(ofColor::white);
testMesh.drawWireframe();
ofSetColor(ofColor::yellow);
for (vector<ofIndexType>::iterator it = testMesh.getIndices().begin(); it != testMesh.getIndices().end(); ++it){
//ofSetBitMapmode(OF_BITMAP_MODE_BILLBOARD);
ofVec3f pos = testMesh.getVertices()[*it]; // fetch point for given index
pos = pos + testMesh.getNormals()[*it] * 0.75; // shift point to draw index number along its normal
ofVec3f colorValue = ofVec3f(0.5, 0.5, 0.5) + 0.5 * testMesh.getNormals()[*it];
ofSetColor(ofFloatColor(colorValue.x, colorValue.y, colorValue.z, 1.0));
ofDrawBitmapString(ofToString(*it), pos.x, pos.y, pos.z);
}
mCam1.end();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment