COLLADA keeps numbers in source elements and reads them through
input elements, the same way for meshes, skins, morphs and animation.
This page follows the COLLADA 1.4.1 schema and, for the semantics, interpolation names and
the common-profile names, COLLADA – Digital Asset Schema Release 1.4.1,
Specification (2nd Edition), March 2008 (Khronos Group and Sony Computer
Entertainment; khronos.org/files/collada_spec_1_4.pdf), chapter 3 “Common
Glossary”, chapter 4 “Curve Interpolation” and the input entries of chapter 5.
Sources and arrays
A source (id, name) holds one array and a
technique_common with an accessor that says how to read
it.
| Array | Holds | Attributes besides id, name, count |
|---|---|---|
float_array | numbers | digits (default 6) and magnitude (default 38): the precision of the source data |
int_array | integers | minInclusive, maxInclusive |
bool_array | true and false | |
Name_array | names, such as joint names or interpolation types | |
IDREF_array | ids of other elements |
Values are separated by white space; count is the number of values.
The accessor has source (the array’s URL),
count (the number of elements), offset (default 0, the
first value used) and stride (default 1, values per element), and one
param per value of an element, each with name (such as
X, Y, Z, S, T,
R, G, B), type (such as
float, float4x4, name) and optional
sid and semantic. A param without a name is
skipped, which lets a reader take only some values of each element.
Inputs
An input joins a meaning to a source: semantic (the
meaning) and source (its URL). Inside primitives, skins’ vertex weights
and morphs’ targets it also has offset (which index of each group in
p or v it reads) and optionally set (for
example which texture coordinate set).
| Semantic | Meaning |
|---|---|
BINORMAL | geometric binormal (bitangent) vectors |
COLOR | colour coordinate vectors; the specification says colour inputs are RGB (float3) |
CONTINUITY | continuity constraints at control vertices |
IMAGE | raster or MIP-level input |
INPUT | sampler input: key times |
IN_TANGENT | tangents entering a key |
INTERPOLATION | sampler interpolation type per key |
INV_BIND_MATRIX | inverse of the local-to-world matrix: the inverse bind matrices of joints |
JOINT | skin influence names or ids |
LINEAR_STEPS | number of linear steps for a spline segment |
MORPH_TARGET | morph targets |
MORPH_WEIGHT | morph weights |
NORMAL | normals |
OUTPUT | sampler output: values |
OUT_TANGENT | tangents leaving a key |
POSITION | positions |
TANGENT | geometric tangents |
TEXBINORMAL | texture binormals |
TEXCOORD | texture coordinates |
TEXTANGENT | texture tangents |
UV | generic parameters |
VERTEX | the mesh’s vertices element: all of its per-vertex inputs at once |
WEIGHT | skin influence weights |
These 23 are exactly the “common input semantic attribute values” the
specification lists. Inputs that share an offset share one index in
p, which the specification calls “a simple form of index compression”. Inputs
of the same kind are told apart by set: its example has two
TEXCOORD and two TEXTANGENT inputs, with set 0 and 1.
In the specification’s naming rules, semantic names and param names are upper
case.
Common-profile parameter and target names
The specification’s Common Glossary lists these names for param and for the
member part of an animation target (all are floats): X, Y,
Z and W (first to fourth Cartesian coordinate);
R, G, B and A (red, green, blue, alpha);
S, T, P and Q (first to fourth texture
coordinate); U and V (first and second generic parameter);
ANGLE (Euler angle); TIME (time in seconds). The param
list also has DOUBLE_SIDED (a Boolean rendering state). A target can also use
(n) or (n)(m) for a vector or matrix field, counting from 0.
Curve interpolation names
The animation section of the specification says COLLADA recognises LINEAR,
BEZIER, CARDINAL, HERMITE, BSPLINE and
STEP. STEP is only for animation curves: the value stays constant
until the next key. The chapter on curve interpolation, which also covers
geometry/spline, names only BEZIER, LINEAR,
BSPLINE and HERMITE for the common profile. A spline segment is
between POSITION[i] and POSITION[i+1], and its interpolation is stored
at INTERPOLATION[i]; a closed spline with n segments has one more.
For Bézier segments (1.4.1 supports only cubic Bézier, always two control points per
segment) the control points are OUT_TANGENT[i] and IN_TANGENT[i+1];
for Hermite the same inputs hold tangents instead, with T0 = 3(C0 − P0).
LINEAR_STEPS is the number of line pieces used to approximate a segment.
CONTINUITY values are C0, C1 and G1.
Meshes
A geometry holds a mesh, a convex_mesh or a
spline (with a closed attribute and
control_vertices). A mesh holds one or more
sources, exactly one vertices (an id and
inputs, at least POSITION, that describe each vertex), and any number of
primitives:
| Primitive | Index children | Shape |
|---|---|---|
triangles | one p | three vertices per triangle |
polylist | vcount (vertices per polygon), one p | polygons of any size |
polygons | one p per polygon, or ph with a p and h holes | polygons, possibly with holes |
lines | one p | two vertices per line |
linestrips | one p per strip | connected lines |
trifans | one p per fan | triangle fans |
tristrips | one p per strip | triangle strips |
Each primitive has count (required: the number of triangles, lines,
polygons, strips or fans), an optional material (a symbol bound in
bind_material) and name, then its inputs. In
p, each vertex takes one index per distinct offset, so a
vertex is (largest offset + 1) integers long; each input reads the index at its
offset. The VERTEX input brings in everything in
vertices.
Example
<mesh>
<source id="pos">
<float_array id="pos-array" count="9">0 0 0 1 0 0 0 1 0</float_array>
<technique_common>
<accessor source="#pos-array" count="3" stride="3">
<param name="X" type="float"/>
<param name="Y" type="float"/>
<param name="Z" type="float"/>
</accessor>
</technique_common>
</source>
<source id="nrm"> … one normal, 0 0 1 … </source>
<vertices id="verts">
<input semantic="POSITION" source="#pos"/>
</vertices>
<triangles count="1" material="Paint">
<input semantic="VERTEX" source="#verts" offset="0"/>
<input semantic="NORMAL" source="#nrm" offset="1"/>
<p>0 0 1 0 2 0</p>
</triangles>
</mesh>
p is a vertex index then a
normal index