Current location - Health Preservation Learning Network - Slimming men and women - SceneKit development tutorial 02
SceneKit development tutorial 02
The structure of this paper is as follows:

Before we begin, we need to compare a noun between Chinese and English.

The SCNScene object represents a 3D scene and its contents. The hierarchical structure (tree structure) composed of nodes constitutes the skeleton of the whole scene, and "contents" such as cameras, lights and geometry are attached to the nodes. These nodes and the attributes attached to them constitute a visible 3D scene.

Scenes are displayed by SCNView, SCNLayer (macOS only) or SCNRender. These display classes all follow the SCNSceneRenderer protocol, which defines the properties and methods shared by these classes.

The SCNScene class also provides an interface for reading and writing scene files.

Generally, you can use some software, such as 3Dsmax and maya, to make 3D scenes, and then import these scene files into the project.

SceneKit provides the following APIs to load scene files:

SceneKit also provides an API for loading scenes from model I/O resources:

Model I/O is not involved here, you just need to know that there is such a method.

Think back to the empty AR project we created before, and there will always be an art.scnassets in it.

This folder contains scene resources (ship.scn in the example) and texture resources (texture.png in the example), which Xcode will optimize to get the best performance on each device, such as applying slimming and loading resources on demand.

In this part, I have a demonstration of loading 3D model (obj/scn/dae) into your AR project in SceneKit |!

SceneKit provides a class method to create a scene:

Calling this method can create an empty scene, which only contains a "root node without any content". You can create a scene by adding child nodes to the root node.

This function is very important. For example, what another colleague of our team is doing recently is to export ARKit's face with depth data from iPhone X, and then print the face with 3D printing equipment. The method I introduce below is one of the methods to derive faces.

SceneKit provides a way to save the scene:

Change the method to write the scene of SceneKit to a file, and the file format is determined by the operating system and the file suffix you specify:

Some high-frequency APIs are introduced above, and more APIs in SCNScene can be consulted in the developer's documentation.

SCNView inherits from UIView and is used to display the contents of SceneKit 3D.

The system provides the following initialization methods:

Displays the specified scene on the view by setting the scene property.

SCNView provides three methods to manage the animation in the current scene:

SCNView provides a method to take a snapshot of the current scene, which can be rendered to a new image object:

The next issue of iOS 1 1 SceneKit development tutorial 03 | Using SCN nodes &; & ampSCNReferenceNode defines SCNNode structure, which will introduce SCNReferenceNode and SCNReferenceNode.