scenekit

SceneKit – Custom geometry does not show up

孤人 提交于 2019-12-01 04:41:14
I should see 2 yellow triangles, but I see nothing. class Terrain { private class func createGeometry () -> SCNGeometry { let sources = [ SCNGeometrySource(vertices:[ SCNVector3(x: -1.0, y: -1.0, z: 0.0), SCNVector3(x: -1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: -1.0, z: 0.0)], count:4), SCNGeometrySource(normals:[ SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0)], count:4) ] let elements = [ SCNGeometryElement(indices: [0, 2, 3, 0, 1, 2], primitiveType:

SceneKit per vertex color

别等时光非礼了梦想. 提交于 2019-12-01 04:23:18
I've been playing with SceneKit, but I can't figure how to create a per vertex color geometry. So to be more precise, I would like to do this : http://openglbook.com/chapter-2-vertices-and-shapes.html Let me know if it's not clear Thanks. Pour info : sceneView = SCNView(frame: sceneContainer.bounds) sceneView.scene = SCNScene() sceneView.allowsCameraControl = true sceneView.autoenablesDefaultLighting = true sceneView.showsStatistics = true sceneView.backgroundColor = UIColor.darkGrayColor() self.sceneContainer.addSubview(sceneView) // Vertex let vertices: [SCNVector3] = [SCNVector3(0, 0, 0),

How to move a rotated SCNNode in SceneKit?

喜欢而已 提交于 2019-12-01 04:21:21
The image below shows a rotated box that should be moved horizontally on the X and Z axes. Y should stay unaffected to simplify the scenario. The box could also be the SCNNode of the camera, so I guess a projection does not make sense at this point. So lets say we want to move the box in the direction of the red arrow. How to achieve this using SceneKit? The red arrow indicates -Z direction of the box. It also shows us it is not parallel to the camera's projection or to the global axes that are shown as dark grey lines of the grid. My last approach is the product of a translation matrix and a

What is an example of drawing custom nodes with vertices in swift SceneKit?

我的未来我决定 提交于 2019-12-01 04:06:35
This area is hardly documented online and it would be great to see a working Swift 3 example, of say, a custom drawn cube with manual SCNvector3s. There is this in objective-C but not Swift. This might not be a usual form of question but I know it would help many. If there is somewhere I missed, please mention. The documentation is not very helpful scngeometrysource, etc. Thanks 0x141E A custom geometry is constructed from a set of vertices and normals. Vertices In this context, a vertex is a point where two or more lines intersect. For a cube, the vertices are the corners shown in the

Adding a SCNBillboardConstraint makes the node dissapear

99封情书 提交于 2019-12-01 03:19:50
After what I've read in the documentation and on the internet a SCNBillboardConstraint would rotate a node to always face the pointOfView node - in the case of ARKit , the user's camera. The thing is, when I add a SCNBillboardConstraint to a child node, it dissapears. The nodes are just some SCNTexts added as a subchild of a more complex model. The hierarchy looks something like this: RootNode - > Text node (two of them). Just after I added the root node to the scene's root node, I add this constraint in the following way: updateQueue.async { self.sceneView.scene.rootNode.addChildNode

SceneKit - Lighting and casting shadows

隐身守侯 提交于 2019-12-01 02:58:35
问题 I'm trying to create a spot light that illuminates a cube. The surface underneath should then show a shadow. Unfortunately I wasn't able to achieve this. The light ignores the cube and casts the light on both - the surface and the cube - regardless that the cube is in the way. How it looks like: The code, I just set castsShadow to YES on every node for testing, but nothing so far helped: BOOL shadows = YES; _baseNode.castsShadow = shadows; _scene.rootNode.castsShadow = shadows; SCNBox *box =

SceneKit – Custom geometry does not show up

大憨熊 提交于 2019-12-01 02:45:15
问题 I should see 2 yellow triangles, but I see nothing. class Terrain { private class func createGeometry () -> SCNGeometry { let sources = [ SCNGeometrySource(vertices:[ SCNVector3(x: -1.0, y: -1.0, z: 0.0), SCNVector3(x: -1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: 1.0, z: 0.0), SCNVector3(x: 1.0, y: -1.0, z: 0.0)], count:4), SCNGeometrySource(normals:[ SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1.0), SCNVector3(x: 0.0, y: 0.0, z: -1

SceneKit per vertex color

一笑奈何 提交于 2019-12-01 01:56:16
问题 I've been playing with SceneKit, but I can't figure how to create a per vertex color geometry. So to be more precise, I would like to do this : http://openglbook.com/chapter-2-vertices-and-shapes.html Let me know if it's not clear Thanks. 回答1: Pour info : sceneView = SCNView(frame: sceneContainer.bounds) sceneView.scene = SCNScene() sceneView.allowsCameraControl = true sceneView.autoenablesDefaultLighting = true sceneView.showsStatistics = true sceneView.backgroundColor = UIColor

SceneKit animate node along path

和自甴很熟 提交于 2019-12-01 01:12:46
问题 I have a box node _boxNode = [SCNNode node]; _boxNode.geometry = [SCNBox boxWithWidth:1 height:1 length:1 chamferRadius:0]; _boxNode.position = SCNVector3Make(0, 0, -2); [scene.rootNode addChildNode:_boxNode]; I have a path CGPathRef path = CGPathCreateWithEllipseInRect(CGRectMake(-2, -2, 4, 4), nil); I want to have my box travel along my path once. How do I do this in SceneKit? I'd like to make a method that would look like [_boxNode runAction:[SCNAction moveAlongPath:path forDuration

How to create a Portal effect in ARKit just using the SceneKit editor?

假装没事ソ 提交于 2019-12-01 01:07:06
I would like to create a prototype like this one : just using Xcode SceneKit Editor. I found an answer where the room is created programmatically with simple SCNPlane objects and playing around with the rendering order. However, I would like to put together something more elaborated like downloading the 3d model of a room and make it accessible only through the portal. I'm trying to achieve the same effect directly in the Xcode's SceneKit editor converting this part: //a. Create The Left Wall And Set Its Rendering Order To 200 Meaning It Will Be Rendered After Our Masks let leftWallNode =