scenekit

Rendering a SceneKit scene to video output

放肆的年华 提交于 2019-12-17 21:57:21
问题 As a primarily high-level/iOS dev, I'm interested in using SceneKit for animation projects. I've been having fun with SceneKit for some months now, despite it obviously being designed for 'live' interaction, I would find it incredibly useful to be able to 'render' an SKScene to video. Currently, I've been using Quicktime's screen recorder to capture video output, but (of course) the frame-rate drops in doing so. Is there an alternative that allows a scene to be rendered at its own pace and

Transform and Rotate in Scenekit

不想你离开。 提交于 2019-12-17 21:35:07
问题 I have a SCN Node that I have Transformed to a desired Rotation and Angle. I now want to rotate it infinitely on its new x-axis, but I can't seem to get it to rotate 360 degrees, it just shifts slightly. let spin = CABasicAnimation(keyPath: "rotation") spin.fromValue = NSValue(SCNVector4: SCNVector4(x: item.rotation.x, y: item.rotation.y, z: item.rotation.z, w: item.rotation.w)) spin.toValue = NSValue(SCNVector4: SCNVector4(x: Float(2*M_PI), y: item.rotation.y, z: item.rotation.z, w: item

Fish Eye Wide-angle with a Scene Kit Camera: Possible?

a 夏天 提交于 2019-12-17 20:48:22
问题 How do I get a distortion like what a fisheye lens does to a view with a SCNCamera in Scene Kit? Something like this kind of "bowing" of the imagery: // as Rickster pointed out, this kind of distortion is known as "Barrel Distortion". From the docs, this is the part that got me intrigued by the possibility of doing this kind of distortion with the camera: If you compute your own projection transform matrix, you can use this method to set it directly, overriding the transformation synthesized

Using shader modifiers to animate texture in SceneKit leads to jittery textures over time

爷,独闯天下 提交于 2019-12-17 20:39:55
问题 I'm writing a scene in SceneKit for iOS. I'm trying to apply a texture to an object using a sprite sheet. I iterate through the images in that sheet with this code: happyMaterial = [SCNMaterial new]; happyMaterial.diffuse.contents = happyImage; happyMaterial.diffuse.wrapS = SCNWrapModeRepeat; happyMaterial.diffuse.wrapT = SCNWrapModeRepeat; happyMaterial.shaderModifiers = @{ SCNShaderModifierEntryPointGeometry : @"_geometry.texcoords[0] = vec2((_geometry.texcoords[0].x+floor(u_time*30.0))/10

SCNCamera limit arcball rotation

℡╲_俬逩灬. 提交于 2019-12-17 18:42:31
问题 I have a scene setup with SCNCamera that rotates around an object. What would be the best way to limit the extents of rotation the camera can achieve around the object? Example: instead of being able to rotate around a whole sphere, how would I limit rotation to a single hemisphere? My first attempt was to see if there was any clamps for .allowsCameraControl. Could not find anything. I then tried adapting c# Unity : mouse orbit script, no luck. Some pointers on how to approach or solve this

Dragging SCNNode in ARKit Using SceneKit

六月ゝ 毕业季﹏ 提交于 2019-12-17 17:58:15
问题 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

SCNBox different colour or texture on each face

时光毁灭记忆、已成空白 提交于 2019-12-17 17:42:08
问题 I'm new to iOS development and I've got myself stumped. I am trying to render a cube using SceneKit that has a different colour for each face. This is what I've got so far: func sceneSetup() { // 1 let scene = SCNScene() // 2 let BoxGeometry = SCNBox(width: 0.9, height: 0.9, length: 0.9, chamferRadius: 0.0) BoxGeometry.firstMaterial?.diffuse.contents = UIColor.redColor() let cube = SCNNode(geometry: BoxGeometry) cube.position = SCNVector3(x: 0, y: 0, z: -1) scene.rootNode.addChildNode(cube) /

SCNBox different colour or texture on each face

浪子不回头ぞ 提交于 2019-12-17 17:42:08
问题 I'm new to iOS development and I've got myself stumped. I am trying to render a cube using SceneKit that has a different colour for each face. This is what I've got so far: func sceneSetup() { // 1 let scene = SCNScene() // 2 let BoxGeometry = SCNBox(width: 0.9, height: 0.9, length: 0.9, chamferRadius: 0.0) BoxGeometry.firstMaterial?.diffuse.contents = UIColor.redColor() let cube = SCNNode(geometry: BoxGeometry) cube.position = SCNVector3(x: 0, y: 0, z: -1) scene.rootNode.addChildNode(cube) /

ARKit – Get current position of ARCamera in a scene

浪尽此生 提交于 2019-12-17 15:25:24
问题 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

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

大城市里の小女人 提交于 2019-12-17 10:34:15
问题 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