scenekit

Revolve a SCNode object in the 3D Space using SceneKit

丶灬走出姿态 提交于 2019-11-30 05:23:06
I am trying to learn my way around SceneKit and as an example, I thought I'd try to build a solar system using the SDK. I am able to add SCNode objects and configure its material properties like pattern and lighting. Also, I am able to rotate the planets, but I can't seem to understand how do I "revolve" them along a particular path. My code so far looks like: // create a new scene SCNScene *scene = [SCNScene scene]; // create and add a camera to the scene SCNNode *cameraNode = [SCNNode node]; cameraNode.camera = [SCNCamera camera]; [scene.rootNode addChildNode:cameraNode]; // place the camera

load a collada (dae) file into SCNNode (Swift - SceneKit)

点点圈 提交于 2019-11-30 04:42:35
问题 This works let scene = SCNScene(named: "house.dae") Is there an equivalent for a node? let node = SCNNode(geometry: SCNGeometry( ..??.. "house.dae" ..??.. )) I have searched high and low, finding nothing that will load an entire dae file into a SCNNode. (not just one ID from it) 回答1: // add a SCNScene as childNode to another SCNScene (in this case to scene) func addSceneToScene() { let geoScene = SCNScene(named: "art.scnassets/ball.dae") scene.rootNode.addChildNode(geoScene.rootNode

ARKit - Projection of ARAnchor to 2D space

早过忘川 提交于 2019-11-29 21:44:45
问题 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

SceneKit - SCNText centering incorrectly

二次信任 提交于 2019-11-29 21:13:59
问题 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

SceneKit - Draw 3D Parabola

最后都变了- 提交于 2019-11-29 21:08:52
I'm given three points and need to draw a smooth 3D parabola. The trouble is that curved line is choppy and has some weird divots in it Here is my code... func drawJump(jump: Jump){ let halfDistance = jump.distance.floatValue/2 as Float let tup = CalcParabolaValues(0.0, y1: 0.0, x2: halfDistance, y2: jump.height.floatValue, x3: jump.distance.floatValue, y3: 0) println("tuple \tup") var currentX = 0 as Float var increment = jump.distance.floatValue / Float(50) while currentX < jump.distance.floatValue - increment { let x1 = Float(currentX) let x2 = Float((currentX+increment)) let y1 =

SceneKit - Crossfade material property textures

风格不统一 提交于 2019-11-29 19:57:44
问题 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];

ARKit –Drop a shadow of 3D object on the plane surface

别等时光非礼了梦想. 提交于 2019-11-29 16:42:59
This is the function that I use to display object on the plane surface. private func loadScene(path: String) -> SCNNode { let spotLight = SCNLight() spotLight.type = SCNLight.LightType.probe spotLight.spotInnerAngle = 30.0 spotLight.spotOuterAngle = 80.0 spotLight.castsShadow = true let result = SCNNode() result.light = spotLight result.position = SCNVector3(-10.0, 20.0, 10.5) result.addChildNode(result) let scene = SCNScene(named: path)! for node in scene.rootNode.childNodes { result.addChildNode(node) } return result } I want to display shadow on the plane surface like this image. When I set

Scenekit some textures have a red hue

时光毁灭记忆、已成空白 提交于 2019-11-29 14:53:57
问题 I have a scene that has many objects, that all have different textures. For some reason 2 objects have a red hue to them, even though their textures have no red. You can still see the pattern in the texture, it just has different shades on red. (On the simulator the 2 objects have black and white textures and on device shades of red) Does anyone have any idea why this is happening? Other objects are working fine. 回答1: For material properties such as metalness and roughness SceneKit has

SceneKit SCNSceneRendererDelegate - renderer function not called

允我心安 提交于 2019-11-29 13:58:14
I recently asked a question which had a pretty obvious answer. I'm still working on the same project and running into another problem. I need to implement per frame logic and the SCNSceneRendererDelegate protocol worked perfectly fine on iOS, but on OSX, the renderer function is not firing. I have created a little example project to illustrate my problem. It consists of a Scene Kit View in storyboard and following code in the ViewController class: import Cocoa import SceneKit class ViewController: NSViewController, SCNSceneRendererDelegate { @IBOutlet weak var sceneView: SCNView! let cubeNode

SceneKit: how to recreate lighting from Google Poly for same OBJ file?

早过忘川 提交于 2019-11-29 11:28:59
The goal is to recreate the lighting for this OBJ file: https://poly.google.com/view/cKryD9VnDEZ Code to load OBJ file into SceneKit (can download file from above link): let modelPath = "model.obj" let url = NSURL(string: modelPath) let scene = SCNScene(named: modelPath)! sceneView.autoenablesDefaultLighting = true sceneView.allowsCameraControl = true sceneView.scene = scene sceneView.backgroundColor = UIColor.white Options tried so far: 1) The default ambient lighting is much harsher than the Google Poly lighting. Removing the ambient lighting rendered everything too flat. 2) Using four