我有 3d 骨架模型,我在我的应用程序中用作节点。我使用 UIPanGesture 和这段代码旋转它
- (void)handleSingleTap:(UIPanGestureRecognizer *)recognizer
{
CGPoint location = [recognizer locationInView:[recognizer.view superview]];
float x = location.x;
float y = location.y;
float anglePan = sqrt(pow(x, 2)*M_PI_4/90.0 + pow(y, 2));//*M_PI/180.0;
SCNVector4 rotationVector = SCNVector4Make(0, 1, 0, anglePan);
geometryNode.rotation = rotationVector;
muscleNode.rotation = rotationVector;
if(recognizer.state == UIGestureRecognizerStateEnded){
SCNMatrix4 currentPivot1 = geometryNode.pivot;
SCNMatrix4 changePivot1 =
SCNMatrix4Invert(geometryNode.transform);
geometryNode.pivot = SCNMatrix4Mult(changePivot1, currentPivot1);
geometryNode.transform = SCNMatrix4Identity;
SCNMatrix4 currentPivot2 = muscleNode.pivot;
SCNMatrix4 changePivot2 = SCNMatrix4Invert(muscleNode.transform);
muscleNode.pivot = SCNMatrix4Mult(changePivot2, currentPivot2);
muscleNode.transform = SCNMatrix4Identity;
}
}
现在我想将我的骨架旋转到最初的初始位置。请指导我完成整个过程。谢谢