So I'm using Cocos3D in Obj-C.
Since my initial question doesn't seems to be clear enough to get any answers i write it again.
I'm making a 3D viewer, with this i want to be able to drag my finger on the screen and make my object(Dobj
) rotates on itself.
-(void) startRotatingObjectOnXYAxis { saveXYAxisStartLocation = Dobj.rotation; }
-(void) rotateObjectOnXYAxisBy: (CGPoint) aMovement
{
CC3Vector rotateVector = CC3VectorMake(aMovement.y, aMovement.x, 0.0f);
Dobj.rotation = CC3VectorAdd(saveXYAxisStartLocation, rotateVector);
}
The problem is that when I do it this way, the object axis also rotates, and some drags after, the X axis will be vertical(instead of horizontal), and rotations become very confusing.
So i would like to reset the axis to their origin point after each drags.
Something like that:
-(void) startRotatingObjectOnXYAxis { saveXYAxisStartLocation = Dobj.rotation; }
-(void) rotateObjectOnXYAxisBy: (CGPoint) aMovement
{
[Dobj moveMeshOriginTo:CC3VectorMake(0.0f, 0.0f, saveXYAxisStartLocation.z)];
CC3Vector rotateVector = CC3VectorMake(aMovement.y, aMovement.x, 0.0f);
Dobj.rotation = CC3VectorAdd(saveXYAxisStartLocation, rotateVector);
}
But it doesn't have any effect ...
In my examples aMovement
is the (UIPanGestureRecognizer*) gesture.translation
value.