Xcode 4.4: Editing 3D Scenes

September 6th, 2012

Filed under: Xcode | Be the first to comment!

One of the new features in Xcode 4.4 involves viewing and editing 3D scenes in Xcode. This feature didn’t fit into any of the book’s chapters so I’m providing an introduction to Xcode’s scene editor here.

You must be running Mac OS X 10.8 or later to edit scenes. Mac OS X 10.7 users can only view 3D scenes.

Preliminary Details

To edit a 3D scene you must create the scene in a 3D modeling program. In the 3D modeling program export the file as a COLLADA file, which has the extension .dae. Add the COLLADA file to your project. Select the COLLADA file in the project navigator to view and edit the file in Xcode.

Scene Editor

3D Scene Editor

As you can see in the screenshot, the scene editor is similar to Interface Builder’s object list and canvas. On the left side of the editor is the entities list and the scene graph list that contain the objects in the scene. On the right side is the viewport, which shows the scene. Selecting an object from the scene graph list highlights it in the viewport. Clicking on an object in the viewport, holding the mouse button down, and moving the mouse rotates the object so you can view it at different angles. At the bottom is the animation preview controller, which lets you play animations.

If you want to edit the scene, you should have the utilities view open. Xcode has three inspectors for 3D scenes: node inspector, attributes inspector, and material inspector.

Entities List

The entities list has the following folders:

  • Geometries
  • Materials
  • Cameras
  • Lights
  • Animations (animation frames)

Click the disclosure triangle next to a folder to examine and edit individual items. There will be no disclosure triangle next to a folder if it has no items.

Node Inspector

To use the node inspector you must select an element from the scene graph list. Use the node inspector to position, rotate, and scale the element. The node inspector also lets you set a scene graph element’s opacity, visibility, and rendering order.

Attributes Inspector

Like Interface Builder’s attributes inspector, what you can set in the attributes inspector depends on the entity you select. For a camera the attributes inspector lets you set the projection, the field of view, and the near and far clipping planes. For a geometric object the attributes inspector tells you the number of vertices and polygons. For a light the attributes inspector lets you specify the type of light, the color of the light, and its attenuation. Animation frames and materials do not use the attributes inspector, as far as I can tell.

Material Inspector

Select a material from the entities list to use the material inspector. Use the material inspector to set a material’s transparency, shininess, lighting model, and visibility. Some materials have a Properties section in the material inspector, which you can see in the following screenshot:

Material Properties

Each property has two buttons on the right side. The color button is initially selected, as you can see in the screenshot. Click the color well next to a property to set the color for the property. Clicking the other button allows you to set filters, wrapping modes, and a UV channel for the property. It also allows you to set an image for a property. Click the color well. An Open panel opens. Select an image file and click the Choose button.

Additional Information

Xcode’s 3D scene editing works with the Scene Kit framework. Read the Scene Kit Programming Guide and Scene Kit Framework Reference to learn more about Scene Kit. Both documents are part of Apple’s Mac documentation.

Jeff LaMarche has written an article introducing Scene Kit that should help anyone interested in learning Scene Kit.

Tags:


Leave a Reply

Your email address will not be published. Required fields are marked *