2015-12-10 37 views
2

創建SCNNode與SCNBox,SceneKit:如何轉換SCNMaterial的內容?

SCNBox *wallBox = [SCNBox boxWithWidth:width height:100 length:4 chamferRadius:0]; 

SCNMaterial *allMaterial = [SCNMaterial new]; 
allMaterial.diffuse.contents = @"allwall.png"; 

SCNMaterial *smallMaterial1 = [SCNMaterial new]; 
smallMaterial1.diffuse.contents [email protected]"bottomwall.png"; 

SCNNode *rightwall = [SCNNode nodeWithGeometry:wallBox]; 

rightwall.geometry.materials = @[smallMaterial1,allMaterial,smallMaterial1,allMaterial,allMaterial,allMaterial]; 

但質地方向的背面是錯誤的。

enter image description here

enter image description here

我想要兩個方向都是一樣的,如何把SCNMaterial的內容?如何使用「contentsTransform」?

+0

嗨,大衛,我不能使用計算器非常好。不會被刪除「可以顯示圖片」嗎? –

回答

1

我一直在使用這個答案解決了這個問題:SceneKit, flip direction of SCNMaterial

rightwall.geometry.materials = @[smallMaterial1,allMaterial,[smallMaterial1 copy],allMaterial,allMaterial,allMaterial]; 
    NSArray *allMaterial = rightwall.geometry.materials; 
    SCNMaterial *smallMaterial2= allMaterial[2]; 
    smallMaterial2.diffuse.contentsTransform = SCNMatrix4MakeScale(-1,1,1); 
    smallMaterial2.diffuse.wrapT = SCNWrapModeRepeat; 
    smallMaterial2.diffuse.wrapS = SCNWrapModeRepeat;