scenekit

SceneKit and with GLSL - how to add shader (GLSL) to a geometry

谁说胖子不能爱 提交于 2019-12-24 06:45:57
问题 I'm learning SceneKit and while using GLSL. I'm having hard time understanding using glsl with SceneKit, e.g., how to load glsl shaders in SceneKit and apply it to a geometry. lets say we have: SCNBox *box = [SCNBox boxWithWidth:50 height:50 length:50 chamferRadius:0]; SCNNode *bNode = [SCNNode nodeWithGeometry:box]; SCNMaterial *redMaterial = [SCNMaterial material]; redMaterial.diffuse.contents = [UIColor redColor]; redMaterial.locksAmbientWithDiffuse = YES; box.materials = @[redMaterial];

Keep node's X and Z axes parallel to ground while rotating Y axis to face camera

拈花ヽ惹草 提交于 2019-12-24 06:43:29
问题 I'm trying to keep an SCNNode always one meter away from the front of the camera, and manipulate the node so that the X and Z axes are always parallel to the ground, while the node rotates around the Y-axis so that the node is always facing the camera. The code below achieves my goal for the most part, but when turning more than 90˚ clockwise or counterclockwise, the node starts turning. How can I fix that? override func viewDidLoad() { super.viewDidLoad() boxParent.position = (sceneView

Getting SCNNode Bounding Size in Meters

限于喜欢 提交于 2019-12-24 06:38:09
问题 I'm trying to wrap an SCNPlane around a SCNNode. I'm using ARKit so everything is measured in meters, but when I get the boundingBox , I get measurements in some other unit. I looked at Apple's documentation, and they don't specify what the units are. For example, one of nodes is roughly 3 meters wide, but it says its 26 units. I could do a rough division to get a constant and use that to do the unit conversions, but I was wondering if there's a less hacky way to do it? let textContainerSize

Angle between 2 Lines in 3D

╄→гoц情女王★ 提交于 2019-12-24 05:49:49
问题 i know how to get Angles with atan2 between 2 Points in 2D, but how does this work in 3D?: lets say i have 3 Points A,B,C (all are SCNVector3 with x,y,z coordinates First Line Endpoints A and B 2nd Line Endpoints B and C Now i want to get the angle between the 2 Lines... (in ios Swift) I read something about the dot product and acos but somehow it does not work... With i=0: var vector1 = SCNVector3((pointArray[i].x - pointArray[i+1].x), (pointArray[i].y - pointArray[i+1].y), (pointArray[i].z

SCNNode static body with .dae causing issues

限于喜欢 提交于 2019-12-24 05:15:10
问题 I have built a landscape model in blender, exported to .dae and added to my xcode project. I have loaded the scene then attached the child (landscape grid mesh) to my landscapeNode, this loads perfectly. However when I attach a static physics body to the landscspeNode my heroNode seems to crash into a invisible wall when attempting to fly above the land. The functionality I am looking for is the obvious collision with the land I have modelled so the heroNode cannot fly through the land and is

Directional Light is affected by Camera's movement

独自空忆成欢 提交于 2019-12-24 00:42:39
问题 I want to achieve the shadows effect like in IKEA Place, where the shadow is stick with the virtual object. Here is my implementation. I added the direction light and shadow plane to the virtual object. When I moved the virtual object in the scene, shadow is not positioned right under the bottom of the virtual object. Here is my code: func setupShadows() { let flourPlane = SCNFloor() let groundPlane = SCNNode() let groundMaterial = SCNMaterial() groundMaterial.lightingModel = .constant

ARKit add 2D Video flipped by X

坚强是说给别人听的谎言 提交于 2019-12-24 00:38:46
问题 So I have following code to create custom wall let wall = SCNPlane(width: CGFloat(distance), height: CGFloat(height)) wall.firstMaterial = wallMaterial() let node = SCNNode(geometry: wall) // always render before the beachballs node.renderingOrder = -10 // get center point node.position = SCNVector3(from.x + (to.x - from.x) * 0.5, from.y + height * 0.5, from.z + (to.z - from.z) * 0.5) node.eulerAngles = SCNVector3(0, -atan2(to.x - node.position.x, from.z - node.position.z) - Float.pi * 0.5, 0

How to make use of cube texture type in XCassets

大兔子大兔子 提交于 2019-12-23 19:04:14
问题 I'm trying to learn SceneKit development and try to add a skybox in the background. To store the cube map textures I found that XCAssets has a type Cube Texture Set which seems to fit the bill perfectly. However. I've not found any way to access the texture in code (e.g. as an image set where you call UIImage(named: "asset_name") ). I've tried creating an SKTexture , MDLTexture og MTKTexture from the asset but without success. Do anyone know how I can use the cube texture set? 回答1: You can

SceneKit: Material Preview is always black

强颜欢笑 提交于 2019-12-23 18:58:42
问题 In Xcode, I have a .SCN file that was transformed from a .DAE file. I've worked with the person who made the model to set all of the Physically Based (PBR) settings. But no matter what I do, the preview is always black. Also, if I change the environment to Procedural Sky the model will also display as black. I'm aware that adding a light to the scene will "fix" this, but should I have to do that? Since it gives my models unrealistic shadows? 回答1: I changed the Illumination settings to be the

what does bake do in SceneKit

旧时模样 提交于 2019-12-23 12:07:26
问题 What is the purpose of "bake" option in SceneKit editor. Does it have an impact on performance? Type offers 2 options: Ambient Occlusion and Light Map Destination offers: Texture and Vertex 回答1: For me, it crashes Xcode. It's supposed to render lighting (specifically shadows) into the textures on objects so you don't need static lights. This should, theoretically, mean that all you need in your scene are the lights used to create dynamic lighting on objects that move, and you can save all the