Serializes the object tree to the underlying stream using the given formatter.
Applications should call this method to serialize a part of the scene graph. The nodes in the scene graph may then choose to conditionally serialize their references by calling WriteConditionalObject from their
GetObjectData method. For example, all nodes implemented in the piccolo framework conditionally serialize their parents so that serializing a node won't pull in the entire object graph. See PNode.GetObjectData.