美文网首页
SceneKit-绘制直线

SceneKit-绘制直线

作者: 酷走天涯 | 来源:发表于2018-09-19 09:28 被阅读39次

// private func lineBetweenNodeA(beginPosition: SCNVector3, endPosition: SCNVector3) -> SCNNode {
// let positions: [Float32] = [beginPosition.x, beginPosition.y, beginPosition.z, endPosition.x, endPosition.y, endPosition.z]
// let positionData = NSData(bytes: positions, length: MemoryLayout<Float32>.size*positions.count)
// let indices: [Int32] = [0, 1]
// let indexData = NSData(bytes: indices, length: MemoryLayout<Int32>.size * indices.count)
// let source = SCNGeometrySource(data: positionData as Data, semantic: SCNGeometrySource.Semantic.vertex, vectorCount: indices.count, usesFloatComponents: true, componentsPerVector: 3, bytesPerComponent: MemoryLayout<Float32>.size, dataOffset: 0, dataStride: MemoryLayout<Float32>.size * 3)
// let element = SCNGeometryElement(data: indexData as Data, primitiveType: SCNGeometryPrimitiveType.line, primitiveCount: indices.count, bytesPerIndex: MemoryLayout<Int32>.size)
// glLineWidth(10)
// let line = SCNGeometry(sources: [source], elements: [element])
// return SCNNode(geometry: line)
// }
//
// func distance(startPosition:SCNVector3,endPosition:SCNVector3) -> CGFloat{
// let x1 = startPosition.x
// let y1 = startPosition.y
// let z1 = startPosition.z
// let x2 = endPosition.x
// let y2 = endPosition.y
// let z2 = endPosition.z
// let r = sqrt(pow(x2-x1, 2) + pow(y2-y1, 2) + pow(z1-z2, 2))
// return CGFloat(r)
// }

// func calculateRotationY(beginPosition:SCNVector3,endPosition:SCNVector3) -> Float{
// var θ:Float = 0.0
// let x = endPosition.x
// let z = endPosition.z
// if z > 0 && x > 0{
// θ = atan(z/x)
// }else if z > 0 && x < 0 {
// θ = atan(z/x) + Float.pi
// }else if z < 0 && x > 0{
// θ = 2*Float.pi + atan(z/x)
// }else if z < 0 && x < 0{
// θ = Float.pi + atan(z/x)
// }else if x == 0 {
// if z > 0 {
// θ = 0
// }else if z < 0 {
// θ = Float.pi
// }else if z == 0 {
// θ = 0
// }
// }
// return θ
// }

相关文章

  • SceneKit-绘制直线

    // private func lineBetweenNodeA(beginPosition: SC...

  • Quartz2D绘图

    标签: 裁剪、多边形、绘制图片、绘制文字、截图、曲线、扇形、椭圆、直线 绘图基本格式 一、绘制直线(虚线为多条直线...

  • 上下文绘图,滤镜简单使用

    一、drawRect绘制功能 1.绘制直线 精简绘制直线 2. 绘制椭圆 3. 绘制弧形 4. 绘制贝塞尔曲线 5...

  • SVG 绘制直线

    本节我们来学习如何在 SVG 中绘制直线,要绘制直线可以使用 元素来实现。 如何绘制直线 我们可以使用 元...

  • SVG

    SVG 绘制长方形绘制圆形绘制椭圆 绘制直线 绘制折线 绘制多边形 ...

  • IOS 直线绘制

    //1.创建贝塞尔路径的实例 UIBezierPath*path = [UIBezierPathbezierPat...

  • Canvas使用方法总结

    引入Canvas标签 绘制直线 绘制矩形 绘制圆弧 绘制文本 绘制图片 我的github:https://gith...

  • Flutter自定义画板

    1. 绘制直线 绘制直线需要调用Canvas的drawLine方法,传入起点和终点坐标即可。 完整代码示例: 2....

  • SVG绘制1

    绘制矩形 绘制圆形 绘制椭圆 绘制直线 SVG常用属性 fill: 修改填充颜色 fill-opacity: 0~...

  • Objective-C ios图形各种线条绘制

    IOS 图形绘制 绘制直线 矩形绘制 三角形绘制 任意弧形绘制 圆形绘制 绘制的属性 虚线的绘制 UIView d...

网友评论

      本文标题:SceneKit-绘制直线

      本文链接:https://www.haomeiwen.com/subject/eeflextx.html