簡體   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