Hello all,
I'm having a bit of trouble with a pan gesture recognizer. I'm making an OpenGL ES app and I intend t use the pan gestures recognizer for swiveling the 3D camera.
So far, I have this code:
The issue is that the translation variable always resets, as it's declared within the method. So the position of the camera always resets whenever the user lets go and pans again. So how can I use the same translation, but with the new translation added on?
I'm having a bit of trouble with a pan gesture recognizer. I'm making an OpenGL ES app and I intend t use the pan gestures recognizer for swiveling the 3D camera.
So far, I have this code:
Code:
- (IBAction)handlePans:(UIPanGestureRecognizer *)recogniser {
CGPoint translation = [recogniser translationInView:self.view];
//self.xRotation is a float which will represent the angle.
self.xRotation = translation.x
if (recogniser.state == UIGestureRecognizerStateChanged) {
_xFinalCameraPoint = //This the the X value of the camera
(4 * sin(GLKMathDegreesToRadians(self.xRotation)));
_zFinalCameraPoint = //This is the Z value of the camera
(4 * cos(GLKMathDegreesToRadians(self.xRotation)));
}
}
The issue is that the translation variable always resets, as it's declared within the method. So the position of the camera always resets whenever the user lets go and pans again. So how can I use the same translation, but with the new translation added on?