scenekit

CGImage related memory leak in SceneKit application

房东的猫 提交于 2020-01-07 03:00:32
问题 I am writing a 3d game using Scene Kit. When I used Leaks profile in Instruments, I find leaks exist. For the first red cross icon, it says 51 new leaks. Also if you see further down the leak checks area, there are grayed out dashed icons which say no new leaks. To put it in context, I try to recreate a scene after one unit of play is completed and present that using presentScene... . That would crash after 4 or 5 units of play. I was getting memory warnings and hence I used the leaks profile

How to save and load apps last data+view? (without NSCoding?)

天涯浪子 提交于 2020-01-06 19:52:52
问题 I am using Swift 2 and Xcode 7 for iOS 9.2 My, basically finished, game-app creates a complex view ( SceneKit + SpriteKit + random variables + game progress). When I switch to the Menu and back, everything stays the same (just switching views or scenes). However, when the application is closed, it restarts with the main.storyboard's entry-point and my data is gone. The app should open the same state it was closed on. I already tried archiving relevant data with NSCoding to save/load the scene

ARKit Ball Pass through Torus hole collision detection

前提是你 提交于 2020-01-06 06:35:19
问题 I have one ball node and one SCNTorus I am able to pass ball thorough torus node. I have added collision and I am able to detect collision when ball pass through the torus using SCNPhysicsContactDelegate But public func physicsWorld(_ world: SCNPhysicsWorld, didEnd contact: SCNPhysicsContact) called multiple times. public func physicsWorld(_ world: SCNPhysicsWorld, didEnd contact: SCNPhysicsContact) { // print("Ended collision ") print(contact.nodeA.name) print(contact.nodeB.name) print(world

Scenekit - convertTransform of a rotated sub-subNode based on world axes

爱⌒轻易说出口 提交于 2020-01-06 06:08:58
问题 I have a following scene: [Root Node] | [Main Container] | | [Node A Wrapper] [Node B Wrapper] | | [Node A] [Node B] I've set up pan gesture recognizers in a way that when u pan in open space, the [Main Container] rotates in the selected direction by +/- Double.pi/2 (90deg). When the pan starts on one of the subnodes A, B (i'm hittesting for this on touchesBegan), i want to rotate the subnode along the direction of world axis (again 90deg increments). I'm rotating the [Main Container] using

Find 3d coordinates of a point on a line projected from another point in 3d space

戏子无情 提交于 2020-01-06 05:45:07
问题 Working in Swift, ARTKit / SceneKit I have a line AB in 3d and I have xyz coordinates of both points A and B. I also have a point C and I know its xyz coordinates too. Now, I want to find out the xyz coordinates of point D on line AB; given that CD is perpendicular to AB. What would be a simple way to do it in Swift. 回答1: Parameterize the line AB with a scalar t : P(t) = A + (B - A) * t` The point D = P(t) is such that CD is perpendicular to AB , i.e. their dot product is zero: dot(C - D, B -

How to get BoundingBox after rotation, scale?

China☆狼群 提交于 2020-01-06 04:56:08
问题 SCNVector3 min, max; [self getBoundingBoxMin:&min max:&max]; the returned min and max value it's base on raw size 回答1: You can ask for the bounding box of the parentNode for the node's transform to be taken into account. 回答2: SCNVector3 min, max; [self getBoundingBoxMin:&min max:&max]; SCNVector3 cMin = [self convertVector:min toNode:rootNode]; SCNVector3 cMax = [self convertVector:max toNode:rootNode]; 来源: https://stackoverflow.com/questions/57470541/how-to-get-boundingbox-after-rotation

Prevent SCNNode from going out of the screen

强颜欢笑 提交于 2020-01-06 03:29:08
问题 I'm playing around with ARKit and SceneKit. I have a node A - this is the only node that I've added to the rootNode. Node A is allowed to move freely by moving the phone around, except that it's not allowed to leave the screen. To achieve that (prevent node A from leaving the screen), I can think of the following ways: Add a transform constraint to node A: I've tried to do it in the following manner: [SCNTransformConstraint transformConstraintInWorldSpace:false withBlock:^SCNMatrix4(SCNNode *

DAE file specified in attribute inspector is not loaded by UIViewController

。_饼干妹妹 提交于 2020-01-05 10:17:08
问题 I created a new project using the iOS game template on Xcode 6.1.1, the options were: Language: Swift Game Technology: SceneKit Device: Universal The app runs ok "as is", but now I want to specify the .dae file directly from the Interface Builder on Xcode, so I changed the method in the view controller like this: override func viewDidLoad() { super.viewDidLoad() let scnView = self.view as SCNView // customize the loaded scene if let scene = scnView.scene { //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

SceneKit SCNGeometryElement TriangleStrip vs triangles

放肆的年华 提交于 2020-01-05 06:27:36
问题 I have draw a scene which contains a SCNGeometryElement object. (it is a terrain. I have 2 triangles per grid item) In order to optimize, i decided to remplace my triangle primitive by TriangleStrip. But it does not give me the same result My Vertex array is a succession of 4 points: C D A B My indices array contains index of A, C, B and D So when i work with TriangleStrip, scene kit is supposed to draw ACB and CBD triangles. That is what is said in apple documentation. I am wondering what i

Custom Variable Declarations Using Metal With Scene Kit Shader Modifiers

假如想象 提交于 2020-01-05 04:58:53
问题 I am having difficulty passing uniforms to Scene Kit's shader modifiers. This seems to work fine when using OpenGL but not when using Metal. I have used SCNProgram successfully before but wanted to take advantage of SceneKit's tessellator instead of setting up compute shaders for tessellation. But I want to use the code I have already written in Metal rather than using OpenGL. There is unfortunately not a great deal of examples of how to do this. This Swift Playground illustrates how to do