Geometry Types
==============

.. contents:: Table of Contents
    :depth: 2
    :local:

.. _polymesh:

``polymesh``
~~~~~~~~~~~~

Polygonal mesh geometry. A polygonal mesh is formed of points, a vertex list
(defining vertices) and start index list (defining faces). Additional
information, such as normals and arbitrary data, can also be defined.

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`float[3n] geometry.point.N`
      * List of per-point normals.

    - * :kat:attr:`float[3n] geometry.point.P`
      * List of points. The geometry points are unique floating point positions
        in object space coordinates (x, y, z). Each point is only stored once
        but it may be indexed many times by a particular vertex.


    - * :kat:attr:`int[] geometry.poly.startIndex`
      * A list of indices defining the faces of a mesh. For example,
        consider a cube. A cube has a :kat:attr:`startIndex` list size equal to
        the number of faces in the mesh plus one. This is because we must store
        the index of the first point on the first face as well as the end point
        of all the faces (including the first). So, for example, the beginning
        of a cube's :kat:attr:`startIndex` list may look like:

        * 0 - 0
        * 1 - 4
        * 2 - 8

        The indices for each polygon N are from ``startIndex(N)`` to
        ``startIndex(N+1)-1``. The value at index 0 of the list tells us the
        first face should start at index 0 in the ``vertexList``, the second
        value in the list tells us the first face ends at index 3 (``n-1``).


    - * :kat:attr:`int[] geometry.poly.vertexList`
      * Describes the vertex data of a mesh. There is a vertex at each edge
        intersection. The value of the :kat:attr:`vertexList` is used as an
        index into the :kat:attr:`geometry.point.P` list, which stores the
        actual object coordinates of each unique point. Many indices in a
        :kat:attr:`vertexList` can index the same point in the
        :kat:attr:`geometry.point.P` list. This saves space as a vertex is
        described as a simple integer rather then the three floating point
        values required to describe a 3D geometry point (x, y, z).

    - * :kat:attr:`float[3n] geometry.vertex.N`
      * List of per-face vertex normals.

    - * :kat:attr:`float[2n] geometry.vertex.UV`
      * List of texture coordinates (per vertex, non face-varying)

``subdmesh``
~~~~~~~~~~~~

Sub-division surfaces geometry. Sub-division surfaces (Subds) are similarly
structured to polygonal meshes.

.. note::
    This section is under construction.

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`int geometry.facevaryinginterpolateboundary`
        :kat:attr:`int geometry.facevaryingpropagatecorners`
        :kat:attr:`int geometry.interpolateBoundary`
      *

    - * :kat:attr:`int[] geometry.creaseIndices`
      *

    - * :kat:attr:`int[] geometry.creaseLengths`
      *

    - * :kat:attr:`float[] geometry.creaseSharpness`
        :kat:attr:`int[] geometry.creaseSharpnessLengths`
      *

    - * :kat:attr:`int[] geometry.cornerIndices`
      *

    - * :kat:attr:`float[] geometry.cornerSharpness`
      *

    - * :kat:attr:`int[] geometry.holePolyIndices`
      *

    - * :kat:attr:`float[] geometry.point.Pref`
      *

    - * :kat:attr:`group geometry.point`
      * See polymesh_.

    - * :kat:attr:`group geometry.poly`
      * See polymesh_.

    - * :kat:attr:`group geometry.vertex`
      * See polymesh_.


``pointcloud``
~~~~~~~~~~~~~~

Point cloud geometry. A point cloud is the simplest form of geometry and only
requires point data to be specified.

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`group geometry.point`
      * See polymesh_.

``nurbspatch``
~~~~~~~~~~~~~~

NURBS patch geometry. NURBS patches are a special type of geometry, quite
different from conventional mesh types. A NURBS curve is defined by its order,
a set of weighted control points and a knot vector.

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`int geometry.uSize`
        :kat:attr:`int geometry.vSize`

      * The size.

    - * :kat:attr:`float[4n] geometry.point.Pw`
      * List of control points and their weights, in the order: x y z w.

    - * :kat:attr:`int geometry.u.order`
        :kat:attr:`int geometry.v.order`

      * The order.

    - * :kat:attr:`float geometry.u.min`
        :kat:attr:`float geometry.u.max`

      * Parameters defining the NURBS patch.

    - * :kat:attr:`float[] geometry.u.knots`
        :kat:attr:`float[] geometry.v.knots`

      * Knot vector, a sequence of parameter values.

    - * :kat:attr:`group geometry.trimcurves`
      * Parameters defining the NURBS patch.

``curves``
~~~~~~~~~~

For creating groups of curves parented to the same transform. Curves cannot be
created by the UI but can be created through the Python API.

The following XML is from a scene graph that creates 3 linear curves
with 3 segments:

.. code-block:: xml

  <attr type="GroupAttr" inheritChildren="false">
    <attr type="IntAttr" name="degree" tupleSize="1">
      <sample value="1 " size="1" time="0"/>
    </attr>
    <attr type="FloatAttr" name="knots" tupleSize="1">
      <sample value="0.0 " size="1" time="0"/>
    </attr>
    <attr type="IntAttr" name="numVertices" tupleSize="1">
      <sample value="4 4 4 " size="3" time="0"/>
    </attr>
    <attr type="GroupAttr" name="point" inheritChildren="false">
      <attr type="FloatAttr" name="P" tupleSize="3">
        <sample value="0.2 0 5 -2.8 0 2.0 0.5 0 1.0 -0.3 0 -1.5 1.8 0
                       4.9 -0.4 0 2.2 2.5 0 1.0 1.6 0 -1.4 3.8 0 4.9
                       1.6 0 2.2 4.5 0 1.0 3.6 0 -1.4"
                       size="36" time="0"/>
      </attr>
    </attr>
  </attr>

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`int geometry.basis`
      * An integer indicating the curve basis. This is defined as follows:

        - ``0`` - No basis
        - ``1`` - Bezier
        - ``2`` - B-Spline
        - ``3`` - Catmull-Rom
        - ``4`` - Hermite
        - ``5`` - Power

        This follows the ``BasisType`` enumeration in the Alembic library.

    - * :kat:attr:`float geometry.constantWidth`
      * A float that defines the width of a curve, which is applied uniformly
        to each control point.


    - * :kat:attr:`int geometry.degree`
      * Specifies whether curves are linear (degree = 1) or cubic (degree = 3).


    - * :kat:attr:`float[] geometry.knots`
      * Knot vector is a sequence of parameter values.

        .. note::
            When splitting :kat:attr:`geometry.point.P` into multiple curves
            using knots, the values in :kat:attr:`numVertices` must correspond.
            For example, given 8 control points in
            :kat:attr:`geometry.point.P`, ``degree = 3``, and
            ``knots = [ 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 ]``, then
            ``numVertices = [ 4 4 ]``.

    - * :kat:attr:`int geometry.vstep`
      * Sets the vertex stride for the curve. This is used by Katana to
        calculate the expected length of point-scoped arbitrary attribute
        arrays.

    - * :kat:attr:`int[] geometry.numVertices`
      * The number of vertices in each curve.

        The :kat:attr:`numVertices` list defines the index ranges of the knots
        used by each curve.

    - * :kat:attr:`float[3n] geometry.point.P`
      * List of points. The geometry points are unique floating point positions
        in object space coordinates (x, y, z). Each point is only stored once
        but it may be indexed many times by the same knot.


    - * :kat:attr:`float[3n] geometry.point.orientation`
      * List of orientations for each control point in the curve, relative to
        the camera.

    - * :kat:attr:`float[n] geometry.point.width`
      * List of widths (diameters) of the curve at each control point.

        .. note::
            If both :kat:attr:`geometry.constantWidth` and
            :kat:attr:`geometry.point.width` are set, the values in
            :kat:attr:`geometry.point.width` are used.


``locator``
~~~~~~~~~~~

Used only in the Viewer; ignored by the renderers.

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`group geometry.point`
      * See polymesh_.

    - * :kat:attr:`group geometry.poly`
      * See polymesh_.


``sphere``
~~~~~~~~~~

Built-in primitive type for a sphere, supported by some renderers.

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`double geometry.radius`
      * The radius of the sphere.

``spheres``
~~~~~~~~~~~

A more efficient way of creating a group of spheres in PRMan at once. This is
ignored by other renderers.

.. list-table::
    :header-rows: 1
    :widths: 20 80

    - * Attribute
      * Description

    - * :kat:attr:`float[3n] geometry.point.P`
      * List of points that represent the sphere centers.

    - * :kat:attr:`float[n] geometry.point.radius`
      * The spheres' radii.

    - * :kat:attr:`float geometry.constantRadius`
      * Can be used instead of :kat:attr:`geometry.point.radius` to specify a
        single radius for all spheres.