Created
January 3, 2014 17:53
-
-
Save ofZach/8242765 to your computer and use it in GitHub Desktop.
billboard using ofNode / ofCamera
This file contains 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 characters
//-------------------------------------------------------------- | |
void testApp::draw(){ | |
glEnable(GL_DEPTH_TEST); | |
ofEnableLighting(); | |
ofLight light; | |
light.setPosition(ofPoint(-200,0, -1000)); | |
light.lookAt( ofPoint(-1000,0,0)); | |
light.setDirectional(); | |
light.enable(); | |
cam.begin(); | |
ofDrawAxis(100); | |
ofSeedRandom(0); // always pick the same random positions | |
for (int i = 0; i < 50; i++){ | |
ofPoint pos(ofRandom(-200,200), ofRandom(-200,200), ofRandom(-200,200)); | |
ofNode posNode; | |
posNode.setGlobalPosition(pos); | |
posNode.lookAt(cam.getGlobalPosition(), cam.getUpDir()); | |
ofQuaternion posQuat = posNode.getGlobalOrientation(); | |
float ang = 0; | |
ofPoint vec; | |
posQuat.getRotate(ang, vec); | |
ofPushMatrix(); | |
ofTranslate(pos); | |
ofRotate(ang, vec.x, vec.y, vec.z); | |
ofRotate(30, 1,1,0); // rotate alittle bit, so you can see the "box" of the object | |
ofDrawBox(0,0,0,50); | |
ofPopMatrix(); | |
} | |
cam.end(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in the .h file:
ofEasyCam cam;