scenekit

Can I get the SCNView camera position when using allowsCameraControl?

心已入冬 提交于 2019-12-05 09:38:19
The SCNView documentation says that setting allowsCameraControl to YES does not update the camera node position when the user changes the point of view. Is there any way to get the user-modified camera parameters when the user changes the point of view? When you enable allowsCameraControl , SceneKit inserts its own camera node into the scene (as an immediate child of the scene's root node), and sets that node as the view's pointOfView . Read the properties of that node to find out the camera's position and orientation, or the properties of the node's camera attribute to find the camera's field

SceneKit : SCNPhysicsBody get current velocity

前提是你 提交于 2019-12-05 08:24:04
How can I get the current velocity of a SCNPhyisicsBody? The velocity property does always return (0.0, 0.0, 0.0), and the physicsBody of the prensetationNode of my SCNNode is also nil. You can get the "current" velocity with physicsBody.velocity But this is valid only within the "game loop" callbacks (updateAtTime, didApplyAnimations, didSimulatePhysics, will/didRenderScene). ...in your view controller, you have to use SCNSceneRendererDelegate protocol like class GameViewController: UIViewController,SCNSceneRendererDelegate{... and in the viewDidLoad method set the SCNView delegate to scnView

SceneKit, flip direction of SCNMaterial

狂风中的少年 提交于 2019-12-05 05:02:51
extremely new to SceneKit, so just looking for help here: I have an SCNSphere with a camera at the center of it I create an SCNMaterial, doubleSided, and assign it to the sphere Since the camera is at the center, the image looks flipped vertically, which when having text inside totally messes things up. So how can i flip the material, or the image (although later it will be frames from a video), any other suggestion is welcome. This solution, btw, is failing on me, normalImage is applied as a material (but the image is flipped when looking from inside the sphere), but assigning flippedImage

SceneKit nodes aren't changing position with scene's root node

北城以北 提交于 2019-12-05 04:02:26
问题 I'm using SceneKit with ARKit, and right now have a simple app where I tap on the screen and it adds an ARAnchor and a SCNNode to my scene. At some point, I'm going to want to move the entire scene, so I tried changing sceneView.scene.rootNode.position.x += 10 to test this out. If I call this on any particular node, that node does move appropriately. But calling this on rootNode , nothing happens, where I'd expect every child node (which is every node in the scene) to move along with it. Why

SKVideoNode as texture for SCNSphere

≡放荡痞女 提交于 2019-12-05 03:45:11
i'm trying to use a SKVideoNode as a video texture source for a SCNSphere within my SCNView I'm following this answer: SKVideoNode (embedded in SKScene) as texture for for Scene Kit Node not working And with my code (pasted at the end of the question) I do get a video and an audio playing. Issue is, the mapping only occurs on a quarter of the sphere (the all xy-positive quarter). The cameraNode is inside (0,0,0) the sphere and independent of the sphereNode. I do apply a scale to the sphere node, just to reverse the nodes of the texture: sphereNode.scale = SCNVector3Make(-1, 1, 1) but

iOS10 - can't render Sprite Kit scene within SceneKit with openGL

白昼怎懂夜的黑 提交于 2019-12-05 03:32:05
Since I've updated to iOS 10, I'm not able anymore to render a Sprite Kit scene to a Scene Node while using openGL for rendering. Things work fine with Metal. The error logs: "Failed to create IOSurface image (texture)" I used to be able to do something like: class ViewController: UIViewController { @IBOutlet weak var scnView: SCNView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. scnView.showsStatistics = true scnView.allowsCameraControl = true let scnScene = SCNScene() scnView.scene = scnScene print("scnView

Creating custom shapes from primitives

吃可爱长大的小学妹 提交于 2019-12-05 02:58:10
问题 I'm trying to create a custom Physics shape with combining primitive shapes. The goal is to create a rounded cube. The appropriate method seems to be init(shapes:transforms:) which I found here https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNPhysicsShape_Class/index.html#//apple_ref/occ/clm/SCNPhysicsShape/shapeWithShapes:transforms: I'm thinking this could be done with 8 spheres, 12 cylinders and a box in the middle. Can anyone provide an example of

Setting ARKit Orientation via Swift

萝らか妹 提交于 2019-12-05 02:54:18
问题 I am developing an ARKit app with OpenGL , so working directly with ARKit and not using SceneKit. By default, ARKit is set to landscape orientation, but I have been unable to track down any documentation or examples to rotate to portrait. SceneKit example works in portrait but the Metal example only works in landscape. Is it possible to change the ARKit tracking orientation? 回答1: I was able to solve this in the application logic by multiplying the camera matrix by a quaternion that is rotated

Most performant image format for SCNParticles?

被刻印的时光 ゝ 提交于 2019-12-05 02:51:55
I've been using 24bit .png with Alpha, from Photoshop, and just tried a .psd which worked fine with OpenGL ES, but Metal didn't see the Alpha channel. What's the absolutely most performant texture format for particles within SceneKit? Here's a sheet to test on, if needs be. It looks white... right click and save as in the blank space. It's an alpha heavy set of rings. You can probably barely make them out if you squint at the screen: exaggerated example use case: https://www.dropbox.com/s/vu4dvfl0aj3f50o/circless.mov?dl=0 // Additional points for anyone can guess the difference between the

How to rotate a SCNSphere using a pan gesture recognizer

*爱你&永不变心* 提交于 2019-12-05 02:18:01
问题 I created an SCNSphere so now it looks like a planet kind of. This is exactly what I want. My next goal is to allow users to rotate the sphere using a pan gesture recognizer. They are allowed to rotate it around the X or Y axis. I was just wondering how I can do that. This is what I have so far. origin = sceneView.frame.origin node.geometry = SCNSphere(radius: 1) node.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "world.jpg") let panGestureRecognizer = UIPanGestureRecognizer