我从.dae文件加载一个场景,该文件没有动画:
scene = [SCNScene sceneNamed:@"TestArm.dae"];
通过一些手势,我在我的根节点上应用了旋转和翻译:
[scene.rootNode convertPosition:SCNVector3Make(movetoX,movetoY,0) toNode:nil];
它就像一个魅力,它很棒。 但现在我需要从当前显示的节点中提取所有SCNGeometry。 这是一个很大的挑战,因为当我在节点甚至动画上应用了一些更改时,SCNGeometry不会更新。
如何更新节点的SCNGeometry?
似乎完全不可能。 提前谢谢。
修改
我试图在每个SCNNode的旋转,变换和缩放的所有顶点上应用一些数学计算。 - >不起作用,也许我没有好的计算。
修改
这是我目前用于更改几何节点的代码。
SCNNode *currentChildren = [[self.childrens objectAtIndex:self.currentIndexParent] objectAtIndex:self.currentIndexChild];
Vertex *v1 = [self.vectrices objectAtIndex:buff[0]];
v1.x = (currentChildren.transform.m11 * v1.x) + (currentChildren.transform.m12 * v1.x) + (currentChildren.transform.m13 * v1.x) + currentChildren.transform.m14;
v1.y = (currentChildren.transform.m21 * v1.y) + (currentChildren.transform.m22 * v1.y) + (currentChildren.transform.m23 * v1.y) + currentChildren.transform.m24;
v1.z = (currentChildren.transform.m31 * v1.z) + (currentChildren.transform.m32 * v1.z) + (currentChildren.transform.m33 * v1.z) + currentChildren.transform.m34;
Vertex *v2 = [self.vectrices objectAtIndex:buff[1]];
v2.x = (currentChildren.transform.m11 * v2.x) + (currentChildren.transform.m12 * v2.x) + (currentChildren.transform.m13 * v2.x) + currentChildren.transform.m14;
v2.y = (currentChildren.transform.m21 * v2.y) + (currentChildren.transform.m22 * v2.y) + (currentChildren.transform.m23 * v2.y) + currentChildren.transform.m24;
v2.z = (currentChildren.transform.m31 * v2.z) + (currentChildren.transform.m32 * v2.z) + (currentChildren.transform.m33 * v2.z) + currentChildren.transform.m34;
Vertex *v3 = [self.vectrices objectAtIndex:buff[2]];
v3.x = (currentChildren.transform.m11 * v3.x) + (currentChildren.transform.m12 * v3.x) + (currentChildren.transform.m13 * v3.x) + currentChildren.transform.m14;
v3.y = (currentChildren.transform.m21 * v3.y) + (currentChildren.transform.m22 * v3.y) + (currentChildren.transform.m23 * v3.y) + currentChildren.transform.m24;
v3.z = (currentChildren.transform.m31 * v3.z) + (currentChildren.transform.m32 * v3.z) + (currentChildren.transform.m33 * v3.z) + currentChildren.transform.m34;
修改 我改变了一些代码,但仍然无效。
for (int index = 0; index < 3; index++) {
Vertex *currentVertex = [self.vectrices objectAtIndex:buff[index]];
currentVertex.x = (currentChildren.presentationNode.worldTransform.m11 * currentVertex.x) + (currentChildren.presentationNode.worldTransform.m12 * currentVertex.x) + (currentChildren.presentationNode.worldTransform.m13 * currentVertex.x) + currentChildren.presentationNode.worldTransform.m14;
currentVertex.y = (currentChildren.presentationNode.worldTransform.m11 * currentVertex.y) + (currentChildren.presentationNode.worldTransform.m12 * currentVertex.y) + (currentChildren.presentationNode.worldTransform.m13 * currentVertex.y) + currentChildren.presentationNode.worldTransform.m24;
currentVertex.z = (currentChildren.presentationNode.worldTransform.m11 * currentVertex.z) + (currentChildren.presentationNode.worldTransform.m12 * currentVertex.z) + (currentChildren.presentationNode.worldTransform.m13 * currentVertex.z) + currentChildren.presentationNode.worldTransform.m34;
}
似乎我的节点上的转换或worldTransformation,当我应用骨骼的mouvement时不会更新。
我正在为这个问题构建一个解决方案,这是我当前的进展:github project