我想知道如何累积相机旋转,因此当我再次单击屏幕时,旋转不会重置到该单击位置,而是从该点开始跟随旋转,如果这有意义的话
这是我的代码。这在单击/触摸拖动事件时执行。
ofVec3f camPos = ofVec3f(0, 0, camDistance);
ofVec3f centerPos = ofVec3f(0, 0, 0);
static float halfWidth = ofGetWidth()/2;
static float halfHeight = ofGetHeight()/2;
float rotX = (touch.x-halfHeight) / (halfWidth);
float rotY = (touch.y-halfHeight) / (halfHeight);
camPos.rotate( rotY * 90, ofVec3f(1, 0, 0) );
camPos.rotate( rotX * 180, ofVec3f(0, 1, 0) );
camPos += centerPos;
cam.setPosition( camPos );
cam.lookAt( centerPos );