Roc.Tian
Roc.Tian

Reputation: 63

SceneKit: how to transform content of SCNMaterial?

I create SCNNode with SCNBox,

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];

but the back of texture direction is wrong.

enter image description here

enter image description here

I want two direction is same,how to transform content of SCNMaterial ? how to use "contentsTransform"?

Upvotes: 2

Views: 1941

Answers (1)

Roc.Tian
Roc.Tian

Reputation: 63

I have solved this problem using this answer: 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;

Upvotes: 1

Related Questions