scenekit

Load uncompressed collada file using iOS Scene Kit

佐手、 提交于 2019-11-28 11:48:00
问题 I need to load a collada file I downloaded on iOS, I intend to use Scene Kit to do it. But reading the documentation I found out that XCode compresses the collada files on compilation time, and Scene Kit can only load the compressed files. After some research I ran into this article where the author was able to find the scripts XCode uses and compress the files using them. The problem is that I'm not being able to run them on my server. So my question is: Is there any other way to load

SceneKit shader modifiers with GLSL arrays

半城伤御伤魂 提交于 2019-11-28 11:06:33
问题 I'm trying to pass in an array of points into a shader modifier in SceneKit, but I can't work out the correct syntax. In my shader extension code I have: uniform vec2 points[100]; If I call… material.setValue(NSValue(point: CGPoint(x: 100.5, y: 50.5)), forKey: "points") …then it sets the value of points[0] , which makes me think that maybe it's not possible. I've tried lots of other combinations for both the key and the value, but nothing seems to work. Is there a better way to do this? My

Using MPMoviePlayerController as texture in SceneKit

你离开我真会死。 提交于 2019-11-28 10:40:53
问题 I created a cube in scenekit and tried to use an instance of an MPMoviePlayerController as its material. It kind-ish works but not exactly well: the video seems to be very jumpy, like it would be jumping between the video frames (basically replaying frames from the beginning till the last point played). The sound is ok. I made a short screencapture of what's happening, I guess it is obvious from the video: Youtube vid This is the code that handles the mapping to the cube and the creation of

Inconsistent SceneKit framerate

情到浓时终转凉″ 提交于 2019-11-28 09:14:44
I'm seeing very inconsistent frame rates in the SceneKit starter project. Sometimes it runs constantly at 60 fps (12ms rendering, 6ms metal flush), and sometimes it runs constantly at 40 fps (20ms rendering, 6ms metal flush), no more, no less. The frame rate changes randomly when I reopen the app, and will stay at that frame rate until the next reopen. I tried switching to OpenGL ES, and while it seems to fix it in the starter project, I still see those drops in my real app. The starter project is unmodified (rotating ship), and I'm testing it on Xcode 7.0 and iPad Mini 4 running iOS 9.0.1. I

SCNCamera limit arcball rotation

谁都会走 提交于 2019-11-28 08:42:55
I have a scene setup with SCNCamera that rotates around an object. What would be the best way to limit the extents of rotation the camera can achieve around the object? Example: instead of being able to rotate around a whole sphere, how would I limit rotation to a single hemisphere? My first attempt was to see if there was any clamps for .allowsCameraControl. Could not find anything. I then tried adapting c# Unity : mouse orbit script , no luck. Some pointers on how to approach or solve this would great. Boilerplate Arcball thanks to this answer. var lastWidthRatio: Float = 0 var

Dragging SCNNode in ARKit Using SceneKit

元气小坏坏 提交于 2019-11-28 06:04:10
I have a simple SCNNode in ARKit and I am trying to drag it wherever I moved my finger on the phone. Here is my code. @objc func pan(recognizer :UIGestureRecognizer) { guard let currentFrame = self.sceneView.session.currentFrame else { return } var translation = matrix_identity_float4x4 translation.columns.3.z = -1.5 let sceneView = recognizer.view as! ARSCNView let touchLocation = recognizer.location(in: sceneView) let hitTestResult = sceneView.hitTest(touchLocation, options: [:]) if !hitTestResult.isEmpty { print("hit result") guard let hitResult = hitTestResult.first else { return } let

SceneKit camera, how to compensate for euler rules (orientation) changes

ぐ巨炮叔叔 提交于 2019-11-28 05:04:01
问题 Maybe this is more of a math question, but I am hoping somebody can help me understand how I would compensate for changes to my camera's orientation. What I would like to do is to be able to move my camera around the scene using game-like controls. I have W S A D keys set up to move the camera forward, backward, left and right respectively. I do this by changing the values of the camera node's position vector. I also have the right left up and down arrow keys mapped to turning and tilting the

SCNBox different colour or texture on each face

你离开我真会死。 提交于 2019-11-28 04:44:33
I'm new to iOS development and I've got myself stumped. I am trying to render a cube using SceneKit that has a different colour for each face. This is what I've got so far: func sceneSetup() { // 1 let scene = SCNScene() // 2 let BoxGeometry = SCNBox(width: 0.9, height: 0.9, length: 0.9, chamferRadius: 0.0) BoxGeometry.firstMaterial?.diffuse.contents = UIColor.redColor() let cube = SCNNode(geometry: BoxGeometry) cube.position = SCNVector3(x: 0, y: 0, z: -1) scene.rootNode.addChildNode(cube) // 3 sceneView.scene = scene sceneView.autoenablesDefaultLighting = true sceneView.allowsCameraControl =

Draw SceneKit object between two points

我的未来我决定 提交于 2019-11-28 04:36:02
Having made some progress in the geometry side of things I'm moving on to putting together an entire scene. That scene has a couple dozen objects, each defined by a bounding cube whose corners are specified by two SCNVector3s (originally two sets of x,y,z). Here's an example of what I have so far - it's an 11-element log-periodic antenna, like the old school TV antennas from the 70s. Each of the grey lines is an "element", typically made of aluminum rod. I used SCNCylinders from +ve to -ve Y and the entire thing is less than 100 lines (SK is pretty amazing). The problem is what happens if the

How can I export DAE files for use in Scene Kit without seeing “untitled-animations”?

ぃ、小莉子 提交于 2019-11-28 03:43:33
I am trying to load animations created in Cheetah 3D and Blender 3D into Scene Kit, but all I get is a bunch of "untitled-animations" with each one being the same animation. Does anyone know how to properly export these from Blender or Cheetah 3D so that Scene Kit can use them? FlippinFun I dug into this because it was annoying me too. All of the "untitled animations" are individual animations for each bone. You can get the id from the attributes inspecter in the panel on the right side of xcode. Using swift like so, you can get your animation. let urlOfScene = Bundle.main.url(forResources: