All of my models and my scene are oriented as follows:
z+ toward the camera, z- away from it. x- to the left, x+ to the right y+ up and y - down
However when I used this:
- (CGFloat) pointPairToBearingDegrees:(CGPoint)startingPoint secondPoint:(CGPoint) endingPoint
{
CGPoint originPoint = CGPointMake(endingPoint.x - startingPoint.x, endingPoint.y - startingPoint.y); /
float bearingRadians = atan2f(originPoint.y, originPoint.x); /
float bearingDegrees = bearingRadians * (180.0 / M_PI); /
bearingDegrees = (bearingDegrees > 0.0 ? bearingDegrees : (360.0 + bearingDegrees)); /
return degreesToRadian(bearingDegrees);
}
or this:
CGFloat angleBetweenPoints(CGPoint first, CGPoint second) {
CGFloat height = second.y - first.y;
CGFloat width = first.x - second.x;
CGFloat rads = atan2(width, height);
return rads;
}
to try to get an angle between two points (given as the nodes x position and z position) and then rotate the model I get wildly unpredictable rotations which are usually +- 45 degree or +- 90 degree, however, if I attempt to correct this, the result remains unpredictable.
I don't know if I simply don't understand how 3d works in scene kit or what.
What is the best orientation for objects? I'll rearrange the scene and models any way I need too if it means I can have slghtly more realistic looking movement.