arkit

Replacement for ARKit in iOS10

孤者浪人 提交于 2019-11-28 13:08:38
I want to include ARKit in an app designed for iOS10+ where I replace ARKit with SceneKit if the iOS version is <11. Unfortunately it seems like there is no way to currently do this? Depending on how you've set your expectations, it is possible to use SceneKit as a "fallback" from ARKit -- specifically, from ARSCNView . What you can easily do is create a 3D content experience that appears "in the real world" via AR when running on an ARKit capable device, and in an entirely virtual setting (that is, rendered in 3D without a camera feed as background) when running without ARKit. Note: ARKit

Dragging SCNNode in ARKit Using SceneKit

元气小坏坏 提交于 2019-11-28 06:04:10
I have a simple SCNNode in ARKit and I am trying to drag it wherever I moved my finger on the phone. Here is my code. @objc func pan(recognizer :UIGestureRecognizer) { guard let currentFrame = self.sceneView.session.currentFrame else { return } var translation = matrix_identity_float4x4 translation.columns.3.z = -1.5 let sceneView = recognizer.view as! ARSCNView let touchLocation = recognizer.location(in: sceneView) let hitTestResult = sceneView.hitTest(touchLocation, options: [:]) if !hitTestResult.isEmpty { print("hit result") guard let hitResult = hitTestResult.first else { return } let

How do I programmatically move an ARAnchor?

我们两清 提交于 2019-11-28 05:33:08
I'm trying out the new ARKit to replace another similar solution I have. It's pretty great! But I can't seem to figure out how to move an ARAnchor programmatically. I want to slowly move the anchor to the left of the user. Creating the anchor to be 2 meters in front of the user: var translation = matrix_identity_float4x4 translation.columns.3.z = -2.0 let transform = simd_mul(currentFrame.camera.transform, translation) let anchor = ARAnchor(transform: transform) sceneView.session.add(anchor: anchor) later, moving the object to the left/right of the user (x-axis)... anchor.transform.columns.3.x

Xcode simd - issue with Translation and Rotation Matrix Example

…衆ロ難τιáo~ 提交于 2019-11-28 02:22:10
问题 Not only is using column-major vs row-major counter-intuitive, Apple's documentation on "Working with Matrices" further exacerbates the confusion by their examples of "constructing" a "Translate Matrix" and a "Rotation Matrix" in 2D. Translate Matrix Per Apple's Documentation () Translate A translate matrix takes the following form: 1 0 0 0 1 0 tx ty 1 The simd library provides constants for identity matrices (matrices with ones along the diagonal, and zeros elsewhere). The 3 x 3 Float

Reliable access and modify captured camera frames under SceneKit

二次信任 提交于 2019-11-28 01:42:58
问题 I try to add a B&W filter to the camera images of an ARSCNView, then render colored AR objects over it. I'am almost there with the following code added to the beginning of - (void)renderer:(id<SCNSceneRenderer>)aRenderer updateAtTime:(NSTimeInterval)time CVPixelBufferRef bg=self.sceneView.session.currentFrame.capturedImage; if(bg){ char* k1 = CVPixelBufferGetBaseAddressOfPlane(bg, 1); if(k1){ size_t x1 = CVPixelBufferGetWidthOfPlane(bg, 1); size_t y1 = CVPixelBufferGetHeightOfPlane(bg, 1);

ARKit Session Paused and Not Resuming

 ̄綄美尐妖づ 提交于 2019-11-27 23:53:59
In my ARKit app I am presenting a modal window. When I close the modal and go back to the ARSCNView then I find out that the session is paused due to this code: override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) // Pause the view's session sceneView.session.pause() } When I close the modal and go back to the ARKit camera view screen this code gets fired: override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) // Create a session configuration let configuration = ARWorldTrackingSessionConfiguration() // Run the view's session sceneView

ARKit: Placing an SCNText at a particular point in front of the camera

一笑奈何 提交于 2019-11-27 21:37:45
I've managed to get a cube (SCNNode) placed on a surface where the camera is pointed, however I am finding it very difficult to do the simple (?) task of also placing text in the same position. I've created the SCNText and subsequent SCNNode, however when I add it to the rootNode the text always seems to be added above my head and off the camera to the right (which tells me thats the global origin point). Even when I use the exact same values of position I used for the the cube, the SCNText node still gets placed above my head in the same spot. Apologies if this is a basic question, I've never

What does the “simd” prefix mean in SceneKit?

烂漫一生 提交于 2019-11-27 20:12:21
问题 There is a SCNNode category named SCNNode(SIMD) , which declares some properties like simdPosition , simdRotation and so on. It seems these are duplicated properties of the original/normal properties position and rotation . @property(nonatomic) simd_float3 simdPosition API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)); @property(nonatomic) simd_float4 simdRotation API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0), watchos(4.0)); What's the difference between position and

SceneKit shadow on a transparent SCNFloor()

徘徊边缘 提交于 2019-11-27 18:37:01
问题 I have a floor node , on which I need to cast shadow from directional light . This node needs to be transparent (used in AR environment). And this works fine when I use ARKit , but the same setup using SceneKit shows no shadow or reflection. How can I cast a shadow in SceneKit like this? The problem with SceneKit is caused by the fact, that I set sceneView.backgroundColor = .clear - but I need this behaviour in this app. Can this be somehow avoided? Sample code, demonstrating this issue

ARKit – Get current position of ARCamera in a scene

一笑奈何 提交于 2019-11-27 18:00:53
I'm in the process of learning both ARKit and Scenekit concurrently, and it's been a bit of a challenge. With a ARWorldTrackingSessionConfiguration session created, I was wondering if anyone knew of a way to get the position of the user's 'camera' in the scene session. The idea is I want to animate an object towards the user's current position. let reaperScene = SCNScene(named: "reaper.dae")! let reaperNode = reaperScene.rootNode.childNode(withName: "reaper", recursively: true)! reaperNode.position = SCNVector3Make(0, 0, -1) let scene = SCNScene() scene.rootNode.addChildNode(reaperNode) //