Tutorial 1 - Trivial Node

The simplest possible node is one that implements only the mandatory fields in a node. These are the “version” and “description” fields.

The existence of the file OgnTutorialEmpty.svg will automatically install this icon into the build directory and add its path to the node type’s metadata. The installed file will be named after the node type, not the class type, so it will be installed at the path $BUILD/exts/omni.graph.tutorials/ogn/icons/Empty.svg.

OgnTutorialEmpty.ogn

The .ogn file containing the implementation of a node named “omni.graph.tutorials.Empty”, in its first version, with a simple description.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
{
    "Empty" : {
        "version": 1,
        "categories": "tutorials",
        "description": [
            "This is a tutorial node. It does absolutely nothing and is only meant to ",
            "serve as an example to use for setting up your build."
        ],
        "metadata":
        {
           "uiName": "Tutorial Node: No Attributes"
        }
    }
}

OgnTutorialEmpty.cpp

The .cpp file contains the minimum necessary implementation of the node class, which contains only the empty compute method. It contains a detailed description of the necessary code components.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto.  Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//

// ============================================================
// Note the name of the generated include file, taken from the name of the file with "Database.h" appended.
// The build system should have added the include path that picks this file up directly.
#include <OgnTutorialEmptyDatabase.h>

// ============================================================
// The class name should match the file name to avoid confusion as the file name will be used
// as a base for the names in the generated interface.
//
class OgnTutorialEmpty
{
public:
    // ------------------------------------------------------------
    // Note the name of the generated computation database, the same as the name of the include file,
    // auto-generated by appending "Database" to the file name.
    //
    static bool compute(OgnTutorialEmptyDatabase&)
    {
        // This node correctly does nothing, but it must return true to indicate a successful compute.
        //
        return true;
    }
};

// ============================================================
// Now that the node has been defined it can be registered for use. This registration takes care of
// automatic registration of the node when the extension loads and deregistration when it unloads.
REGISTER_OGN_NODE()