//----------------------------------------
void ofxViewportCam::begin(ofRectangle viewport)
{
    ofPushStyle();
    if(drawWireFrame)
    {
        ofNoFill();
    }
    else
    {
        ofFill();
    }
    
    ofVec3f pos = getPosition();
    ofVec2f mousePosScreen = ofVec3f(ofGetMouseX() - viewport.width / 2 - viewport.x, viewport.height / 2 - (ofGetMouseY() - viewport.y), 0);
    
#ifdef TARGET_LINUX
    if(ofGetKeyPressed(OF_KEY_SHIFT))
#else
    if(ofGetKeyPressed(OF_KEY_ALT))
#endif
    {
        ofVec2f trans(mousePosScreenPrev - mousePosScreen);
        if(ofGetMousePressed(0))
        {
            tumble(trans.x, -trans.y);
        }
        else if(ofGetMousePressed(1))
        {
            track(trans.x, trans.y);
        }
        else if(ofGetMousePressed(2))
        {
            float zoomAmount = trans.y;
            zoom(zoomAmount);
        }
    }
    
    mousePosScreenPrev = mousePosScreen;
    ofCamera::begin(viewport);
    
    ofPopStyle();
}
예제 #2
0
void Camera::mouseDragged(ofMouseEventArgs& event) 
{
	if(event.button == 0)
	{
		tumble(prevMouseX, prevMouseY, event.x, event.y);
	}
	else if(event.button == 1)
	{
		track(prevMouseX, prevMouseY, event.x, event.y);
	}
	else if(event.button == 2)
	{
		dolly(prevMouseX, prevMouseY, event.x, event.y);
		setClippingPlane();
	}

	prevMouseX = event.x;
	prevMouseY = event.y;

	mouseClicked = false;;

}