scenekit

ARKit: How to tell if user's face is parallel to camera

痞子三分冷 提交于 2019-12-22 12:02:30
问题 In my Swift / ARKit / SceneKit project, I need to tell if the user's face in front-facing camera is parallel to the camera. I was able to tell horizontal parallel by comparing the left and right eyes distance (using faceAnchor.leftEyeTransform and the worldPosition property) from the camera. But I am stuck on vertical parallel. Any ideas, how to achieve that? 回答1: Assuming you are using ARFaceTrackingConfiguration in your app, you can actually retrieve the transforms of both the ARFaceAnchor

Determine which side of SCNBox got touched, Scene Kit ios

﹥>﹥吖頭↗ 提交于 2019-12-22 11:24:19
问题 I am using Scene Kit and have created an SCNBox. On the front face of the box I want it so "A" happens if the left side of the front face gets clicked, and "B" happens if the right side of the front face gets clicked. How can I achieve this. I checked on stack but most answers cover if a node gets touched, not part of a node. 回答1: SCNHitTestResult has a geometryIndex that will give you the index of the geometry element that was hit (i.e. the cube face). It also has a faceIndex property that

Metal shader in SceneKit to outline an object

对着背影说爱祢 提交于 2019-12-22 10:55:30
问题 I'm playing around and trying to implement Metal shader in SceneKit that will outline an object. The idea is to draw an outline (or silhouette) similar to this image found in this blogpost (the blogpost doesn't contain any code): I'm new to SceneKit and Metal shaders so I'm able just to draw some geometry and write simple vertex or fragment shader. I'm curious how can I achieve this kind of effect? Is it done in multiple passes? Cheers! 回答1: The basic idea here is to clone the "selected" node

SceneKit flattenedClone - incorrect use of objc_storeWeak() and objc_loadWeak() error

[亡魂溺海] 提交于 2019-12-22 10:49:57
问题 I am building a simple game in SceneKit. It's a car racing game on a highway. My lane is a SCNNode which holds children that are actually flattened clones of other static non-moving geometry models (vegetation, grass roadside, etc.). The problem is happening when I remove parts of the road that are invisible in camera by simply: func removeLastLane() { guard let laneNode = lanes.first else { return } if lanes.count > 0 { lanes.removeFirst() } laneNode.removeFromParentNode() } In the console

Explaining in Detail the ScnVector4 method

梦想的初衷 提交于 2019-12-22 09:24:01
问题 I am using 3ds max for a long time and I know xyz axis. what I see in xcode in rotation the scnnode what made my mind blowed up is w component of scnvector4. Can someone explain in detail how to use this method because I searched a lot of time but I can't make my object spin as I desire. anyone can help to make him spin to his back in 180 degree but I will appreciate if someone explain more for further rotations, Knowing that I saw this link but I didn't understand something. http://www

SceneKit: isResting never returns true

牧云@^-^@ 提交于 2019-12-22 09:20:11
问题 I am trying to make an app that uses 3D physics and detects when the various nodes in the scene have all come to rest. The logical way to do this would seem to be testing their isResting property on their physics body. However, no matter how stationary the objects are, this value is never set. I have checked that allowsResting is true and am testing the attribute as follows, but I have never seen even one object 'at rest' despite logging out its status on each update. I've also tried putting

How to change SCNPlane color as clear color

ε祈祈猫儿з 提交于 2019-12-22 08:12:51
问题 I am working on a ARKit project which needs Ripple animation effect when tapped on Horizontal Plane. For that I have took UIView object and pass that as contents for material of SCNPlane object. I have added Ripple animation to UIView object. Everything works fine. But I can't change the SCNPlane colour to clear color. I can use transparency property for the material. But it is hiding Ripple animation too. So, what I need here is, the background colour of SCNPlane object should be transparent

SKVideoNode as texture for SCNSphere

为君一笑 提交于 2019-12-22 04:17:17
问题 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

Most performant image format for SCNParticles?

我怕爱的太早我们不能终老 提交于 2019-12-22 04:12:16
问题 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

Adding custom game logic to Scene Kit (Swift)

不羁岁月 提交于 2019-12-22 00:51:02
问题 I need to add a game loop to my GameViewController (From the Swift "Game" template for iOS development) in order to create an application and found this reference page explaining how to do this: https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNSceneRendererDelegate_Protocol/ However when I try to set the delegate of the SCNView to be the ViewController it throws up warnings and errors (inside viewDidLoad()): gameView.delegate = self Where gameView is