I tried out @omz's idea. but go some conflicting results, so I dug into this some more with some interesting results.
The answer is the inverse of the pivot is applied as a child of the main transformation. This provides quite different semantics than supplying an intermediate parent node.
Specifically, if I start with a parent node with transform P, and a child node with transform C, they combine to make a world transform W = CATransform3DConcat(C, P). The same world transform W is obtained by setting the parent node's pivot to the inverse of C, and not setting a transform on the child.
This approach does appear to provide some additional utility as it cannot be duplicated by interposing an intermediate node, as well as being inverted before being applied. As Hal Mueller pointed out, the documentation does say the pivot influences rotation and scale, as well as position, but is silent on the nature of the influence.
Here are the result of testing this conclusion:
Set parent rotation and node position.
Transform:
{ 1.00, 0.00, 0.00, 0.00 }
{ 0.00, 1.00, 0.00, 0.00 }
{ 0.00, 0.00, 1.00, 0.00 }
{ 1.00, 2.00, 3.00, 1.00 }
Pivot:
{ 1.00, 0.00, 0.00, 0.00 }
{ 0.00, 1.00, 0.00, 0.00 }
{ 0.00, 0.00, 1.00, 0.00 }
{ 0.00, 0.00, 0.00, 1.00 }
World Transform:
{ 1.00, 0.00, 0.00, 0.00 }
{ 0.00, 0.00, 1.00, 0.00 }
{ 0.00, -1.00, 0.00, 0.00 }
{ 1.00, -3.00, 2.00, 1.00 }
2013-04-04 13:49:55.453 Model Importer[43504:303]
CATransform3DConcat(node.transform, node.parentNode.transform)]
{ 1.00, 0.00, 0.00, 0.00 }
{ 0.00, 0.00, 1.00, 0.00 }
{ 0.00, -1.00, 0.00, 0.00 }
{ 1.00, -3.00, 2.00, 1.00 }
2013-04-04 13:49:55.454 Model Importer[43504:303]
Set parent rotation and parent.pivot to inverse position.
Transform:
{ 1.00, 0.00, 0.00, 0.00 }
{ 0.00, 1.00, 0.00, 0.00 }
{ 0.00, 0.00, 1.00, 0.00 }
{ 0.00, 0.00, 0.00, 1.00 }
Pivot:
{ 1.00, 0.00, 0.00, 0.00 }
{ 0.00, 1.00, 0.00, 0.00 }
{ 0.00, 0.00, 1.00, 0.00 }
{ 0.00, 0.00, 0.00, 1.00 }
World Transform:
{ 1.00, 0.00, 0.00, 0.00 }
{ 0.00, 0.00, 1.00, 0.00 }
{ 0.00, -1.00, 0.00, 0.00 }
{ 1.00, -3.00, 2.00, 1.00 }
Here's the code:
// Verification
SCNVector3 v3 = {1.0, 2.0, 3.0};
SCNVector4 v4 = {1.0, 0, 0, M_PI/2.0};
node.parentNode.rotation = v4;
node.position = v3;
NSLog(@"\n\nSet parent rotation and node position.%@",
[self transformsForNodeToString:node]);
//
// Verify match with CATransform3DConcat
NSLog(@"\n\nCATransform3DConcat(node.transform, node.parentNode.transform)]%@",
[self transformToString:CATransform3DConcat(node.transform, node.parentNode.transform)]);
//
// Clear the child node transform and put the inverse in the parent's pivot.
CATransform3D position = node.transform;
CATransform3D inversePosition = CATransform3DInvert(position);
node.transform = CATransform3DIdentity;
node.parentNode.pivot = inversePosition;
NSLog(@"\n\nSet parent rotation and parent.pivot to inverse position.%@",
[self transformsForNodeToString:node]);
node.parentNode.pivot = CATransform3DIdentity;
node.parentNode.transform = CATransform3DIdentity;
+ (NSString*)transformsForNodeToString: (SCNNode*)node {
NSString* result = @"\n";
result = [result stringByAppendingFormat:
@"\nTransform:%@\nPivot:%@\nWorld Transform:%@",
[self transformToString:node.transform],
[self transformToString:node.pivot],
[self transformToString:[node worldTransform]]];
return result;
}
+ (NSString*)transformToString: (CATransform3D)transform {
NSString* result = @"\n";
result = [result stringByAppendingFormat:
@"{ % .2f, % .2f, % .2f, % .2f }\n", transform.m11, transform.m12, transform.m13, transform.m14];
result = [result stringByAppendingFormat:
@"{ % .2f, % .2f, % .2f, % .2f }\n", transform.m21, transform.m22, transform.m23, transform.m24];
result = [result stringByAppendingFormat:
@"{ % .2f, % .2f, % .2f, % .2f }\n", transform.m31, transform.m32, transform.m33, transform.m34];
result = [result stringByAppendingFormat:
@"{ % .2f, % .2f, % .2f, % .2f }\n", transform.m41, transform.m42, transform.m43, transform.m44];
return result;
}
Comments welcome!