Tutorial 7 - Role-Based Data Node

The role-based data node creates one input attribute and one output attribute of each of the role-based type. A role-based type is defined as data with an underlying simple data type, with an interpretation of that simple data, called a “role”.

Examples of roles are color, quat, and timecode. For consistency the tuple counts for each of the roles are included in the declaration so that the “shape” of the underlying data is more obvious.

OgnTutorialRoleData.ogn

The ogn file shows the implementation of a node named “omni.graph.tutorials.RoleData”, which has one input and one output attribute of each Role type.

  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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
{
    "RoleData" : {
        "version": 1,
        "categories": "tutorials",
        "description": [
            "This is a tutorial node. It creates both an input and output attribute of every supported ",
            "role-based data type. The values are modified in a simple way so that the compute modifies values. "
        ],
        "metadata":
        {
            "uiName": "Tutorial Node: Role-Based Attributes"
        },
        "inputs": {
            "a_color3d": {
                "type": "colord[3]",
                "description": ["This is an attribute interpreted as a double-precision 3d color"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_color3f": {
                "type": "colorf[3]",
                "description": ["This is an attribute interpreted as a single-precision 3d color"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_color3h": {
                "type": "colorh[3]",
                "description": ["This is an attribute interpreted as a half-precision 3d color"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_color4d": {
                "type": "colord[4]",
                "description": ["This is an attribute interpreted as a double-precision 4d color"],
                "default": [0.0, 0.0, 0.0, 0.0]
            },
            "a_color4f": {
                "type": "colorf[4]",
                "description": ["This is an attribute interpreted as a single-precision 4d color"],
                "default": [0.0, 0.0, 0.0, 0.0]
            },
            "a_color4h": {
                "type": "colorh[4]",
                "description": ["This is an attribute interpreted as a half-precision 4d color"],
                "default": [0.0, 0.0, 0.0, 0.0]
            },
            "a_frame": {
                "type": "frame[4]",
                "description": ["This is an attribute interpreted as a coordinate frame"],
                "default": [[1.0,0.0,0.0,0.0], [0.0,1.0,0.0,0.0], [0.0,0.0,1.0,0.0], [0.0,0.0,0.0,1.0]]
            },
            "a_matrix2d": {
                "type": "matrixd[2]",
                "description": ["This is an attribute interpreted as a double-precision 2d matrix"],
                "default": [[1.0, 0.0], [0.0, 1.0]]
            },
            "a_matrix3d": {
                "type": "matrixd[3]",
                "description": ["This is an attribute interpreted as a double-precision 3d matrix"],
                "default": [[1.0,0.0,0.0], [0.0,1.0,0.0], [0.0,0.0,1.0]]
            },
            "a_matrix4d": {
                "type": "matrixd[4]",
                "description": ["This is an attribute interpreted as a double-precision 4d matrix"],
                "default": [[1.0,0.0,0.0,0.0], [0.0,1.0,0.0,0.0], [0.0,0.0,1.0,0.0], [0.0,0.0,0.0,1.0]]
            },
            "a_normal3d": {
                "type": "normald[3]",
                "description": ["This is an attribute interpreted as a double-precision 3d normal"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_normal3f": {
                "type": "normalf[3]",
                "description": ["This is an attribute interpreted as a single-precision 3d normal"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_normal3h": {
                "type": "normalh[3]",
                "description": ["This is an attribute interpreted as a half-precision 3d normal"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_point3d": {
                "type": "pointd[3]",
                "description": ["This is an attribute interpreted as a double-precision 3d point"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_point3f": {
                "type": "pointf[3]",
                "description": ["This is an attribute interpreted as a single-precision 3d point"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_point3h": {
                "type": "pointh[3]",
                "description": ["This is an attribute interpreted as a half-precision 3d point"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_quatd": {
                "type": "quatd[4]",
                "description": ["This is an attribute interpreted as a double-precision 4d quaternion"],
                "default": [0.0, 0.0, 0.0, 0.0]
            },
            "a_quatf": {
                "type": "quatf[4]",
                "description": ["This is an attribute interpreted as a single-precision 4d quaternion"],
                "default": [0.0, 0.0, 0.0, 0.0]
            },
            "a_quath": {
                "type": "quath[4]",
                "description": ["This is an attribute interpreted as a half-precision 4d quaternion"],
                "default": [0.0, 0.0, 0.0, 0.0]
            },
            "a_texcoord2d": {
                "type": "texcoordd[2]",
                "description": ["This is an attribute interpreted as a double-precision 2d texcoord"],
                "default": [0.0, 0.0]
            },
            "a_texcoord2f": {
                "type": "texcoordf[2]",
                "description": ["This is an attribute interpreted as a single-precision 2d texcoord"],
                "default": [0.0, 0.0]
            },
            "a_texcoord2h": {
                "type": "texcoordh[2]",
                "description": ["This is an attribute interpreted as a half-precision 2d texcoord"],
                "default": [0.0, 0.0]
            },
            "a_texcoord3d": {
                "type": "texcoordd[3]",
                "description": ["This is an attribute interpreted as a double-precision 3d texcoord"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_texcoord3f": {
                "type": "texcoordf[3]",
                "description": ["This is an attribute interpreted as a single-precision 3d texcoord"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_texcoord3h": {
                "type": "texcoordh[3]",
                "description": ["This is an attribute interpreted as a half-precision 3d texcoord"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_timecode": {
                "type": "timecode",
                "description": ["This is a computed attribute interpreted as a timecode"],
                "default": 1.0
            },
            "a_vector3d": {
                "type": "vectord[3]",
                "description": ["This is an attribute interpreted as a double-precision 3d vector"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_vector3f": {
                "type": "vectorf[3]",
                "description": ["This is an attribute interpreted as a single-precision 3d vector"],
                "default": [0.0, 0.0, 0.0]
            },
            "a_vector3h": {
                "type": "vectorh[3]",
                "description": ["This is an attribute interpreted as a half-precision 3d vector"],
                "default": [0.0, 0.0, 0.0]
            }
        },
        "outputs": {
            "a_color3d": {
                "type": "colord[3]",
                "description": ["This is a computed attribute interpreted as a double-precision 3d color"]
            },
            "a_color3f": {
                "type": "colorf[3]",
                "description": ["This is a computed attribute interpreted as a single-precision 3d color"]
            },
            "a_color3h": {
                "type": "colorh[3]",
                "description": ["This is a computed attribute interpreted as a half-precision 3d color"]
            },
            "a_color4d": {
                "type": "colord[4]",
                "description": ["This is a computed attribute interpreted as a double-precision 4d color"]
            },
            "a_color4f": {
                "type": "colorf[4]",
                "description": ["This is a computed attribute interpreted as a single-precision 4d color"]
            },
            "a_color4h": {
                "type": "colorh[4]",
                "description": ["This is a computed attribute interpreted as a half-precision 4d color"]
            },
            "a_frame": {
                "type": "frame[4]",
                "description": ["This is a computed attribute interpreted as a coordinate frame"]
            },
            "a_matrix2d": {
                "type": "matrixd[2]",
                "description": ["This is a computed attribute interpreted as a double-precision 2d matrix"]
            },
            "a_matrix3d": {
                "type": "matrixd[3]",
                "description": ["This is a computed attribute interpreted as a double-precision 3d matrix"]
            },
            "a_matrix4d": {
                "type": "matrixd[4]",
                "description": ["This is a computed attribute interpreted as a double-precision 4d matrix"]
            },
            "a_normal3d": {
                "type": "normald[3]",
                "description": ["This is a computed attribute interpreted as a double-precision 3d normal"]
            },
            "a_normal3f": {
                "type": "normalf[3]",
                "description": ["This is a computed attribute interpreted as a single-precision 3d normal"]
            },
            "a_normal3h": {
                "type": "normalh[3]",
                "description": ["This is a computed attribute interpreted as a half-precision 3d normal"]
            },
            "a_point3d": {
                "type": "pointd[3]",
                "description": ["This is a computed attribute interpreted as a double-precision 3d point"]
            },
            "a_point3f": {
                "type": "pointf[3]",
                "description": ["This is a computed attribute interpreted as a single-precision 3d point"]
            },
            "a_point3h": {
                "type": "pointh[3]",
                "description": ["This is a computed attribute interpreted as a half-precision 3d point"]
            },
            "a_quatd": {
                "type": "quatd[4]",
                "description": ["This is a computed attribute interpreted as a double-precision 4d quaternion"]
            },
            "a_quatf": {
                "type": "quatf[4]",
                "description": ["This is a computed attribute interpreted as a single-precision 4d quaternion"]
            },
            "a_quath": {
                "type": "quath[4]",
                "description": ["This is a computed attribute interpreted as a half-precision 4d quaternion"]
            },
            "a_texcoord2d": {
                "type": "texcoordd[2]",
                "description": ["This is a computed attribute interpreted as a double-precision 2d texcoord"]
            },
            "a_texcoord2f": {
                "type": "texcoordf[2]",
                "description": ["This is a computed attribute interpreted as a single-precision 2d texcoord"]
            },
            "a_texcoord2h": {
                "type": "texcoordh[2]",
                "description": ["This is a computed attribute interpreted as a half-precision 2d texcoord"]
            },
            "a_texcoord3d": {
                "type": "texcoordd[3]",
                "description": ["This is a computed attribute interpreted as a double-precision 3d texcoord"]
            },
            "a_texcoord3f": {
                "type": "texcoordf[3]",
                "description": ["This is a computed attribute interpreted as a single-precision 3d texcoord"]
            },
            "a_texcoord3h": {
                "type": "texcoordh[3]",
                "description": ["This is a computed attribute interpreted as a half-precision 3d texcoord"]
            },
            "a_timecode": {
                "type": "timecode",
                "description": ["This is a computed attribute interpreted as a timecode"]
            },
            "a_vector3d": {
                "type": "vectord[3]",
                "description": ["This is a computed attribute interpreted as a double-precision 3d vector"]
            },
            "a_vector3f": {
                "type": "vectorf[3]",
                "description": ["This is a computed attribute interpreted as a single-precision 3d vector"]
            },
            "a_vector3h": {
                "type": "vectorh[3]",
                "description": ["This is a computed attribute interpreted as a half-precision 3d vector"]
            }
        },
        "tests": [
            {
                "description": "Compute method just increments the component values",
                "inputs:a_color3d": [1.0, 2.0, 3.0], "outputs:a_color3d": [2.0, 3.0, 4.0],
                "inputs:a_color3f": [11.0, 12.0, 13.0], "outputs:a_color3f": [12.0, 13.0, 14.0],
                "inputs:a_color3h": [21.0, 22.0, 23.0], "outputs:a_color3h": [22.0, 23.0, 24.0],
                "inputs:a_color4d": [1.0, 2.0, 3.0, 4.0], "outputs:a_color4d": [2.0, 3.0, 4.0, 5.0],
                "inputs:a_color4f": [11.0, 12.0, 13.0, 14.0], "outputs:a_color4f": [12.0, 13.0, 14.0, 15.0],
                "inputs:a_color4h": [21.0, 22.0, 23.0, 24.0], "outputs:a_color4h": [22.0, 23.0, 24.0, 25.0],
                "inputs:a_frame": [[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0], [9.0, 10.0, 11.0, 12.0], [13.0, 14.0, 15.0, 16.0]],
                "outputs:a_frame": [[2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0], [10.0, 11.0, 12.0, 13.0], [14.0, 15.0, 16.0, 17.0]],
                "inputs:a_matrix2d": [[1.0, 2.0], [3.0, 4.0]], "outputs:a_matrix2d": [[2.0, 3.0], [4.0, 5.0]],
                "inputs:a_matrix3d": [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]],
                "outputs:a_matrix3d": [[2.0, 3.0, 4.0], [5.0, 6.0, 7.0], [8.0, 9.0, 10.0]],
                "inputs:a_matrix4d": [[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0], [9.0, 10.0, 11.0, 12.0], [13.0, 14.0, 15.0, 16.0]],
                "outputs:a_matrix4d": [[2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0], [10.0, 11.0, 12.0, 13.0], [14.0, 15.0, 16.0, 17.0]],
                "inputs:a_normal3d": [1.0, 2.0, 3.0], "outputs:a_normal3d": [2.0, 3.0, 4.0],
                "inputs:a_normal3f": [11.0, 12.0, 13.0], "outputs:a_normal3f": [12.0, 13.0, 14.0],
                "inputs:a_normal3h": [21.0, 22.0, 23.0], "outputs:a_normal3h": [22.0, 23.0, 24.0],
                "inputs:a_point3d": [1.0, 2.0, 3.0], "outputs:a_point3d": [2.0, 3.0, 4.0],
                "inputs:a_point3f": [11.0, 12.0, 13.0], "outputs:a_point3f": [12.0, 13.0, 14.0],
                "inputs:a_point3h": [21.0, 22.0, 23.0], "outputs:a_point3h": [22.0, 23.0, 24.0],
                "inputs:a_quatd": [1.0, 2.0, 3.0, 4.0], "outputs:a_quatd": [2.0, 3.0, 4.0, 5.0],
                "inputs:a_quatf": [11.0, 12.0, 13.0, 14.0], "outputs:a_quatf": [12.0, 13.0, 14.0, 15.0],
                "inputs:a_quath": [21.0, 22.0, 23.0, 24.0], "outputs:a_quath": [22.0, 23.0, 24.0, 25.0],
                "inputs:a_texcoord2d": [1.0, 2.0], "outputs:a_texcoord2d": [2.0, 3.0],
                "inputs:a_texcoord2f": [11.0, 12.0], "outputs:a_texcoord2f": [12.0, 13.0],
                "inputs:a_texcoord2h": [21.0, 22.0], "outputs:a_texcoord2h": [22.0, 23.0],
                "inputs:a_texcoord3d": [1.0, 2.0, 3.0], "outputs:a_texcoord3d": [2.0, 3.0, 4.0],
                "inputs:a_texcoord3f": [11.0, 12.0, 13.0], "outputs:a_texcoord3f": [12.0, 13.0, 14.0],
                "inputs:a_texcoord3h": [21.0, 22.0, 23.0], "outputs:a_texcoord3h": [22.0, 23.0, 24.0],
                "inputs:a_timecode": 10.0, "outputs:a_timecode": 11.0,
                "inputs:a_vector3d": [1.0, 2.0, 3.0], "outputs:a_vector3d": [2.0, 3.0, 4.0],
                "inputs:a_vector3f": [11.0, 12.0, 13.0], "outputs:a_vector3f": [12.0, 13.0, 14.0],
                "inputs:a_vector3h": [21.0, 22.0, 23.0], "outputs:a_vector3h": [22.0, 23.0, 24.0]
            }
        ]
    }
}

OgnTutorialRoleData.cpp

The cpp file contains the implementation of the compute method, which modifies each of the inputs by adding 1.0 to all components to create outputs that have different, testable, values.

  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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// 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.
//
#include <OgnTutorialRoleDataDatabase.h>

// This class exercises access to the DataModel through the generated database class for all role-based data types

namespace
{
// Helper values to make it easy to add 1 to values of different lengths
GfHalf h1{ 1.0f };
GfVec2d increment2d{ 1.0, 1.0 };
GfVec2f increment2f{ 1.0f, 1.0f };
GfVec2h increment2h{ h1, h1 };
GfVec3d increment3d{ 1.0, 1.0, 1.0 };
GfVec3f increment3f{ 1.0f, 1.0f, 1.0f };
GfVec3h increment3h{ h1, h1, h1 };
GfVec4d increment4d{ 1.0, 1.0, 1.0, 1.0 };
GfVec4f increment4f{ 1.0f, 1.0f, 1.0f, 1.0f };
GfVec4h increment4h{ h1, h1, h1, h1 };
GfQuatd incrementQd{ 1.0, 1.0, 1.0, 1.0 };
GfQuatf incrementQf{ 1.0f, 1.0f, 1.0f, 1.0f };
GfQuath incrementQh{ h1, h1, h1, h1 };
GfMatrix4d incrementM4d{ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
GfMatrix3d incrementM3d{ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
GfMatrix2d incrementM2d{ 1.0, 1.0, 1.0, 1.0 };
}

// Helper macro to simplify the code but include all of the error checking
#define ComputeOne(ATTRIBUTE_NAME, INCREMENT_VARIABLE, ROLE_EXPECTED)                                                  \
    foundError = false;                                                                                                \
    if (db.inputs.ATTRIBUTE_NAME.role() != ROLE_EXPECTED)                                                              \
    {                                                                                                                  \
        db.logWarning("Input role type %d != %d", (int)db.inputs.ATTRIBUTE_NAME.role(), (int)ROLE_EXPECTED);           \
        foundError = true;                                                                                             \
        foundAnyErrors = true;                                                                                         \
    }                                                                                                                  \
    if (db.outputs.ATTRIBUTE_NAME.role() != ROLE_EXPECTED)                                                             \
    {                                                                                                                  \
        db.logWarning("output role type %d != %d", (int)db.outputs.ATTRIBUTE_NAME.role(), (int)ROLE_EXPECTED);         \
        foundError = true;                                                                                             \
        foundAnyErrors = true;                                                                                         \
    }                                                                                                                  \
    if (!foundError)                                                                                                   \
    {                                                                                                                  \
        db.outputs.ATTRIBUTE_NAME() = db.inputs.ATTRIBUTE_NAME() + INCREMENT_VARIABLE;                                 \
    }

class OgnTutorialRoleData
{
public:
    static bool compute(OgnTutorialRoleDataDatabase& db)
    {
        // The roles for the attributes only serve to guide how to interpret them. When accessed from the
        // database they take the form of their raw underlying type. For example a point3d will have the
        // same GfVec3d type as a double[3], as will a vector3d and a normal3d.

        // Keep track if any role errors were found with this, continuing to the end of evaluation after errors
        bool foundAnyErrors{ false }; // Toggled on as soon as any error is found
        bool foundError{ false }; // Toggled off and on for each attribute

        // Walk through all of the data types, using the macro to perform error checking
        ComputeOne(a_color3d, increment3d, AttributeRole::eColor);
        ComputeOne(a_color3f, increment3f, AttributeRole::eColor);
        ComputeOne(a_color3h, increment3h, AttributeRole::eColor);
        //
        ComputeOne(a_color4d, increment4d, AttributeRole::eColor);
        ComputeOne(a_color4f, increment4f, AttributeRole::eColor);
        ComputeOne(a_color4h, increment4h, AttributeRole::eColor);
        //
        ComputeOne(a_frame, incrementM4d, AttributeRole::eFrame);
        //
        ComputeOne(a_matrix2d, incrementM2d, AttributeRole::eMatrix
        );
        ComputeOne(a_matrix3d, incrementM3d, AttributeRole::eMatrix
        );
        ComputeOne(a_matrix4d, incrementM4d, AttributeRole::eMatrix
        );
        //
        ComputeOne(a_normal3d, increment3d, AttributeRole::eNormal);
        ComputeOne(a_normal3f, increment3f, AttributeRole::eNormal);
        ComputeOne(a_normal3h, increment3h, AttributeRole::eNormal);
        //
        ComputeOne(a_point3d, increment3d, AttributeRole::ePosition);
        ComputeOne(a_point3f, increment3f, AttributeRole::ePosition);
        ComputeOne(a_point3h, increment3h, AttributeRole::ePosition);
        //
        ComputeOne(a_quatd, incrementQd, AttributeRole::eQuaternion);
        ComputeOne(a_quatf, incrementQf, AttributeRole::eQuaternion);
        ComputeOne(a_quath, incrementQh, AttributeRole::eQuaternion);
        //
        ComputeOne(a_texcoord2d, increment2d, AttributeRole::eTexCoord);
        ComputeOne(a_texcoord2f, increment2f, AttributeRole::eTexCoord);
        ComputeOne(a_texcoord2h, increment2h, AttributeRole::eTexCoord);
        //
        ComputeOne(a_texcoord3d, increment3d, AttributeRole::eTexCoord);
        ComputeOne(a_texcoord3f, increment3f, AttributeRole::eTexCoord);
        ComputeOne(a_texcoord3h, increment3h, AttributeRole::eTexCoord);
        //
        ComputeOne(a_timecode, 1.0, AttributeRole::eTimeCode);
        //
        ComputeOne(a_vector3d, increment3d, AttributeRole::eVector);
        ComputeOne(a_vector3f, increment3f, AttributeRole::eVector);
        ComputeOne(a_vector3h, increment3h, AttributeRole::eVector);

        return foundAnyErrors;
    }
};

REGISTER_OGN_NODE()

Role-Based Attribute Access

Here is a subset of the generated role-based attributes from the database. It contains color attributes, a matrix attribute, and a timecode attribute. Notice how the underlying data types of the attributes are provided, again with the ability to cast to different interface classes with the same memory layout.

Database Function

Returned Type

inputs.a_color3d()

const GfVec3d&

inputs.a_color4f()

const GfVec4f&

inputs.a_frame()

const GfMatrix4d&

inputs.a_timecode()

const double&

outputs.a_color3d()

GfVec3d&

outputs.a_color4f()

GfVec4f&

outputs.a_frame()

GfMatrix4d&

outputs.a_timecode()

double&

The full set of corresponding data types can be found in Attribute Types With Roles.

This role information is available on all attribute interfaces through the role() method. For example you can find that the first attribute is a color by making this check:

static bool compute(OgnTutorialRoleDataDatabase& db)
{
    if (db.inputs.a_color3d.role == eColor )
    {
        processValueAsAColor( db.inputs.a_color3d() );
    }
}