Created
December 1, 2014 23:03
-
-
Save ofZach/5c122f3ad33b47cd068a to your computer and use it in GitHub Desktop.
trying to figure out setupOffAxisViewPortal
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
// make a sphere | |
ofSpherePrimitive sph; | |
sph.set(100, 10); | |
ofMesh s = sph.getMesh(); | |
// grab the current camera | |
// this is to figure out where a camera "should" be, ie, for this overall picture where is the camera. | |
ofCamera mainCam; | |
mainCam.setupPerspective(); | |
// grab the main viewport also | |
ofRectangle mainViewport = ofGetCurrentViewport(); | |
// this is the camera that we will be doing the off axis stuff with | |
ofCamera subViewCam; | |
for (int i = 0; i < 3; i++){ | |
// let's look at the scene in 3s | |
ofRectangle subView = mainViewport; | |
subView.width/=3.0; | |
subView.x += subView.width * i; | |
// move to the subview & scissor test | |
ofViewport(subView); | |
glEnable(GL_SCISSOR_TEST); | |
glScissor(subView.x, subView.y, subView.width, subView.height); | |
ofClear(i*90, 255,255); | |
if (ofGetMousePressed()){ | |
// not sure what's the best way to show this *not* working | |
subViewCam.setupPerspective(); | |
//subViewCam.setPosition(subView.width * i + subView.width/2, subView.height/2, -mainCam.getPosition().z); | |
} else { | |
subViewCam.setPosition(mainViewport.width/2, mainViewport.height/2, -mainCam.getPosition().z); // camera is based on where it would be normally for a window this size. | |
subViewCam.lookAt( ofPoint(subView.getWidth()/2, subView.getHeight()/2)); | |
subViewCam.setupOffAxisViewPortal(subView.getTopLeft(), subView.getBottomLeft(), subView.getBottomRight()); | |
subViewCam.setScale(1, 1, 1); | |
subViewCam.setNearClip(0.1); | |
} | |
subViewCam.begin(); | |
ofFill(); | |
ofPushMatrix(); | |
if (ofGetMousePressed()){ | |
ofTranslate(mouseX - subView.width * i, mouseY); | |
} else { | |
ofTranslate(mouseX, mouseY); | |
} | |
//ofRect(0,0,50,50); | |
ofSetColor(ofColor::darkBlue); | |
sph.drawWireframe(); | |
ofPopMatrix(); | |
subViewCam.end(); | |
// draw a bounding box around each scene | |
glDisable(GL_SCISSOR_TEST); | |
ofViewport(mainViewport); | |
ofSetColor(255); | |
ofSetLineWidth(5); | |
ofNoFill(); | |
ofRect(i*subView.width,0, subView.width, subView.height); | |
ofSetLineWidth(1); | |
} | |
ofDrawBitmapStringHighlight("mouse pressed = non offaxis cam..", ofPoint(50,50)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment