Speakers simd_float4x4

I want to translate a plane without rotating the image. For whatever reason, my image is 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 noticed it matrix_identity_float4x4

contains 4 columns, but no documentation is available.

Why 4 columns? Is there a frame

plane?

+4


source to share


1 answer


The easiest way to do this is to use the following positioning code:

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 like this:



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 would like to learn more about the matrices used in the ARKit and SceneKit frameworks, just look at the matrix configurations in Fig. 1-8 for general conversions .

Hope this helps.

0


source







All Articles