SCNScene from collada file node.geometry is nil - ios

The problem is in the title. I need to access the SCNGeometry of a SCNNode and then edit the SCNMaterial collection of the SCNGeometry but when I inspect the node almost all its properties are set to nil including the geometry property. The weird thing is that all the nodes have been loaded from a .dae file and are all rendered fine in the scene. Any insight would be much appreciated.

are you sure that you are retrieving the correct node? What API do you use to do that? What do you see in the SceneKit editor that's built into Xcode?

Related

Swift Scenekit show image on basic plane

My goal is to have an app where I can scan a certain image and display an AR-Generated Model next to it. I am following this project.
I already imported the image I want to scan and that is working as expected. The problem now is to import my own Model. And that is where I struggle.
What I want is to display a 2D Image on a simple PlaneScene on top or next to the detected image.
I managed to create a .dae file from Blender. I also imported it into Xcode and converted it inside XCode to a .scn file.
This is how it looks:
As you can see the image is not correctly displayed.. It is just white. Also when running the app, the Object is not being displayed. I can not see it anywhere, but it is also not throwing an error.
This is my .dae file: File
Maybe I dont even need Blender for that but I couldn't find a way to display an image onto a Plane in XCode...
What am I missing here? I feel like there is something wrong with my Model. Any help is appreciated!
As I can see, when I open your file in Blender and go to the Front view:
Your Plane is wrong oriented in the space. One looks at it from the side and it is not well centered. (but this is probably what you want).
But you don't need an imported geometry object. Apple has a solution to this.
I recommend you to use the built in plane (SCNPlane, what is a SCNGeometry object) for your project. It will have a front view oriantation by default and you can easely move the offset position.
Let me know if you need an example. But it should be easy to find out how to do this.
PS: If you want to import Models this here is a useful extension to do this:
extension SCNNode {
convenience init(named name: String) {
self.init()
guard let scene = SCNScene(named: name) else {return}
for childNode in scene.rootNode.childNodes {addChildNode(childNode)}
}
}

Why Does An Empty SceneKit Scene Have High Polygon Count?

Why does an empty scene have 2k-5k polies?
Even the start template with the "ship" shows 2k-5k...
Well basically because the geometry contains all those polygons. Open the asset and see.
The Default Template does have not-empty scene if there's a SHIP model. It has a scene containing a 3D geometry and that geometry has 2.8K polygons (as well as 5.8K vertices).
Check it in the Inspector :

Detect touches on different positions of a SCNNode in ARKit

I have a 3D character in .dae format which i use in ARKit. I need to have different actions for touches at different positions of the character.eg: Menu options. I use scene kit and scnnode to create ar. I just started learning AR. Can someone please help me to get this done?
I fixed this by using hit test.I was having different meshes for different parts in my model. So simply calling node.name from hit test gets me which node was selected.
Thanks all.

Changing SCNNode scale has no effect

I'm new to ARKit and SceneKit. I have a rather complex scene coming from an 3D artist. He replaced some items with SceneKit objects. I now try to change the properties of one of the SCNNodes, in this case the scale property, in another case the position in space, and in yet another I have a SCNText where I change the string property:
feedScaler?.scale = SCNVector3Make(1.0, scale, 1.0)
feedText?.string = String(feedValue)
feedIndicator?.position.y = someNewValue
So, pretty straight forward. When I run the scene though, it seems that the changes here are only commited once, before the scene appears. Then nothing happens. Here's the thing:
the method which updates the properties runs once per frame
I print out the property values of the nodes to the console and they update each frame
the text updates, too, and is the only update which is actually rendered and visible.
Note: There's also animations in that scene that do not play unless I uncheck "Use scene time base". Maybe that is a hint regarding how the Scene's animations are handled...
I found the issue. I used a clone of the scene which caused the references to get lost. The documentation says:
Cloning or copying a node creates a duplicate of the node object, but not the geometries, lights, cameras, and other SceneKit objects attached to it—instead, each copied node shares references to these objects.
When the original gets lost all the references get useless.

Show shadow for SCNScene from .dae file [iOS]

I've got a SCNView with a SCNScene from a .dae file. I can access the objects in the scene, move and modify them properly, but I don't find the way to show the shadow projected by the light over the object.
SCNView *myScene.scene = [SCNScene sceneNamed:#"scene.dae"];
The scene already includes lights and shadows, I can preview them, but the SCNView only shows the lights, not the projected shadow.
Do you know how to make the shadow visible? I know SpriteKit allows it, but I need to use SceneKit for my 3D scene.
Many thanks

Resources