scenekit

Cylinder Orientation between two points on a sphere, Scenekit, Quaternions IOS

强颜欢笑 提交于 2019-11-29 04:37:05
I've been trying to draw a cylinder between two points on the outer edge of a sphere using SceneKit. I have already produced a line between these two points using primitive geometry and openGL with SCNRendering Delegate, but now I need to produce a cylinder between these two (well, not just two, but any two 3D vectors that sit on the surface of the sphere). I've been working on this for about 3 days straight now, and I've gone through everything I could find on implementing Quaternions to make this happen, but as it stands, I can't get it to work. Academic articles, scientific studies, and

SceneKit shadow on a transparent SCNFloor()

时光怂恿深爱的人放手 提交于 2019-11-29 04:28:32
I have a floor node , on which I need to cast shadow from directional light . This node needs to be transparent (used in AR environment). And this works fine when I use ARKit , but the same setup using SceneKit shows no shadow or reflection. How can I cast a shadow in SceneKit like this? The problem with SceneKit is caused by the fact, that I set sceneView.backgroundColor = .clear - but I need this behaviour in this app. Can this be somehow avoided? Sample code, demonstrating this issue (works only on device, not in simulator): @IBOutlet weak var sceneView: SCNView! { didSet { sceneView.scene

iOS SpriteKit/SceneKit/Metal浅析

☆樱花仙子☆ 提交于 2019-11-29 02:49:54
【SpriteKit】 在iOS7中内置了新的SpriteKit框架,该框架主要用来开发2D游戏。是开发iOS和OS X 下的2D游戏引擎,可以使用OC或者Swift来进行开发。目前已经支持的内容包括:精灵、很酷的特效(例如视频、滤镜和遮罩),并且还集成了物理库等许多东西。首先指出在iOS中开发2D游戏SpriteKit并不是唯一的选择,我们先来看看SpriteKit的特点和优缺点: 1.特点: (1)提供了游戏引擎必备的图形渲染和动画API,可以通过这些API让精灵动起来; (2)使用传统的渲染和动画,允许在渲染每一帧之前处理该帧; (3)提供了声音播放; (4)提供的物理引擎; (5)与Xcode集成,可以更容易的创建基于Sprite Kit的游戏工程,调试也很方便; (6)可以使用Swift语言; 2.优点: (1)它是内置到iOS中的,因此并不需要下载额外的库或者其他的外部依赖,并且它是由苹果开发的,所以对他的支持和更新我们可以放心; (2)它内置的工具支持纹理和粒子; (3)它可以让你做一些其他框架难以做到的事情,例如把视频当做精灵一样处理,或者使用很酷的图形效果和遮罩。 3.缺点: (1)如果使用了SpriteKit,那么你将被iOS生态圈绑架,导致很难把游戏移植到Android等其他平台; (2)SpriteKit现在还处于初始阶段,提供的内容还不够丰富

How do you convert Wavefront OBJ file to an SCNNode with Model I/O

痞子三分冷 提交于 2019-11-29 02:31:50
I've imported a Wavefront OBJ file from a URL and now I'd like to insert it into my scene (SceneKit) on my iOS 9 app (in Swift). What I've done so far is: let asset = MDLAsset(URL: localFileUrl) print("count = \(asset.count)") // 1 Any help converting this to a SCNNode would be appreciated. According to to Apple's docs: Model I/O can share data buffers with the MetalKit, GLKit, and SceneKit frameworks to help you load, process, and render 3D assets efficiently. But I'm not sure how to get buffer from an MDLAsset into a SCNNode. Turns out this quite easy as many of the ModelIO classes already

ARKit – Drag a node along a specific axis (not on a plane)

↘锁芯ラ 提交于 2019-11-29 00:46:53
I am trying to drag a node exactly where my finger is on the screen on the Y -axis. But I don't find any way to do it, here is my current code. Do you have any idea? var movedObject:SCNNode? @objc func handlePan(_ recognizer: UIPanGestureRecognizer) { if recognizer.state == .began { let tapPoint: CGPoint = recognizer.location(in: sceneView) let result = sceneView.hitTest(tapPoint, options: nil) if result.count == 0 { return } let hitResult: SCNHitTestResult? = result.first movedObject = hitResult?.node //.parent?.parent } else if recognizer.state == .changed { if (movedObject != nil) { let

Camera pose estimation from homography or with solvePnP() function

↘锁芯ラ 提交于 2019-11-28 23:35:32
I'm trying to build static augmented reality scene over a photo with 4 defined correspondences between coplanar points on a plane and image. Here is a step by step flow: User adds an image using device's camera. Let's assume it contains a rectangle captured with some perspective. User defines physical size of the rectangle, which lies in horizontal plane (YOZ in terms of SceneKit). Let's assume it's center is world's origin (0, 0, 0), so we can easily find (x,y,z) for each corner. User defines uv coordinates in image coordinate system for each corner of the rectangle. SceneKit scene is created

SceneKit. Which way is up?

冷暖自知 提交于 2019-11-28 23:24:46
问题 It seems that most 3D authoring applications use Z as the 'Up' axis. While SceneKit uses Y as the 'Up' axis. SceneKit allows you to load scenes as Collada .DAE files. When loading a Scene via either: SCNScene(named: String?, inDirectory: String?, options: [NSObject : AnyObject]?) or SCNSceneSource(URL url: NSURL!, options: [NSObject : AnyObject]!) You can specify options including SCNSceneSourceConvertToYUpKey and SCNSceneSourceConvertUnitsToMetersKey. Setting these accordingly, I expected

How to set contents of scenekit background to cube map

陌路散爱 提交于 2019-11-28 20:53:44
I am trying to set the background contents of a scene to a skybox effect using about array of 6 images. I have created the array of images in the correct order, I know I need to then use + (instancetype) materialPropertyWithContents:(id)contents However I'm struggling to work out how and where exactly I use that class method to return the property containing the cube map. SCNScene's "background" property is of the SCNMaterialProperty class. So you can directly set it's contents to an array of 6 images to setup your skybox (see SCNScene.h). aScene.background.contents = @[@"Right.png", @"Left

How can i add a 2dView having text in ARkit scene iOS

我的梦境 提交于 2019-11-28 19:48:05
How can i add a 2dView having text in ARkit scene iOS.How can i add that view in top of a node that won't rotate when we rotate the node. You can add a SCNPlane and use a SCNLookAtConstraint to so that the plane always looks at the camera. You can create a custom material and set it's material properties to: A color (UIColor or CGColor), specifying a constant color across the material’s surface A number ( An image (UIImage or CGImage), specifying a texture to be mapped across the material’s surface A Core Animation layer (CALayer) A texture (SKTexture, MDLTexture, MTLTexture, or GLKTextureInfo

Including textures when exporting from Blender to COLLADA/.dae format for use in SceneKit

╄→гoц情女王★ 提交于 2019-11-28 18:01:36
I am able to export meshes created in Blender for use in SceneKit by using the COLLADA/.dae format - however no textures show up on iOS device. Also, Preview on OS X won't open any COLLADA file exported from Blender - yet the sidebar preview does show the mesh. What are the options needed at export to make this work? FlippinFun Create a scnassets folder first (not required but useful) Create a folder on your desktop and give it an extension of ".scnassets" Put your collada(.dae) file along with any textures you will be using in it. Drag the folder into your project and save as copy like usual.