scenekit

ARKit vs SceneKit coordinates

删除回忆录丶 提交于 2019-12-20 20:19:19
问题 I'm trying to understand the difference between the different element introduced in ArKit and their maybe equivalents in SceneKit: SCNNode.simdTransform vs SCNNode.transform . In ARKit, it seems that people use SCNNode.simdTransform instead of SCNNode.transform . How do they differ? simdTransform seems to use column major order, while transform (SCNMatrix4) is row major. How do I convert one to the other? Just transpose? I've the impression that the tracking doesn't work as well if I use

SceneKit – Get direction of camera

拥有回忆 提交于 2019-12-20 10:55:54
问题 I need to find out which direction a camera is looking at, e.g. if it is looking towards Z+ , Z- , X+ , or X- . I've tried using eulerAngles , but the range for yaw goes 0 -> 90 -> 0 -> -90 -> 0 which means I can only detect if the camera is looking towards Z or X , not if it's looking towards the positive or negative directions of those axes. 回答1: You can create an SCNNode that place it in worldFront property to get a vector with the x, y, and z direction. Another way you could do it is like

How to record video from ARKit?

孤街浪徒 提交于 2019-12-20 10:19:33
问题 Now I'm testing ARKit/SceneKit implementation. The basic rendering to the screen is kinda working so then I wanna try recording what I see on the screen into a video. Just for recording of Scene Kit I found this Gist: // // ViewController.swift // SceneKitToVideo // // Created by Lacy Rhoades on 11/29/16. // Copyright © 2016 Lacy Rhoades. All rights reserved. // import SceneKit import GPUImage import Photos class ViewController: UIViewController { // Renders a scene (and shows it on the

Scenekit SCNShadable accessing _surface.diffuseTexcoord paints the object white

我的未来我决定 提交于 2019-12-20 04:12:30
问题 I'm experiencing odd behaviour when trying to extend a PBR material from scenekit. All i want to do is read a texture, map it using the first uv channel (same as normal). As soon as i mention _surface.diffuseTexcoord , _surface.diffuse seems to turn to white. It doesn't seem to be constant ( _output.rgb = vec3(1.) ) but rather color white is passed through the lighting pipeline. let myShader = "#pragma arguments\n" + "sampler uMaskTex;\n" + "uniform sampler2D uMaskTex;\n" + "#pragma body\n" +

Scenekit SCNShadable accessing _surface.diffuseTexcoord paints the object white

故事扮演 提交于 2019-12-20 04:12:13
问题 I'm experiencing odd behaviour when trying to extend a PBR material from scenekit. All i want to do is read a texture, map it using the first uv channel (same as normal). As soon as i mention _surface.diffuseTexcoord , _surface.diffuse seems to turn to white. It doesn't seem to be constant ( _output.rgb = vec3(1.) ) but rather color white is passed through the lighting pipeline. let myShader = "#pragma arguments\n" + "sampler uMaskTex;\n" + "uniform sampler2D uMaskTex;\n" + "#pragma body\n" +

Face texture from ARKit

这一生的挚爱 提交于 2019-12-20 03:09:49
问题 I am running a face tracking configuration in ARKit with SceneKit, in each frame i can access the camera feed via the snapshot property or the capturedImage as a buffer, i have also been able to map each face vertex to the image coordinate space and add some UIView helpers(1 point squares) to display in realtime all the face vertices on the screen, like this: func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) { guard let faceGeometry = node.geometry as?

Tube Physics Body acting like SCNCylinder, but how to make it act like SCNTube?

≡放荡痞女 提交于 2019-12-20 02:56:12
问题 I am trying to make a tube and its physics body like so in SceneKit. let BoxGeometry = SCNTube(innerRadius: 5, outerRadius: 12.5, height: 4) Box = SCNNode(geometry: BoxGeometry) Box.pivot = SCNMatrix4MakeRotation(Float(M_PI_2/8), 0, 1, 0) Box.physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.Static, shape: nil) Box.physicsBody?.mass = 5 Box.categoryBitMask = colorCategory scene.rootNode.addChildNode(Box) However, when another object falls onto this object it does not pass through the

Rotate SCNNode relative local coordinates

别等时光非礼了梦想. 提交于 2019-12-20 01:14:27
问题 I'm trying to rotate a node by SCNAction , but it rotates relative to parent’s coordinate space. Is it possible to rotate a node relative local's coordinate system? 回答1: Sure. You can obtain parent's space coordinates for rotation axis with convertVector method. For example, this action will do 180 degrees rotation around local x-axis: SCNAction.rotate(by: .pi, around: node.convertVector(SCNVector3(1, 0, 0), to: node.parent), duration: TimeInterval(5)) 回答2: Have you tried: [node runAction:

Getting an SCNPhysicsVehicle's Position

冷暖自知 提交于 2019-12-19 13:48:23
问题 I am working on a basic racing game using Apple's SceneKit and am running into issues simulating a car. Using the SCNPhysicsVehicle behavior, I am able to properly set up the car and drive it using the documented methods. However, I am unable to get the car's position. It seems logical that the SCNPhysicsVehicle would move the SCNNodes that contain the chassis and the wheels as the car moves but the SCNNodes remain at their original position and orientation. Strangely enough, the chassis'

SKScene becomes unresponsive while being Idle

混江龙づ霸主 提交于 2019-12-19 11:36:10
问题 Hello I have a SceneKit game. All the game play is in one scene and when the game is over the sprit kit overlay acts as a game over screen and when they hit play again the sprite kit labels disappear and the game resets all in the same scene. My issuing is coming in the game over. If the user hits the replay button within a few seconds then everything goes well. But if the user sits on the game over place for over five seconds then the scene freezes. I am really confused as the app is idle