simd_float4x4 列 [英] simd_float4x4 Columns

查看:38
本文介绍了simd_float4x4 列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在不旋转图像的情况下平移平面.出于某种原因,我的图像正在旋转.

var translation = matrix_identity_float4x4翻译.colum = -0.2让变换 = simd_mul(currentFrame.camera.transform, translation)planeNode.simdWorldTransform = matrix_multiply(currentFrame.camera.transform,平移)

另外,我注意到 matrix_identity_float4x4 包含 4 列但文档不可用.

为什么是 4 列?有飞机的frame吗?

解决方案

最简单的方法是使用以下代码进行定位:

let planeNode = SCNNode()planeNode.geometry = SCNPlane(宽:20,高:20)//首先,我们需要以弧度为单位绕 x 轴旋转平面:planeNode.rotation = SCNVector4(1, 0, 0, -Double.pi/2)planeNode.geometry?.materials.first?.diffuse.contents = UIColor.red平面节点.位置.x = 10平面节点.位置.z = 10//planeNode.position = SCNVector3(x: 10, y: 0, z: 10)scene.rootNode.addChildNode(planeNode)

或者这样:

让 cameraNode = SCNNode()cameraNode.camera = SCNCamera()cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)scene.rootNode.addChildNode(cameraNode)让planeNode = SCNNode()planeNode.geometry = SCNPlane(宽:20,高:20)planeNode.rotation = SCNVector4(1, 0, 0, -Double.pi/2)planeNode.geometry?.materials.first?.diffuse.contents = UIColor.red让距离:浮动= 50planeNode.simdPosition = cameraNode.simdWorldFront * distance//-Z 轴planeNode.simdPosition = cameraNode.simdWorldRight * distance//+X 轴scene.rootNode.addChildNode(planeNode)

<块引用>

如果您想了解有关 ARKit 和 SceneKit 框架中使用的矩阵的更多信息,请查看 图 1-8 常见变换的矩阵配置.

希望这会有所帮助.

I want to translate a plane without rotating the image. For any reason my image is being rotated.

var translation = matrix_identity_float4x4
translation.colum = -0.2
let transform = simd_mul(currentFrame.camera.transform, translation)
planeNode.simdWorldTransform = matrix_multiply(currentFrame.camera.transform, translation)

Also, I notice that matrix_identity_float4x4 contains 4 columns but the documentation is not available.

Why 4 columns? Are there the frame of the plane?

解决方案

The simplest way to do it is to use the following code for positioning:

let planeNode = SCNNode()
planeNode.geometry = SCNPlane(width: 20, height: 20)
// At first we need to rotate a plane about its x axis in radians:
planeNode.rotation = SCNVector4(1, 0, 0, -Double.pi/2)  
planeNode.geometry?.materials.first?.diffuse.contents = UIColor.red

planeNode.position.x = 10
planeNode.position.z = 10

// planeNode.position = SCNVector3(x: 10, y: 0, z: 10)

scene.rootNode.addChildNode(planeNode)

or this way:

let cameraNode = SCNNode()
cameraNode.camera = SCNCamera()
cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)
scene.rootNode.addChildNode(cameraNode)

let planeNode = SCNNode()
planeNode.geometry = SCNPlane(width: 20, height: 20)
planeNode.rotation = SCNVector4(1, 0, 0, -Double.pi/2)
planeNode.geometry?.materials.first?.diffuse.contents = UIColor.red

let distance: Float = 50
planeNode.simdPosition = cameraNode.simdWorldFront * distance  // -Z axis
planeNode.simdPosition = cameraNode.simdWorldRight * distance  // +X axis

scene.rootNode.addChildNode(planeNode)

If you wanna know more about matrices used in ARKit and SceneKit frameworks just look at Figure 1-8 Matrix configurations for common transformations.

Hope this helps.

这篇关于simd_float4x4 列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆