我需要对SCNNode
上包含的所有顶点应用变换。每个SCNNode
都包含一个 SCNMatrix4 转换属性。我还得到了SCNNode
的所有顶点.
Vertex *currentVertex = [self.vectrices objectAtIndex:buff[index]];
SCNNode *currentChildren = myNode;
Vertex *new = [Vertex new];
new.x = (currentChildren.transform.m11 * currentVertex.x) + (currentChildren.transform.m12 * currentVertex.y) + (currentChildren.transform.m13 * currentVertex.z);
new.y = (currentChildren.transform.m21 * currentVertex.x) + (currentChildren.transform.m22 * currentVertex.y) + (currentChildren.transform.m23 * currentVertex.z);
new.z = (currentChildren.transform.m31 * currentVertex.x) + (currentChildren.transform.m32 * currentVertex.y) + (currentChildren.transform.m33 * currentVertex.z);
我得到了一个奇怪的结果,旋转和平移错误。我的计算,正确吗?
>SCNMatrix4
是一个 4x4 矩阵,但在这里你将其用作 3x3 矩阵。您基本上删除了所有翻译,只保留旋转和比例因子。查看SCNMatrix4ToMat4
和SCNVector4ToFloat4
(w=1
),并使用 SIMD 执行转换。