HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 场景套件中的彩色线?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用以下代码在两个节点之间绘制一条线:

class func linebetweenNodeA(nodeA: SCNNode,nodeB: SCNNodE) -> SCNNode {
    let positions: [Float32] = [nodeA.position.x,nodeA.position.y,nodeA.position.z,nodeB.position.x,nodeB.position.y,nodeB.position.z]
    let positionData = NSData(bytes: positions,length: sizeof(Float32)*positions.count)
    let inDices: [Int32] = [0,1]
    let indexData = NSData(bytes: inDices,length: sizeof(Int32) * inDices.count)
    let source = SCNGeometrysource(data: positionData,semantic: SCNGeometrysourceSemanticVertex,vectorCount: inDices.count,floatComponents: true,componentsPerVector: 3,bytesPerComponent: sizeof(Float32),dataOffset: 0,dataStride: sizeof(Float32) * 3)
    let element = SCNGeometryElement(data: indexData,primitiveType: SCNGeometryPrimitiveType.Line,primitiveCount: inDices.count,bytesPerIndex: sizeof(Int32))
    let line = SCNGeometry(sources: [source],elements: [element])
    line.firstMaterial?.lighTingModelName = SCNLighTingModelConstant
    line.firstMaterial?.emission.contents = UIColor.orangeColor()
    return SCNNode(geometry: linE)
}

我希望能够在调用函数时传递颜色,以便相应地更改颜色…

如何指定绘制线条的颜色?

我编辑了代码以适合我.我使用发射属性而不是漫反射,我使用恒定光…

解决方法

材质的lighTingModelName认为SCNLighTingModelBlinn.使用此照明模型,漫反射材质属性使用如下:

color = ... + diffuse * max(0,dot(N,L)) + ...

但由于几何体没有法线,因此漫反射总是乘以0.

您可能希望使用SCNLighTingModelConstant光照模型或使用发射材质属性而不是漫反射.

大佬总结

以上是大佬教程为你收集整理的ios – 场景套件中的彩色线?全部内容,希望文章能够帮你解决ios – 场景套件中的彩色线?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。