scenekit

How to get the real position of a sub node in SceneKit after rotation?

放肆的年华 提交于 2019-12-01 16:28:44
I am developing a scene with SceneKit. I have a main node with a subnode: // Main node SCNNode* planet = [SCNNode node]; planet.geometry = [SCNSphere sphereWithRadius:2]; planet.position = SCNVector3Make(0, -3, 5); // sub-node SCNNode* satellite = [SCNNode node]; satellite.geometry = [SCNSphere sphereWithRadius:0.4]; satellite.position = SCNVector3Make(4, 0, 0); [planet addChildNode:satellite]; [scene.rootNode addChildNode:planet]; I use a NSTimer to make some actions and some animations. In the timer event I do that: planetRotation += 0.1; planet.rotation = SCNVector4Make(0,1,0,

Getting an SCNPhysicsVehicle's Position

*爱你&永不变心* 提交于 2019-12-01 15:30:09
I am working on a basic racing game using Apple's SceneKit and am running into issues simulating a car. Using the SCNPhysicsVehicle behavior, I am able to properly set up the car and drive it using the documented methods. However, I am unable to get the car's position. It seems logical that the SCNPhysicsVehicle would move the SCNNodes that contain the chassis and the wheels as the car moves but the SCNNodes remain at their original position and orientation. Strangely enough, the chassis' SCNPhysicsBody's velocity remains accurate throughout the simulation so I can assume that the car's

SceneKit: too much memory persisting

本秂侑毒 提交于 2019-12-01 13:23:55
I’m out of ideas here, SceneKit is piling on the memory and I’m only getting started. I’m displaying SNCNodes which are stored in arrays so I can separate components of the molecule for animation. These trees model molecules of which I will ultimately have maybe 50 to display, say one per “chapter”. The issue is when I move to another chapter the molecules from previous chapters persist in memory. The molecule nodes are trees of child nodes. About half of the nodes are empty containers for orientation purposes. Otherwise, the geometries are SCNPrimitives (spheres, capsules, and cylinders).

Scene Kit: projectPoint calculated is displaced

£可爱£侵袭症+ 提交于 2019-12-01 12:44:26
I am trying do draw an frame over a sphere on the parent view of the scene, but for some reason the points converted by SCNScene.projectPoint method are displaced. To make it simple, i created a sphere at the center of the scene with 2 radius. The sphere is attached to the root node, so top left corner on world coordinates is at (-2,-2,0) point. Here the complete code: func sphereWithFrame(){ var v1 = SCNVector3(x: 0,y: 0,z: 0) var v2 = SCNVector3(x: 0,y: 0,z: 0) let topSphere = SCNSphere(radius: 2.0) topSphere.firstMaterial!.diffuse.contents = UIColor.greenColor() let topSphereNode = SCNNode

Convert Scene's (x, y) to screen's (x, y)

限于喜欢 提交于 2019-12-01 12:17:35
问题 I have an application built with SceneKit that is currently displaying several nodes. I can figure out which node is pressed and want to use that to make a label appear below the Node that was touched. Now, when I set the label's center the following way... nameLabel.center = CGPointMake(CGFloat(result.node.position.x), CGFloat(result.node.position.y+20) …it appears in the upper left corner since the node is on (1, 0) . What I figured is that the sceneView's (0, 0) is in the center of the

How do I use a web mercator projection map for SCNMaterial on an SCNShere geometry?

时光毁灭记忆、已成空白 提交于 2019-12-01 11:23:01
I have a simple globe view in my app. Previously we were using WhirlyGlobe, but have opted to use SceneKit instead. Everything works great and we are happy with it EXCEPT we used map tiles in Whirly Globe and the do not work (as far as I can tell) in SceneKit. We want to use that map (tiled, split or as one file) on an SCNSphere geometry. I copied the satellite map that Apple uses in their documentation and it looks right, but is not the map we need. Our map is in web/sphere mercator projection and it looks bad in SceneKit on my sphere. I do not* know what the 2x1 projection Apple is using is

Scene Kit: projectPoint calculated is displaced

吃可爱长大的小学妹 提交于 2019-12-01 11:21:42
问题 I am trying do draw an frame over a sphere on the parent view of the scene, but for some reason the points converted by SCNScene.projectPoint method are displaced. To make it simple, i created a sphere at the center of the scene with 2 radius. The sphere is attached to the root node, so top left corner on world coordinates is at (-2,-2,0) point. Here the complete code: func sphereWithFrame(){ var v1 = SCNVector3(x: 0,y: 0,z: 0) var v2 = SCNVector3(x: 0,y: 0,z: 0) let topSphere = SCNSphere

Scenekit detecting User tapped object

风流意气都作罢 提交于 2019-12-01 11:01:41
I recently started using scenekit for scenekit in iOS 8. I am facing difficulty in detecting whether the user has tapped or pressed on the object. Is there any way to do that? See the documentation for the hitTest method. Call that from wherever you're handling touch events to get a list of 3D scene objects/locations "under" a 2D screen point. An easy way to get sample code that shows the hitTest in action is to create a sample app using the Game template in XCode6. Create a new project, select the "Game" template. The hitTest code should be there in the implementation of: - (void) handleTap:

What is the type of SCNVector3 components? CGFloat or Float?

我只是一个虾纸丫 提交于 2019-12-01 10:47:01
The apple documentation gives the declaration of SCNVector3 : typedef struct SCNVector3 { CGFloat x, y , z; } SCNVector3; Or when trying to write an overload function : func * (left: SCNVector3, right: CGFloat) -> SCNVector3 { return SCNVector3Make(left.x * right, left.y * right, left.z * right) } I get the "cannot invoke ' ' with an argument list of type" error. Aren't left.x, left.y and left.z supposed to be CGfloat ? How and when is it decided if CGFloat will be a double or a float? In the iOS 8.1 SDK headers, the SCNVectorX types are based on Float , as can be seen by command-clicking on

SceneKit: too much memory persisting

爱⌒轻易说出口 提交于 2019-12-01 10:25:01
问题 I’m out of ideas here, SceneKit is piling on the memory and I’m only getting started. I’m displaying SNCNodes which are stored in arrays so I can separate components of the molecule for animation. These trees model molecules of which I will ultimately have maybe 50 to display, say one per “chapter”. The issue is when I move to another chapter the molecules from previous chapters persist in memory. The molecule nodes are trees of child nodes. About half of the nodes are empty containers for