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 "Empty" : {
3 "version": 1,
4 "categories": "tutorials",
5 "scheduling": ["threadsafe"],
6 "description": [
7 "This is a tutorial node. It does absolutely nothing and is only meant to ",
8 "serve as an example to use for setting up your build."
9 ],
10 "metadata":
11 {
12 "uiName": "Tutorial Node: No Attributes"
13 }
14 }
15}
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// SPDX-FileCopyrightText: Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
3//
4// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
5// property and proprietary rights in and to this material, related
6// documentation and any modifications thereto. Any use, reproduction,
7// disclosure or distribution of this material and related documentation
8// without an express license agreement from NVIDIA CORPORATION or
9// its affiliates is strictly prohibited.
10
11// ============================================================
12// Note the name of the generated include file, taken from the name of the file with "Database.h" appended.
13// The build system adds the include path that picks this file up from the generated file location.
14#include <OgnTutorialEmptyDatabase.h>
15
16// ============================================================
17// The class name should match the file name to avoid confusion as the file name will be used
18// as a base for the names in the generated interface.
19//
20class OgnTutorialEmpty
21{
22public:
23 // ------------------------------------------------------------
24 // Note the name of the generated computation database, the same as the name of the include file,
25 // auto-generated by appending "Database" to the file name.
26 //
27 static bool compute(OgnTutorialEmptyDatabase&)
28 {
29 // This node correctly does nothing, but it must return true to indicate a successful compute.
30 //
31 return true;
32 }
33};
34
35// ============================================================
36// Now that the node has been defined it can be registered for use. This registration takes care of
37// automatic registration of the node when the extension loads and deregistration when it unloads.
38REGISTER_OGN_NODE()