scenekit

SceneKit unproject Z documentation explanation?

爷,独闯天下 提交于 2019-12-06 13:35:44
问题 I am going through some SceneKit concepts and one I am trying to solidify in my head is unprojectPoint. I understand that the function will take a point in 2D and return a point in 3D (so one with the proper Z value). When I read the documentation I read this: /*! @method unprojectPoint @abstract Unprojects a screenspace 2D point with depth info using the receiver's current point of view and viewport. @param point The screenspace position to be unprojected. @discussion A point whose z

SCNCylinder diffuse.contents - Render different contents for both radius and height sections

岁酱吖の 提交于 2019-12-06 13:33:43
Is there any way to render different contents for both radius and height sections I am trying to use a cylinder shaped object and rendering image on it using diffuse.contents of SCMaterial instance myCustomMaterial.diffuse.contents = UIImage(named: "image") It renders this image on cylinder, however same image gets rendered on both height and render section. I would like to render a different image on height section than radius section. Is it possible? Use an array of materials. let cylinder = SCNCylinder(radius: 1.0, height: 1.0) let cylinderNode = SCNNode(geometry: cylinder) let fillMurray =

How to dynamically create annotations for 3D object using scenekit - ARKit in iOS 11?

℡╲_俬逩灬. 提交于 2019-12-06 12:03:54
问题 I am working on creating annotations using overlaySKScene something similar to this(https://sketchfab.com/models/1144d7be20434e8387a2f0e311eca9b1#). I followed https://github.com/halmueller/ImmersiveInterfaces/tree/master/Tracking%20Overlay to create the overlay. But in the provided example, they are creating only one annotation and it is static. I want to create multiple annotations dynamically based on the number of child nodes we have and also should be able to position annotation on top

scaling a SCNNode in runtime using the Pinch gesture

↘锁芯ラ 提交于 2019-12-06 11:52:35
问题 I am trying to scale and SCNNode in real time using the Pinch gesture: This is my current code let pinchGestureRecognizer = UIPinchGestureRecognizer(target: self, action: #selector(handlePinch(from:))) sceneView.addGestureRecognizer(pinchGestureRecognizer) @objc func handlePinch(from recognizer: UIPinchGestureRecognizer){ var pinchScale = recognizer.scale pinchScale = round(pinchScale * 1000) / 1000.0 sceneView.scene.rootNode.enumerateChildNodes { (node, stop) -> Void in if(node.name ==

SceneKit physics add velocity in local space

两盒软妹~` 提交于 2019-12-06 11:34:36
I am trying to manipulate the player node using physicsBody.velocity by adding or subtracting velocity to the axis for different directions. The problem is that I'm having trouble finding the method for applying that to local space or at least applying the velocity in relation to the direction the object is facing. In other words, it works fine if I have not rotated the object's node. If I do it will still add the velocity to the unrotated space. I know there is a way to add velocity to the current SCNVector3, but I cannot figure it out. if isZThrustPositive { if let velocity = self

Drag SceneKit Node Along X-Axis while maintaining velocity? Swift 3

╄→гoц情女王★ 提交于 2019-12-06 11:27:35
Swift 3, SceneKit: In my game, I have an SCNSphere node in the center of the screen. The sphere drops by gravity onto an SCNBox node, and a velocity of SCNVector3(0,6,0) is applied to it once it collides with the box. A new box is created and moves forward (z+) towards my camera and towards the sphere as well. The sphere rises, peaks, and then falls back down (by gravity) towards the new box, and when it collides with the new box, a velocity of SCNVector(0,6,0) is applied to it. This process repeats continuously. A sphere that repeatedly bounces on a new approaching box, basically. Instead of

SceneKit view renders as phong instead of physically based materials

别来无恙 提交于 2019-12-06 11:21:10
I have several objects in my scene, all of which had the "lighting model" of their material set to be physically based. When I run the app, the view I get looks nothing like the scene editor - it instead looks more like Phong materials. Is there a root node I need to change in order to have it render physically based from the get-go? I'm new to objective-c, so I'm not sure if I need to set the lighting model of the root node to physically based, and if so, how I would access the root node (and furthermore, can the root node even have a lighting model attribute since it itself is not renderable

Why would Xcode show MUCH more memory use than Instruments for SceneKit app?

安稳与你 提交于 2019-12-06 10:48:46
I'm trying to debug why our SceneKit-based app is using so much memory but Xcode and Instruments / Allocations seem to have very different values for the amount of memory being used. When I look in Xcode I see something like 600 MB but when I transfer the same running session over to Instruments / Allocations, I see a very different number for persistent bytes, like 150 MB . Which one is correct? Why the difference? Are they measuring different things? (Regardless of whether I Transfer an Xcode debug session or start fresh in Instruments, it doesn't seem to make much difference.) The reason

How to use a shaderModifier to alter the color of specific triangles in a SCNGeometry

喜夏-厌秋 提交于 2019-12-06 10:20:09
问题 First, before I go on, I have read through: SceneKit painting on texture with texture coordinates which seems to suggest I'm on the right track. I have a complex SCNGeometry representing a hexasphere. It's rendering really well, and with a full 60fps on all of my test devices. At the moment, all of the hexagons are being rendered with a single material, because, as I understand it, every SCNMaterial I add to my geometry adds another draw call, which I can't afford. Ultimately, I want to be

Is refraction in SceneKit possible?

旧城冷巷雨未停 提交于 2019-12-06 10:16:51
问题 Is it possible to make a shape that passes through light so you can see through it with the light bent due to refraction? Like a lens or a glass (or water)? 回答1: Yes, everything is possible with the amazing power of Physics ! You'll need to create your own shader though. From Wikipedia: In the field of computer graphics, a shader is a computer program that is used to do shading: the production of appropriate levels of color within an image, or, in the modern era, also to produce special