scenekit

Which format file for 3d model SceneKit/ARKit better to use

拥有回忆 提交于 2019-11-30 17:06:12
问题 I read several tutorials how to place 3d objects in SceneKit/ARKit applications and all of them uses .scn format files for the objects. But I found there is no any issues if I use original .dae format and do not convert it to .scn format. I don't really see any difference between .dae and .scn formats. Actually result seems to me the same but can you explain what the difference between them and what I should use in what cases? Thank you! 回答1: DAE (Digital Asset Exchange, aka Collada) is a

Drawing a 3D arc and helix in SceneKit

女生的网名这么多〃 提交于 2019-11-30 15:24:19
A recent question here made me think of SceneKit again, and I remembered a problem I never solved. My app displays antenna designs using SK. Most antennas use metal rods and mesh reflectors so I used SCNCylinder for the rods, SCNPlane for the reflector and SCNFloor for the ground. The whole thing took a couple of hours, and I'm utterly noob at 3D. But some antennas use wires bent into arcs or helixes, and I punted here and made crappy segmented objects using several cylinders end-to-end. It looks ass-tastic. Ideally I would like a single object that renders the arc or helix with a cylindrical

ARKit - Projection of ARAnchor to 2D space

大城市里の小女人 提交于 2019-11-30 15:15:21
I am trying to project an ARAnchor to the 2D space but I am facing on an orientation issue... Below my function to project the top left, top right, bottom left, bottom right corner position to 2D space: /// Returns the projection of an `ARImageAnchor` from the 3D world space /// detected by ARKit into the 2D space of a view rendering the scene. /// /// - Parameter from: An Anchor instance for projecting. /// - Returns: An optional `CGRect` corresponding on `ARImageAnchor` projection. internal func projection(from anchor: ARImageAnchor, alignment: ARPlaneAnchor.Alignment, debug: Bool = false) -

SceneKit - SCNText centering incorrectly

拥有回忆 提交于 2019-11-30 15:01:25
I have tried to make a text string (SCNText) fit inside a box (SCNBox) in the code below. The size of the box looks correct but the text is not in the right center of the box. Any idea or solution? Thanks let geoText = SCNText(string: "Hello", extrusionDepth: 1.0) geoText.font = UIFont (name: "Arial", size: 8) geoText.firstMaterial!.diffuse.contents = UIColor.red let textNode = SCNNode(geometry: geoText) let (minVec, maxVec) = textNode.boundingBox scnScene.rootNode.addChildNode(textNode) let w = CGFloat(maxVec.x - minVec.x) let h = CGFloat(maxVec.y - minVec.y) let d = CGFloat(maxVec.z - minVec

ARKIT: Move Object with PanGesture (the right way)

最后都变了- 提交于 2019-11-30 14:53:35
问题 I've been reading plenty of StackOverflow answers on how to move an object by dragging it across the screen. Some use hit tests against .featurePoints some use the gesture translation or just keeping track of the lastPosition of the object. But honestly.. none work the way everyone is expecting it to work. Hit testing against .featurePoints just makes the object jump all around, because you dont always hit a featurepoint when dragging your finger. I dont understand why everyone keeps

How can I rotate an SCNNode on the axis the camera is looking down?

混江龙づ霸主 提交于 2019-11-30 13:56:08
问题 I've added a UIRotationGestureRecognizer and want to use it rotate a node that the user has selected. Currently, it rotates around z-axis, like so: private var startingRotation: CGFloat = 0 @objc private func handleRotation(_ rotation: UIRotationGestureRecognizer) { guard let node = sceneView.hitTest(rotation.location(in: sceneView), options: nil).first?.node else { return } if rotation.state == .began { startingRotation = CGFloat(node.rotation.w) } node.rotation = SCNVector4(0, 0, 1, -Float

How To Apply .MTL File on .OBJ 3d Model via SceneKit & Model I/O

拥有回忆 提交于 2019-11-30 13:55:56
问题 I am trying to apply an .mtl file texture on .obj 3d model via SceneKit & Model I/0. My code below works fine when I try to apply .jpg of a texture on it: let url = NSBundle.mainBundle().URLForResource("chair", withExtension: "obj") let asset = MDLAsset(URL: NSURL(string:url)!) guard let object = asset.objectAtIndex(0) as? MDLMesh else { //fatalError("Failed to get mesh from asset.") return } if shouldApplyTexture == true { var textureFileName = "chair.mtl" // Create a material from the

SceneKit - Crossfade material property textures

寵の児 提交于 2019-11-30 13:49:03
The documentation for SCNMaterialProperty.contents states that it is an animatable property and indeed I can perform a crossfade between two colors. However I’m unable to crossfade between two images. So I’m starting to wonder if this is possible at all or if I need to create a custom shader for this? I’ve tried an implicit animation, in which case it immediately shows the ‘after’ image: node.geometry.firstMaterial.diffuse.contents = [UIImage imageNamed:@"before"]; [SCNTransaction begin]; [SCNTransaction setAnimationDuration:5]; node.geometry.firstMaterial.diffuse.contents = [UIImage

How to create a border for SCNNode to indicate its selection in iOS 11 ARKit-Scenekit?

廉价感情. 提交于 2019-11-30 13:26:37
How to draw a border to highlight a SCNNode and indicate to user that the node is selected? In my project user can place multiple virtual objects and user can select any object anytime. Upon selection i should show the user highlighted 3D object. Is there a way to directly achieve this or draw a border over SCNNode? You need to add a tap gesture recognizer to the sceneView . // add a tap gesture recognizer let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTap(_:))) scnView.addGestureRecognizer(tapGesture) Then, handle the tap and highlight the node: @objc func

ARKIT: Move Object with PanGesture (the right way)

痞子三分冷 提交于 2019-11-30 12:46:44
I've been reading plenty of StackOverflow answers on how to move an object by dragging it across the screen. Some use hit tests against .featurePoints some use the gesture translation or just keeping track of the lastPosition of the object. But honestly.. none work the way everyone is expecting it to work. Hit testing against .featurePoints just makes the object jump all around, because you dont always hit a featurepoint when dragging your finger. I dont understand why everyone keeps suggesting this. Solutions like this one work: Dragging SCNNode in ARKit Using SceneKit But the object doesnt