繁体   English   中英

SceneKit:在顶点上应用变换

[英]SceneKit : Apply transformation on vertices

我需要对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矩阵。 基本上,您将删除所有平移,仅保留旋转和比例因子。 看一下SCNMatrix4ToMat4SCNVector4ToFloat4 (取w=1 ),然后使用SIMD执行转换。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM