scenekit

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

Drawing a line between two points using SceneKit

懵懂的女人 提交于 2019-11-27 18:50:17
I have two points (let's call them pointA and pointB) of type SCNVector3. I want to draw a line between them. Seems like it should be easy, but can't find a way to do it. I see two options, both have issues: Use a SCNCylinder with a very small radius, with length |pointA-pointB| and then position it/rotate it. Use a custom SCNGeometry but not sure how; would have to define two triangles to form a very thin rectangle perhaps? It seems like there should be an easier way of doing this, but I can't seem to find one. Edit: Using the triangle method gives me this for drawing a line between (0,0,0)

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

Cylinder Orientation between two points on a sphere, Scenekit, Quaternions IOS

两盒软妹~` 提交于 2019-11-27 18:26:00
问题 I've been trying to draw a cylinder between two points on the outer edge of a sphere using SceneKit. I have already produced a line between these two points using primitive geometry and openGL with SCNRendering Delegate, but now I need to produce a cylinder between these two (well, not just two, but any two 3D vectors that sit on the surface of the sphere). I've been working on this for about 3 days straight now, and I've gone through everything I could find on implementing Quaternions to

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) //

ARKit hide objects behind walls

你。 提交于 2019-11-27 17:15:43
How can I use the horizontal and vertical planes tracked by ARKit to hide objects behind walls/ behind real objects? Currently the 3D added objects can be seen through walls when you leave a room and/ or in front of objects that they should be behind. So is it possible to use the data ARKit gives me to provide a more natural AR experience without the objects appearing through walls? You have two issues here. (And you didn't even use regular expressions !) How to create occlusion geometry for ARKit/SceneKit? If you set a SceneKit material's colorBufferWriteMask to an empty value ( [] in Swift),

How do you convert Wavefront OBJ file to an SCNNode with Model I/O

主宰稳场 提交于 2019-11-27 16:49:00
问题 I've imported a Wavefront OBJ file from a URL and now I'd like to insert it into my scene (SceneKit) on my iOS 9 app (in Swift). What I've done so far is: let asset = MDLAsset(URL: localFileUrl) print("count = \(asset.count)") // 1 Any help converting this to a SCNNode would be appreciated. According to to Apple's docs: Model I/O can share data buffers with the MetalKit, GLKit, and SceneKit frameworks to help you load, process, and render 3D assets efficiently. But I'm not sure how to get

Using Blending Functions in Scenekit

≯℡__Kan透↙ 提交于 2019-11-27 15:25:38
I can't see an obvious way to change the blending function (glBlendFunc) for a scene kit node or geometry - it doesn't seem to be part of the material, and it isn't very obvious from the scene kit documentation how it organises render passes. Do I need to make a Render delegate for the node which just changes the GLblending mode, or do I need to somehow set up different render passes etc. (It's not obvious from the documentation how I even control things like render passes)? Will It Blend? - SceneKit Yes! In iOS 9 and OS X 10.11 (currently in beta), blendMode is an attribute on materials, so

How can i add a 2dView having text in ARkit scene iOS

假装没事ソ 提交于 2019-11-27 12:02:40
问题 How can i add a 2dView having text in ARkit scene iOS.How can i add that view in top of a node that won't rotate when we rotate the node. 回答1: You can add a SCNPlane and use a SCNLookAtConstraint to so that the plane always looks at the camera. You can create a custom material and set it's material properties to: A color (UIColor or CGColor), specifying a constant color across the material’s surface A number ( An image (UIImage or CGImage), specifying a texture to be mapped across the

How do I find my mouse point in a scene using SceneKit?

非 Y 不嫁゛ 提交于 2019-11-27 11:51:07
I have set up a scene in SceneKit and have issued a hit-test to select an item. However, I want to be able to move that item along a plane in my scene. I continue to receive mouse drag events, but don't know how to transform those 2D coordinates into 3D coordinate in the scene. My case is very simple. The camera is located at 0, 0, 50 and pointed at 0, 0, 0. I just want to drag my object along the z-plane with a z-value of 0. The hit-test works like a charm, but how do I translate the mouse point from a drag event into a new position in the scene for the 3D object I am dragging? You don't need