Welcome to the Viewpoint XML Reference Guide, your best resource for learning how to use Viewpoint MTX code. A published Viewpoint scene comprises an .mtx file, which contains MTX code that describes the attributes and behavior of the scene, including rich media file streaming. MTX code is based on XML (eXtensible Markup Language), a flexible, easily compressed, industry-standard data format, easily read by humans and machines.
Get started by reviewing the following features of this reference guide:
For information relating to XML, see www.xml.com. For information on how to author Viewpoint rich media and ZoomView content, see the documentation section.
Viewpoint MTX code describes the attributes of your Viewpoint scene and streams files, such as .swf and .mts files, into the scene. Use any of the following methods to generate, publish, and edit MTX code:
The following information explains the MTX key code concepts, how to structure your code, and the supported code syntax.
To understand Viewpoint MTX code, it is important to understand some of the key concepts of the code, such as object instances, scene properties, and code hierarches.
An instance is a generalized container for an object. An instance typically holds one object and its parts, but can hold other sets of display elements, also, such as multiple objects, some subset of object parts, or a duplicate reference to a previously defined part, as described below.
If a model has two or more identical components, they can be referenced as instances of the same object.
Nearly every scene attribute defined in the .mtx file has a corresponding property that either matches the exact spelling of the attribute or is a truncated match of the attribute comprising four characters. By design, most properties can be set to manipulate the scene from its original state. Properties can be set through the MTX tags listed in the scene .mtx file. They can also be set using a scripting language, such as JavaScript.
You set a property by accessing the property's corresponding value type. This value type describes how the property acts and how it can be set to modify the Viewpoint scene. For example, a Boolean property type can be set to turn on or off depending on how you design the scene. The following table lists and describes all MTX property value types.
Property Value |
Type Description |
| Boolean | Indicates off or on; value "0" or "1". Unlike boolean values in some other languages, true and false are not accepted, and 0 and 1 must be in quotes. |
| String | String of characters |
| Integer | Whole number |
| Real | Floating point number |
| Point3d | Set of three floating point numbers |
| Point2d | Set of two floating point numbers |
| Quaternion | Set of four floating point numbers, the first three specifying the 3D axes of rotation, the other being the cosine of an angle rotation |
| Rect | Set of four floating point numbers |
| Matrix | Set of 12 floating point numbers |
| Unknown | Direct pointer to objects of any type (the object's type is not specified). The Unknown value type is NOT the same as undefined. undefined means the type is not known because, in most cases, the property does not exist |
Scene animators modify a scene over time. Animators can be applied to three scene elements:
Interactors are the elements of a Viewpoint scene used to catch system, user, or scene events to trigger an action. In a Viewpoint scene, these events can include:
Hierarchies are parent-child relationships that allow certain attributes to be inherited by a child component from its parent. Within a hierarchy, each child has a parent, and can have children of its own. Each of those children, in turn, can have children, and so on.
XML is hierarchical in nature, and .mtx files take advantage of this hierarchical structure to determine how things happen in the scene. The .mtx file supports nested hierarchies for three groups of information:
Hierarchies make it possible for you to apply a command to an individual element, or to a group of elements (a parent and its children). Hierarchies can be leveraged in scene animation, including Flash and video asset files, and interactor systems, as well as 3D objects.
The .mtx file contains global information about the entire scene and the camera (the vantage point from which the scene is viewed) and other information, such as the scene properties that define the particular aspects of the scene, such as 3D objects (instances), interactors, and animators.
Since Viewpoint Media Player parses scene .mtx files from top to bottom, the order of the tags within the .mtx file is important. A scene element that refers to another scene element must ALWAYS follow the referenced element. For example, to trigger an action in your scene, such as an animation, via some specified user interaction, in the MTX code the action declaration must preceed the interactor declaration.
While a scene can contain only a subset of the MTX code structure illustrated in the following graphic, the order of these listed elements ensures the greatest content flexibility
IMPORTANT! Currently, Viewpoint publishing tools and exporters from 3D modeling applications output MTX code that is slightly different than represented in this graphic. In most cases, the published code from these tools functions as expected. However, for some content to work, such as content using interactive Flash or SVG, you must rearrange your code as illustrated here. For best results for all types of content, structure your MTX code as illustrated.
As illustrated above, for best results, a Viewpoint .mtx file should be organized in this order:
The basic building blocks of XML script are elements (or nodes), attributes, and values. "Tag" is a general term that can be used for elements and attributes.
In the following example, the MTSInstance element is made up of a starting tag (<MTSInstance>), attributes (Name and AntiAlias), values (indicated here by "value"), and a closing tag for the element (</MTSInstance>):
<MTSInstance Name="value" AntiAlias="value"></MTSInstance>
Simple tags like this one can also close themselves:
<MTSInstance Name="value" AntiAlias="value"/>
There are two broad categories of XML tags: "simple" tags, which assign a single value to a particular attribute, and "complex" tags, which can have multiple attributes. This MTSTextureMap element is simple:
<MTSTextureMap Type="Diffuse" Name="sample_file_TEXTURE_0" />
Some elements, such as MTSInstance, can have multiple subelements associated with them, some of which have their own subelements. These are called complex elements. In the following example, MTSCamera is a complex tag with one level of nested subelements:
<MTSCamera OrbitDist="4" >
<Rotate x="27.50196" y="-42.39884" z="0" />
<ViewLocation x="0" y="0" z="4" />
</MTSCamera>
Viewpoint Media Player supports Document Object Model (DOM) syntax as the means of accessing and setting MTX properties in a scene. In the words of the W3C web consortium responsible for the conception of the DOM and its further evolution, "W3C's Document Object Model (DOM) is a standard Application Programming Interface (API) to the structure of documents; it aims to make it easy for programmers to access components and to delete, add, or edit their content, attributes, and style.
At its most simple, the DOM is simply a way of navigating hierarchies or declaring ownership, both using the period (".") as separator. In hierarchies, one could think of the "." as being shorthand for "is the parent of":
grandparent.parent.child
Or, regarding ownership, you could think of it as being shorthand for "has the property":
ball.color
Or both, assuming there are no conflicts with the naming of properties and instances:
grandparent.parent.child.ball.color
Currently, the DOM syntax employs the "." to distinguish object hierarchy relationships, objects from object names, object names from property names, and property names from subproperty names. It also harmonizes Viewpoint content authoring syntax with all other DOM syntax available in JavaScript, C++, Flash ActionScript, and so forth. Also, the double colons syntax convention ("::") can distinguish object names from property names, though this convention is being phased out of the Viewpoint Media Player DOM syntax support and should only be used to declare function calls, which are explained under "Functions" below, and for referencing the Propagate property.
For more information on DOM syntax, refer to http://www.w3.org/DOM/, or to a reference for any language that uses it, like Java, JavaScript or ActionScript.
A major advantage of DOM syntax is that it allows greater access to Viewpoint scene information. For example, MTSInstance objects have a property called Geometry, which corresponds to the MTSGeometry tag in MTX code. The Geometry property has properties of its own, including Vertices. Here, we access the Vertices property of the Geometry property of the MTSInstance named cube:
MTSInstance.cube.Geometry.Vertices
The basic property value types, such as Point3d, Point2d, Quaternion, and Rect, also have subproperties. For example, the MTSInstance property Translation has the following sub-properties: x, y, and z. Therefore, to modify only an object's x translation value, specify the following path:
MTSInstance.cube.Translation.x
The following table presents the subproperties of the basic property value types:
Value Type |
Subproperties |
| Point3d | x, y, z |
| Point2d | x, y |
| Quaternion | qx, qy, qz, qs |
| Rect | left, top, right, bottom, x (same as left), y (same as top), width (same as right -left), height (same as bottom - top) |
| Matrix | Rotation, Translation, Scale, Shear |
Some properties do not correspond to one value but to a set of indexed values. These property types are called array properties. For example, the MTSGeometry property, Vertices, is an array property. The Vertices array property accesses all vertex coordinates of a geometry. Each vertex has 3D coordinates (value type: Point3d); the Vertices property is an array of the Point3d value type.
Objects have properties and functions that can be accessed using a DOM path. An object function is a specific action that a specific object knows how to execute. Unlike properties, functions do not store a state of the object, but instead trigger an action on the object. Currently, very few objects execute these built-in functions.
All Viewpoint functions are called via the VETDispatchCall element, which names the function derived from the MTSBaseComponent element. Normally, you use functions in actions. As noted above, contrary to the normal DOM syntax convention, function calls are declared using the double-colon syntax (::) instead of the period (.):
<VETDispatchCall Function="MTSBaseComponent::ClearScene()"/>