scenekit

Is there a way to make a dark/low light SceneKit scene?

社会主义新天地 提交于 2019-11-29 11:19:31
I've searched and there doesn't appear to be a way to make a dark SceneKit scene... As in a scene with low lighting. I've removed all lights from my scene, set my autoenablesDefaultLighting to false, made sure it's unchecked in the storyboard, I even tried adding a black ambient light but that didn't do anything. Is there a way to make a SceneKit Scene with low/dark lighting?? Had to try this for myself, as it didn't sound right. Removing all lights from the default SceneKit game template does indeed result in a model lit with an ambient light. I expect it's some kind of default that kicks

Xcode simd - issue with Translation and Rotation Matrix Example

十年热恋 提交于 2019-11-29 08:58:46
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 identity matrix is matrix_identity_float3x3. The following function returns a simd_float3x3 matrix using the

Reliable access and modify captured camera frames under SceneKit

六月ゝ 毕业季﹏ 提交于 2019-11-29 08:21:28
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); memset(k1, 128, x1*y1*2); } } This works really fast on mobile, but here's the thing: sometimes a colored

Can we render shadow on a transparent Plane in SceneKit

空扰寡人 提交于 2019-11-29 08:17:13
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] The SceneKit: What's New session from WWDC 2017 explains how to do that. For the plane, use a material with constant as its lightingModel . It's the cheapest one. This material will have writesToDepthBuffer

SCNGeometry with polygon as primitiveType

会有一股神秘感。 提交于 2019-11-29 07:44:53
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), SCNVector3Make(0.4629132, 0.4383712, 0.7704169), SCNVector3Make(0.1333823, 0.5224985, 0.8421428),

Cannot create a Screenshot of a SCNView

我们两清 提交于 2019-11-29 07:36:09
Is it possible to get a screenshot of an SCNView? I'm trying with the below code, but it always comes out white... NSRect bounds = [window.contentView bounds]; NSImage *screenshot = [[NSImage alloc] initWithData:[window.contentView dataWithPDFInsideRect:bounds]]; It works fine when the view is a standard NSView... SceneKit uses an OpenGL context to draw. You can't turn that into PDF data as easily as a Quartz based context (as used by "normal" AppKit views). But you can grab the rasterized bitmap data from OpenGL: - (IBAction)takeShot:(id)sender { NSString* path = @"/Users/weichsel/Desktop

why is metal shader gradient lighter as a SCNProgram applied to a SceneKit Node than it is as a MTKView?

人走茶凉 提交于 2019-11-29 07:32:50
I have a gradient, generated by a Metal fragment shader that I've applied to a SCNNode defined by a plane geometry. It looks like this: When I use the same shader applied to a MTKView rendered in an Xcode playground, the colors are darker. What is causing the colors to be lighter in the Scenekit version? Here is the Metal shader and the GameViewController. Shader: #include <metal_stdlib> using namespace metal; #include <SceneKit/scn_metal> struct myPlaneNodeBuffer { float4x4 modelTransform; float4x4 modelViewTransform; float4x4 normalTransform; float4x4 modelViewProjectionTransform; float2x3

SceneKit Culling Plane

怎甘沉沦 提交于 2019-11-29 07:29:41
I have a SCNScene rendering in a SCNView. I have some *.dae models that are rendered/moving in the scene. I have a transparent cube, when one of my models goes behind it, I would like the model to not be rendered, because at the moment, as the cube is transparent, you can see it through the cube. Is there any property/setting/shader I can apply to the transparent cube so that anything behind it is not rendered? Example: My eye is the green dot, the cube is the blue square, my model is the red circle, However the part of the circle hidden by the cube is purple...this would actually be invisible

Revolve a SCNode object in the 3D Space using SceneKit

Deadly 提交于 2019-11-29 05:06:26
问题 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]

SpriteKit and SceneKit – How to completely pause a game?

时光毁灭记忆、已成空白 提交于 2019-11-29 04:49:23
I succeeded to pause a scene game with this code: override func touchesBegan(touches: NSSet!, withEvent event: UIEvent!) { var touch:UITouch = touches.anyObject() as UITouch pauseText.text = "Continuer" pauseText.fontSize = 50 pauseText.position = CGPointMake(self.frame.size.width/2, self.frame.size.height/2) /* bouton play/pause */ var locationPause: CGPoint = touch.locationInNode(self) if self.nodeAtPoint(locationPause) == self.pause { println("pause") addChild(pauseText) pause.removeFromParent() paused = true } if self.nodeAtPoint(locationPause) == self.pauseText { pauseText