Professional Documents
Culture Documents
SM4125 07
SM4125 07
If you prepare your models using other 3D software, you have to export your model into a file,
and import it into TouchDesigner. There are a lot of 3D file format exists. Some of them are
software specific (such as Maya .mb format or 3DMax .max format). These formats are not open
specification; therefore, other software doesn’t know how to read this format, and it is hard to
use them in interactive applications.
For open specification file format, the most commonly used one is the OBJ format. OBJ file can
be used to store a polygonal model. Most software can export OBJ file format. Note that OBJ
file is in ASCII format; therefore, you can open it using Wordpad. This is a sample OBJ files:
vt 0.097491 0.216394
Lines specify the vertex texture coordinate
vt 0.118324 0.225427
……
……
usemtl blinn1SG
Lines specify the material being used
f 1/1/1 2/2/2 3/3/3 4/4/4
However, OBJ format does not support animation. Moreover, the “material” specification for OBJ
is not a “standard”. A file with extension .mtl (stands for the material) will usually be created
together with the .obj file, but most software will ignore this .mtl file when it reads the .obj file.
You can import an OBJ file into TouchDesigner (e.g. W:\SM4125\week07\head.obj and
Prepared by Kam Wong 1
SCM, City University of Hong Kong
Jan 2009
SM4125 Computer Animation for Interactive Content I
head.mtl):
1. File > Import File….
2. Locate your OBJ file, and click “Import”. (If the file size is large, it will take a few seconds
to load it.)
After that, a Geometry COMP is created, which contains the models and the materials:
Note that the converted models are stored externally in your project folder, under a
sub-folder named “Import”. Note also that TouchDesigner can preserve simple material only;
if a material file .mtl contains a texture, TouchDesigner cannot preserve it. In this case, you
have to go all the way down to the imported model’s materials, and adjust the material
parameters by yourselves:
Go all the way down the Geometry COMP You can also find the SOP of the model.
you can find the material. If the Of course, you can attach other SOPs
material is not preserved, you can adjust afterward to further modify your model.
There doesn’t exist a “standard” 3D file format that contains animation data. Recently,
Autodesk defines a 3D file format called .FBX file, and it also provides a utility libraries for us to
read and manipulate those .FBX files. Moreover, as it is defined by Autodesk, the 3D software
Maya is shipped with a plug-in to export this file format. Lastly, there are free 3D models on the
Internet with this file format. So, FBX may be one of the best formats for 3D models exchange
between different software.
There are some features of .FBX file that you may want to know:
FBX file can be in text (ASCII) format, i.e. you can open it using WordPad.
FBX file contains all the information about a 3D model, including the mesh (i.e. the
triangles), materials, textures, animation, skinning information and object hierarchy.
FBX file stores animation data as “takes”. A file can contain more than one “takes”. For
example, a FBX file can contain a take for “walk”, another take for “jump”, another take for
“die”, etc. However, the Maya exporter cannot output more than one takes.
Usually we will not use the lights and camera included in an FBX file. Lights and camera will
the texture. The Maya exporter will store the absolute filename as
“G:\abc\def\texture.tga”. However, if you move the files to other folder (or to other
machine), the absolute filename may not be valid again. In this case, you can modify the
stored texture name directly using Wordpad: just open the .FBX file, and search for the
Open the file robot.fbx using WordPad, and get a feeling how a FBX file looks like. Also search
for the word “Grid.tga”. You will find that texture name is stored in the FBX file; so you need to
copy the texture file “Grid.tga” to your folder as well.
sub-folder “Import”
Select the Component “takes” and go inside. You can find the following:
A File CHOP, which is used to read A Switch CHOP, which is used to switch
Because the Maya exporter cannot output more than one takes, when I prepared this
robot.fbx file, I arranged the animation inside Maya in the following manner:
“rotate” animation. Can either animation, supposed to be play animation, supposed to be play
be played by trigger, or keep once when trigger, and stop at once when trigger, and stop at
playing in TouchDesigner. first frame (i.e. frame 24) last frame (i.e. frame 52)
Therefore, in order to use the animation inside the TouchDesigner, I have to modify the network
inside the “takes”. I need to “split the time-line” back into 3 animation segments.
Before I modify the network, it is better the change the option of the “exportAnim” OP to “Cook
Type: always”, so to force it to calculate at every frame. Otherwise, in some situation it will not
compute the most updated value of “takes”, as a result making your object doesn’t move:
Before we go ahead, you should also pay attention about the frame-per-second and frame
number issue: by default, TouchDesigner uses 60 fps (suitable for real-time applications), but
animation created in Maya is usually 24 fps. After import into TouchDesigner, the speed of the
animation will be kept the same, but the “frame number” is stretched to fit the new rate 60
fps. Therefore, a frame number “5” in Maya may not be “5” inside TouchDesigner after imported.
So if you need to specify “frame number” in any parameters of TouchDesigner OPs, you should be
careful.
Moreover, TouchDesigner will start the animation at frame#0, and in Maya I start the animation
at frame#1. Middle-click on the “Take_001” OP, you will find that the animation is from frame 0
to frame 129. A simple formula can be written down:
So my next step is to separate my animations into 3 segments, using Trim CHOP to take out the
frames, and Shift CHOP to shift all the animation segments to start at frame#1 (i.e. second 0).
Moreover, by default the animation will be looped; but for animation that should be triggered,
such as “jump” and “die”, I attach an Extend CHOP to prevent the animation becomes “cycle” at
the end:
Trim CHOP
Unit Values: Absolute Shift CHOP
Start: 59 (frame)
I also want to create a “do nothing” action: the object holds at its first frame and do nothing. I
can use the Lookup CHOP to create a “new action” and plug it into Switch CHOP:
Lookup CHOP
Now I have 4 actions, and I can modify the Switch CHOP so that I can use a “radio button”
network (taught in previous class) to be the index for choosing one of the actions. Suppose I use
keypad-0 as dummy key, keypad-1 for “do nothing”, keypad-2 for “rotate”, keypad-3 for “jump”,
The next step is to attach different CHOP network to “activate” each animation segment, and loop
it or stop it at the suitable frame.
(1) For the “rotate” sequence, I don’t need to do extra thing, because the default is “looping”.
(2) For the “jump” sequence (i.e. play once and stop at the first frame), I can use the Lookup
CHOP again. Whenever keypad-3 is pressed, I want to pass a “ramp” to the first input of
Lookup CHOP. It will then output the “animation channels” to the Switch CHOP:
(3) And for the “die” sequence, I want to trigger the animation (i.e. a ramp for the Lookup CHOP),
but then hold it at the last frame (i.e. a value “1” for the Lookup CHOP). Therefore, I want to
Count CHOP
However, the above answer is not prefect, as the Lag CHOP will output a non-linear ramp. A
better approach will be more complicate: use a Count CHOP to output 1 when the “ramp” has
reached its end, and the output of Count CHOP will be used to control a Switch CHOP:
Constant CHOP
Now, I can use keyboard (or any kinds of pulse) to trigger the 4 actions (“do nothing”, “rotate”,
“jump” and “die”).
Maya comes with a .OBJ exporter and a .FBX exporter. To enable the plug-in:
option that I would like to change is to turn off the “lights” and “cameras” export options,
and also export the file in ASCII format, so that I can edit the .FBX file directly using
WordPad:
** Week 07 END **