.. _ogn_tutorial_defaults:

Tutorial 14 - Defaults
======================

While most inputs are required to have default values it's not strictly necessary to provide explicit values
for those defaults. If a default is required and not specified then it will get a default value equal to an
empty value. See the table at the bottom for what is considered an "empty" value for each type of attribute.

OgnTutorialDefaults.ogn
------------------------
The *ogn* file shows the implementation of a node named
"omni.graph.tutorials.Defaults", which has sample inputs of several types without default values and matching outputs.

.. literalinclude:: OgnTutorialDefaults.ogn
    :linenos:
    :language: json

OgnTutorialDefaults.cpp
------------------------
The *cpp* file contains the implementation of the compute method, which
copies the input values over to the corresponding outputs. All values should be the empty defaults.

.. literalinclude:: OgnTutorialDefaults.cpp
    :linenos:
    :language: c++

Empty Values For Attribute Types
--------------------------------
The empty values for each of the attribute types is defined below. Having no default specified in the .ogn file
for any of them is equivalent to defining a default of the given value.

+-----------+---------------+
| Type Name | Empty Default |
+===========+===============+
| bool      |     False     |
+-----------+---------------+
| double    |      0.0      |
+-----------+---------------+
| float     |      0.0      |
+-----------+---------------+
| half      |      0.0      |
+-----------+---------------+
| int       |       0       |
+-----------+---------------+
| int64     |       0       |
+-----------+---------------+
| string    |      ""       |
+-----------+---------------+
| token     |      ""       |
+-----------+---------------+
| uchar     |       0       |
+-----------+---------------+
| uint      |       0       |
+-----------+---------------+
| uint64    |       0       |
+-----------+---------------+

.. note::

    All attributes that are array types have empty defaults equal to the empty array []

.. note::

    All tuple types have empty defaults equal to a tuple of the correct count, each member containing the empty
    value for the base type. e.g. a float[2] will have empty default [0.0, 0.0], and a matrix[2] will have
    empty default [[0.0, 0.0], [0.0, 0.0]]
