I need to apply a transformation to all my vertices contained on a SCNNode
. Each SCNNode
contains a SCNMatrix4 transform property. I got also all vertices of my 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);
I got a strange resultant with wrong rotation and translation. My calcul, is it correct ?
SCNMatrix4
is a 4x4 matrix, but here you're using it as 3x3 matrix. You're basically removing all translations and just keeping rotations and scale factors. Take a look at SCNMatrix4ToMat4
and SCNVector4ToFloat4
(take w=1
) and use SIMD to perform your transformations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.