Skip to content

Instantly share code, notes, and snippets.

@mattfelsen
Created January 14, 2015 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattfelsen/3b32e1dac09eb6ad3534 to your computer and use it in GitHub Desktop.
Save mattfelsen/3b32e1dac09eb6ad3534 to your computer and use it in GitHub Desktop.
3D -> 2D on a Cylinder
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