gpt4 book ai didi

ios - 如何更改绘图线的粗细?

转载 作者:行者123 更新时间:2023-11-30 11:32:10 25 4
gpt4 key购买 nike

private func lineFrom(vector vector1: SCNVector3, toVector vector2: SCNVector3) -> SCNGeometry {

let indices: [Int32] = [0,1]
let source = SCNGeometrySource(vertices: [vector1, vector2])
let element = SCNGeometryElement(indices: indices, primitiveType: .line)
return SCNGeometry(sources: [source], elements: [element])
}


@objc private func tapped(rec: UITapGestureRecognizer) {

let hitTransform = SCNMatrix4(hit.worldTransform)

let hitPoint = SCNVector3Make(hitTransform.m41 , hitTransform.m42, hitTransform.m43)

if points.start == nil{
print("start touch")
points.start = hitPoint
print(points.start!.x, points.start!.y, points.start!.z)

}

else{
points.end = hitPoint
print(points.end!.x, points.end!.y, points.end!.z

line.geometry = lineFrom(vector: points.start!, toVector: points.end!)

line.geometry?.firstMaterial?.diffuse.contents = UIColor.red
line.geometry?.firstMaterial?.isDoubleSided = true

sceneView.scene.rootNode.addChildNode(line)
func renderer(_ renderer: SCNSceneRenderer, willRenderScene scene: SCNScene, atTime time: TimeInterval) {
glLineWidth(80)
}
canPlacePoint = false
}
}
}
}

我触摸两个点来保存位置,并尝试画一条连接这两点的线。虽然画了线,但触摸点的位置不正确。 我还用了glLineWidth(),因为我想改变画线的粗细,但是它没有改变。我该怎么办?

最佳答案

SCeneKit 更喜欢使用 Metal 而不是 OpenGl,而在 Metal 中无法绘制粗线;此外,OpenGl 现已弃用。您需要使用三角形来绘制脂肪线。

关于ios - 如何更改绘图线的粗细?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50149132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com