SCNCylinder上的设置内容(图像)反转(翻转)



我试图使用以下代码在SCNCylinder对象上渲染图像:

    let coinGeometry = SCNCylinder(radius: 50, height: 55)
    coinNode = SCNNode(geometry: coinGeometry)
    coinNode.position = SCNVector3Make(0.0, 25.0, 25.0)
    coinScene.rootNode.addChildNode(coinNode)
   //Add image on cylinder shape
    let frontFacingImageMaterial = SCNMaterial()
    frontFacingImageMaterial.diffuse.contents = UIImage(named: "map")
    frontFacingImageMaterial.specular.contents = UIColor.blueColor()
    frontFacingImageMaterial.shininess = 5.0
    coinGeometry.firstMaterial = frontFacingImageMaterial

在圆柱体上,此图像显示为反转(翻转)。我该怎么修?

感谢

如何水平翻转UIImage?:

UIImage* sourceImage = [UIImage imageNamed:@"whatever.png"];
UIImage* flippedImage = [UIImage imageWithCGImage:sourceImage.CGImage 
                                        scale:sourceImage.scale
                           orientation:UIImageOrientationUpMirrored];

所以在Swift中,类似于:

if let originalImage = UIImage(named: "map") {
    let materialImage = UIImage(CGImage: originalImage.CGImage!, 
                                scale: originalImage.scale, 
                                orientation: .UpMirrored)
}

不要翻转原始图像数据,只翻转它映射到几何体上的方式。将frontFacingImageMaterial.diffuse.contentsTransform设置为翻转X或Y的矩阵。

最新更新