scenekit

Modify the Bounding Box Size of 3D model

社会主义新天地 提交于 2019-12-10 21:24:44
问题 This function is supposed to add a 3D model to screen in a confined space: func addCharacter(gridPosition: SCNVector3, levelNode: SCNNode){ let carScene = SCNScene(named: "assets.scnassets/Models/cube.dae") // Create a material using the model_texture.tga image let carMaterial = SCNMaterial() carMaterial.diffuse.contents = UIImage(named: "assets.scnassets/Textures/model_texture.tga") carMaterial.locksAmbientWithDiffuse = false // Create a clone of the Car node of the carScene - you need a

SceneKit: how to control size of imported assets, one DAE file creates SCNNode of huge size while another is “normal”

試著忘記壹切 提交于 2019-12-10 21:23:40
问题 A designer provided the attached two DAE files created in Cinema 4D. Both assets are of comparable size inside of Cinema 4D. Both DAE files were produced with the same export process. Importing the DAE files into a SceneKit scene, however, produces different results. Chango.dae imports at a "normal" size with a bounding box of ~3x4x3. Tiki.dae imports at a huge size with a bounding box of ~155x325x140. Its dimensions inside C4D are ~122x283x142. Questions: 1) How do you make sure assets "fit"

SceneKit – material's colorBufferWriteMask

 ̄綄美尐妖づ 提交于 2019-12-10 20:22:42
问题 I'm working with SceneKit (swift) and found colorBufferWriteMask parameter that working with SCNMaterial. But it's still working with iOS11+. So, have anyone know a parameter like colorBufferWriteMask that working with iOS9+? Thanks. 回答1: After research about scenekit, i found a solution. The first, i create a SCNNode (A) that is setting with opacity = 0.000001 and renderingOrder = -1. The second, i create other SCNNode (B) that setting with renderingOrder = 100 and add A. So, right now, Part

How to know if node is visible in screen or not in SceneKit?

佐手、 提交于 2019-12-10 19:38:53
问题 I have an arrow in pointofview which points towards a node. I want that arrow to appear only if the node is not visible in the screen. I have found an approach: projectPoint 8 corners of node's boundingBox and check if: 1) Any point lies inside screen 2) Any edge from the points lie inside screen 3) Any plane lie inside screen But it seems very big hard and messy. So is there any simpler approach to it? 回答1: You can use isNode(_:insideFrustumOf:) to check if the bounding box of a given node

How to call glPointSize() (or the SceneKit equivalent) when making custom geometries using SceneKit and SCNGeometryPrimitiveTypePoint

杀马特。学长 韩版系。学妹 提交于 2019-12-10 17:54:25
问题 I'm writing an iOS app that renders a pointcloud in SceneKit using a custom geometry. This post was super helpful in getting me there (though I translated this to Objective-C), as was David Rönnqvist's book 3D Graphics with SceneKit (see chapter on custom geometries). The code works fine, but I'd like to make the points render at a larger point size - at the moment the points are super tiny. According to the OpenGL docs, you can do this by calling glPointSize() . From what I understand,

Extending SCNNode in Swift

三世轮回 提交于 2019-12-10 17:34:01
问题 I would like to extend SCNNode (if possible) in Swift. Here's my attempt: class MyNode : SCNNode { override init(geometry: SCNGeometry) -> SCNNode { return super.init(geometry) } /* Xcode required this */ required init(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } The -> operator is being tagged with an error "Consecutive declarations on a line must be separated by ;". I know this is not right but if I humour Xcode it "fixes" it as follows: override init

SceneKit - Adding a new SCNNode to the scene causes severe lag

房东的猫 提交于 2019-12-10 17:13:49
问题 I found out that adding SCNNodes (with SCNGeometry) to the scene causes a severe lag spike. According to the Time Profiler it has to generate the geometry (at least the functions/methods are called like that). It does that at the time when the node is added to the scene, not when the node is created. Hence, creating a pool with SCNNodes will not work. Is there a way to get rid of this lag? I'd like to be able to add nodes to the scene without any FPS drop. The only idea I have so far is

How to convert 2D point to 3D using SceneKit's unprojectPoint without having a depth value?

拈花ヽ惹草 提交于 2019-12-10 15:38:23
问题 Is it possible to use SceneKit's unprojectPoint to convert a 2D point to 3D without having a depth value? I only need to find the 3D location in the XZ plane. Y can be always 0 or any value since I'm not using it. I'm trying to do this for iOS 8 Beta. I had something similar with JavaScript and Three.js (WebGL) like this: function getMouse3D(x, y) { var pos = new THREE.Vector3(0, 0, 0); var pMouse = new THREE.Vector3( (x / renderer.domElement.width) * 2 - 1, -(y / renderer.domElement.height)

Why SCNPhysicsBody resets position when set eulerAngles?

人盡茶涼 提交于 2019-12-10 15:26:19
问题 I'm trying to use SceneKit to develop a game for tvOS, and I'm having an issue. When I set the node's eulerAngle before apply an impulse to the physicsBody the node is reset to his original position. I was expecting to see the nodes moving around on the floor's plane, but on each tap the nodes are moved to the origin position before the impulse is applied. I'm new at the use of this framework, so I wonder where is the mistake. I'm using the new AppleTV with tvOS 9.0 and XCode 7.1.1 To

Camera is not following the airplane in Scenekit

穿精又带淫゛_ 提交于 2019-12-10 14:43:19
问题 I have a flying aircraft which I am following and I am also showing the path the aircraft has followed. I am drawing cylinders as a line for drawing the path. Its kind of drawing a line between 2 points. I have a cameraNode which is set to (0,200,200) initially. At that point I can see the aircraft. But when I start my flight. It goes out of the screen. I want 2 things : Follow just the aircraft (Path won't matter). Show whole path and also the aircraft. I tried finding the min ad max x,y and