FileFormats Maya
FileFormats Maya
Version 5
2003, Alias|Wavefront, a division of Silicon Graphics Limited. All rights reserved.
Alias and the Alias|Wavefront logo are registered trademarks and Alias|Wavefront, Conductors, Trax, IPR, Maya Shockwave 3D
Exporter, Maya Artisan, Maya Cloth, Maya Complete, Maya Fluid Effects, Maya Fur, Maya Live, Maya Paint Effects, Maya Unlimited,
and MEL are trademarks of Alias|Wavefront, a division of Silicon Graphics Limited. Maya is a registered trademark of Silicon
Graphics, Inc., used exclusively by Alias|Wavefront, a division of Silicon Graphics Limited. IRIX, Open GL, and Silicon Graphics are
registered trademarks and SGI is a trademark of Silicon Graphics, Inc. mental ray and mental images are registered trademarks of
mental images GmbH & Co. KG. Lingo is a trademark and Macromedia, Director, Shockwave and Macromedia Flash are registered
trademarks of Macromedia, Inc. Wacom is a trademark of Wacom Co., Ltd. NVidia is a registered trademark and Gforce is a
trademark of NVidia Corporation. Linux is a registered trademark of Linus Torvalds. Intel and Pentium are registered trademarks of
Intel Corporation. Red Hat is a registered trademark of Red Hat, Inc. ActiveX, Microsoft, and Windows are trademarks of Microsoft
Corporation in the United States and/or other countries. Mac, Macintosh and QuickTime are trademarks of Apple Computer, Inc.,
registered in the United States and other countries. Adobe, Acrobat, and Photoshop are trademarks of Adobe Systems Incorporated.
UNIX is a registered trademark, licensed exclusively through X/Open Company, Ltd. All other trade names, trademarks and/or service
marks are trademarks or registered trademarks of their respective owners. AutoCAD is a registered trademark of Autodesk, Inc.
Adobe Illustrator and Acrobat are registered trademarks of Adobe Systems Incorporated. OpenFlight is a registered trademark of
MultiGen Inc. Java is a registered trademark of Sun Microsystems, Inc. All other trademarks, trade names, services marks, or product
names mentioned herein are property of their respective owners.
Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Animation curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Developer File formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Animation curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Import anim curves. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Export anim curves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Anim File Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
File Formats
3
Table of Contents
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
File Formats
4
1 Maya ASCII file
format
Developer File formats
Note .pda and .pdb file formats are documented in the dynExport
command documentation.
Overview
Maya scene files define the geometry, lighting, animation, rendering, and
other properties of a scene.
Maya scenes can be saved as binary or ASCII files. A Maya ASCII file can
be easily edited.
If you have written a script using Maya’s MEL programming language,
you are already familiar with the Maya ASCII file format. A Maya ASCII
file uses a tiny subset of the MEL language—in fact, of the hundreds of
commands available in MEL, only eleven are used:
• file
• requires
• createNode
• setAttr
• addAttr
• parent
• connectAttr
• disconnectAttr
• select
• currentUnit
File Formats
5
Maya ASCII file format | 1
Developer > Write file translators
• fileInfo
These MEL commands are the only MEL commands that can be safely
used in a Maya ASCII file.
If you are not familiar with MEL, you may want to look at the MEL
documentation before continuing. See <PalItal>Using Maya: MEL (on-line
only) for details.
A statement in MEL consists of a keyword, followed by a series of options
and arguments, and ends in a semicolon. A statement can span any
number of lines in the file.
• A keyword is always the first word in a statement.
• An option provides more specific information to the statement.
• An argument further defines each option.
For the examples in this chapter, the following typefaces designate the
keywords, options, and arguments:
Keywords and options are in bold-face type, such as bump or -s. The
option is always preceded by a dash.
Arguments are in non-bold italic, such as u or file.txb. The names of the
arguments are arbitrary labels. In your files, use the actual value or string.
File Formats
6
Maya ASCII file format | 1
Developer > Embedded comments
Embedded comments
An embedded comment is text in a MEL file that is ignored when the file
is read in.
If a line in the file contains two consecutive slashes (“//”), everything
from there to the end of the line is considered to be a comment. This is
commonly known as a “C++ style comment”.
If a line in the file contains a slash followed by an asterisk (“/*”),
everything from there on is considered a to be comment, until the next
occurrence of an asterisk followed by a slash (“*/”). This is commonly
known as a “C style comment”.
File Formats
7
Maya ASCII file format | 1
Developer > Organization of Maya ASCII files
Header
The file header consists of a block of comments to help identify where and
when the file was created. Like all comments, this block is ignored by the
code that reads in a Maya file. There is one exception, however: the first
six characters of the file must be “//Maya”.
File Formats
8
Maya ASCII file format | 1
Developer > Organization of Maya ASCII files
File references
The next section of the file specifies all the non-procedural references. That
is, all the other Maya files that are being referred to by this one, if any. For
each file that is referenced, there will be a single file command to read it in.
All the objects in the referenced Maya file will be available in this file, but
their names will be prefixed with a string, usually the file name. The
syntax of the file command when used for referencing is:
file -r -rpr prefixString fileName;
or
file -r -ns nameSpace fileName
The -r option specifies that the file is to be referenced. The -rpr option
specifies the string that will be prefixed to all the object names in the file.
For complete information about the file command, see the MEL Command
Reference online document.
Here is an example:
file -r -rpr “solar” “/u/sally/work/solar.ma”;
If the file “solar” contained an object called “sun”, that object would be
accessible in this file using the name “solar_sun”.
Requirements
The next section specifies the requirements. This consists of a series of
requires commands. This section of the file tells Maya what software is
needed to load the file properly. Specifically, what version of Maya, and
what plug-ins.
A statement in the Requirements section looks like this:
requires productName version
This is an example of a typical requirements section:
requires maya “2.0”;
requires specialPlugIn “1.2”;
(For a full description of the requires command, see the MEL Command
Reference online document.)
File Formats
9
Maya ASCII file format | 1
Developer > Organization of Maya ASCII files
Units
This section of the file consists of a single currentUnit command, stating
what units are used in this file. This setting will determine how all the
numbers found in the file are interpreted.
Example:
currentUnit -l cm -a deg -t ntsc;
This example would set the current linear unit to centimeters (other
options are millimeters, meters, kilometers, inches, feet, yards, and miles),
the angular unit to degrees (other option is radians) and the time unit to
NTSC. (For a full description of the currentUnit command and all of its
options, see the MEL Command Reference online document.)
File Information
This next section consists of several lines providing information about the
file. The first five of these are defined by Maya: the application name
(Maya), productization (e.g. Complete or Unlimited), version, cut
identifier (date and time), and operating system and version. If you have
provided additional fileInfo commands specific to your file, they will also
appear in this section.
fileInfo "application" "./maya.bin";
fileInfo "product" "Maya Unlimited 4.5";
fileInfo "version" "4.5";
fileInfo "cutIdentifier" "200111121041";
fileInfo "osv" "IRIX 6.5 04151556 IP32";
Maya saves out the current values for the 5 predefined fileInfo statements
each time you save your file. Any other fileInfo statements (or binary
equivalents) found when loading a file, or issued during the Maya session,
are preserved during a session and saved back out with the file.
File Formats
10
Maya ASCII file format | 1
Developer > Organization of Maya ASCII files
File Formats
11
Maya ASCII file format | 1
Developer > Organization of Maya ASCII files
“solar”, which contains an object called “sun”. In the file called “lunar”,
the scale of this object is changed to 3. This is how that would look in the
Maya ASCII file called “lunar”.
select -ne solar_sun;
setAttr “.s” -type “double3” 3.0 3.0 3.0;
It is also possible to add new (dynamic) attributes to nodes. This is done
with the addAttr command, used similarly to the setAttr command. For
this example, say you have created a sphere, and added a float-valued
attribute to it called “squish”, which can range from -1 to 1, and set that
attribute to 0.3. When you save the file, the code will look like this:
createNode transform -n “sphere”;
addAttr -ci true -sn “squish” -ln “squish”
-min -1 -max 1 -at “double”;
setAttr -k on “.squish”;
setAttr “.squish” 0.3;
// etc...
Not all of the parenting in the file can be done using the -p flag on the
createNode command. For example, nodes may need to be parented to
other nodes in referenced files. All the remaining parenting relationships
are established with the parent command, which looks like this:
parent childNodeName parentNodeName;
The parent command is also used to do instancing. (That is, when you
want to have two nodes that share children). This is done using the -add
flag, like this:
parent -add childNodeName parentNodeName;
For the special case of instancing an object at the top level (also called the
world), the -w flag is used in conjunction with the -add flag.
parent -w -add childNodeName;
(A parent node name is not specified, because the parent is the world,
which contains all things.)
Script nodes
Script nodes hold MEL code as part of a scene file. They are also set up to
(possibly) execute after loading from a file, just before closing a file, or just
before the node is deleted. The “before” scripts are executed when a file is
loaded. If a file is closed or the node is deleted, the “after” script is
executed. If a scene contains several script nodes, there is no guaranteed
order of execution and the scripts should not depend on a specific
execution sequence. See the MEL command documentation for scriptNode
and the node documentation for script node for details on how to create
script nodes.
File Formats
12
Maya ASCII file format | 1
Developer > Organization of Maya ASCII files
Because MEL gives access to virtually everything you can do in Maya, the
possibilities opened up by script nodes are endless. Specifically, script
nodes can be useful for things such as scene cleanup or custom UI.
Disconnections
In files that contain file references, this next section of the Maya ASCII file
breaks attribute connections among nodes from referenced files. This is
done with a series of disconnectAttr commands which have the following
syntax:
disconnectAttr sourceAttributeName destinationAttributeName;
For example:
disconnectAttr "sphere.tx" "cone.ry";
For complete information on the disconnectAttr command, see the MEL
Command Reference online document.
Connections
The next section of the Maya ASCII file establishes the attribute
connections among all the nodes that have been created and referenced.
This is done with a series of connectAttr commands. (For complete
information on the connectAttr command, see the MEL Command Reference
online document.)
The format of these commands is this:
connectAttr sourceAttributeName destinationAttributeName;
For example:
connectAttr “sphere.tx” “cone.ry”;
connectAttr “sphere.squish” “sphere.sz”;
Note It is possible to edit a Maya ASCII file and add MEL commands
to it. However, we advise you against doing this.
If you do decide to add custom MEL code directly to a Maya ASCII file,
keep the following in mind:
• If you edit a Maya ASCII file and add arbitrary MEL commands to it,
these commands will not be saved out after you read in the file.
File Formats
13
Maya ASCII file format | 1
Developer > Organization of Maya ASCII files
File Formats
14
2 Animation curves
Overview
Maya provides a plug-in for importing and exporting animation to a
separate file. This facilitates copying animation from one scene to another.
For example, you could animate a scene with a lightweight representation
of a character and then transfer the animation to the final rendered
version of the character in another file.
File Formats
15
Animation curves | 2
Developer > Anim File Format
Note Since MEL commands are used, any limitations they have are also
limitations of the plug-in. For example, if an anim curve is
upstream from an attribute, but there are blend nodes in-between
the attribute and the anim curve, the export command will not
work.
The File > Export Selection options window lets you set the same options
as Edit > Keys > Copy keys (see <PalItal>Using Maya: Animation for
details) which are used to export the animation from the selected object(s).
When an anim file is exported, any information previously on the API
clipboard is replaced with the new anim curves after the file export.
File Formats
16
Animation curves | 2
Developer > Anim File Format
// The following two lines are optional. If they are not included,
// the clipboard is set to the range defined by the anim curves
// contained in the clipboard.
//
// These are used by anim curves that have time inputs.
//
startTime [float] // The starting frame for the clipboard.
endTime [float] // The ending frame for the clipboard.
// The following two lines are optional. If they are not included,
// the clipboard is set to the range defined by the anim curves
// contained in the clipboard.
//
// These are used by anim curves with unitless inputs.
//
startUnitless [float] // The starting value for for the clipboard.
endUnitless [float] // The ending value for the clipboard.
// The following three keywords are used to set the units for the file.
// Each anim curve may have its own units, but these are the default
// units if the anim curve units are not given (see the animData section).
//
// If the units are not given, then the ui units are used.
//
timeUnit [game|film|pal|ntsc|show|palf|ntscf|hour|min|sec|millisec]
linearUnit [mm|cm|m|km|in|ft|yd|mi]
angularUnit [rad|deg|min|sec]
// All of the keywords described above can only be in the header section
// of the file. As soon as anim curve information is encountered, the
// header section is completed and the body of the file is begun.
//
// The string is the name of the attribute the anim curve is connected to.
// The next three ints are the row, child, and attr values used by the
// clipboard. See the documentation for MAnimCurveClipboard for more
// information.
//
// If the anim curve is not connected to any attributes, the string
// is not needed, but the following ints should be 0 0 0.
anim [string] [int] [int] [int]
File Formats
17
Animation curves | 2
Developer > Anim File Format
// The second form of the anim line has three strings which list what
// the anim curve was connected to.
//
// The strings are: the full attribute name, the leaf attribute name,
// and the node name. The row, child, and attr ints are still required.
//
anim [string] [string] [string] [int] [int] [int]
// The third and final form of the anim line is used for clipboard
// place holder objects. These are used to skip node which do not
// contain any anim curve data, but are positioned in a hierarchy
// with nodes that have attached anim curves.
//
// In this case, the string is the node name and the three ints are the
// same as the other two formats.
//
anim [string] [int] [int] [int]
// The unit of the anim curve output. The output unit should match
// the output type of the curve. These default to the units specified
// in the header.
outputUnit [game|film|pal|ntsc|show|palf|ntscf|hour|min|sec|millisec]
outputUnit [mm|cm|m|km|in|ft|yd|mi]
outputUnit [rad|deg|min|sec]
// The unit of the tangent angles, if there are any fixed tangents.
// The units default to the angular units specified in the file header.
tangentAngleUnit [rad|deg|min|sec]
File Formats
18
Animation curves | 2
Developer > Anim File Format
// The start of the actual keyframe data. Each key is a row in the
// braced section.
keys {
[float] [float] [in tan] [out tan] [tan locked] [weight locked]
// animVersion 1.1 adds breakdown information
[float] [float] [in tan] [out tan] [tan locked] [weight locked]
[breakdown]
.
.
.
// The first two values are the input and output values in the
// units defined by the inputUnit and outputUnit keywords.
// The in and out tangents should be valid tangent types.
// These are followed by three int values for tangent locking,
// weight locking and the breakdown flag. If they are 0, the values
// are unlocked, or not a breakdown, otherwise they are locked.
//
// If either, or both, or the tangents are fixed, then additional
// information is needed: a tangent angle and weight.
// These two values, per fixed tangent, are added at the end of
// the above line.
//
// For example:
// 1.0 2.0 fixed linear 1 1 0 62.345 0.04;
//
// In the above case, 62.345 is the tangent angle for the first
// tangent and the tangent weight is 0.04.
//
// An example with two fixed tangents:
// 1.0 2.0 fixed fixed 1 1 0 62.345 0.04 45.3 0.023;
}
}
The pattern of an anim line followed by animData should be used until all of
the anim curves are described.
The following example is an animated joint chain consisting of 4 joints. The
first three joints are animated and the fourth joint is not animated.
animVersion 1.1;
mayaVersion 2.0;
timeUnit ntsc;
linearUnit cm;
angularUnit deg;
startTime 1;
endTime 30;
anim rotate.rotateX rotateX joint1 0 1 0;
animData {
input time;
output angular;
File Formats
19
Animation curves | 2
Developer > Anim File Format
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
1 0 linear linear 1 1 0;
30 0 linear linear 1 1 0;
}
}
anim rotate.rotateY rotateY joint1 0 1 1;
animData {
input time;
output angular;
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
1 0 linear linear 1 1 0;
30 0 linear linear 1 1 0;
}
}
anim rotate.rotateZ rotateZ joint1 0 1 2;
animData {
input time;
output angular;
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
1 0 spline spline 1 1 0;
10 -16.774359 spline spline 1 1 0;
15 -1.6493069 spline spline 1 1 0;
22 -3.064691 spline spline 1 1 0;
30 0 spline spline 1 1 0;
}
}
anim rotate.rotateX rotateX joint2 1 1 0;
animData {
input time;
output angular;
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
1 0 linear linear 1 1 0;
30 0 linear linear 1 1 0;
}
}
anim rotate.rotateZ rotateZ joint2 1 1 1;
animData {
input time;
File Formats
20
Animation curves | 2
Developer > Anim File Format
output angular;
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
1 0 spline spline 1 1 0;
10 60.962438 spline spline 1 1 0;
15 106.06094 spline spline 1 1 0;
22 33.259896 spline spline 1 1 0;
30 0 spline spline 1 1 0;
}
}
anim rotate.rotateX rotateX joint3 2 1 0;
animData {
input time;
output angular;
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
1 0 spline spline 1 1 0;
10 0 spline spline 1 1 0;
15 0 spline spline 1 1 0;
22 0 spline spline 1 1 0;
30 0 spline spline 1 1 0;
}
}
anim rotate.rotateY rotateY joint3 2 1 1;
animData {
input time;
output angular;
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
1 0 spline spline 1 1 0;
10 0 spline spline 1 1 0;
15 0 spline spline 1 1 0;
22 0 spline spline 1 1 0;
30 0 spline spline 1 1 0;
}
}
anim rotate.rotateZ rotateZ joint3 2 1 2;
animData {
input time;
output angular;
weighted 0;
preInfinity constant;
postInfinity constant;
keys {
File Formats
21
Animation curves | 2
Developer > Anim File Format
1 0 spline spline 1 1 0;
10 0 spline spline 1 1 0;
15 0 spline spline 1 1 0;
22 0 spline spline 1 1 0;
30 0 spline spline 1 1 0;
}
}
anim joint4 3 0 0;
File Formats
22
3 Maya Image File
Format (IFF)
Developer File formats
Maya IFF
Overview
Maya outputs images in the Interchange File Format (IFF). IFF is a generic
structured file access mechanism, and is not limited to images - for
example, AIFF files are audio IFF. IFF images can have 8 or 16 bit per
channel RGB, and optionally Alpha, and can optionally contain a 32-bit
floating point depth map (sometimes called a Z-buffer).
Shadow maps
Light sources in Maya can read and write shadow maps. These shadow
maps are stored as a depth map in an IFF file. The depth map may be
either a traditional Z buffer or a midmap. The stored value for a midmap
File Formats
23
Maya Image File Format (IFF) | 3
Developer > View and convert IFF images
is half of the distance between the first and second surfaces. Midmaps
reduce the number of incorrect self shadowing occurrences. For more
information on midmaps, see Graphics Gems 3, p. 338.
Different light sources produce different shadow maps. A spot light
subtending an angle below 90 degrees will produce one shadow map. If
the subtended angle is greater than 90 degrees, it will produce five
shadow maps - one central and five peripheral. A point light will produce
one shadow map in a simple scene, and up to six shadow maps in more
complicated scenes.
Try the following example:
1 Load a scene with a light in it, such as torusShadow.ma
2 Select the light and open the Attribute Editor.
3 Expand the Shadows section.
4 Check the Use depth map check box in the Depth Map Shadow
Attributes section.
5 If you want a midmap, check the Use Mid Dist Depth Map check box
in the same section.
6 Check the Write shadow map check box in the same section. Enter a
file prefix in the Depth map name text field.
7 Render a scene.
8 You should now have one file*, each beginning with the prefix
selected in step 6. The suffix will be the name of the light source and
then the type of shadow map generated. For the torusShadow
example, you should have one of two images,
shadowmap_pointLightShape1_int.SM.iff or
shadowmap_pointLightShape1_int.MIDMAP.SM.iff, depending upon
your choice in step 5.
File Formats
24
Maya Image File Format (IFF) | 3
Developer > Program with the IL and FL libraries
Additional resources
IL and FL man pages
The IL and FL man pages contain documentation for each of the functions
that can be called from a plug-in to manipulate IFF files. See the
IFFmanPages for details.
File Formats
25
Maya Image File Format (IFF) | 3
Developer > IFF Format overview
Kernel
File type independence
The primary goal of the flib library is to present all file accesses in a
homogeneous manner. Disk files, pipes, memory segments, and so on are
all logically represented as files and are manipulated through the same set
of functions. The flib kernel is composed of eight functions: FLopen,
FLreopen, FLclose, FLread, FLwrite, FLseek, FLtell and FLflush. These low
level IO routines can be used instead of the libc routines (open, fopen,
read, fread, write, fwrite...).
Another advantage is the removal of certain restrictions caused by the
files opening mode. For example, writing in a read open pipe file (such as
“pipe:cat file”) is made possible.
FLopen uses naming conventions to identify the type of logical file you
wish to handle (no longer necessary to specify different methods for open,
popen, fopen, socket, and so on). The currently recognized names are:
File Formats
26
Maya Image File Format (IFF) | 3
Developer > IFF Format overview
Certain limitations exist depending on the exact nature of the opened file
object (e.g. can’t FLseek on a pipe).
Files are buffered when this makes sense. Transfers can equally be
accelerated by minimizing the amount of memory moves. FLbgnread,
FLendread, FLbgnwrite and FLendwrite allow you to gain direct access to
the read/write buffers in the library. These are particularly efficient for
memory mapped files.
Format independence
File access libraries based on flib can provide an extra degree of
independence with respect to the format of the data it contains by using
the FLfilter function which lets you pass a file through an external filter
before reading/writing it.
Control
Error handling is similar to that offered by the standard C IO functions
and system calls. The state variable flerror is modified when a error occurs
and several functions are provided to allow access to this value: FLerror,
FLseterror, FLperror, FLstrerror, FLoserror, and FLsetoserror. The set of
errors that are handled is a superset of the IRIX and Linux standard errors
(errno, strerror, h_errno and hstrerror if supported by the system).
IO functions are implemented to avoid cascading errors. However, it is
strongly suggested that you do not attempt to continue reading/writing
when an error occurs.
Certain parameters of the library can be modified by calling FLconfig:
creation of temporary files, mapping, automatic compression/
decompression.
FLsetpath and FLaddpath allow you to define and augment the path used
to resolve file names for read access.
FLbuildpath and FLfreepath are used to construct and destroy path that
are activatable by the FLswitchpath call which optimizes frequent path
changes. FLsetreorder can also be called to optimize path traversal.
File Formats
27
Maya Image File Format (IFF) | 3
Developer > IFF Format overview
Structured files
Flib implements a set of rules for file structure derived from IFF. The
structure is based on the use of tags to identify blocks of data called
chunks or structures of chunks called groups. Each tag is made up of four
characters and is immediately followed by the size of the chunk or group
that it describes coded on 4 bytes. This structure is the same as in the IFF
(Interchange File Format) used by PC, Mac, Indigo... , with a few
extensions. All data is written in big endian format, except for tags, which
are handled as pseudo character strings. (Byte swapping is handled at
compile time).
Block size data allows the parser to skip information it does not recognize.
There are two types of tags: tags that define the file structure (i.e groups)
and tags that contain data.
Groups
Four tags are used to arrange blocks into groups: FORM, CAT, LIST, and
PROP. The first four characters following the size are used to identify the
type of the group.
FORM defines the beginning of a data block, in a way similar to a C struct.
FORM 38 TEXT
CHAR 6 “Times”
CHAR 12 “Hello World”
EOF
is similar to
struct Text t = {
char *f = “Times”;
char *c = “Hello World”;
};
The size of the group (38) is equal to the size of the data it contains (6 plus
12) plus the size of the headers (4 for TEXT, 8 for CHAR 6 and 8 for CHAR
12) giving, in this case, 6+12+4+8+8 = 38.
As in C structures you can nest groups as in the following example:
FORM 52 TEXT
FORM 8 FONT
CHAR 6 “Times”
LONG 4 <12>
LONG 4 <0>
CHAR 12 “Hello World”
EOF
or in C terms:
struct Text t = {
File Formats
28
Maya Image File Format (IFF) | 3
Developer > IFF Format overview
struct Font f = {
char *n = “Times”;
int s = 12;
int d = 0;
};
char *string = “Hello World”;
};
This example may not show that blocks are not constrained to use a
unique data type and may contain the equivalent of a complete C
structure. The role of the FORM tag is to separate independent blocks of
data that can be handled separately and to specify the meaning of each
sub-unit. In the example above the CHAR chunk in the FONT FORM does
not mean the same thing as the CHAR chunk in the TEXT FORM. The
FORM tag is used to determine how you interpret an ordered set of data
types.
CAT defines a concatenation of independent objects with no order relation
between them. Two typical uses of CAT’s are for libraries of objects
(pictures in the upcoming example) or clipboards (second example).
CAT 3632 PICT
FORM 1234 PICT ...
FORM 2378 PICT ...
EOF
File Formats
29
Maya Image File Format (IFF) | 3
Developer > IFF Format overview
Data blocks
Data blocks are defined by:
[tag] [size] [data]
Example: an image could have the following structure:
FORM 12304 IMAG
IHDR 200 ... picture header, size, maps ...
LINE 800 ... data from line 1 ...
LINE 800 ... data from line 2 ...
...
for a library:
CAT 64200 IMAG
FORM 12304 IMAG
IHDR 200
...
FORM 12304 IMAG
...
and for a sequence,
LIST 64200 IMAG
PROP 208 IMAG
IHDR 200 ... Common header ...
FORM 12394 IMAG
...
FORM 12304 IMAG
IHDR 200 ... Local redefinition ...
...
Alignment considerations
IFF blocks align to 2 byte boundaries. The size specified in the header does
not take the padding into account. Current machines typically align their
memory on 4 or 8 byte boundaries. Flib uses 8 extra TAGS to let you
File Formats
30
Maya Image File Format (IFF) | 3
Developer > Introduction to the image library
Extensions
One of the major constraints of IFF is that you have to know the size of a
group or a chunk before writing it to a file. If you want to change the
information a block contains you have to be able to modify the header to
reflect changes in the size of the structure. This poses no problem for
seekable file (memory or disk files) but does pose problems for other types
of files. Rather than create intermediate temporary files, flib implements a
mechanism allowing you to say that you don’t know the size of the block
you are working on. Since negative block sizes are meaningless, two
special values are set aside for this purpose: FL_szFile, indicating that the
size will be written in later once the entire group has been written and
FL_szFifo indicating that the size will not be written because the file is not
seekable, A special zero sized block (GEND) is used to indicate the end of
the structure.
Functions
Blocks can be read and written using calls to FLgetchunk and
FLputchunk. For more direct control the user can call FLbgnget and
FLbgnput to open a block. FLput and FLget supply services equivalent to
FLread and FLwrite within a block. After appropriate number of FLput or
FLget calls you close the block using FLendput or FLendget.
Groups are handled using FLbgnrgroup, FLbgnWgroup, FLendrgroup
and FLendwgroup. Flib also implements a generic parser, FLparse, that
can scan a file and check its consistency as well install callbacks for each
step of the parse (start of group end of group).
Toolbox
The flib library also provides tools for the handling of linked lists
(FLxxxnode and FLxxxlist), buffers ((FLmalloc and al) and external filters
(FLfilter and FLexec).
File Formats
31
Maya Image File Format (IFF) | 3
Developer > Introduction to the image library
File format
The format of an image file is very flexible. Constraints on the number and
relative position of the different blocks are minimal and often purely of a
logical nature (for example, “the header must come before the pixel
blocks” rather than more static constraints such as “the header begins at
offset 124”).
An image file being first and foremost a file (as far as flib is concerned) the
user is free to insert extra blocks. A minimal image is composed of a FOR4
group (aligned to a word) of CIMG type containing, in the following
order:
• a BMHD header (bitmap header)
• a FOR4 group of type TBMP (tiled bitmap)
Pixel information is contained in the TBMP group, which can be quickly
skipped if necessary.
In its minimal version, the TBMP group contains pixel related data blocks,
in some order. For example, for a picture divided in four tiles we have:
FOR4 <size> CIMG
BMHD 24 ... definition of size, maps, etc...
FOR4 <size2> TBMP
RGBA <ttile1>... tile 1 pixels ...
RGBA <ttile2>... tile 2 pixels ...
RGBA <ttile3>... tile 3 pixels ...
RGBA <ttile4>... tile 4 pixels ...
The header is defined by structure ILheader. RGBA blocks have the
following structure:
[x1, y1, x2, y2] : tile coordinates (2 bytes each)
[pixels] : encoded according to compression mode.
If the image has a z-buffer, it is described by ZBUF blocks with the same
structure as the RGBA blocks, RLE encoded.
• End fields. They display at the end of any image data, and will be
displayed by fcheck. Calls to FLIB after image loading can be used to
check for and retrieve this data. ILIB ignores these fields. The
following four fields provide information about the image:
HIST—string data giving the Maya command line from which this image
was created.
VERS—string data giving the Maya cut information.
CLPZ—depth map specific field giving the clipping planes used. This
information is stored as two float values.
File Formats
32
Maya Image File Format (IFF) | 3
Developer > Extensions to the IFF format
ESXY—eye x-y ratios. This is a depth map specific field used to compute
the xy eye coordinates from the normalized pixel coordinates stored as
two float values.
Note: The ILIB library does not support these end fields.
Functions
Some functions allow the reading and writing of images in line to line
mode without worrying about tile management. Images can also be
automatically zoomed and/or corrected (by lookup) during read
(correction on compressed data being significantly more efficient). Finally,
an automatic conversion system makes it possible to read images stored
under other formats.
For more details on routines from the image library, see the man pages as
well as “includes” and examples provided with the library.
Syntax:
PATH # <directory names>
INCL # <file names>
EOVC szUnknown
GEND 0
PATH and INCL are data chunks and thus inherit alignment.
EOVC and GEND are use in fifo files since the chunk and group sizes can
not be random accessed. Creating groups or chunks with unspecified size
on a fifo will give something like:
FORM sz_Fifo TYPE; start of form
BLCK sz_Fifodata; block 1
EOVC sz_Unknown; end of block 1
.... ;
BLCK sz_Fifodata; block 2
EOVC sz_Unknown; end of block 2
GEND 0 ; no more block in this FORM
EOVC is a block/group end marker, while GEND is understood as a
request to close the current group, going up one level.
File Formats
33
Maya Image File Format (IFF) | 3
Developer > Extensions to the IFF format
Using unknown sizes when writing a seekable file will produce a very
similar structure except that no EOVC is written. This is very useful when
parsing a file under construction since the end of group can be detected
w/o any random access to the group header. The size field of GEND is set
to zero to allow other standard IFF parsers to skip it silently. The EOVC’s
size field value will produce an error if read by a standard parser (w/o
fifo extensions).
File Formats
34
4 Channel move files
(.mov)
Developer File formats
Channel move files (.mov)
A move file is an ASCII file that stores the channel data (such as x
translate, y translate, and z translate).
Format
The .mov file is a matrix of numbers where rows represent frames and
columns represent channels. There is one row for each frame in the .mov
file and one column for each channel.
Each row must start on a new line and each column must be separated by
spaces. The channel data is represented as doubles. This allows for
roughly 16 significant digits.
The following is a sample format from a .mov file. It has four rows and six
columns. This means that the sample shows the channel data for four
frames and six channels.
1.000 0.000 0.900 36.0000.000
0.000
4.000 0.000 2.000 36.0000.000
8.000
0.000 9.500 16.0008.0000.000
0.000
9.450 0.000 0.000 50.0003.500
8.000
You can read and write .mov files to import and export motion data.
Remember, however, that the .mov file is simply columns of numbers
without any header information. In order for data to be written out and
read back into the same objects and channels, the list of channels must be
identical in the File Import/Export option boxes or with the movIn/
movOut commands.
File Formats
35
Channel move files (.mov) | 4
Developer > Channel move files (.mov)
File Formats
36
Index
E
A editing limitations
addAttr command . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . 13
alignment considerations embedded comments . . . . . . . . . . . . . . . . . . . . . . . . . 7
in Maya image file format . . . . . . . . . . . . . . . . . 30 EOVC extension
attribute connections to Maya image file format . . . . . . . . . . . . . . . . . 33
in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . . 8 example programs
attributes image programs. . . . . . . . . . . . . . . . . . . . . . . . . . 25
in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . 10 extensions
EOVC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
GEND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
B in Maya image file format . . . . . . . . . . . . . . . . . 31
blocks INCL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
alignment considerations . . . . . . . . . . . . . . . . . . 30 PATH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
F
C fcheck stand-alone utility
CAT to view Maya image files . . . . . . . . . . . . . . . . . . 24
in image file format groups . . . . . . . . . . . . . . . . 28 file formats
comments, embedded . . . . . . . . . . . . . . . . . . . . . . . . . 7 and depth maps . . . . . . . . . . . . . . . . . . . . . . . . . . 23
connectAttr command. . . . . . . . . . . . . . . . . . . . . . . . 13 and shadow maps . . . . . . . . . . . . . . . . . . . . . . . . 23
connections generating. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
attribute. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Maya image file format (IFF) . . . . . . . . . . . . . . . 23
in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . 13 file references
converting Maya image files in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . . 9
with imgcvt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 file structure
createNode command . . . . . . . . . . . . . . . . . . . . . . . . 11 and Maya image file format. . . . . . . . . . . . . . . . 28
currentUnit command. . . . . . . . . . . . . . . . . . . . . . . . 10 file translators
from Maya ASCII format . . . . . . . . . . . . . . . . . . . 6
to Maya ASCII format. . . . . . . . . . . . . . . . . . . . . . 6
D FL library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
data blocks FL_szFifo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
in Maya image file format . . . . . . . . . . . . . . . . . 30 FL_szFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
data organization FLaddpath. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . . 7 FLbgnget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
FLbgnput. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
FLbgnread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
File Formats
37
Index
FLbgnrgroup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 FLwrite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
FLbgnWgroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 FORM
FLbgnwrite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 in image file format groups . . . . . . . . . . . . . . . . 28
FLbuildpath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 format independence
FLconfig. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 and FLfilter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
FLendget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
reading and writing blocks . . . . . . . . . . . . . . . . 31
FLendput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
FLendread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
FLendrgroup. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 G
FLendwgroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
GEND extension
FLendwrite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 to Maya image file format . . . . . . . . . . . . . . . . . 33
FLerror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 groups
FLfilter in file structure. . . . . . . . . . . . . . . . . . . . . . . . . . . 28
and format independence . . . . . . . . . . . . . . . . . 27
FLfreepath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
FLget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 I
FLgetchunk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 IFF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Flib and depth maps . . . . . . . . . . . . . . . . . . . . . . . . . . 23
and file structure . . . . . . . . . . . . . . . . . . . . . . . . . 28 and shadow maps . . . . . . . . . . . . . . . . . . . . . . . . 23
and groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 generating images . . . . . . . . . . . . . . . . . . . . . . . . 23
toolbox. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 LIST groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Flib kernel overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
FLclose. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 PROP groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
FLflush . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 IL library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
FLopen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 image file format
FLread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 and depth maps . . . . . . . . . . . . . . . . . . . . . . . . . . 23
FLreopen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 and shadow maps . . . . . . . . . . . . . . . . . . . . . . . . 23
FLseek . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 CAT groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
FLtell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 FORM groups. . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
FLwrite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 generating images . . . . . . . . . . . . . . . . . . . . . . . . 23
FLopen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Maya IFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
FLoserror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Maya image file functions . . . . . . . . . . . . . . . . . 33
FLparse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Maya image files . . . . . . . . . . . . . . . . . . . . . . . . . 32
overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
FLperror. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
image library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
FLput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
imgcvt stand-alone utility
FLputchunk. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
to convert Maya image files . . . . . . . . . . . . . . . . 24
FLread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
INCL extension
FLseterror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
to Maya image file format . . . . . . . . . . . . . . . . . 33
FLsetoserror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
IO image library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
FLsetpath. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
FLsetreorder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
FLstrerror . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
FLswitchpath . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
File Formats
38
Index
N
M
nodes
Maya ASCII files in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . 7, 10
attribute connections. . . . . . . . . . . . . . . . . . . . . . . 8
attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 O
data organization. . . . . . . . . . . . . . . . . . . . . . . . . . 7
organization
file references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
of Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . . 8
limitations to editing . . . . . . . . . . . . . . . . . . . . . . 13
nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7, 10 organization of data, in Maya ASCII files . . . . . . . . 7
organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
parenting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
P
units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 parent command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Maya image file format parenting
and CAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . 7, 10
and data blocks . . . . . . . . . . . . . . . . . . . . . . . . . . 30 PATH extension
and file structure . . . . . . . . . . . . . . . . . . . . . . . . . 28 to Maya image file format . . . . . . . . . . . . . . . . . 33
and file structure groups . . . . . . . . . . . . . . . . . . 28 programming
and FORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 with FL library . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
and LIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 with IL library . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
and PROP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 PROP
block alignment considerations. . . . . . . . . . . . . 30 in IFF groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
EOVC extensions . . . . . . . . . . . . . . . . . . . . . . . . . 33
extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31, 33 R
GEND extensions. . . . . . . . . . . . . . . . . . . . . . . . . 33
references file, in Maya ASCII files . . . . . . . . . . . . . . 9
INCL extensions . . . . . . . . . . . . . . . . . . . . . . . . . 33
IO image library. . . . . . . . . . . . . . . . . . . . . . . . . . 31 rendering images with Maya IFF . . . . . . . . . . . . . . 23
overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 requirements
PATH extensions . . . . . . . . . . . . . . . . . . . . . . . . . 33 in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . . 9
Maya image file format (IFF) . . . . . . . . . . . . . . . . . . 23
and depth maps . . . . . . . . . . . . . . . . . . . . . . . . . . 23
and shadow maps . . . . . . . . . . . . . . . . . . . . . . . . 23
S
generating images . . . . . . . . . . . . . . . . . . . . . . . . 23 setAttr command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
File Formats
39
Index
shadow maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
T
toolbox
in Flib library . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
translators
writing from Maya ASCII format . . . . . . . . . . . . 6
writing to Maya ASCII format. . . . . . . . . . . . . . . 6
U
units
in Maya ASCII files . . . . . . . . . . . . . . . . . . . . . . . 10
V
viewing Maya image files
with fcheck . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
W
writing file translators
from Maya ASCII format . . . . . . . . . . . . . . . . . . . 6
to Maya ASCII format. . . . . . . . . . . . . . . . . . . . . . 6
File Formats
40