Created
January 14, 2015 05:14
-
-
Save mattfelsen/3b32e1dac09eb6ad3534 to your computer and use it in GitHub Desktop.
3D -> 2D on a Cylinder
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 characters
float theta, x, y, z; | |
theta = ofDegToRad(230); // 0 -> 360 | |
x = cylRadius * cos(theta); | |
y = cylHeight * -0.4; // -h/2 -> h/2 | |
z = cylRadius * sin(theta); | |
ofVec3f center = cam.worldToScreen( ofVec3f(x, y, z) ); | |
cam.end(); | |
ofDisableDepthTest(); | |
ofPushMatrix(); | |
ofTranslate(center); | |
ofRotateY( ofRadToDeg(sin(ofGetElapsedTimef()))); | |
ofFill(); | |
ofSetColor(ofColor::white, 100); | |
ofRect(0, 0, 0, 50, 30); | |
ofNoFill(); | |
ofSetColor(ofColor::white, 255); | |
ofRect(0, 0, 0, 50, 30); | |
ofPopMatrix(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment