scenekit

Creating path using CGMutablePath creates line to wrong CGPoint

≯℡__Kan透↙ 提交于 2019-12-04 05:55:42
问题 I was planning to display information of AR object in screen with arrow in 2D. So I used projectPoint to get corresponding position of object in screen. I have this function to return convert 3D position of node to 2D and CGPoint to display info text in. func getPoint(sceneView: ARSCNView) -> (CGPoint, CGPoint){ let projectedPoint = sceneView.projectPoint(node.worldPosition) return (point, CGPoint(x: CGFloat(projectedPoint.x), y: CGFloat(projectedPoint.y)) ) } and this to draw line using

Subclassing SCNScene and SceneKit Editor

安稳与你 提交于 2019-12-04 05:49:02
问题 I have SCNScene subclass with a camera setup, that I want to use in all the subclasses. let scene01 = TheSubclassScene() let scene02 = TheSubclassScene(named:"art.scnassets/testScene.scn")! self.sceneArray.addObject(scene01) self.sceneArray.addObject(scene02) I want to change the scenes at runtime. This works when I create the scene in code but not with a scene from the SceneKit Editor. So scene01 is working but scene02 isn't. In the debugger I can see the two scenes in the array. One is of

Node group's position is reset at the start of SCNNode.runAction

时光怂恿深爱的人放手 提交于 2019-12-04 05:38:31
问题 I have some code that rotates several SCNNodes around the x axis when the screen is tapped like so: func handleTap(gestureRecognize: UIGestureRecognizer) { let sceneView = self.view as SCNView let slice = self.cubes[0...8] let container = SCNNode() for node: SCNNode in slice { container.addChildNode(node) } sceneView.scene!.rootNode.addChildNode(container) container.runAction(SCNAction.rotateByX(CGFloat(M_PI / 2), y: 0.0, z: 0.0, duration: 1), completionHandler: { () -> Void in println(

How to add transparency with a shader in SceneKit?

被刻印的时光 ゝ 提交于 2019-12-04 04:27:36
问题 I would like to have a transparency effect from an image, for now I just test with a torus, but the shader does not seem to work with alpha. From what I understood from this thread (Using Blending Functions in Scenekit) and this wiki link about transparency : (http://en.wikibooks.org/wiki/GLSL_Programming/GLUT/Transparency), GLBlendFunc is replaced by pragma transparency in SceneKit. Would you know what is wrong with this code? I created a new project with SceneKit, and I changed the ship

Write text on sphere surface SceneKit?

心不动则不痛 提交于 2019-12-04 04:14:10
I am wondering if there is a way to write text along a surface of a sphere object in SceneKit. I know I put a texture on the surface and achieve this kind of effect if I have an image, but I want to know if I can just add text dynamically somehow over the surface of the sphere. Any idea? EDIT: This works: let layer = CALayer() layer.frame = CGRectMake(0, 0, 100, 100) layer.backgroundColor = UIColor.orangeColor().CGColor var textLayer = CATextLayer() textLayer.frame = layer.bounds textLayer.fontSize = layer.bounds.size.height textLayer.string = "Test" textLayer.alignmentMode = kCAAlignmentLeft

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

夙愿已清 提交于 2019-12-04 03:49:27
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 across y-axis). I figured it out that there is very little I can do about the first 2 lines of code,

How to I turn off the ambient light in Scene Kit (with Swift)?

℡╲_俬逩灬. 提交于 2019-12-04 03:20:00
When I create a new Scene Kit Game using the Swift language, there is already some come which gives this result : I want to turn off the ambient light which is lighting the cube but I don't get how to do that since there isn't any light explicitly attached to any node. Her's the Game View Controller code : import SceneKit import QuartzCore class GameViewController: NSViewController { @IBOutlet var gameView: GameView override func awakeFromNib(){ // create a new scene let scene = SCNScene() // create and add a camera to the scene let cameraNode = SCNNode() cameraNode.camera = SCNCamera() scene

Render an SCNGeometry as a wireframe

醉酒当歌 提交于 2019-12-04 03:06:46
I'm using SceneKit on iOS and I have a geometry I want to render as a wireframe. So basically I want to draw only the lines, so no textures. I figured out that I could use the shaderModifiers property of the used SCNMaterial to accomplish this. Example of a shader modifier: material.shaderModifiers = [ SCNShaderModifierEntryPointFragment: "_output.color.rgb = vec3(1.0) - _output.color.rgb;" ] This example apparently simply inverts the output colors. I know nothing about this 'GLSL' language I have to use for the shader fragment. Can anybody tell me what code I should use as the shader fragment

using sks file with SKScene subclass

£可爱£侵袭症+ 提交于 2019-12-04 02:04:06
问题 I'm pretty exicted to see all that you can do with the SKS editor in Xcode 6. I'm able to lay out some sprites, lights, normals, etc... in the sks editor. I can then load the sks file in my view controller like such: -(void)viewWillLayoutSubviews { [super viewWillLayoutSubviews]; // Configure the view. SKView * skView = (SKView *)self.view; if (!skView.scene) { skView.showsFPS = YES; skView.showsNodeCount = YES; NSString *scenePath = [[NSBundle mainBundle] pathForResource:@"MyScene" ofType:@

Xcode 6.1 Swift issue - 'init()' is unavailable: superseded by import of -[NSObject init]

无人久伴 提交于 2019-12-04 01:35:33
I have just upgraded my Xcode to 6.1 an am now getting a strange compilation error. 'init()' is unavailable: superseded by import of -[NSObject init] I am subclassing SCNNode and have a optional references to other classes of the same type I am defining. i.e. import UIKit import SceneKit class BayNode: SCNNode { var leftBay:BayNode? var rightBay:BayNode? func addLeftBay() { leftBay = BayNode() // 'init()' is unavailable: superseded by import of -[NSObject init] } } Does anybody know how I can resolve this. Many Thanks I have same problem, one way I found to suppress the error is to explicitly