scenekit

Xcode simd - issue with Translation and Rotation Matrix Example

…衆ロ難τιáo~ 提交于 2019-11-28 02:22:10
问题 Not only is using column-major vs row-major counter-intuitive, Apple's documentation on "Working with Matrices" further exacerbates the confusion by their examples of "constructing" a "Translate Matrix" and a "Rotation Matrix" in 2D. Translate Matrix Per Apple's Documentation () Translate A translate matrix takes the following form: 1 0 0 0 1 0 tx ty 1 The simd library provides constants for identity matrices (matrices with ones along the diagonal, and zeros elsewhere). The 3 x 3 Float

Reliable access and modify captured camera frames under SceneKit

二次信任 提交于 2019-11-28 01:42:58
问题 I try to add a B&W filter to the camera images of an ARSCNView, then render colored AR objects over it. I'am almost there with the following code added to the beginning of - (void)renderer:(id<SCNSceneRenderer>)aRenderer updateAtTime:(NSTimeInterval)time CVPixelBufferRef bg=self.sceneView.session.currentFrame.capturedImage; if(bg){ char* k1 = CVPixelBufferGetBaseAddressOfPlane(bg, 1); if(k1){ size_t x1 = CVPixelBufferGetWidthOfPlane(bg, 1); size_t y1 = CVPixelBufferGetHeightOfPlane(bg, 1);

Can we render shadow on a transparent Plane in SceneKit

最后都变了- 提交于 2019-11-28 01:38:42
问题 I have used shader modifiers for Plane but its not working. Can anyone suggest me how to solve it? let myShaderfragment = "#pragma transparent;\n" + "_output.color.a = 0.0;" let myShaderSurface = "#pragma transparent;\n" + "_surface.diffuse.a = 0.0;" material.shaderModifiers = [SCNShaderModifierEntryPoint.fragment : myShaderfragment, SCNShaderModifierEntryPoint.surface : myShaderSurface] 回答1: The SceneKit: What's New session from WWDC 2017 explains how to do that. For the plane, use a

SCNGeometry with polygon as primitiveType

只愿长相守 提交于 2019-11-28 01:24:42
问题 Trying to figure out how I create a SCNGeometry with polygon as primitiveType, My goal is to add polygon shaped node as a child of a sphere node, and make it look like MKPolygon for map kit, like in this example. My current code is: //Take an arbitrary array of vectors let vertices: [SCNVector3] = [ SCNVector3Make(-0.1304485, 0.551937, 0.8236193), SCNVector3Make(0.01393811, 0.601815, 0.7985139), SCNVector3Make(0.2971005, 0.5591929, 0.7739732), SCNVector3Make(0.4516893, 0.5150381, 0.7285002),

iOS SceneKit Neon Glow

 ̄綄美尐妖づ 提交于 2019-11-27 23:09:48
Have been looking at lighting on Scenekit, and while I can now apply a lighting node to light something I'm looking for a way to light from within an object. As an example imagine a neon glow, or a lightbulb that casts light on other objects. Any ideas how to achieve this? Many thanks. As @DavidRönnqvist hints in comments, there are multiple ways to make an object appear to glow. You can do these together or individually — you'll probably need to tweak how you combine them to get the effect you want. For an object that emits light, you probably don't want shading from other light sources in

Custom SceneKit Geometry in Swift on iOS not working but equivalent Objective C code does

半城伤御伤魂 提交于 2019-11-27 22:20:25
I am keen to adopt the new Swift language as this seems to be the way forward with Apple development. I have also been impressed with the new SceneKit support in iOS 8. I would like to programatically create custom geometry at runtime but I am struggling to get the Swift code to work. Yet the equivalent code in Objective C works OK. This could be a bug, or something I am doing wrong. I am simply trying to create and render a single triangle. I will ignore the normals and textures etc at this point for simplicity. So I am only expecting to see a black triangle. Swift Code (not working) var

ARKit: Placing an SCNText at a particular point in front of the camera

一笑奈何 提交于 2019-11-27 21:37:45
I've managed to get a cube (SCNNode) placed on a surface where the camera is pointed, however I am finding it very difficult to do the simple (?) task of also placing text in the same position. I've created the SCNText and subsequent SCNNode, however when I add it to the rootNode the text always seems to be added above my head and off the camera to the right (which tells me thats the global origin point). Even when I use the exact same values of position I used for the the cube, the SCNText node still gets placed above my head in the same spot. Apologies if this is a basic question, I've never

How to set contents of scenekit background to cube map

◇◆丶佛笑我妖孽 提交于 2019-11-27 20:48:16
问题 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. 回答1: SCNScene's "background" property is of the SCNMaterialProperty class. So you can directly set it's contents to an

Stroke Width with a SceneKit line primitive type

蓝咒 提交于 2019-11-27 20:17:02
I am trying to replicate this cube image shape (with permission from the original creator ) using scene kit. Thus far, I have the drawing code for the lines and the vertices. I cannot use an image because the background has to be transparent. The specific I am trying to solve right now is how to edit the stroke width for the SCNGeometryPrimitiveType.Line element. The basic way I am creating lines is like this: private func squareVertices(length: Float) -> [SCNVector3] { let m = length/Float(2) let topLeft = SCNVector3Make(-m-q, m+q, m+q) let topRight = SCNVector3Make( m+q, m+q, m+q) let

cameranode rotate as iOS device moving

廉价感情. 提交于 2019-11-27 20:14:28
It's 360 degree video player project. I add a cameranode( SCNNode ) to a rootnode, the cameranode was put at the center(0,0,0) of the SCNSphere , It can play video by now. Now I have to use devicemotion. I need to rotate the camera when device moves. Not just rotate a certain angle. (Not just device move, When I'm holding a device, my moving regard as the device moving. because I found if I use deviceMotion.attitude.roll , the cameranode only moves when device moves by itself, not when I circle around with device) When device is located in (x1,y1,z1) position, the cameranode would rotate as