1<html>
2<head>
3<title>Defining Model Shape and Vertex Attributes Data</title>
4<link rel="stylesheet" href="../css/mainpage.css" type="text/css">
5<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6</head>
7
8<body>
9
10<h1>Defining Model Shape and Vertex Attributes Data</h1>
11
12<h2>Overview</h2>
13<p>
14This page describes elements used to define model shape and vertex attributes data. Multiple models making up a scene can be recorded in a model data file (.cmdl). If a model consists of more than one material, primitives (polygons, etc.) for each material are grouped. The primitives grouped for each material are called <EM>shapes</EM>. A shape consists of vertex attribute data (a vertex buffer) and an index buffer that points to it. Information required to call the <CODE>glDrawElement</CODE> function is gathered here.
15</p>
16
17<center><img src="../image/Model-Material-Shape.jpg"></center>
18
19<br>
20
21<p>
22The &lt;SeparateDataShapeCtr&gt; element is used to define a single shape. This element basically includes a data array for vertex attributes data, an index array for defining primitives, center coordinates for the shape, skinning mode, etc.
23</p>
24
25<h3>XML Hierarchical Structure</h3>
26<p>
27The &lt;Shapes&gt; element appears inside the &lt;SkeletalModel&gt; element only once. It indicates the start of the definition of the &lt;SeparateDataShapeCtr&gt; element. If a scene includes more than one shape, multiple &lt;SeparateDataShapeCtr&gt; elements can be defined.
28</p>
29
30<table>
31<tr><td>
32<pre>
33&lt;NintendoWareIntermediateFile&gt;<br>
34  &lt;GraphicsContentCtr&gt;<br>
35    &lt;Models&gt;<br>
36     &lt;SkeletalModel&gt;<br>
37      &lt;Shapes&gt;<br>
38       &lt;SeparateDataShapeCtr&gt;<br>
39</pre>
40</td></tr>
41</table>
42
43<h2>Vertex Attributes Data</h2>
44<p>
45Elements for the vertex coordinates, normal vector, and texture coordinates making up a shape are called <EM>vertex attributes</EM>. This data is called <EM>vertex attributes data</EM>. The elements listed in the table below are included in the vertex attributes that make up a shape. The required combinations of vertex attributes are determined based on the material and shading. Typically, shapes have multiple instances of vertex attributes data.
46</p>
47
48<center><img src="../image/VertexAttributes.jpg"></center>
49
50<br>
51
52<p>
53Actual data is defined for each vertex attribute. The &lt;Vector#VertexStreamCtr&gt; element is used to define the data for each vertex attribute. Here, # represents the number of elements and indicates the number of numeric values per vertex. It is used to stand for any one of 1, 2, 3 or 4. This element basically includes the type of attribute, number of data items, and numeric type.
54</p>
55
56<h3>Constant Vertex Attribute Data</h3>
57<p>
58If attributes with a fixed value are included among the vertices in a shape, constant data can be used instead of data strings. (For example, the normal vector for a planar model fits this description. ) This allows data size to be kept small. The <CODE>&lt;Vector#VertexAttributeCtr&gt;</CODE> element, as opposed to the <CODE> &lt;Vector#VertexStreamCtr&gt;</CODE> element, is used for the constant data.
59</p>
60
61<h3>XML Hierarchical Structure</h3>
62<p>
63The &lt;VertexAttributes&gt; element appears inside the &lt;SeparateDataShapeCtr&gt; element only once. It indicates the start of the definition of the &lt;Vector#VertexStreamCtr&gt; element. If a shape includes more than one vertex attribute, multiple &lt;Vector#VertexStreamCtr&gt; elements can be defined.
64</p>
65
66<table>
67<tr><td>
68<pre>
69&lt;NintendoWareIntermediateFile&gt;<br>
70 &lt;GraphicsContentCtr&gt;<br>
71  &lt;Models&gt;<br>
72   &lt;SkeletalModel&gt;<br>
73    &lt;Shapes&gt;<br>
74     &lt;SeparateDataShapeCtr&gt;<br>
75      &lt;VertexAttributes&gt;<br>
76       &lt;Vector4VertexStreamCtr&gt;<br>
77        (data)<br>
78</pre>
79</td></tr>
80</table>
81
82<h2>Converting Vertex Attribute Data</h2>
83
84<h3>Quantization</h3>
85<p>
86The size of binary data at runtime can be reduced by using a fixed-point (integer type) format for the numeric values of vertex attribute data. The act of converting the data values to fixed-point format is called <I>quantization</I> and is  set in the <CODE>&lt;Vector#VertexStreamCtr&gt;</CODE> element. You can apply a different quantization to each vertex attribute. Data values converted to fixed-point format can be restored to their original values by applying a floating point scaling value. For example, if the scaling value is 0.00390625 (= 1/256), 256 is restored to 1.0 and 128 is restored to 0.5. The different types of  fixed-point formats are shown in the table below. Note that the fixed-point format type and scaling value used for restoration are independent parameters. The scaling value is not determinant on the range of fixed-point format types.
87</p>
88
89<h3>Quantization Integer Types</h3>
90<table class="arguments">
91<tr><td>Type</td><td>Description</td></tr>
92<tr><td>Short</td><td>16-bit signed integer. Set from -32768 (minimum) to 32767 (maximum).</td></tr>
93<tr><td>Ushort</td><td>16-bit unsigned integer. Set from 0 (minimum) to 65535 (maximum).</td></tr>
94<tr><td>Byte</td><td>8-bit signed integer. Set from -128 (minimum) to 127 (maximum).</td></tr>
95<tr><td>Ubyte</td><td>8-bit unsigned integer. Set from 0 (minimum) to 255 (maximum).</td></tr>
96</table>
97
98<h3>Offset for Vertex Coordinate Values</h3>
99<p>
100In order to minimize conversion errors when vertex coordinates are expressed as floating-point numbers or fixed-point numbers, large coordinate values that represent positions far away from the origin are offset to be closer to 0.0 and then quantized.<br>
101<pre>Large value = Small value near 0.0 + Offset value.</pre>
102</p>
103<p>
104This gives you small values and reduces error.<br> The use of the offset is particularly important with the fixed-point format, since the range of values is limited (see the previous section: Quantization Integer Types)<br> This offset value can be specified for each shape.<br>
105</p>
106
107<h3>XML Hierarchical Structure</h3>
108<p>
109The &lt;PositionOffset&gt; element is used to define the offset value for vertex coordinates. The &lt;PositionOffset&gt; element only appears once in the &lt;SeparateDataShapeCtr&gt; element.
110</p>
111
112<table>
113<tr><td>
114<pre>
115&lt;NintendoWareIntermediateFile&gt;<br>
116 &lt;GraphicsContentCtr&gt;<br>
117  &lt;Models&gt;<br>
118   &lt;SkeletalModel&gt;<br>
119    &lt;Shapes&gt;<br>
120     &lt;SeparateDataShapeCtr&gt;<br>
121      &lt;PositionOffset&gt;<br>
122
123</pre>
124</td></tr>
125</table>
126
127<h3>Conversion formula</h3>
128<p>
129Vertex coordinate values are ultimately restored in the following way:<br>
130<pre>Original value = (Scaling value x Post-conversion value) + Offset value. </pre>
131</p>
132
133<h2>Primitive Definitions</h2>
134<p>
135Primitives available for rendering can be defined as triangles, lines or points by indexing the data strings representing vertex attribute data. The &lt;PrimitiveSetCtr&gt; element is used to define primitives. This element basically includes the type of primitive, index array, and skinning parameters. (Skinning parameters are required even for fixed shapes that do not undergo skinning.) For details, see the page <a href="page_overview_scene.html">Definition of a Scene's Hierarchical Structure</a>.)
136</p>
137
138<h3>Primitive Types and Index Arrays</h3>
139<p>
140Primitive types include those given in the table below. The &lt;UbyteIndexStreamCtr&gt; element is used to define the primitive type and index array.
141</p>
142
143<h3>XML Hierarchical Structure</h3>
144<p>
145The &lt;PrimitiveSets&gt; element appears inside the &lt;SeparateDataShapeCtr&gt; element only once. It indicates the start of the definition of the &lt;PrimitiveSetCtr&gt; element. If a shape includes more than one primitive, multiple &lt;PrimitiveSetCtr&gt; elements can be defined. Shapes and primitives have a one-to-one correspondence for models that do not undergo skinning. However, a shape may be split up into multiple primitives for models that do undergo skinning. For details see, <a href="page_overview_skinning.html">Defining Skinning</a>
146</p>
147
148<table>
149<tr><td>
150<pre>
151&lt;NintendoWareIntermediateFile&gt;<br>
152 &lt;GraphicsContentCtr&gt;<br>
153  &lt;Models&gt;<br>
154   &lt;SkeletalModel&gt;<br>
155    &lt;Shapes&gt;<br>
156     &lt;SeparateDataShapeCtr&gt;<br>
157      &lt;PrimitiveSets&gt;<br>
158       &lt;PrimitiveSetCtr&gt;<br>
159</pre>
160</td></tr>
161</table>
162
163<p>
164The &lt;UbyteIndexStreamCtr&gt; element for defining index arrays appears in the &lt;PrimitiveSetCtr&gt; element only once. The hierarchy from the &lt;PrimitiveSetCtr&gt; element to the &lt;UbyteIndexStreamCtr&gt; element is fixed.
165</p>
166
167<table>
168<tr><td>
169<pre>
170  :<br>
171 &lt;SeparateDataShapeCtr&gt;<br>
172  &lt;PrimitiveSets&gt;<br>
173   &lt;PrimitiveSetCtr&gt;<br>
174    &lt;Primitives&gt;<br>
175     &lt;PrimitiveCtr&gt;<br>
176      &lt;IndexStreams&gt;<br>
177       &lt;UbyteIndexStreamCtr&gt;<br>
178        (index array)<br>
179</pre>
180</td></tr>
181</table>
182
183<h3>Primitive Type</h3>
184<table class="arguments">
185<tr><td>Type</td><td>Description</td></tr>
186<tr><td>Points</td><td>Point primitive.</td></tr>
187<tr><td>Lines</td><td>Line primitive.</td></tr>
188<tr><td>LineStrip</td><td>Line strip primitive.</td></tr>
189<tr><td>Triangles</td><td>Triangle list primitive.</td></tr>
190<tr><td>TriangleStrip</td><td>Triangle strip primitive.</td></tr>
191<tr><td>TriangleFan</td><td>Triangle fan primitive.</td></tr>
192<tr><td>PointSprites</td><td>Point sprite primitive.</td></tr>
193<tr><td>SilhouetteTriangles</td><td>Triangle list primitive with silhouette.</td></tr>
194<tr><td>SilhouetteStrip</td><td>Triangle strip primitive with silhouette.</td></tr>
195<tr><td>Subdivision</td><td>Subdivision primitive.</td></tr>
196<tr><td>SubdivisionLoop </td><td>Subdivision loop primitive.</td></tr>
197</table>
198
199<hr><p>CONFIDENTIAL</p></body>
200</HTML>
201