Importing scenes from an external 3D application
Although we can add objects, cameras, and light through code, it will become very tedious and confusing when we have a lot of objects to add to the scene. In SceneKit, this problem can be easily overcome by importing scenes prebuilt in other 3D applications.
All 3D applications, such as 3D StudioMax, Maya, Cheetah 3D, Blender, and so on, have the ability to export scenes in Collada(.dae)
and Alembic(.abc)
format. We can import this scene with lighting, camera, and textured objects in SceneKit directly, without the need for setting up the scene.
In this section, we will import a Collada file into the scene. In the resources folder for this chapter, you will find the theDude.DAE
file and theDude.png
file. Drag the files into the current project under the art.scnassets
:
If the model is not showing up in the scene, then you might have to drag and drop the .png
onto the model in the view.
Next, in the GameSCNScene
, add the following code after the...