Class

MDLObject

The base class for objects that are part of a 3D asset, including meshes, cameras, and lights.

Declaration

@interface MDLObject : NSObject

Overview

When you load content from an asset file using the MDLAsset class, Model I/O creates instances of the MDLObject subclasses MDLMesh, MDLCamera, and MDLLight. For asset formats that describe a collection of meshes, cameras, and lights organized in a hierarchy of spatial transforms, Model I/O also creates instances of the MDLObject class itself to describe the transform nodes that organize the asset’s visual content. Similarly, you use the MDLObject class and its subclasses when creating an object graph to be exported as an asset file using the MDLAsset class.

Extending Model I/O with Components

Model I/O allows you to customize the content and relationships in an object graph with components. For each aspect of an object’s functionality, you use a component protocol (extending the MDLComponent protocol) to define functionality and a class adopting that protocol to implement it. Then, you can use the componentConformingToProtocol: and setComponent:forProtocol: methods to associate those objects with any instance of the MDLObject class or of one of its subclasses. For example, you might define a protocol to add gameplay-related information such as scripting triggers to certain meshes, lights, or cameras in a scene.

Model I/O itself uses this mechanism to handle object hierarchies and spatial transforms: The methods listed in Working with Object Hierarchies use the MDLObjectContainerComponent protocol to model hierarchic relationships between objects in an asset, and the methods listed in Working with Objects in Space use the MDLTransformComponent protocol to model coordinate space relationships. To add support for an asset file format or object graph that uses other ways to store or compute these relationships, you can use your own classes that adopt these protocols.

Topics

Customizing Objects with Components

- componentConformingToProtocol:

Returns the object’s component for the specified protocol.

- setComponent:forProtocol:

Associates a component with the object for the specified protocol.

Working with Object Hierarchies

parent

The parent object that contains this object.

children

A component that manages this object’s collection of children.

- addChild:

Adds a child object to this object, creating a container for the object’s children if necessary.

- enumerateChildObjectsOfClass:root:usingBlock:stopPointer:

Executes the specified block using each object in this object's child hierarchy.

path

A path that identifies the object in an asset's object hierarchy using object names.

- objectAtPath:

Returns the child object at the specified path.

Working with Objects in Space

- boundingBoxAtTime:

Returns the minimum region entirely enclosing the object’s contents at the specified time sample.

transform

A component that manages this object’s spatial transform and its changes over time.

Managing Rendering Intent

hidden

A Boolean value indicating whether this object should be used in rendering.

instance

The master object, if applicable, of which this object is an instance.

path

A path that identifies the object in an asset's object hierarchy using object names.

Object Instancing

- objectAtPath:

Returns the child object at the specified path.

- enumerateChildObjectsOfClass:root:usingBlock:stopPointer:

Executes the specified block using each object in this object's child hierarchy.

Importing Objects from SceneKit

+ objectWithSCNNode:bufferAllocator:

Creates a Model I/O object from the specified SceneKit node, using the specified allocator.

+ objectWithSCNNode:

Creates a Model I/O object from the specified SceneKit node.

Constants

MDLAxisAlignedBoundingBox

The minimal volume containing an object, used by the boundingBoxAtTime: method.

Relationships

Inherits From

Conforms To

See Also

3D Asset Basics

MDLAsset

An indexed container for 3D objects and associated information, such as transform hierarchies, meshes, cameras, and lights.

MDLTransform

A description of the local coordinate space transformations for a 3D object.

MDLMesh

A container for vertex buffer data to be used in rendering a 3D object.

MDLSubmesh

A container for index buffer data and material information to be used in rendering all or part of a 3D object.

MDLSubmeshTopology

A description of how a submesh's index buffer data is arranged and how that arrangement should be used to produce the submesh's intended 3D shape.

MDLNamed

The common interface for Model I/O objects that expose a human-readable name.