Skip to content

Geometry Definition

Christian Schlinkmann edited this page Mar 31, 2016 · 7 revisions

The <mesh> or the <assetmesh> are the two elements that lead to rendered geometry in a XML3D scene. The <assetmesh> has additional functionality for scope, for details refer to Assets. Otherwise, the definition of geometry is exactly the same as for the <mesh>, that is explained in more detail below:

Mesh

The <mesh> element defines a geometry in the transformation hierarchy. The mesh has a type attribute, which specifies the primitive the mesh attribute defines. Depending on the type attribute, the mesh has mandatory and optional data entries. The entries described below, have a specific semantic for the description of the geometry. All other parameters end up as either vertex attributes (if they qualify in terms of number of entries) or as uniform parameters where they override parameters provided in the attached <material>.

[type=triangle]

A mesh of type triangle describes a triangle mesh (surprise!). It has a mandatory field positions that describes the positions of the vertices in object space.

name type mandatory description
position float3 X The positions of the vertices of the mesh
index int If provided, one triangle is defined for each three entries in the index. Allows sharing vertices between multiple triangles.
vertexCount int If provided, the first vertexCount vertices are considered for rendering (should be a multiple of 3 for triangle meshes)
boundingBox float3 Two positions in object space that define the min and max vertices of an axis-aligned bounding box. If provided, this annotated bounding box is used for all calculations where a bounding box is required (e.g. frustum culling). If not, the boundingBox is derived from the mesh's positions. For dynamic meshes (e.g. skinned virtual characters) annotating the bounding box avoids xml3d.js has to perform the bounding box calculation per frame.

[type=points]

Renders points.

name type mandatory description
position float3 X The positions of the points in object space.
index int If provided, only the points provided in the index are rendered.
vertexCount int If provided, the first vertexCount points are considered. What is first depends on if index is given or not.
boundingBox float3 Two positions in object space that define the min and max vertices of an axis-aligned bounding box. If provided, this annotated bounding box is used for all calculations where a bounding box is required (e.g. frustum culling). If not, the boundingBox is derived from the point's positions. For dynamic points, annotating the bounding box avoids xml3d.js has to perform the bounding box calculation per frame.

[type=linestrips]

name type mandatory description
position float3 X The positions of the line strip's vertices in object space.
index int If provided, the index field defines the vertices of the line strips and vertices can be shared between multiple strips.
vertexCount int XML3D will draw one strip for each entry in the provided vertexCount field. The number of each entry specifies the number of vertices should be used for the next strip. If not given, the vertices are rendered as a single strip.
boundingBox float3 Two positions in object space that define the min and max vertices of an axis-aligned bounding box. If provided, this annotated bounding box is used for all calculations where a bounding box is required (e.g. frustum culling). If not, the boundingBox is derived from the line strips positions. For dynamic points, annotating the bounding box avoids xml3d.js has to perform the bounding box calculation per frame.
Example
<mesh type="linestrips">
  <int name="index">0 1 2 3 0 4 5 6 7 4 0 4 1 5 2 6 3 7</int>
  <int name="vertexCount">5 5 2 2 2 2</int>
  <float3 name="position"> -1 1 1 1 1 1 1 1 -1 -1 1 -1 -1 -1 1 1 -1 1 1 -1 -1 -1 -1 -1 </float3>
  <!-- Color only required for the attached material -->
  <float3 name="color">1 0 0 1 0 0 1 1 0 1 1 0 0 1 0 0 1 0 0 0 1 0 0 1 </float3>
</mesh>

[type=lines]

TODO

[type=trianglestrips]

TODO