SceneKit:如何转换SCNMaterial的内容?

问题描述 投票:2回答:1

我用SCNBox创建了SCNNode。

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 =@"bottomwall.png";
        
SCNNode *rightwall = [SCNNode nodeWithGeometry:wallBox];
        
rightwall.geometry.materials = @[smallMaterial1,allMaterial,smallMaterial1,allMaterial,allMaterial,allMaterial];

但后面的纹理方向是错的,我想让两个方向一致,如何转换SCNMaterial的内容?

enter image description here

enter image description here

如何使用 "contentsTransform "来转换SCNMaterial的内容?

textures transform scenekit
1个回答
1
投票

我已经用这个答案解决了这个问题。SceneKit,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;
© www.soinside.com 2019 - 2024. All rights reserved.