gpt4 book ai didi

ios - 场景套件 : Apply transformation on vertices

转载 作者:行者123 更新时间:2023-11-28 21:47:06 25 4
gpt4 key购买 nike

我需要对包含在 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 执行转换。

关于ios - 场景套件 : Apply transformation on vertices,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29695737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com