scenekit

Can't display 3d file from cache directory

无人久伴 提交于 2019-12-05 20:53:14
Can you please help me determine the problem here? It seems that I can't display the 3d file from cache directory. I'm having this error SceneKit IO: error, COLLADA files are not supported on this platform. The zip file im saving in the cache directory contains .dae file and .png for the texturee. With Scene Kit you can: Import COLLADA 3D objects and build scenes composed by cameras, lights, and meshes. https://developer.apple.com/library/mac/documentation/3DDrawing/Conceptual/SceneKit_PG/Introduction/Introduction.html Thanks. dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE

Could not cast value of type 'UIView' to 'SCNView'

拟墨画扇 提交于 2019-12-05 20:31:20
App was building fine until I started adding buttons to the storyboard then I got the above error. It stops at this line of code inside my GameViewController. let scnView = self.view as! SCNView The storyboard itself has its custom class set to GameViewController (theres no option for SCNView). GameViewController itself inherits from UIViewController. Im using Xcode7.2. Make sure to also import SceneKit at the top of the file. import SceneKit Open the “Main.storyboard” File. Select ViewController -> View go to “Identity Inspector” and change the Class field to SCNView. SceneKit Help If you are

ARKit - place a SCNPlane between 2 vector points on a plane in Swift 3 [duplicate]

人走茶凉 提交于 2019-12-05 20:15:33
This question already has an answer here: Scenekit shape between 4 points 1 answer Similar to some of the measuring apps you can see being demonstrated in ARKit, I have a plane with 2 marker nodes on it and a line drawn between the 2. What I need though is an SCNPlane between the 2. So, if your original was the floor and you put a marker either side of a wall, you could represent the physical wall with a SCNPlane in your AR world. Currently I'm placing the line with the following code: let line = SCNGeometry.lineFrom(vector: firstPoint.position, toVector: secondPoint.position) let lineNode =

SceneKit Rigged Character Animation increase performance

落爺英雄遲暮 提交于 2019-12-05 19:42:09
I have *.DAE files for characters each has 45-70 bones, I want to have about 100 animated characters on the screen. However when I have ~60 Characters the animations takes ~13ms of my update loop which is very costly, and leaves me almost no room for other tasks. I am setting the animations "CAAnimationGroup" to the Mesh SCNNode when I want to swap animations I am removing the previous animations with fadeOut set to 0.2 and adding the new Animation with FadeIn set to 0.2 as well. -> Is it bad ? Should I just pause a previous animation and play a new one ? or is it even worse? Is there better

Mapping a vector across the y-axis if it has 4 components

萝らか妹 提交于 2019-12-05 19:01:07
问题 I am applying a force and a torque on an node. This is my code: myNode?.physicsBody?.applyForce(SCNVector3Make(0, -6, 4), atPosition: SCNVector3Make(0, 1, -1), impulse: true) myNode?.physicsBody?.applyForce(SCNVector3Make(0, -2, 10), impulse: true) myNode?.physicsBody?.applyTorque(SCNVector4Make(4, 2, 2.5, 1.6), impulse: true) The object now falls down and moves from left to right afterwards. I want it fall down and move from right to the left(basically a reflection of the first movement

How to programmatically wrap png texture around cube in SceneKit

北城以北 提交于 2019-12-05 18:49:31
I'm new to SceneKit... trying to get some basic stuff working without much success so far. For some reason when I try to apply a png texture to a CNBox I end up with nothing but blackness. Here is the simple code snippet I have in viewDidLoad: let sceneView = (view as SCNView) let scene = SCNScene() let boxGeometry = SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 1.0) let mat = SCNMaterial() mat.locksAmbientWithDiffuse = true mat.diffuse.contents = ["sofb.png","sofb.png","sofb.png","sofb.png","sofb.png", "sofb.png"] mat.specular.contents = UIColor.whiteColor() boxGeometry

Scenekit PhysicEngine follow rolling ball

∥☆過路亽.° 提交于 2019-12-05 18:44:33
I want to follow a rotating sphere in Apple's SceneKit. I've added an LookAt Constraint to the camera and as the sphere falls down the cam aleays points to it but if the sphere rolls away the camera stays at its current position. I want the cam to follow this sphere like in a third persond shooter with a predefined distance to it. If I make the cam a childNode of the sphere the cam "orbits" around it as the ball is rolling. Any ideas how I can follow the ball with the cam? It's pretty simple. You just need to change the camera node's position at each frame to the ball's presentationNode plus

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

拜拜、爱过 提交于 2019-12-05 18:29:05
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 the error appears: objc[37558]: __weak variable at 0x600002701cf0 holds 0x600002701d99 instead of

Explaining in Detail the ScnVector4 method

我是研究僧i 提交于 2019-12-05 18:20:59
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.cprogramming.com/tutorial/3d/rotationMatrices.html I believe that your are trying to rotate nodes ( rotation

SceneKit - Map cube texture to box

风流意气都作罢 提交于 2019-12-05 17:47:27
I've a texture for a cube that looks like I'd like to use it on a cube in a SceneKit view. I'm using the SceneKit geometry SCNBox for that. Unfortunately, the result is that the texture is projected entirely on each face, instead of using only the corresponding part: let videoGeometry = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0) videoGeometry.firstMaterial?.isDoubleSided = true videoGeometry.firstMaterial?.diffuse.contents = UIImage(named: "test")! I know I can use shader modifiers on the geometry but I'm not sure where to get started. Since the texture is currently used six