.. _ogn_tutorial_tupleArrays:

Tutorial 6 - Array of Tuples
============================

Arrays and tuples can be combined to create common attribute types such as **float[3][]**, and array of
3 floats. This node takes two arrays of float[3]s and generates an output array consisting of the element-wise
dot products.

The *ogn* file shows the implementation of a node named
"omni.graph.tutorials.TupleArrays", which has two tuple-array inputs and a simple array output.

OgnTutorialTupleArrays.ogn
--------------------------
.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial6/OgnTutorialTupleArrays.ogn
    :linenos:
    :language: json

OgnTutorialTupleArrays.cpp
--------------------------
The *cpp* file contains the implementation of the compute method, which computes the dot products.

.. literalinclude:: ../../../../../source/extensions/omni.graph.tutorials/tutorials/tutorial6/OgnTutorialTupleArrays.cpp
    :linenos:
    :language: c++

There are typedefs set up for USD-compatible types, e.g. for *float[3]* you get *GfVec3f*. Other types, for whom
there is no USD equivalent, are implemented as *ogn::tuple<TYPE, N>*. See the complete table
of data types in :ref:`ogn_attribute_types`.

+-------------------+----------------------------------+
| Database Function | Returned Type                    |
+===================+==================================+
| inputs.a()        | const ogn::const_array<GfVec3f>& |
+-------------------+----------------------------------+
| inputs.b()        | const ogn::const_array<GfVec3f>& |
+-------------------+----------------------------------+
| outputs.result()  | ogn::array<GfVec3f>&             |
+-------------------+----------------------------------+

Note that the tuple array access is identical to the simple data array access, except that the types are now
the compound tuple types.
