file_path
stringlengths
21
224
content
stringlengths
0
80.8M
omniverse-code/kit/exts/omni.kit.renderer.imgui/omni/kit/imgui_renderer_test/__init__.py
from ._imgui_renderer_test import * # Cached interface instance pointer def get_imgui_renderer_test_interface() -> IImGuiRendererTest: if not hasattr(get_imgui_renderer_test_interface, "imgui_renderer_test"): get_imgui_renderer_test_interface.imgui_renderer_test = acquire_imgui_renderer_test_interface() return get_imgui_renderer_test_interface.imgui_renderer_test
omniverse-code/kit/exts/omni.kit.renderer.imgui/omni/kit/ui/editor_menu.py
import carb from typing import Callable, Union, Tuple extension_id = "omni.kit.ui.editor_menu_bridge" class EditorMenu(): active_menus = {} window_handler = {} setup_hook = False omni_kit_menu_utils_loaded = False def __init__(self): import omni.kit.app manager = omni.kit.app.get_app().get_extension_manager() self._hooks = [] self._hooks.append( manager.subscribe_to_extension_enable( on_enable_fn=lambda _: EditorMenu.set_menu_loaded(True), on_disable_fn=lambda _: EditorMenu.set_menu_loaded(False), ext_name="omni.kit.menu.utils", hook_name="editor menu omni.kit.menu.utils listener", ) ) @staticmethod def clean_menu_path(path): import re return re.sub(r"[^\x00-\x7F]+", "", path).lstrip() @staticmethod def set_menu_loaded(state: bool): EditorMenu.omni_kit_menu_utils_loaded = state class EditorMenuItem: def __init__(self, menu_path): self._menu_path = menu_path def __del__(self): carb.log_info(f"{self._menu_path} went out of scope and is being automatically removed from the menu system") EditorMenu.remove_item(self._menu_path) @staticmethod def sort_menu_hook(merged_menu): from omni.kit.menu.utils import MenuItemDescription def priority_sort(menu_entry): if hasattr(menu_entry, "priority"): return menu_entry.priority return 0 for name in ["Window", "Help"]: if name in merged_menu: merged_menu[name].sort(key=priority_sort) priority = 0 for index, menu_entry in enumerate(merged_menu[name]): if hasattr(menu_entry, "priority"): if index > 0 and abs(menu_entry.priority - priority) > 9: spacer = MenuItemDescription() spacer.priority = menu_entry.priority merged_menu[name].insert(index, spacer) priority = menu_entry.priority @staticmethod def get_action_name(menu_path): import re action = re.sub(r'[^\x00-\x7F]','', menu_path).lower().strip().replace('/', '_').replace(' ', '_').replace('__', '_') return(f"action_editor_menu_bridge_{action}") @staticmethod def convert_to_new_menu(menu_path:str, menu_name: Union[str, list], on_click: Callable, toggle: bool, priority: int, value: bool, enabled: bool, original_svg_color: bool): from omni.kit.menu.utils import MenuItemDescription action_name = EditorMenu.get_action_name(menu_path) if on_click: import omni.kit.actions.core omni.kit.actions.core.get_action_registry().register_action( extension_id, action_name, lambda: on_click(menu_path, EditorMenu.toggle_value(menu_path)), display_name=action_name, description=action_name, tag=action_name, ) if isinstance(menu_name, list): menu_item = menu_name.pop(-1) sub_menu_item = MenuItemDescription(name=menu_item, enabled=enabled, ticked=toggle, ticked_value=value if toggle else None, onclick_action=(extension_id, action_name), original_svg_color=original_svg_color) sub_menu = [sub_menu_item] while(len(menu_name) > 0): menu_item = menu_name.pop(-1) menu = MenuItemDescription(name=menu_item, sub_menu=sub_menu, original_svg_color=original_svg_color) menu.priority=priority sub_menu = [menu] return menu, sub_menu_item else: menu = MenuItemDescription(name=menu_name, enabled=enabled, ticked=toggle, ticked_value=value if toggle else None, onclick_action=(extension_id, action_name), original_svg_color=original_svg_color) menu.priority=priority return menu, menu @staticmethod def split_menu_path(menu_path: str): menu_name = None menu_parts = menu_path.replace("\/", "@TEMPSLASH@").split("/") menu_title = menu_parts.pop(0) if len(menu_parts) > 1: menu_name = menu_parts elif menu_parts: menu_name = menu_parts[0] if menu_name: if isinstance(menu_name, list): menu_name = [name.replace("@TEMPSLASH@", "\\") for name in menu_name] else: menu_name = menu_name.replace("@TEMPSLASH@", "\\") if menu_title: menu_title = menu_title.replace("@TEMPSLASH@", "\\") return menu_title, menu_name @staticmethod def add_item(menu_path: str, on_click: Callable=None, toggle: bool=False, priority: int=0, value: bool=False, enabled: bool=True, original_svg_color: bool=False, auto_release=True): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for add_item({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return import omni.kit.menu.utils if EditorMenu.setup_hook == False: omni.kit.menu.utils.add_hook(EditorMenu.sort_menu_hook) EditorMenu.setup_hook = True menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.convert_to_new_menu(menu_path, menu_name, on_click, toggle, priority, value, enabled, original_svg_color) EditorMenu.active_menus[menu_path] = (menu, menuitem) omni.kit.menu.utils.add_menu_items([menu], menu_title) # disabled for fastShutdown as auto-release causes exceptions on shutdown, so editor_menus may leak as most are not removed if auto_release: return EditorMenu.EditorMenuItem(menu_path) return menu_path @staticmethod def set_on_click(menu_path: str, on_click: Callable=None): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for set_on_click({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return import omni.kit.menu.utils action_name = EditorMenu.get_action_name(menu_path) if menu_path in EditorMenu.active_menus: import omni.kit.actions.core omni.kit.actions.core.get_action_registry().deregister_action( extension_id, action_name ) if on_click: omni.kit.actions.core.get_action_registry().register_action( extension_id, action_name, lambda: on_click(menu_path, EditorMenu.toggle_value(menu_path)), display_name=action_name, description=action_name, tag=action_name, ) menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] omni.kit.menu.utils.remove_menu_items([menu], menu_title) menuitem.onclick_action = None if on_click: menuitem.onclick_action=(extension_id, action_name) omni.kit.menu.utils.add_menu_items([menu], menu_title) return None carb.log_warn(f"set_on_click menu {EditorMenu.clean_menu_path(menu_path)} not found") return None @staticmethod def remove_item(menu_path: str): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for remove_item({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return import omni.kit.menu.utils import omni.kit.actions.core if menu_path in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] omni.kit.menu.utils.remove_menu_items([menu], menu_title) del EditorMenu.active_menus[menu_path] omni.kit.actions.core.get_action_registry().deregister_action( extension_id, EditorMenu.get_action_name(menu_path) ) return None carb.log_warn(f"remove_item menu {EditorMenu.clean_menu_path(menu_path)} not found") return None @staticmethod def set_priority(menu_path: str, priority: int): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for set_priority({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return import omni.kit.menu.utils menu_title_id, menu_name = EditorMenu.split_menu_path(menu_path) if menu_title_id and not menu_name: for menu_id in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_id) if menu_title == menu_title_id: menu, menuitem = EditorMenu.active_menus[menu_id] omni.kit.menu.utils.remove_menu_items([menu], menu_title) omni.kit.menu.utils.add_menu_items([menu], menu_title, priority) return if menu_path in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] omni.kit.menu.utils.remove_menu_items([menu], menu_title) menuitem.priority = priority omni.kit.menu.utils.add_menu_items([menu], menu_title) return carb.log_warn(f"set_priority menu {EditorMenu.clean_menu_path(menu_path)} not found") return @staticmethod def set_enabled(menu_path: str, enabled: bool): if not EditorMenu.omni_kit_menu_utils_loaded: return None import omni.kit.menu.utils if menu_path in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] menuitem.enabled = enabled return None carb.log_warn(f"set_enabled menu {EditorMenu.clean_menu_path(menu_path)} not found") return None @staticmethod def set_hotkey(menu_path: str, modifier: int, key: int): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for set_hotkey({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return None import omni.kit.menu.utils if menu_path in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] omni.kit.menu.utils.remove_menu_items([menu], menu_title) menuitem.set_hotkey((modifier, key)) omni.kit.menu.utils.add_menu_items([menu], menu_title) return None carb.log_warn(f"set_hotkey menu {EditorMenu.clean_menu_path(menu_path)} not found") return None @staticmethod def set_value(menu_path: str, value: bool): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for set_value({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return None import omni.kit.menu.utils if menu_path in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] if menuitem.ticked_value != value: menuitem.ticked_value = value omni.kit.menu.utils.refresh_menu_items(menu_title) return None carb.log_warn(f"set_value menu {EditorMenu.clean_menu_path(menu_path)} not found") return None @staticmethod def get_value(menu_path: str): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for get_value({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return None if menu_path in EditorMenu.active_menus: menu, menuitem = EditorMenu.active_menus[menu_path] return menuitem.ticked_value carb.log_warn(f"get_value menu {EditorMenu.clean_menu_path(menu_path)} not found") return None @staticmethod def toggle_value(menu_path: str): if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for toggle_value({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return None import omni.kit.menu.utils if menu_path in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] menuitem.ticked_value = not menuitem.ticked_value omni.kit.menu.utils.refresh_menu_items(menu_title) return menuitem.ticked_value carb.log_warn(f"toggle_value menu {EditorMenu.clean_menu_path(menu_path)} not found") return None @staticmethod def has_item(menu_path: str): return (menu_path in EditorMenu.active_menus) @staticmethod def set_on_right_click(menu_path: str, on_click: Callable=None): carb.log_warn(f"EditorMenu.set_on_right_click(menu_path='{EditorMenu.clean_menu_path(menu_path)}', on_click={on_click}) not supported") return None @staticmethod def set_action(menu_path: str, action_mapping_path: str, action_name: str): carb.log_warn(f"EditorMenu.set_action(menu_path='{EditorMenu.clean_menu_path(menu_path)}', action_mapping_path='{action_mapping_path}', action_name='{action_name}') not supported") return None @staticmethod def add_action_to_menu( menu_path: str, on_action: Callable, action_name: str = None, default_hotkey: Tuple[int, int] = None, on_rmb_click: Callable = None, ) -> None: if not EditorMenu.omni_kit_menu_utils_loaded: carb.log_warn(f"omni.kit.menu.utils not loaded for add_action_to_menu({EditorMenu.clean_menu_path(menu_path)}) - Extension needs dependency to omni.kit.menu.utils") return None import omni.kit.menu.utils from omni.kit.menu.utils import MenuActionControl if on_rmb_click: carb.log_warn(f"add_action_to_menu {EditorMenu.clean_menu_path(menu_path)} on_rmb_click not supported") if menu_path in EditorMenu.active_menus: menu_title, menu_name = EditorMenu.split_menu_path(menu_path) menu, menuitem = EditorMenu.active_menus[menu_path] omni.kit.menu.utils.remove_menu_items([menu], menu_title) action_name = EditorMenu.get_action_name(menu_path) if on_action: import omni.kit.actions.core omni.kit.actions.core.get_action_registry().deregister_action( extension_id, action_name ) omni.kit.actions.core.get_action_registry().register_action( extension_id, action_name, on_action, display_name=action_name, description=action_name, tag=action_name, ) # HACK - async/frame delay breaks fullscreen mode if action_name in ["action_editor_menu_bridge_window_fullscreen_mode"]: menuitem.onclick_action=(extension_id, action_name, MenuActionControl.NODELAY) else: menuitem.onclick_action=(extension_id, action_name) menuitem.set_hotkey(default_hotkey) omni.kit.menu.utils.add_menu_items([menu], menu_title) return None carb.log_warn(f"add_action_to_menu menu {EditorMenu.clean_menu_path(menu_path)} not found") return None
omniverse-code/kit/exts/omni.kit.renderer.imgui/omni/kit/ui/_ui.pyi
from __future__ import annotations import omni.kit.ui._ui import typing import carb import carb._carb import carb.events._events import omni.ui._ui __all__ = [ "BroadcastModel", "Button", "CheckBox", "ClippingType", "CollapsingFrame", "ColorRgb", "ColorRgba", "ColumnLayout", "ComboBox", "ComboBoxInt", "Container", "ContainerBase", "ContentWindow", "DelegateAction", "DelegateResult", "DockPreference", "DragDouble", "DragDouble2", "DragDouble3", "DragDouble4", "DragInt", "DragInt2", "DragUInt", "DraggingType", "FieldDouble", "FieldInt", "FileDialogDataSource", "FileDialogOpenMode", "FileDialogSelectType", "FilePicker", "Image", "Label", "Length", "ListBox", "MODEL_META_SERIALIZED_CONTENTS", "MODEL_META_WIDGET_TYPE", "Mat44", "Menu", "MenuEventType", "Model", "ModelChangeInfo", "ModelEventType", "ModelNodeType", "ModelWidget", "Percent", "Pixel", "Popup", "ProgressBar", "RowColumnLayout", "RowLayout", "ScalarXYZ", "ScalarXYZW", "ScrollingFrame", "Separator", "SimpleTreeView", "SimpleValueWidgetBool", "SimpleValueWidgetColorRgb", "SimpleValueWidgetColorRgba", "SimpleValueWidgetDouble", "SimpleValueWidgetDouble2", "SimpleValueWidgetDouble3", "SimpleValueWidgetDouble4", "SimpleValueWidgetInt", "SimpleValueWidgetInt2", "SimpleValueWidgetMat44", "SimpleValueWidgetString", "SimpleValueWidgetUint", "SliderDouble", "SliderDouble2", "SliderDouble3", "SliderDouble4", "SliderInt", "SliderInt2", "SliderUInt", "Spacer", "TextBox", "Transform", "UnitType", "ValueWidgetBool", "ValueWidgetColorRgb", "ValueWidgetColorRgba", "ValueWidgetDouble", "ValueWidgetDouble2", "ValueWidgetDouble3", "ValueWidgetDouble4", "ValueWidgetInt", "ValueWidgetInt2", "ValueWidgetMat44", "ValueWidgetString", "ValueWidgetUint", "ViewCollapsing", "ViewFlat", "ViewTreeGrid", "WINDOW_FLAGS_FORCE_HORIZONTAL_SCROLLBAR", "WINDOW_FLAGS_FORCE_VERTICAL_SCROLLBAR", "WINDOW_FLAGS_MODAL", "WINDOW_FLAGS_NONE", "WINDOW_FLAGS_NO_CLOSE", "WINDOW_FLAGS_NO_COLLAPSE", "WINDOW_FLAGS_NO_FOCUS_ON_APPEARING", "WINDOW_FLAGS_NO_MOVE", "WINDOW_FLAGS_NO_RESIZE", "WINDOW_FLAGS_NO_SAVED_SETTINGS", "WINDOW_FLAGS_NO_SCROLLBAR", "WINDOW_FLAGS_NO_TITLE_BAR", "WINDOW_FLAGS_SHOW_HORIZONTAL_SCROLLBAR", "Widget", "Window", "WindowEventType", "WindowMainStandalone", "WindowStandalone", "activate_menu_item", "get_custom_glyph_code", "get_editor_menu_legacy", "get_main_window" ] class BroadcastModel(Model): def __init__(self) -> None: ... def add_target(self, arg0: Model, arg1: str, arg2: str) -> int: ... def remove_target(self, arg0: int) -> None: ... pass class Button(Label, Widget): """ Button Widget. Args: text (str): Text on button. is_image (bool): Text is an image filename. """ def __init__(self, text: str = '', is_image: bool = False, default_color: int = 4294967295) -> None: ... def set_clicked_fn(self, arg0: typing.Callable[[Widget], None]) -> None: ... @property def url(self) -> str: """ :type: str """ @url.setter def url(self, arg1: str) -> None: pass pass class CheckBox(SimpleValueWidgetBool, ValueWidgetBool, ModelWidget, Widget): """ CheckBox Widget. Args: text (str, default=""): Text on label. value (bool, default=False): Initial value. left_handed (bool, default=False): Initial value. styled (bool, default=False): Initial value """ def __init__(self, text: str = '', value: bool = False, left_handed: bool = False, styled: bool = False) -> None: ... @property def styled(self) -> bool: """ :type: bool """ @styled.setter def styled(self, arg0: bool) -> None: pass pass class ClippingType(): """ Supported text clipping types. Members: NONE ELLIPSIS_LEFT ELLIPSIS_RIGHT WRAP """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ ELLIPSIS_LEFT: omni.kit.ui._ui.ClippingType # value = <ClippingType.ELLIPSIS_LEFT: 1> ELLIPSIS_RIGHT: omni.kit.ui._ui.ClippingType # value = <ClippingType.ELLIPSIS_RIGHT: 2> NONE: omni.kit.ui._ui.ClippingType # value = <ClippingType.NONE: 0> WRAP: omni.kit.ui._ui.ClippingType # value = <ClippingType.WRAP: 3> __members__: dict # value = {'NONE': <ClippingType.NONE: 0>, 'ELLIPSIS_LEFT': <ClippingType.ELLIPSIS_LEFT: 1>, 'ELLIPSIS_RIGHT': <ClippingType.ELLIPSIS_RIGHT: 2>, 'WRAP': <ClippingType.WRAP: 3>} pass class CollapsingFrame(Container, Widget): def __init__(self, arg0: str, arg1: bool) -> None: ... @property def open(self) -> bool: """ :type: bool """ @open.setter def open(self, arg1: bool) -> None: pass @property def title(self) -> str: """ :type: str """ @title.setter def title(self, arg1: str) -> None: pass @property def use_frame_background_color(self) -> bool: """ :type: bool """ @use_frame_background_color.setter def use_frame_background_color(self, arg1: bool) -> None: pass @property def visible(self) -> bool: """ :type: bool """ @visible.setter def visible(self, arg1: bool) -> None: pass pass class ColorRgb(SimpleValueWidgetColorRgb, ValueWidgetColorRgb, ModelWidget, Widget): """ Color Picker Widget (Tuple[float, float, float]). Args: text (str, default=""): Text on label. value (Tuple[float, float, float], default=(0.0, 0.0, 0.0)): Initial value. """ def __init__(self, text: str = '', value: carb._carb.ColorRgb = carb.ColorRgb(0,0,0)) -> None: ... pass class ColorRgba(SimpleValueWidgetColorRgba, ValueWidgetColorRgba, ModelWidget, Widget): """ Color Picker Widget (Tuple[float, float, float, float]). Args: text (str, default=""): Text on label. value (Tuple[float, float, float, float], default=(0.0, 0.0, 0.0)): Initial value. """ def __init__(self, text: str = '', value: carb._carb.ColorRgba = carb.ColorRgba(0,0,0,0)) -> None: ... pass class ColumnLayout(Container, Widget): def __init__(self, spacing: int = -1, padding_x: int = -1, padding_y: int = -1) -> None: ... pass class ComboBox(SimpleValueWidgetString, ValueWidgetString, ModelWidget, Widget): """ ComboBox Widget. Args: text (str, default=""): Text on label. items (List[[str], default=[]): List of elements. display_names (List[str], default=[]): List of element display names. Optional. """ def __init__(self, text: str = '', items: typing.List[str] = [], display_names: typing.List[str] = []) -> None: ... def add_item(self, item: str, display_name: str = '') -> None: ... def clear_items(self) -> None: ... def get_item_at(self, arg0: int) -> str: ... def get_item_count(self) -> int: ... def remove_item(self, arg0: int) -> None: ... def set_items(self, items: typing.List[str], display_names: typing.List[str] = []) -> None: ... @property def selected_index(self) -> int: """ :type: int """ @selected_index.setter def selected_index(self, arg1: int) -> None: pass pass class ComboBoxInt(SimpleValueWidgetInt, ValueWidgetInt, ModelWidget, Widget): """ ComboBox Widget. Args: text (str, default=""): Text on label. items (List[[int], default=[]): List of elements. display_names (List[int], default=[]): List of element display names. Optional. """ def __init__(self, text: str = '', items: typing.List[int] = [], display_names: typing.List[str] = []) -> None: ... def add_item(self, item: int, display_name: str = '') -> None: ... def clear_items(self) -> None: ... def get_item_at(self, arg0: int) -> int: ... def get_item_count(self) -> int: ... def remove_item(self, arg0: int) -> None: ... def set_items(self, items: typing.List[int], display_names: typing.List[str] = []) -> None: ... @property def selected_index(self) -> int: """ :type: int """ @selected_index.setter def selected_index(self, arg1: int) -> None: pass pass class Container(Widget): """ Base class for all UI containers. Container can hold arbitrary number of other :class:`.Widget` s """ def add_child(self, arg0: Widget) -> Widget: ... def clear(self) -> None: ... def get_child_at(self, arg0: int) -> Widget: ... def get_child_count(self) -> int: ... def remove_child(self, arg0: Widget) -> None: ... @property def child_spacing(self) -> carb._carb.Float2: """ :type: carb._carb.Float2 """ @child_spacing.setter def child_spacing(self, arg1: carb._carb.Float2) -> None: pass pass class ContainerBase(Widget): """ Class for the complex widget that can have children, but doesn;t allow to add children for the external user. """ def draw(self, arg0: float) -> None: ... pass class ContentWindow(Widget): """ Content Window. Content Window is container that hosts a file picker widget. """ @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: int, arg1: int) -> None: ... def get_selected_icon_paths(self) -> tuple: ... def get_selected_node_paths(self) -> tuple: ... def navigate_to(self, arg0: str) -> None: ... def refresh(self) -> None: ... def set_filter(self, arg0: str) -> None: ... pass class DelegateAction(): """ Members: CREATE_DEFAULT_WIDGET SKIP_KEY USE_CUSTOM_WIDGET """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ CREATE_DEFAULT_WIDGET: omni.kit.ui._ui.DelegateAction # value = <DelegateAction.CREATE_DEFAULT_WIDGET: 0> SKIP_KEY: omni.kit.ui._ui.DelegateAction # value = <DelegateAction.SKIP_KEY: 1> USE_CUSTOM_WIDGET: omni.kit.ui._ui.DelegateAction # value = <DelegateAction.USE_CUSTOM_WIDGET: 2> __members__: dict # value = {'CREATE_DEFAULT_WIDGET': <DelegateAction.CREATE_DEFAULT_WIDGET: 0>, 'SKIP_KEY': <DelegateAction.SKIP_KEY: 1>, 'USE_CUSTOM_WIDGET': <DelegateAction.USE_CUSTOM_WIDGET: 2>} pass class DelegateResult(): @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: typing.Sequence) -> None: ... @typing.overload def __init__(self, arg0: DelegateAction) -> None: ... @typing.overload def __init__(self, arg0: Widget) -> None: ... @property def action(self) -> DelegateAction: """ :type: DelegateAction """ @action.setter def action(self, arg0: DelegateAction) -> None: pass @property def custom_widget(self) -> Widget: """ :type: Widget """ @custom_widget.setter def custom_widget(self, arg0: Widget) -> None: pass pass class DockPreference(): """ Members: DISABLED MAIN RIGHT LEFT RIGHT_TOP RIGHT_BOTTOM LEFT_BOTTOM """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ DISABLED: omni.kit.ui._ui.DockPreference # value = <DockPreference.DISABLED: 0> LEFT: omni.kit.ui._ui.DockPreference # value = <DockPreference.LEFT: 3> LEFT_BOTTOM: omni.kit.ui._ui.DockPreference # value = <DockPreference.LEFT_BOTTOM: 6> MAIN: omni.kit.ui._ui.DockPreference # value = <DockPreference.MAIN: 1> RIGHT: omni.kit.ui._ui.DockPreference # value = <DockPreference.RIGHT: 2> RIGHT_BOTTOM: omni.kit.ui._ui.DockPreference # value = <DockPreference.RIGHT_BOTTOM: 5> RIGHT_TOP: omni.kit.ui._ui.DockPreference # value = <DockPreference.RIGHT_TOP: 4> __members__: dict # value = {'DISABLED': <DockPreference.DISABLED: 0>, 'MAIN': <DockPreference.MAIN: 1>, 'RIGHT': <DockPreference.RIGHT: 2>, 'LEFT': <DockPreference.LEFT: 3>, 'RIGHT_TOP': <DockPreference.RIGHT_TOP: 4>, 'RIGHT_BOTTOM': <DockPreference.RIGHT_BOTTOM: 5>, 'LEFT_BOTTOM': <DockPreference.LEFT_BOTTOM: 6>} pass class DragDouble(SimpleValueWidgetDouble, ValueWidgetDouble, ModelWidget, Widget): """ Drag Widget (double). If `min` >= `max` widget value has no bound. Args: text (str, default=""): Text on label. value (double, default=0): Initial value. min (double, default=0): Lower value limit. max (double, default=0): Upper value limit. drag_speed (float, default=1.0): Drag speed. """ def __init__(self, text: str = '', value: float = 0.0, min: float = 0, max: float = 0, drag_speed: float = 1.0) -> None: ... @property def drag_speed(self) -> float: """ :type: float """ @drag_speed.setter def drag_speed(self, arg0: float) -> None: pass @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass pass class DragDouble2(SimpleValueWidgetDouble2, ValueWidgetDouble2, ModelWidget, Widget): """ Drag Widget (Tuple[double, double]). If `min` >= `max` widget value has no bound. Args: text (str, default=""): Text on label. value (Tuple[double, double], default=0): Initial value. min (double, default=0): Lower value limit. max (double, default=0): Upper value limit. drag_speed (float, default=1.0): Drag speed. """ def __init__(self, text: str = '', value: carb._carb.Double2 = carb.Double2(0,0), min: float = 0, max: float = 0, drag_speed: float = 1.0) -> None: ... @property def drag_speed(self) -> float: """ :type: float """ @drag_speed.setter def drag_speed(self, arg0: float) -> None: pass @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass pass class DragDouble3(SimpleValueWidgetDouble3, ValueWidgetDouble3, ModelWidget, Widget): """ Drag Widget (Tuple[double, double, double]). If `min` >= `max` widget value has no bound. Args: text (str, default=""): Text on label. value (Tuple[double, double, double], default=0): Initial value. min (double, default=0): Lower value limit. max (double, default=0): Upper value limit. drag_speed (float, default=1.0): Drag speed. """ def __init__(self, text: str = '', value: carb._carb.Double3 = carb.Double3(0,0,0), min: float = 0, max: float = 0, drag_speed: float = 1.0) -> None: ... @property def drag_speed(self) -> float: """ :type: float """ @drag_speed.setter def drag_speed(self, arg0: float) -> None: pass @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass pass class DragDouble4(SimpleValueWidgetDouble4, ValueWidgetDouble4, ModelWidget, Widget): """ Drag Widget (Tuple[double, double, double, double]). If `min` >= `max` widget value has no bound. Args: text (str, default=""): Text on label. value (Tuple[double, double, double, double], default=0): Initial value. min (double, default=0): Lower value limit. max (double, default=0): Upper value limit. drag_speed (float, default=1.0): Drag speed. """ def __init__(self, text: str = '', value: carb._carb.Double4 = carb.Double4(0,0,0,0), min: float = 0, max: float = 0, drag_speed: float = 1.0) -> None: ... @property def drag_speed(self) -> float: """ :type: float """ @drag_speed.setter def drag_speed(self, arg0: float) -> None: pass @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass pass class DragInt(SimpleValueWidgetInt, ValueWidgetInt, ModelWidget, Widget): """ Drag Widget (int). If `min` >= `max` widget value has no bound. Args: text (str, default=""): Text on label. value (int, default=0): Initial value. min (int, default=0): Lower value limit. max (int, default=0): Upper value limit. drag_speed (float, default=1.0): Drag speed. """ def __init__(self, text: str = '', value: int = 0, min: int = 0, max: int = 0, drag_speed: float = 1.0) -> None: ... @property def drag_speed(self) -> float: """ :type: float """ @drag_speed.setter def drag_speed(self, arg0: float) -> None: pass @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> int: """ :type: int """ @max.setter def max(self, arg0: int) -> None: pass @property def min(self) -> int: """ :type: int """ @min.setter def min(self, arg0: int) -> None: pass pass class DragInt2(SimpleValueWidgetInt2, ValueWidgetInt2, ModelWidget, Widget): """ Drag Widget (Tuple[int, int]). If `min` >= `max` widget value has no bound. Args: text (str, default=""): Text on label. value (Tuple[int, int], default=0): Initial value. min (int, default=0): Lower value limit. max (int, default=0): Upper value limit. drag_speed (float, default=1.0): Drag speed. """ def __init__(self, text: str = '', value: carb._carb.Int2 = carb.Int2(0,0), min: int = 0, max: int = 0, drag_speed: float = 1.0) -> None: ... @property def drag_speed(self) -> float: """ :type: float """ @drag_speed.setter def drag_speed(self, arg0: float) -> None: pass @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> int: """ :type: int """ @max.setter def max(self, arg0: int) -> None: pass @property def min(self) -> int: """ :type: int """ @min.setter def min(self, arg0: int) -> None: pass pass class DragUInt(SimpleValueWidgetUint, ValueWidgetUint, ModelWidget, Widget): """ Drag Widget (uint32_t). If `min` >= `max` widget value has no bound. Args: text (str, default=""): Text on label. value (uint32_t, default=0): Initial value. min (uint32_t, default=0): Lower value limit. max (uint32_t, default=0): Upper value limit. drag_speed (float, default=1.0): Drag speed. """ def __init__(self, text: str = '', value: int = 0, min: int = 0, max: int = 0, drag_speed: float = 1.0) -> None: ... @property def drag_speed(self) -> float: """ :type: float """ @drag_speed.setter def drag_speed(self, arg0: float) -> None: pass @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> int: """ :type: int """ @max.setter def max(self, arg0: int) -> None: pass @property def min(self) -> int: """ :type: int """ @min.setter def min(self, arg0: int) -> None: pass pass class DraggingType(): """ Supported dragging types. Members: STARTED STOPPED """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ STARTED: omni.kit.ui._ui.DraggingType # value = <DraggingType.STARTED: 0> STOPPED: omni.kit.ui._ui.DraggingType # value = <DraggingType.STOPPED: 1> __members__: dict # value = {'STARTED': <DraggingType.STARTED: 0>, 'STOPPED': <DraggingType.STOPPED: 1>} pass class FieldDouble(SimpleValueWidgetDouble, ValueWidgetDouble, ModelWidget, Widget): """ Field Widget (double). Args: text (str, default=""): Text on label. value (double, default=0): Initial value. step (double, default=1): Value step. step_fast (double, default=100): Fast value step. """ def __init__(self, text: str = '', value: float = 0.0, step: float = 1, step_fast: float = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def step(self) -> float: """ :type: float """ @step.setter def step(self, arg0: float) -> None: pass @property def step_fast(self) -> float: """ :type: float """ @step_fast.setter def step_fast(self, arg0: float) -> None: pass pass class FieldInt(SimpleValueWidgetInt, ValueWidgetInt, ModelWidget, Widget): """ Field Widget (int). Args: text (str, default=""): Text on label. value (int, default=0): Initial value. step (int, default=1): Value step. step_fast (int, default=100): Fast value step. """ def __init__(self, text: str = '', value: int = 0, step: int = 1, step_fast: int = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def step(self) -> int: """ :type: int """ @step.setter def step(self, arg0: int) -> None: pass @property def step_fast(self) -> int: """ :type: int """ @step_fast.setter def step_fast(self, arg0: int) -> None: pass pass class FileDialogDataSource(): """ Data source of File Dialog. Members: LOCAL OMNIVERSE ALL """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ ALL: omni.kit.ui._ui.FileDialogDataSource # value = <FileDialogDataSource.ALL: 2> LOCAL: omni.kit.ui._ui.FileDialogDataSource # value = <FileDialogDataSource.LOCAL: 0> OMNIVERSE: omni.kit.ui._ui.FileDialogDataSource # value = <FileDialogDataSource.OMNIVERSE: 1> __members__: dict # value = {'LOCAL': <FileDialogDataSource.LOCAL: 0>, 'OMNIVERSE': <FileDialogDataSource.OMNIVERSE: 1>, 'ALL': <FileDialogDataSource.ALL: 2>} pass class FileDialogOpenMode(): """ Open mode of File Dialog. Members: OPEN SAVE """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ OPEN: omni.kit.ui._ui.FileDialogOpenMode # value = <FileDialogOpenMode.OPEN: 0> SAVE: omni.kit.ui._ui.FileDialogOpenMode # value = <FileDialogOpenMode.SAVE: 1> __members__: dict # value = {'OPEN': <FileDialogOpenMode.OPEN: 0>, 'SAVE': <FileDialogOpenMode.SAVE: 1>} pass class FileDialogSelectType(): """ File selection type of File Dialog. Members: FILE DIRECTORY ALL """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ ALL: omni.kit.ui._ui.FileDialogSelectType # value = <FileDialogSelectType.ALL: 2> DIRECTORY: omni.kit.ui._ui.FileDialogSelectType # value = <FileDialogSelectType.DIRECTORY: 1> FILE: omni.kit.ui._ui.FileDialogSelectType # value = <FileDialogSelectType.FILE: 0> __members__: dict # value = {'FILE': <FileDialogSelectType.FILE: 0>, 'DIRECTORY': <FileDialogSelectType.DIRECTORY: 1>, 'ALL': <FileDialogSelectType.ALL: 2>} pass class FilePicker(): def __init__(self, title: str, mode: FileDialogOpenMode = FileDialogOpenMode.OPEN, file_type: FileDialogSelectType = FileDialogSelectType.FILE, on_file_selected: typing.Callable[[str], None] = None, on_dialog_cancelled: typing.Callable[[], None] = None, width: float = 800.0, height: float = 440.0) -> None: ... def add_filter(self, arg0: str, arg1: str) -> None: ... def clear_all_filters(self) -> None: ... def is_visible(self) -> bool: ... def set_current_directory(self, arg0: str) -> None: ... def set_default_save_name(self, name: str) -> None: """ sets the default name to use for the filename on save dialogs. This sets the default filename to be used when saving a file. This name will be ignored if the dialog is not in @ref FileDialogOpenMode::eSave mode. The given name will still be stored regardless. This default filename may omit the file extension to take the extension from the current filter. If an extension is explicitly given here, no extension will be appended regardless of the current filter. Args: name: the default filename to use for this dialog. This may be None or an empty string to use the USD stage's default prim name. In this case, if the prim name cannot be retrieved, "Untitled" will be used instead. If a non-empty string is given here, this will always be used as the initial suggested filename. Returns: No return value. """ def set_dialog_cancelled_fn(self, arg0: typing.Callable[[], None]) -> None: ... def set_file_selected_fn(self, arg0: typing.Callable[[str], None]) -> None: ... def show(self, data_source: FileDialogDataSource = FileDialogDataSource.ALL) -> None: ... @property def selection_type(self) -> FileDialogSelectType: """ :type: FileDialogSelectType """ @selection_type.setter def selection_type(self, arg1: FileDialogSelectType) -> None: pass @property def title(self) -> str: """ :type: str """ @title.setter def title(self, arg1: str) -> None: pass pass class Image(Widget): def __init__(self, url: str = '', width: int = 0, height: int = 0) -> None: ... @property def url(self) -> str: """ :type: str """ @url.setter def url(self, arg1: str) -> None: pass pass class Label(Widget): """ Label Widget. Displays non-editable text. Args: text (str, default=""): Text to display. """ def __init__(self, text: str = '', useclipboard: bool = False, clippingmode: ClippingType = ClippingType.NONE, font_style: omni.ui._ui.FontStyle = FontStyle.NONE) -> None: ... def reset_text_color(self) -> None: ... def set_clicked_fn(self, arg0: typing.Callable[[Widget], None]) -> None: ... def set_text_color(self, arg0: carb._carb.ColorRgba) -> None: ... @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg1: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip """ pass class Length(): """ Length. Represents any length as a value and unit type. Examples: >>> l1 = omni.kit.ui.Length(250, omni.kit.ui.UnitType.PIXEL) >>> l2 = omni.kit.ui.Pixel(250) >>> l3 = omni.kit.ui.Percent(30) `l1` and `l2` represent the same value: 250 in pixels. `l3` is 30%. """ @typing.overload def __init__(self) -> None: ... @staticmethod @typing.overload def __init__(*args, **kwargs) -> typing.Any: ... @typing.overload def __init__(self, arg0: float) -> None: ... @typing.overload def __init__(self, arg0: int) -> None: ... def __str__(self) -> str: ... @property def unit(self) -> omni::kit::ui::UnitType: """ (:obj:`.UnitType.`) Unit. :type: omni::kit::ui::UnitType """ @unit.setter def unit(self, arg0: omni::kit::ui::UnitType) -> None: """ (:obj:`.UnitType.`) Unit. """ @property def value(self) -> float: """ (float) Value :type: float """ @value.setter def value(self, arg0: float) -> None: """ (float) Value """ pass class ListBox(Label, Widget): """ ListBox Widget. Args: text (str, default=""): Text on label. multi_select (bool, default=True): Multi selection enabled. item_height_count (int, default=-1): Height in items. items (List[str], default=[]): List of elements. """ def __init__(self, text: str = '', multi_select: bool = True, item_height_count: int = -1, items: typing.List[str] = []) -> None: ... def add_item(self, arg0: str) -> None: ... def clear_items(self) -> None: ... def clear_selection(self) -> None: ... def get_item_at(self, arg0: int) -> str: ... def get_item_count(self) -> int: ... def get_selected(self) -> typing.List[int]: ... def remove_item(self, arg0: int) -> None: ... def set_selected(self, arg0: int, arg1: bool) -> None: ... def set_selection_changed_fn(self, arg0: typing.Callable[[Widget], None]) -> None: ... @property def item_height_count(self) -> int: """ :type: int """ @item_height_count.setter def item_height_count(self, arg1: int) -> None: pass @property def multi_select(self) -> bool: """ :type: bool """ @multi_select.setter def multi_select(self, arg1: bool) -> None: pass pass class Mat44(): @typing.overload def __getitem__(self, arg0: int) -> float: ... @typing.overload def __getitem__(self, arg0: slice) -> list: ... @typing.overload def __init__(self) -> None: ... @typing.overload def __init__(self, arg0: typing.Sequence) -> None: ... def __len__(self) -> int: ... def __repr__(self) -> str: ... @typing.overload def __setitem__(self, arg0: int, arg1: float) -> None: ... @typing.overload def __setitem__(self, arg0: slice, arg1: typing.Sequence) -> None: ... def __str__(self) -> str: ... def get_row(self, arg0: int) -> carb._carb.Double4: ... def set_row(self, arg0: int, arg1: carb._carb.Double4) -> carb._carb.Double4: ... pass class Menu(Widget): """ Menu. """ def __init__(self) -> None: ... def add_item(self, menu_path: str, on_click: typing.Callable[[str, bool], None] = None, toggle: bool = False, priority: int = 0, value: bool = False, enabled: bool = True, original_svg_color: bool = False, auto_release: bool = True) -> carb._carb.Subscription: ... def get_item_count(self) -> int: ... def get_items(self) -> typing.List[str]: ... def get_value(self, arg0: str) -> bool: ... def has_item(self, arg0: str) -> bool: ... def remove_item(self, arg0: str) -> None: ... def set_action(self, arg0: str, arg1: str, arg2: str) -> None: ... def set_enabled(self, arg0: str, arg1: bool) -> None: ... def set_hotkey(self, menu_path: str, modifier: int, key: int) -> None: """ Set menu hotkey. Args: menu_path (str): Path to menu item. modifier(int): Keyboard modifier from :mod:`carb.input`. key(int): Keyboard key code from :class:`carb.input.KeyboardInput`. """ def set_on_click(self, menu_path: str, on_click: typing.Callable[[str, bool], None] = None) -> None: ... def set_on_right_click(self, menu_path: str, on_click: typing.Callable[[str, bool], None] = None) -> None: ... def set_priority(self, arg0: str, arg1: int) -> None: ... def set_value(self, arg0: str, arg1: bool) -> None: ... static_class = None pass class MenuEventType(): """ menu operation results. Members: ACTIVATE """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ ACTIVATE: omni.kit.ui._ui.MenuEventType # value = <MenuEventType.ACTIVATE: 0> __members__: dict # value = {'ACTIVATE': <MenuEventType.ACTIVATE: 0>} pass class Model(): def __init__(self) -> None: ... def get_type(self, arg0: str, arg1: str) -> ModelNodeType: ... def signal_change(self, path: str, meta: str = '', type: ModelEventType = ModelEventType.NODE_VALUE_CHANGE, sender: int = 0) -> None: ... pass class ModelChangeInfo(): def __init__(self) -> None: ... @property def sender(self) -> int: """ :type: int """ @sender.setter def sender(self, arg0: int) -> None: pass @property def transient(self) -> bool: """ :type: bool """ @transient.setter def transient(self, arg0: bool) -> None: pass pass class ModelEventType(): """ Model event types. Members: NODE_ADD NODE_REMOVE NODE_TYPE_CHANGE NODE_VALUE_CHANGE """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ NODE_ADD: omni.kit.ui._ui.ModelEventType # value = <ModelEventType.NODE_ADD: 0> NODE_REMOVE: omni.kit.ui._ui.ModelEventType # value = <ModelEventType.NODE_REMOVE: 1> NODE_TYPE_CHANGE: omni.kit.ui._ui.ModelEventType # value = <ModelEventType.NODE_TYPE_CHANGE: 2> NODE_VALUE_CHANGE: omni.kit.ui._ui.ModelEventType # value = <ModelEventType.NODE_VALUE_CHANGE: 3> __members__: dict # value = {'NODE_ADD': <ModelEventType.NODE_ADD: 0>, 'NODE_REMOVE': <ModelEventType.NODE_REMOVE: 1>, 'NODE_TYPE_CHANGE': <ModelEventType.NODE_TYPE_CHANGE: 2>, 'NODE_VALUE_CHANGE': <ModelEventType.NODE_VALUE_CHANGE: 3>} pass class ModelNodeType(): """ Model node types. Members: UNKNOWN OBJECT ARRAY STRING BOOL NUMBER """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ ARRAY: omni.kit.ui._ui.ModelNodeType # value = <ModelNodeType.ARRAY: 2> BOOL: omni.kit.ui._ui.ModelNodeType # value = <ModelNodeType.BOOL: 4> NUMBER: omni.kit.ui._ui.ModelNodeType # value = <ModelNodeType.NUMBER: 5> OBJECT: omni.kit.ui._ui.ModelNodeType # value = <ModelNodeType.OBJECT: 1> STRING: omni.kit.ui._ui.ModelNodeType # value = <ModelNodeType.STRING: 3> UNKNOWN: omni.kit.ui._ui.ModelNodeType # value = <ModelNodeType.UNKNOWN: 0> __members__: dict # value = {'UNKNOWN': <ModelNodeType.UNKNOWN: 0>, 'OBJECT': <ModelNodeType.OBJECT: 1>, 'ARRAY': <ModelNodeType.ARRAY: 2>, 'STRING': <ModelNodeType.STRING: 3>, 'BOOL': <ModelNodeType.BOOL: 4>, 'NUMBER': <ModelNodeType.NUMBER: 5>} pass class ModelWidget(Widget): """ Model Widget. """ def get_model(self) -> Model: ... def get_model_root(self) -> str: ... def get_model_stream(self) -> carb.events._events.IEventStream: ... def set_model(self, model: Model, root: str = '', isTimeSampled: bool = False, value: float = -1.0) -> None: ... @property def is_time_sampled_widget(self) -> bool: """ :type: bool """ @property def time_code(self) -> float: """ :type: float """ pass class Percent(Length): """ Convenience class to express :class:`.Length` in percents. """ def __init__(self, arg0: float) -> None: ... pass class Pixel(Length): """ Convenience class to express :class:`.Length` in pixels. """ def __init__(self, arg0: float) -> None: ... pass class Popup(): def __init__(self, title: str, modal: bool = False, width: float = 0.0, height: float = 0.0, auto_resize: bool = False) -> None: ... def hide(self) -> None: ... def is_visible(self) -> bool: ... def set_close_fn(self, arg0: typing.Callable[[], None]) -> None: ... def set_update_fn(self, arg0: typing.Callable[[float], None]) -> None: ... def show(self) -> None: ... @property def height(self) -> float: """ :type: float """ @height.setter def height(self, arg1: float) -> None: pass @property def layout(self) -> Container: """ :type: Container """ @layout.setter def layout(self, arg1: Container) -> None: pass @property def pos(self) -> carb._carb.Float2: """ :type: carb._carb.Float2 """ @pos.setter def pos(self, arg1: carb._carb.Float2) -> None: pass @property def title(self) -> str: """ :type: str """ @title.setter def title(self, arg1: str) -> None: pass @property def width(self) -> float: """ :type: float """ @width.setter def width(self, arg1: float) -> None: pass pass class ProgressBar(Widget): """ ProgressBar Widget. Displays a progress bar. Args: width (:class:`.Length`): Width. height (:class:`.Length`, default=omni.kit.ui.Pixel(0)): Height. """ @typing.overload def __init__(self, width: Length, height: Length = ...) -> None: ... @typing.overload def __init__(self, width: float) -> None: ... def set_progress(self, value: float, text: str = None) -> None: ... @property def overlay(self) -> str: """ :type: str """ @overlay.setter def overlay(self, arg1: str) -> None: pass @property def progress(self) -> float: """ :type: float """ @progress.setter def progress(self, arg1: float) -> None: pass pass class RowColumnLayout(Container, Widget): def __init__(self, column_count: int, borders: bool = False) -> None: ... def get_column_width(self, arg0: int) -> Length: ... def set_column_width(self, index: int, val: object, min: float = 0.0, max: float = 0.0) -> None: """ Set column width. Args: index: column index. val: width value. Should be either a :class:`.Length` or `float` (treated as :class:`.Pixel` length). """ pass class RowLayout(Container, Widget): def __init__(self) -> None: ... pass class ScalarXYZ(ValueWidgetDouble3, ModelWidget, Widget): """ ScalarXYZ Widget. If `min` >= `max` widget value has no bound. Args: format_string (str, default="%0.1f"): Format string. drag_speed (float, default=1.0): Drag speed. value_wrap (float, default=0.0): Value wrap. min (double, default=0.0): Lower value limit. max (double, default=0.0): Upper value limit. value (Tuple[double, double, double], default=(0, 0, 0)): Initial value. """ def __init__(self, format_string: str = '%0.1f', drag_speed: float = 1.0, wrap_value: float = 0.0, min: float = 0.0, max: float = 0.0, dead_zone: float = 0.0, value: carb._carb.Double3 = carb.Double3(0,0,0)) -> None: ... def skip_ypos_update(self, arg0: bool) -> None: ... pass class ScalarXYZW(ValueWidgetDouble4, ModelWidget, Widget): """ ScalarXYZW Widget. If `min` >= `max` widget value has no bound. Args: format_string (str, default="%0.1f"): Format string. drag_speed (float, default=1.0): Drag speed. value_wrap (float, default=0.0): Value wrap. min (double, default=0.0): Lower value limit. max (double, default=0.0): Upper value limit. value (Tuple[double, double, double, double], default=(0, 0, 0, 0)): Initial value. """ def __init__(self, format_string: str = '%0.1f', drag_speed: float = 1.0, wrap_value: float = 0.0, min: float = 0.0, max: float = 0.0, value: carb._carb.Double4 = carb.Double4(0,0,0,0)) -> None: ... pass class ScrollingFrame(Container, Widget): def __init__(self, arg0: str, arg1: float, arg2: float) -> None: ... def scroll_to(self, arg0: float) -> None: ... pass class Separator(Widget): """ Separator. Separator UI element. """ def __init__(self) -> None: ... pass class SimpleTreeView(Widget): """ SimpleTreeView Widget. Args: items (List[str], default=[]): List of string as the source of the Tree hierarchy. separator(str, default='/'): A string separator to parse the strings into tree node tokens """ def __init__(self, items: typing.List[str] = [], separator: str = '/') -> None: ... def clear_selection(self) -> None: ... def get_selected_item_name(self) -> str: ... def set_clicked_fn(self, arg0: typing.Callable[[Widget], None]) -> None: ... def set_tree_data(self, arg0: typing.List[str]) -> None: ... pass class SimpleValueWidgetBool(ValueWidgetBool, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetColorRgb(ValueWidgetColorRgb, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetColorRgba(ValueWidgetColorRgba, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetDouble(ValueWidgetDouble, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetDouble2(ValueWidgetDouble2, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetDouble3(ValueWidgetDouble3, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetDouble4(ValueWidgetDouble4, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetInt(ValueWidgetInt, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetInt2(ValueWidgetInt2, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetMat44(ValueWidgetMat44, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetString(ValueWidgetString, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SimpleValueWidgetUint(ValueWidgetUint, ModelWidget, Widget): """ Model Widget with single value for simple controls. """ @property def left_handed(self) -> bool: """ :type: bool """ @left_handed.setter def left_handed(self, arg0: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg0: str) -> None: pass @property def tooltip(self) -> Widget: """ Widget to be shown when mouse is over the Widget as a tooltip. :type: Widget """ @tooltip.setter def tooltip(self, arg0: Widget) -> None: """ Widget to be shown when mouse is over the Widget as a tooltip. """ pass class SliderDouble(SimpleValueWidgetDouble, ValueWidgetDouble, ModelWidget, Widget): """ Slider Widget (double). Args: text (str, default=""): Text on label. value (double, default=0): Initial value. min (double, default=0): Lower value limit. max (double, default=100): Upper value limit. """ def __init__(self, text: str = '', value: float = 0.0, min: float = 0, max: float = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass @property def power(self) -> float: """ :type: float """ @power.setter def power(self, arg0: float) -> None: pass pass class SliderDouble2(SimpleValueWidgetDouble2, ValueWidgetDouble2, ModelWidget, Widget): """ Slider Widget (Tuple[double, double]). Args: text (str, default=""): Text on label. value (Tuple[double, double], default=0): Initial value. min (Tuple[double, double], default=0): Lower value limit. max (Tuple[double, double], default=100): Upper value limit. """ def __init__(self, text: str = '', value: carb._carb.Double2 = carb.Double2(0,0), min: float = 0, max: float = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass @property def power(self) -> float: """ :type: float """ @power.setter def power(self, arg0: float) -> None: pass pass class SliderDouble3(SimpleValueWidgetDouble3, ValueWidgetDouble3, ModelWidget, Widget): """ Slider Widget (Tuple[double, double, double]). Args: text (str, default=""): Text on label. value (Tuple[double, double, double], default=0): Initial value. min (Tuple[double, double, double], default=0): Lower value limit. max (Tuple[double, double, double], default=100): Upper value limit. """ def __init__(self, text: str = '', value: carb._carb.Double3 = carb.Double3(0,0,0), min: float = 0, max: float = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass @property def power(self) -> float: """ :type: float """ @power.setter def power(self, arg0: float) -> None: pass pass class SliderDouble4(SimpleValueWidgetDouble4, ValueWidgetDouble4, ModelWidget, Widget): """ Slider Widget (Tuple[double, double, double, double]). Args: text (str, default=""): Text on label. value (Tuple[double, double, double, double], default=0): Initial value. min (Tuple[double, double, double, double], default=0): Lower value limit. max (Tuple[double, double, double, double], default=100): Upper value limit. """ def __init__(self, text: str = '', value: carb._carb.Double4 = carb.Double4(0,0,0,0), min: float = 0, max: float = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> float: """ :type: float """ @max.setter def max(self, arg0: float) -> None: pass @property def min(self) -> float: """ :type: float """ @min.setter def min(self, arg0: float) -> None: pass @property def power(self) -> float: """ :type: float """ @power.setter def power(self, arg0: float) -> None: pass pass class SliderInt(SimpleValueWidgetInt, ValueWidgetInt, ModelWidget, Widget): """ Slider Widget (int). Args: text (str, default=""): Text on label. value (int, default=0): Initial value. min (int, default=0): Lower value limit. max (int, default=100): Upper value limit. """ def __init__(self, text: str = '', value: int = 0, min: int = 0, max: int = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> int: """ :type: int """ @max.setter def max(self, arg0: int) -> None: pass @property def min(self) -> int: """ :type: int """ @min.setter def min(self, arg0: int) -> None: pass @property def power(self) -> float: """ :type: float """ @power.setter def power(self, arg0: float) -> None: pass pass class SliderInt2(SimpleValueWidgetInt2, ValueWidgetInt2, ModelWidget, Widget): """ Slider Widget (Tuple[int, int]). Args: text (str, default=""): Text on label. value (Tuple[int, int], default=0): Initial value. min (Tuple[int, int], default=0): Lower value limit. max (Tuple[int, int], default=100): Upper value limit. """ def __init__(self, text: str = '', value: carb._carb.Int2 = carb.Int2(0,0), min: int = 0, max: int = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> int: """ :type: int """ @max.setter def max(self, arg0: int) -> None: pass @property def min(self) -> int: """ :type: int """ @min.setter def min(self, arg0: int) -> None: pass @property def power(self) -> float: """ :type: float """ @power.setter def power(self, arg0: float) -> None: pass pass class SliderUInt(SimpleValueWidgetUint, ValueWidgetUint, ModelWidget, Widget): """ Slider Widget (uint32_t). Args: text (str, default=""): Text on label. value (uint32_t, default=0): Initial value. min (uint32_t, default=0): Lower value limit. max (uint32_t, default=100): Upper value limit. """ def __init__(self, text: str = '', value: int = 0, min: int = 0, max: int = 100) -> None: ... @property def format(self) -> str: """ :type: str """ @format.setter def format(self, arg0: str) -> None: pass @property def max(self) -> int: """ :type: int """ @max.setter def max(self, arg0: int) -> None: pass @property def min(self) -> int: """ :type: int """ @min.setter def min(self, arg0: int) -> None: pass @property def power(self) -> float: """ :type: float """ @power.setter def power(self, arg0: float) -> None: pass pass class Spacer(Widget): """ Spacer. Dummy UI element to fill in space. Args: width (:class:`.Length`): Width. height (:class:`.Length`, default=omni.kit.ui.Pixel(0)): Height. """ @typing.overload def __init__(self, width: Length, height: Length = ...) -> None: ... @typing.overload def __init__(self, width: float) -> None: ... pass class TextBox(ValueWidgetString, ModelWidget, Widget): """ TextBox Widget. Displays editable text. Args: value (str, default=""): Initial text. """ @typing.overload def __init__(self, value: str = '', hint: str = '', change_on_enter: bool = False) -> None: ... @typing.overload def __init__(self, value: str = '', change_on_enter: bool = False) -> None: ... def reset_text_color(self) -> None: ... def set_list_suggestions_fn(self, arg0: typing.Callable[[Widget, str], typing.List[str]]) -> None: ... def set_text_changed_fn(self, arg0: typing.Callable[[Widget], None]) -> None: ... def set_text_color(self, arg0: carb._carb.ColorRgba) -> None: ... def set_text_finalized_fn(self, arg0: typing.Callable[[Widget], None]) -> None: ... def text_width(self) -> float: ... @property def clipping_mode(self) -> ClippingType: """ :type: ClippingType """ @clipping_mode.setter def clipping_mode(self, arg1: ClippingType) -> None: pass @property def readonly(self) -> bool: """ :type: bool """ @readonly.setter def readonly(self, arg1: bool) -> None: pass @property def show_background(self) -> bool: """ :type: bool """ @show_background.setter def show_background(self, arg1: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg1: str) -> None: pass pass class Transform(ValueWidgetMat44, ModelWidget, Widget): def __init__(self, position_format_string: str = '%0.1f', position_drag_speed: float = 1.0, position_wrap_value: float = 0.0, position_min: float = 0.0, position_max: float = 0.0, rotation_format_string: str = '%0.1f', rotation_drag_speed: float = 1.0, rotation_wrap_value: float = 0.0, rotation_min: float = 0.0, rotation_max: float = 0.0) -> None: ... pass class UnitType(): """ Unit types. Widths, heights or other UI length can be specified in pixels or relative to window (or child window) size. Members: PIXEL PERCENT """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ PERCENT: omni.kit.ui._ui.UnitType # value = <UnitType.PERCENT: 1> PIXEL: omni.kit.ui._ui.UnitType # value = <UnitType.PIXEL: 0> __members__: dict # value = {'PIXEL': <UnitType.PIXEL: 0>, 'PERCENT': <UnitType.PERCENT: 1>} pass class ValueWidgetBool(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[bool], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetBool], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> bool: """ : Widget value property. :type: bool """ @value.setter def value(self, arg1: bool) -> None: """ : Widget value property. """ pass class ValueWidgetColorRgb(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[carb._carb.ColorRgb], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetColorRgb], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> carb._carb.ColorRgb: """ : Widget value property. :type: carb._carb.ColorRgb """ @value.setter def value(self, arg1: carb._carb.ColorRgb) -> None: """ : Widget value property. """ pass class ValueWidgetColorRgba(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[carb._carb.ColorRgba], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetColorRgba], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> carb._carb.ColorRgba: """ : Widget value property. :type: carb._carb.ColorRgba """ @value.setter def value(self, arg1: carb._carb.ColorRgba) -> None: """ : Widget value property. """ pass class ValueWidgetDouble(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[float], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetDouble], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> float: """ : Widget value property. :type: float """ @value.setter def value(self, arg1: float) -> None: """ : Widget value property. """ pass class ValueWidgetDouble2(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[carb._carb.Double2], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetDouble2], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> carb._carb.Double2: """ : Widget value property. :type: carb._carb.Double2 """ @value.setter def value(self, arg1: carb._carb.Double2) -> None: """ : Widget value property. """ pass class ValueWidgetDouble3(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[carb._carb.Double3], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetDouble3], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> carb._carb.Double3: """ : Widget value property. :type: carb._carb.Double3 """ @value.setter def value(self, arg1: carb._carb.Double3) -> None: """ : Widget value property. """ pass class ValueWidgetDouble4(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[carb._carb.Double4], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetDouble4], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> carb._carb.Double4: """ : Widget value property. :type: carb._carb.Double4 """ @value.setter def value(self, arg1: carb._carb.Double4) -> None: """ : Widget value property. """ pass class ValueWidgetInt(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[int], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetInt], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> int: """ : Widget value property. :type: int """ @value.setter def value(self, arg1: int) -> None: """ : Widget value property. """ pass class ValueWidgetInt2(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[carb._carb.Int2], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetInt2], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> carb._carb.Int2: """ : Widget value property. :type: carb._carb.Int2 """ @value.setter def value(self, arg1: carb._carb.Int2) -> None: """ : Widget value property. """ pass class ValueWidgetMat44(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[Mat44], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetMat44], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> Mat44: """ : Widget value property. :type: Mat44 """ @value.setter def value(self, arg1: Mat44) -> None: """ : Widget value property. """ pass class ValueWidgetString(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[str], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetString], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> str: """ : Widget value property. :type: str """ @value.setter def value(self, arg1: str) -> None: """ : Widget value property. """ pass class ValueWidgetUint(ModelWidget, Widget): """ Model Widget with single value. """ def get_value_ambiguous(self) -> bool: ... def set_on_changed_fn(self, fn: typing.Callable[[int], None]) -> None: """ Set a callback function to be called when value changes. Args: fn: Function to be called when value changes. New value is passed into the function. """ def set_on_right_click_fn(self, fn: typing.Callable[[ValueWidgetUint], None]) -> None: """ Set a callback function to be called when right mouse button is clicked. Args: fn: Function to be called when right mouse button is clicked. ValueWidget is passed into the function. """ def set_value_ambiguous(self, arg0: bool) -> None: ... @property def value(self) -> int: """ : Widget value property. :type: int """ @value.setter def value(self, arg1: int) -> None: """ : Widget value property. """ pass class ViewCollapsing(ModelWidget, Widget): def __init__(self, defaultOpen: bool, sort: bool = False) -> None: ... def set_filter(self, arg0: str) -> None: ... @property def use_frame_background_color(self) -> bool: """ :type: bool """ @use_frame_background_color.setter def use_frame_background_color(self, arg1: bool) -> None: pass pass class ViewFlat(ModelWidget, Widget): def __init__(self, sort: bool = False) -> None: ... def set_filter(self, arg0: str) -> int: ... pass class ViewTreeGrid(ModelWidget, Widget): def __init__(self, default_open: bool, sort: bool = False, column_count: int = 1) -> None: ... def get_header_cell_widget(self, arg0: int) -> Widget: ... def set_build_cell_fn(self, arg0: typing.Callable[[Model, str, int, int], DelegateResult]) -> None: ... def set_header_cell_text(self, arg0: int, arg1: str) -> None: ... def set_header_cell_widget(self, arg0: int, arg1: Widget) -> None: ... @property def draw_table_header(self) -> bool: """ :type: bool """ @draw_table_header.setter def draw_table_header(self, arg1: bool) -> None: pass @property def is_root(self) -> bool: """ :type: bool """ @is_root.setter def is_root(self, arg1: bool) -> None: pass @property def text(self) -> str: """ :type: str """ @text.setter def text(self, arg1: str) -> None: pass pass class Widget(): """ Widget. Base class for all UI elements. """ def get_font_size(self) -> float: ... def set_dragdrop_fn(self, arg0: typing.Callable[[Widget, str], None], arg1: str) -> None: ... @staticmethod def set_dragged_fn(*args, **kwargs) -> typing.Any: ... @property def enabled(self) -> bool: """ :type: bool """ @enabled.setter def enabled(self, arg1: bool) -> None: pass @property def font_style(self) -> omni.ui._ui.FontStyle: """ :type: omni.ui._ui.FontStyle """ @font_style.setter def font_style(self, arg1: omni.ui._ui.FontStyle) -> None: pass @property def height(self) -> Length: """ (:class:`.Length`, default=omni.kit.ui.Pixel(0)): Height. :type: Length """ @height.setter def height(self, arg1: object) -> None: """ (:class:`.Length`, default=omni.kit.ui.Pixel(0)): Height. """ @property def user_data(self) -> dict: """ :class:`dict` with additional user data attached to widget. Lifetime of it depends on lifetime of the widget. :type: dict """ @user_data.setter def user_data(self, arg1: dict) -> None: """ :class:`dict` with additional user data attached to widget. Lifetime of it depends on lifetime of the widget. """ @property def visible(self) -> bool: """ :type: bool """ @visible.setter def visible(self, arg1: bool) -> None: pass @property def width(self) -> Length: """ (:class:`.Length`, default=omni.kit.ui.Pixel(0)): Width. :type: Length """ @width.setter def width(self, arg1: object) -> None: """ (:class:`.Length`, default=omni.kit.ui.Pixel(0)): Width. """ pass class Window(): """ UI Window. Window is a starting point for every new UI. It contains a :class:`.Container`, which can contain other :class:`.Widget`'s. Args: title (str): The title to be displayed on window title bar. width (int, default=640): Window width in pixels. height (int, default=480): Window height in pixels. open (bool, default=True): Is window opened when created. add_to_menu (bool, default=True): Create main menu item with this window in the Kit. menu_path (str, default=""): Menu path if add_to_menu is True. If empty string is passed it is added under "Extensions" menu item. is_toggle_menu (bool, default=True): Can menu item be toggled? dock (:obj:`omni.ui.DockPreference`, default=LEFT_BOTTOM): Docking preference for a window, see :class:`.DockPreference` flags (:obj:`omni.kit.ui.Window`, default=NONE): flags for a window, see :class:`.Window` """ def hide(self) -> None: ... def is_modal(self) -> bool: ... def is_visible(self) -> bool: ... def set_alpha(self, arg0: float) -> None: ... def set_size(self, arg0: int, arg1: int) -> None: ... def set_update_fn(self, arg0: typing.Callable[[float], None]) -> None: ... def set_visibility_changed_fn(self, arg0: typing.Callable[[bool], None]) -> None: ... def show(self) -> None: ... def title(self) -> str: ... @property def event_stream(self) -> carb.events._events.IEventStream: """ Event stream with events of type: :class:`.WindowEventType` :type: carb.events._events.IEventStream """ @property def flags(self) -> int: """ :type: int """ @flags.setter def flags(self, arg1: int) -> None: pass @property def height(self) -> int: """ :type: int """ @height.setter def height(self, arg1: int) -> None: pass @property def layout(self) -> Container: """ :type: Container """ @layout.setter def layout(self, arg1: Container) -> None: pass @property def menu(self) -> omni::kit::ui::Menu: """ Window optional menu bar. :type: omni::kit::ui::Menu """ @menu.setter def menu(self, arg0: omni::kit::ui::Menu) -> None: """ Window optional menu bar. """ @property def mouse_pos(self) -> carb._carb.Float2: """ :type: carb._carb.Float2 """ @property def width(self) -> int: """ :type: int """ @width.setter def width(self, arg1: int) -> None: pass pass class WindowEventType(): """ Members: VISIBILITY_CHANGE UPDATE """ def __eq__(self, other: object) -> bool: ... def __getstate__(self) -> int: ... def __hash__(self) -> int: ... def __index__(self) -> int: ... def __init__(self, value: int) -> None: ... def __int__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __repr__(self) -> str: ... def __setstate__(self, state: int) -> None: ... @property def name(self) -> str: """ :type: str """ @property def value(self) -> int: """ :type: int """ UPDATE: omni.kit.ui._ui.WindowEventType # value = <WindowEventType.UPDATE: 1> VISIBILITY_CHANGE: omni.kit.ui._ui.WindowEventType # value = <WindowEventType.VISIBILITY_CHANGE: 0> __members__: dict # value = {'VISIBILITY_CHANGE': <WindowEventType.VISIBILITY_CHANGE: 0>, 'UPDATE': <WindowEventType.UPDATE: 1>} pass class WindowMainStandalone(Container, Widget): def __init__(self) -> None: ... pass class WindowStandalone(ContainerBase, Widget): """ UI Window. Window is a starting point for every new UI. It contains a :class:`.Container`, which can contain other :class:`.Widget`'s. Args: title (str): The title to be displayed on window title bar. width (int, default=640): Window width in pixels. height (int, default=480): Window height in pixels. open (bool, default=True): Is window opened when created. add_to_menu (bool, default=True): Create main menu item with this window in the Kit. menu_path (str, default=""): Menu path if add_to_menu is True. If empty string is passed it is added under "Extensions" menu item. is_toggle_menu (bool, default=True): Can menu item be toggled? dock (:obj:`omni.ui.DockPreference`, default=LEFT_BOTTOM): Docking preference for a window, see :class:`.DockPreference` flags (:obj:`omni.kit.ui.Window`, default=NONE): flags for a window, see :class:`.Window` """ def __init__(self, title: str, width: int = 640, height: int = 480, open: bool = True, add_to_menu: bool = True, menu_path: str = '', is_toggle_menu: bool = True, dock: DockPreference = DockPreference.LEFT_BOTTOM, flags: int = 0) -> None: ... def hide(self) -> None: ... def is_visible(self) -> bool: ... def set_alpha(self, arg0: float) -> None: ... def set_size(self, arg0: int, arg1: int) -> None: ... def set_update_fn(self, arg0: typing.Callable[[float], None]) -> None: ... def set_visibility_changed_fn(self, arg0: typing.Callable[[bool], None]) -> None: ... def show(self) -> None: ... @property def event_stream(self) -> carb.events._events.IEventStream: """ Event stream with events of type: :class:`.WindowEventType` :type: carb.events._events.IEventStream """ @property def flags(self) -> int: """ :type: int """ @flags.setter def flags(self, arg1: int) -> None: pass @property def height(self) -> int: """ :type: int """ @height.setter def height(self, arg1: int) -> None: pass @property def layout(self) -> Container: """ :type: Container """ @layout.setter def layout(self, arg1: Container) -> None: pass @property def menu(self) -> omni::kit::ui::Menu: """ Window optional menu bar. :type: omni::kit::ui::Menu """ @menu.setter def menu(self, arg0: omni::kit::ui::Menu) -> None: """ Window optional menu bar. """ @property def mouse_pos(self) -> carb._carb.Float2: """ :type: carb._carb.Float2 """ @property def width(self) -> int: """ :type: int """ @width.setter def width(self, arg1: int) -> None: pass pass def activate_menu_item(arg0: str) -> None: pass def get_custom_glyph_code(file_path: str, font_style: omni.ui._ui.FontStyle = FontStyle.NORMAL) -> str: """ Get glyph code. Args: file_path (str): Path to svg file font_style(:class:`.FontStyle`): font style to use. """ def get_editor_menu_legacy() -> Menu: pass def get_main_window(*args, **kwargs) -> typing.Any: pass MODEL_META_SERIALIZED_CONTENTS = 'serializedContents' MODEL_META_WIDGET_TYPE = 'widgetType' WINDOW_FLAGS_FORCE_HORIZONTAL_SCROLLBAR = 512 WINDOW_FLAGS_FORCE_VERTICAL_SCROLLBAR = 256 WINDOW_FLAGS_MODAL = 4096 WINDOW_FLAGS_NONE = 0 WINDOW_FLAGS_NO_CLOSE = 2048 WINDOW_FLAGS_NO_COLLAPSE = 16 WINDOW_FLAGS_NO_FOCUS_ON_APPEARING = 1024 WINDOW_FLAGS_NO_MOVE = 4 WINDOW_FLAGS_NO_RESIZE = 2 WINDOW_FLAGS_NO_SAVED_SETTINGS = 32 WINDOW_FLAGS_NO_SCROLLBAR = 8 WINDOW_FLAGS_NO_TITLE_BAR = 1 WINDOW_FLAGS_SHOW_HORIZONTAL_SCROLLBAR = 128
omniverse-code/kit/exts/omni.kit.renderer.imgui/omni/kit/ui/__init__.py
"""UI Toolkit Starting with the release 2020.1, Omniverse Kit UI Toolkit has been replaced by the alternative UI toolkit :mod:`Omni::UI <omni.ui>`. Currently the Omniverse Kit UI Toolkit is deprecated. Omniverse Kit UI Toolkit is retained mode UI library which enables extending and changing Omniverse Kit look and feel in any direction. It contains fundamental building primitives, like windows, containers, layouts, widgets. As well as additional API (built on top of it) to create widgets for USD attributes and omni.kit settings. Typical example to create a window with a drag slider widget: .. code-block:: import omni.kit.ui window = omni.kit.ui.Window('My Window') d = omni.kit.ui.DragDouble() d.width = omni.kit.ui.Percent(30) window.layout.add_child(d) All objects are python-friendly reference counted object. You don't need to explicitly release or control lifetime. In the code example above `window` will be kept alive until `window` is released. Core: ------ * :class:`.Window` * :class:`.Popup` * :class:`.Container` * :class:`.Value` * :class:`.Length` * :class:`.UnitType` * :class:`.Widget` Widgets: -------- * :class:`.Label` * :class:`.Button` * :class:`.Spacer` * :class:`.CheckBox` * :class:`.ComboBox` * :class:`.ComboBoxInt` * :class:`.ListBox` * :class:`.SliderInt` * :class:`.SliderDouble` * :class:`.DragInt` * :class:`.DragInt2` * :class:`.DragDouble` * :class:`.DragDouble2` * :class:`.DragDouble3` * :class:`.DragDouble4` * :class:`.Transform` * :class:`.FieldInt` * :class:`.FieldDouble` * :class:`.TextBox` * :class:`.ColorRgb` * :class:`.ColorRgba` * :class:`.Image` Containers: ----------- * :class:`.ColumnLayout` * :class:`.RowLayout` * :class:`.RowColumnLayout` * :class:`.CollapsingFrame` * :class:`.ScrollingFrame` """ # This module depends on other modules. VSCode python language server scrapes modules in an isolated environment # (ignoring PYTHONPATH set). import fails and for that we have separate code path to explicitly add it's folder to # sys.path and import again. try: import weakref import carb import carb.dictionary import omni.ui except: import os, sys sys.path.append(os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", ".."))) import weakref import carb import carb.dictionary import omni.ui from ._ui import * from .editor_menu import EditorMenu legacy_mode = False def add_item_attached(self: _ui.Menu, *args, **kwargs): subscription = self.add_item(*args, **kwargs) self.user_data.setdefault("items", []).append(subscription) return subscription def create_window_hook(self, title:str, *args, **kwargs): menu_path = None add_to_menu = True if "menu_path" in kwargs: menu_path = kwargs["menu_path"] kwargs["menu_path"] = "" if "add_to_menu" in kwargs: add_to_menu = kwargs["add_to_menu"] kwargs["add_to_menu"] = False Window.create_window_hook(self, title, *args, **kwargs) if add_to_menu and not menu_path: menu_path = f"Window/{title}" if menu_path: def on_window_click(visible, weak_window): window = weak_window() if window: if visible: window.show() else: window.hide() def on_window_showhide(visible, weak_window): window = weak_window() if window: Menu.static_class.set_value(menu_path, visible) EditorMenu.window_handler[title] = omni.kit.ui.get_editor_menu().add_item(menu_path, on_click=lambda m, v, w=weakref.ref(self): on_window_click(v, w), toggle=True, value=self.is_visible()) self.set_visibility_changed_fn(lambda v, w=weakref.ref(self): on_window_showhide(v, w)) def get_editor_menu(): if legacy_mode: return get_editor_menu_legacy() elif Menu.static_class == None: Menu.static_class = EditorMenu() return Menu.static_class def using_legacy_mode(): carb.log_warn(f"using_legacy_mode: function is depricated as it always return False") return legacy_mode def init_ui(): import carb.settings import carb # Avoid calling code below at documentation building time with try/catch try: settings = carb.settings.get_settings() except RuntimeError: return if not legacy_mode: if hasattr(Window, "create_window_hook"): carb.log_warn(f"init_ui window hook already initialized") else: # hook into omni.kit.ui.window to override menu creation Window.create_window_hook = Window.__init__ Window.__init__ = create_window_hook Menu.static_class = None Menu.add_item_attached = add_item_attached Menu.get_editor_menu = get_editor_menu Menu.using_legacy_mode = using_legacy_mode init_ui()
omniverse-code/kit/exts/omni.kit.renderer.imgui/omni/kit/extensionwindow/__init__.py
from ._extensionwindow import *
omniverse-code/kit/exts/omni.kit.renderer.imgui/omni/kit/ui_windowmanager/__init__.py
from ._window_manager import *
omniverse-code/kit/exts/omni.kit.renderer.imgui/data/regions/japanese_extended.txt
串乍乎乞云亙些什仇仔佃佼侠侭侶俄俣俺倦倶傭僅僑僻儲兇兎兜其冥冨凄凋凧函剃剥劃劉劫勃勾勿匂匙匝匪卜卦卿厨厩厭叉叛叢叩叱吃吊吋吠吻呆 呑呪咋咳咽哨哩唖唾喉喋喧喰嘗嘘嘩噂噌噛噸噺嚢圃坐坤坦垢埜埠埴埼堆堰堵堺塘塙塞填塵壕壬壷夙夷奄套妓妖妬妾姐姑姥姦姪姶娃娩娼婁嫉嬬嬰 孜宋宍宕宛寓寵尖尤尻屍屑屠屡岡岨岱峨峯崖嶋巷巾帖幌幡庇庖庚庵廓廟廠廻廼廿弄弗弛弼彊徽忽怨怯恢恰悉悶惚惹愈慾憐戊戎或戚戟戴托扮拭拶 按挨挫挺挽捉捌捗捧捲捻掠掩掬掴掻揃揖摸摺撒撚撞撫播撰撹擢擾斌斑斡斧斬斯昏昧晒晦曝曳曽曾杓杖杢杭杵杷枇枕柁柏柑柘柴柵柿栂栃栖栢栴桁 桓桔桝桧桶梁梗梯梱梶梼棉棲椀椅椙椛椴楕楚楢楯楳榊榎榔槌槍樋樗樟樫樵樽橡橿檎櫓櫛櫨欝歎此歪殆毘氾汎汝汲沃沌沓沫洛洩浬涌涛涜淀淋淘淫 淵渠湊湘湛溌溜溢溺漉漕漣潅潰澗澱濠濡瀕瀞瀦瀧灘灸灼烏烹焔焚煉煎煤煽熔燈燐燕燭爪爺牌牒牙牝牟牡牢牽犀狐狗狙狛狸狼狽猷獅玩珂珊珪琵琶 瓜瓢瓦甑甜甥畏畠畢畦畷畿疋疏疹痔痕痩癌盃盈瞥矧砥砦砧砺砿硯硲碇碍碓碕碗磐祁祇祢祷禦禰禽禾禿秤稗稽穆穎穐穿窄窟窪窺竃竪竺竿笈笠笥筈 筏筑箆箔箕箪箭箸篇篠篭簸簾籾粁粂粍粕粟粥糊糎糞糟糠紐綬綴綻緬縞繋繍纂纏罫罵羨翫翰而耽聯聾肋肘股肱肴脆脇脊腎腔腫腺腿膏膝膳膿臆臥臼 舘舛舵舷艮芥芦芭芯苅苓苔苛苧苫茨茸荊荏荻莫莱菅菟菩菰菱萄萎萱葎葛葡董葦葱葺蒋蒐蒙蒜蒲蓋蓑蓬蔀蔑蔓蔚蔭蔽蕃蕊蕎蕨蕩蕪薗薙薩薮薯藁藷 蘇虻蚤蛋蛎蛙蛤蛭蛸蛾蜂蜘蜜蝉蝋蝕蝦蝿螺蟹蟻袖袴袷裡裳裾襖覗訊訣註詑詣詫詮誰誹諌諏諜諦諺謂謎謬讃讐豹貌貰貼賂賎賑賭贋赫趨跨蹄蹟蹴躯 輯輿轍轟轡辻辿迂迄迦迩逗這逢逼遁遜遡鄭酋酎醍醐醒醗醤釆釘釜釦釧鈎鈷鉦鉾銚鋒鋤鋪鋲鋸錆錐錨錫鍋鍍鍔鍬鍵鍾鎗鎚鎧鏑鐙鐸鑓閃閏閤闇阜阪 陀隈隙雀雁雫靭鞄鞍鞘鞭韓韮頁頃頓頗頚頬頴顎顛飴餅餌餐饗馳馴駁駈駕騨骸髭魯鮒鮪鮫鮭鯖鯵鰍鰐鰭鰯鰹鰻鱈鱒鱗鳶鴇鴎鴛鴨鴫鴬鵜鵠鵡鷲鷺鹸 麓麹麺黍鼎鼠龍
omniverse-code/kit/exts/omni.kit.renderer.imgui/data/regions/japanese.txt
一丁七万丈三上下不与丑且世丘丙丞両並中丸丹主乃久之乏乗乙九也乱乳乾亀了予争事二互五井亘亜亡交亥亦亨享京亭亮人仁今介仏仕他付仙代令 以仮仰仲件任企伊伍伎伏伐休会伝伯伴伶伸伺似伽但位低住佐佑体何余作佳併使侃例侍侑供依価侮侯侵便係促俊俗保信修俳俵俸倉個倍倒倖候借倣 値倫倭倹偉偏停健偲側偵偶偽傍傑傘備催債傷傾働像僕僚僧儀億儒償優允元兄充兆先光克免児党入全八公六共兵具典兼内円冊再冒冗写冠冬冴冶冷 准凌凍凜凝凡処凪凱凶凸凹出刀刃分切刈刊刑列初判別利到制刷券刺刻則削前剖剛剣剤副剰割創劇力功加劣助努励労効劾勁勅勇勉動勘務勝募勢勤 勧勲勺匁包化北匠匡匹区医匿十千升午半卑卒卓協南単博占卯印危即却卵卸厄厘厚原厳去参又及友双反収叔取受叙叡口古句只叫召可台史右叶号司 各合吉同名后吏吐向君吟否含吸吹吾呂呈呉告周味呼命和咲哀品哉員哲唄唆唇唐唯唱啄商問啓善喚喜喝喪喫喬営嗣嘆嘉嘱器噴嚇囚四回因団困囲図 固国圏園土圧在圭地坂均坊坑坪垂型垣埋城域執培基堀堂堅堕堤堪報場塀塁塊塑塔塗塚塩塾境墓増墜墨墳墾壁壇壊壌士壮声壱売変夏夕外多夜夢大 天太夫央失奇奈奉奎奏契奔奥奨奪奮女奴好如妃妄妊妙妥妨妹妻姉始姓委姫姻姿威娘娠娯婆婚婦婿媒媛嫁嫌嫡嬉嬢子孔字存孝孟季孤学孫宅宇守安 完宏宗官宙定宜宝実客宣室宥宮宰害宴宵家容宿寂寄寅密富寒寛寝察寡寧審寮寸寺対寿封専射将尉尊尋導小少尚尭就尺尼尽尾尿局居屈届屋展属層 履屯山岐岩岬岳岸峠峡峰島峻崇崎崚崩嵐嵩嵯嶺巌川州巡巣工左巧巨差己巳巴巻巽市布帆希帝帥師席帯帰帳常帽幅幕幣干平年幸幹幻幼幽幾庁広庄 床序底店府度座庫庭庶康庸廃廉廊延廷建弁弊式弐弓弔引弘弟弥弦弧弱張強弾当彗形彦彩彪彫彬彰影役彼往征径待律後徐徒従得御復循微徳徴徹心 必忌忍志忘忙応忠快念怒怖怜思怠急性怪恋恐恒恕恥恨恩恭息恵悌悔悟悠患悦悩悪悲悼情惇惑惜惟惣惨惰想愁愉意愚愛感慈態慌慎慕慢慣慧慨慮慰 慶憂憎憤憧憩憲憶憾懇懐懲懸成我戒戦戯戸戻房所扇扉手才打払扱扶批承技抄把抑投抗折抜択披抱抵抹押抽担拍拐拒拓拘拙招拝拠拡括拳拷拾持指 挑挙挟振挿捕捜捨据捷捺掃授掌排掘掛採探接控推措掲描提揚換握揮援揺損搬搭携搾摂摘摩撃撤撮撲擁操擦擬支改攻放政故敏救敗教敢散敦敬数整 敵敷文斉斎斐斗料斜斤斥断新方於施旅旋族旗既日旦旧旨早旬旭旺昂昆昇昌明易昔星映春昨昭是昴昼時晃晋晏晟晨晩普景晴晶智暁暇暉暑暖暗暢暦 暫暮暴曇曙曜曲更書曹替最月有朋服朔朕朗望朝期木未末本札朱朴机朽杉李杏材村杜束条来杯東松板析林枚果枝枠枢枯架柄柊某染柔柚柱柳査柾栄 栓栗栞校株核根格栽桂桃案桐桑桜桟梅梓梢梧梨械棄棋棒棚棟森棺椋植椎検椰椿楊楓楠業極楼楽概榛構様槙槻槽標模権横樹樺橋橘機檀欄欠次欣欧 欲欺欽款歌歓止正武歩歯歳歴死殉殊残殖殴段殺殻殿毅母毎毒比毛毬氏民気水氷永汀汁求汐汗汚江池汰決汽沈沖沙没沢河沸油治沼沿況泉泊泌法泡 波泣泥注泰泳洋洗洞津洪洲洵洸活派流浄浅浜浦浩浪浮浴海浸消涙涯液涼淑淡深淳混添清渇済渉渋渓渚減渡渥渦温測港湖湧湯湾湿満源準溝溶滅滉 滋滑滝滞滴漁漂漆漏演漠漢漫漬漱漸潔潜潟潤潮澄澪激濁濃濫濯瀬火灯灰災炉炊炎炭点為烈無焦然焼煙照煩煮熊熙熟熱燃燎燥燦燿爆爵父爽爾片版 牛牧物牲特犠犬犯状狂狩独狭猛猟猪猫献猶猿獄獣獲玄率玉王玖玲珍珠班現球理琉琢琳琴瑚瑛瑞瑠瑳瑶璃環璽瓶甘甚生産用甫田由甲申男町画界畑 畔留畜畝略番異畳疎疑疫疲疾病症痘痛痢痴療癒癖発登白百的皆皇皐皓皮皿盆益盗盛盟監盤目盲直相盾省眉看県真眠眸眺眼着睡督睦瞬瞭瞳矛矢知 矩短矯石砂研砕砲破硝硫硬碁碑碧碩確磁磨磯礁礎示礼社祈祉祐祖祝神祥票祭禁禄禅禍禎福秀私秋科秒秘租秦秩称移稀程税稔稚稜種稲稼稿穀穂積 穏穣穫穴究空突窃窒窓窮窯立竜章竣童端競竹笑笙笛符第笹筆等筋筒答策箇算管箱節範築篤簡簿籍米粉粋粒粗粘粛粧精糖糧糸系糾紀約紅紋納純紗 紘紙級紛素紡索紫紬累細紳紹紺終絃組経結絞絡絢給統絵絶絹継続綜維綱網綸綺綾綿緊緋総緑緒線締編緩緯練縁縄縛縦縫縮績繁繊織繕繭繰缶罪置 罰署罷羅羊美群義羽翁翌習翔翠翻翼耀老考者耐耕耗耳耶聖聞聡聴職肇肉肌肖肝肢肥肩肪肯育肺胃胆背胎胞胡胤胴胸能脂脅脈脚脩脱脳脹腐腕腰腸 腹膚膜膨臓臣臨自臭至致興舌舎舗舜舞舟航般舶船艇艦良色艶芋芙芝花芳芸芹芽苑苗若苦英茂茄茅茉茎茜茶草荒荘荷莉莞菊菌菓菖菜菫華萌萩落葉 著葬葵蒔蒸蒼蓄蓉蓮蔦蔵蕉蕗薄薦薪薫薬藍藤藩藻蘭虎虐虚虜虞虫虹蚊蚕蛇蛍蛮蝶融血衆行術街衛衝衡衣表衰衷衿袈袋被裁裂装裏裕補裟裸製複褐 褒襟襲西要覆覇見規視覚覧親観角解触言訂計討訓託記訟訪設許訳訴診証詐詔評詞詠詢試詩詰話該詳誇誉誌認誓誕誘語誠誤説読課誼調諄談請諒論 諭諮諸諾謀謁謄謙講謝謡謹識譜警議譲護谷豆豊豚象豪貝貞負財貢貧貨販貫責貯貴買貸費貿賀賃賄資賊賓賛賜賞賠賢賦質購贈赤赦走赳赴起超越趣 足距跡路跳践踊踏躍身車軌軍軒軟転軸軽較載輔輝輩輪輸轄辛辞辰辱農辺込迅迎近返迪迫迭述迷追退送逃逆透逐逓途通逝速造連逮週進逸遂遅遇遊 運遍過道達違遠遣遥適遭遮遵遷選遺遼避還邑那邦邪邸郁郊郎郡部郭郵郷都酉酌配酒酔酢酪酬酵酷酸醇醜醸采釈里重野量金針釣鈍鈴鉄鉛鉢鉱銀銃 銅銑銘銭鋭鋳鋼錘錠錦錬錯録鍛鎌鎖鎮鏡鐘鑑長門閉開閑間関閣閥閲闘防阻阿附降限陛院陣除陥陪陰陳陵陶陸険陽隅隆隊階随隔際障隠隣隷隻隼雄 雅集雇雌雑雛離難雨雪雰雲零雷電需震霊霜霞霧露青靖静非面革靴鞠音韻響頂項順須頌預頑頒領頭頻頼題額顔顕願類顧風颯飛食飢飯飲飼飽飾養餓 館首香馨馬駄駅駆駐駒駿騎騒験騰驚骨髄高髪鬼魁魂魅魔魚鮎鮮鯉鯛鯨鳥鳩鳳鳴鴻鵬鶏鶴鷹鹿麗麟麦麻麿黄黎黒黙黛鼓鼻齢
omniverse-code/kit/exts/omni.graph.tutorials/ogn/nodes.json
{ "nodes": { "omni.graph.tutorials.Empty": { "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.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.SimpleDataPy": { "description": "This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values. It is the same as node omni.graph.tutorials.SimpleData, except it is implemented in Python instead of C++.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.ComplexDataPy": { "description": "This is a tutorial node written in Python. It will compute the point3f array by multiplying each element of the float array by the three element vector in the multiplier.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.AbiPy": { "description": "This tutorial node shows how to override ABI methods on your Python node. The algorithm of the node converts an RGB color into HSV components.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.StatePy": { "description": "This is a tutorial node. It makes use of internal state information to continuously increment an output.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.Defaults": { "description": "This is a tutorial node. It will move the values of inputs to corresponding outputs. Inputs all have unspecified, and therefore empty, default values.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.BundleManipulation": { "description": "This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.BundleManipulationPy": { "description": "This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents. The configuration is the same as omni.graph.tutorials.BundleManipulation except that the implementation language is Python", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.BundleData": { "description": "This is a tutorial node. It exercises functionality for access of data within bundle attributes.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.BundleDataPy": { "description": "This is a tutorial node. It exercises functionality for access of data within bundle attributes. The configuration is the same as omni.graph.tutorials.BundleData except that the implementation language is Python", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.StateAttributesPy": { "description": "This is a tutorial node. It exercises state attributes to remember data from on evaluation to the next.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.State": { "description": "This is a tutorial node. It makes use of internal state information to continuously increment an output.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.ExtendedTypes": { "description": "This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.ExtendedTypesPy": { "description": "This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types. It is identical to OgnTutorialExtendedTypes.ogn, except the language of implementation is selected to be python.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.SimpleData": { "description": "This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.Tokens": { "description": "This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.TokensPy": { "description": "This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.BundleAddAttributes": { "description": "This is a tutorial node. It exercises functionality for adding and removing attributes on output bundles.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.BundleAddAttributesPy": { "description": "This is a Python tutorial node. It exercises functionality for adding and removing attributes on output bundles.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.CpuGpuBundles": { "description": "This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes their dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundlesPy.ogn, except it is implemented in C++.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.CpuGpuBundlesPy": { "description": "This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes the dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundles.ogn, except is is implemented in Python.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.CpuGpuExtended": { "description": "This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtendedPy.ogn, except is is implemented in C++.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.CpuGpuExtendedPy": { "description": "This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtended.ogn, except is is implemented in Python.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.OverrideType": { "description": "This is a tutorial node. It has an input and output of type float[3], an input and output of type double[3], and a type override specification that lets the node use Carbonite types for the generated data on the float[3] attributes only. Ordinarily all of the types would be defined in a seperate configuration file so that it can be shared for a project. In that case the type definition build flag would also be used so that this information does not have to be embedded in every .ogn file in the project. It is placed directly in the file here solely for instructional purposes. The compute is just a rotation of components from x->y, y->z, and z->x, for each input type.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.DynamicAttributes": { "description": "This is a Python node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001).", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.DynamicAttributesPy": { "description": "This is a Python node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001).", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.GenericMathNode": { "description": "This is a tutorial node. It is functionally equivalent to the built-in Multiply node, but written in python as a practical demonstration of using extended attributes to write math nodes that work with any numeric types, including arrays and tuples.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.CudaCpuArrays": { "description": "This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.CudaCpuArraysPy": { "description": "This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device. Both plain attribute and bundle attribute extraction are shown.", "version": 1, "extension": "omni.graph.tutorials", "language": "Python" }, "omni.graph.tutorials.Abi": { "description": "This tutorial node shows how to override ABI methods on your node.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.tutorials.TupleData": { "description": "This is a tutorial node. It creates both an input and output attribute of some of the supported tuple types. The values are modified in a simple way so that the compute can be tested.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.ArrayData": { "description": "This is a tutorial node. It will compute the array 'result' as the input array 'original' with every element multiplied by the constant 'multiplier'.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.TupleArrays": { "description": "This is a tutorial node. It will compute the float array 'result' as the elementwise dot product of the input arrays 'a' and 'b'.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.RoleData": { "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. ", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.CudaData": { "description": "This is a tutorial node. It performs different functions on the GPU to illustrate different types of data access. The first adds inputs 'a' and 'b' to yield output 'sum', all of which are on the GPU. The second is a sample expansion deformation that multiplies every point on a set of input points, stored on the GPU, by a constant value, stored on the CPU, to yield a set of output points, also on the GPU. The third is an assortment of different data types illustrating how different data is passed to the GPU. This particular node uses CUDA for its GPU computations, as indicated in the memory type value. Normal use case for GPU compute is large amounts of data. For testing purposes this node only handles a very small amount but the principle is the same.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" }, "omni.graph.tutorials.CpuGpuData": { "description": "This is a tutorial node. It illustrates how to access data whose memory location, CPU or GPU, is determined at runtime in the compute method. The data types are the same as for the purely CPU and purely GPU tutorials, it is only the access method that changes. The input 'is_gpu' determines where the data of the other attributes can be accessed.", "version": 1, "extension": "omni.graph.tutorials", "language": "C++" } } }
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialSimpleData.rst
.. _omni_graph_tutorials_SimpleData_1: .. _omni_graph_tutorials_SimpleData: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Attributes With Simple Data :keywords: lang-en omnigraph node tutorials threadsafe tutorials simple-data Tutorial Node: Attributes With Simple Data ========================================== .. <description> This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Sample Boolean Input (*inputs:a_bool*)", "``bool``", "This is an attribute of type boolean", "True" "inputs:a_constant_input", "``int``", "This is an input attribute whose value can be set but can only be connected as a source.", "0" "", "*outputOnly*", "1", "" "inputs:a_double", "``double``", "This is an attribute of type 64 bit floating point", "0" "inputs:a_float", "``float``", "This is an attribute of type 32 bit floating point", "0" "Sample Half Precision Input (*inputs:a_half*)", "``half``", "This is an attribute of type 16 bit float", "0.0" "inputs:a_int", "``int``", "This is an attribute of type 32 bit integer", "0" "inputs:a_int64", "``int64``", "This is an attribute of type 64 bit integer", "0" "inputs:a_objectId", "``objectId``", "This is an attribute of type objectId", "0" "inputs:a_path", "``path``", "This is an attribute of type path", "" "inputs:a_string", "``string``", "This is an attribute of type string", "helloString" "inputs:a_token", "``token``", "This is an attribute of type interned string with fast comparison and hashing", "helloToken" "inputs:unsigned:a_uchar", "``uchar``", "This is an attribute of type unsigned 8 bit integer", "0" "inputs:unsigned:a_uint", "``uint``", "This is an attribute of type unsigned 32 bit integer", "0" "inputs:unsigned:a_uint64", "``uint64``", "This is an attribute of type unsigned 64 bit integer", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Sample Boolean Output (*outputs:a_bool*)", "``bool``", "This is a computed attribute of type boolean", "False" "outputs:a_double", "``double``", "This is a computed attribute of type 64 bit floating point", "5.0" "outputs:a_float", "``float``", "This is a computed attribute of type 32 bit floating point", "4.0" "Sample Half Precision Output (*outputs:a_half*)", "``half``", "This is a computed attribute of type 16 bit float", "1.0" "outputs:a_int", "``int``", "This is a computed attribute of type 32 bit integer", "2" "outputs:a_int64", "``int64``", "This is a computed attribute of type 64 bit integer", "3" "outputs:a_objectId", "``objectId``", "This is a computed attribute of type objectId", "8" "outputs:a_path", "``path``", "This is a computed attribute of type path", "/" "outputs:a_string", "``string``", "This is a computed attribute of type string", "seven" "outputs:a_token", "``token``", "This is a computed attribute of type interned string with fast comparison and hashing", "six" "outputs:unsigned:a_uchar", "``uchar``", "This is a computed attribute of type unsigned 8 bit integer", "9" "outputs:unsigned:a_uint", "``uint``", "This is a computed attribute of type unsigned 32 bit integer", "10" "outputs:unsigned:a_uint64", "``uint64``", "This is a computed attribute of type unsigned 64 bit integer", "11" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.SimpleData" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.SimpleData.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Attributes With Simple Data" "Categories", "tutorials" "Generated Class Name", "OgnTutorialSimpleDataDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialDynamicAttributesPy.rst
.. _omni_graph_tutorials_DynamicAttributesPy_1: .. _omni_graph_tutorials_DynamicAttributesPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Dynamic Attributes :keywords: lang-en omnigraph node tutorials tutorials dynamic-attributes-py Tutorial Python Node: Dynamic Attributes ======================================== .. <description> This is a Python node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001). .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:value", "``uint``", "Original value to be modified.", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:result", "``uint``", "Modified value", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.DynamicAttributesPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.DynamicAttributesPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Dynamic Attributes" "__tokens", "{""firstBit"": ""inputs:firstBit"", ""secondBit"": ""inputs:secondBit"", ""invert"": ""inputs:invert""}" "Categories", "tutorials" "Generated Class Name", "OgnTutorialDynamicAttributesPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialTokensPy.rst
.. _omni_graph_tutorials_TokensPy_1: .. _omni_graph_tutorials_TokensPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Tokens :keywords: lang-en omnigraph node tutorials tutorials tokens-py Tutorial Python Node: Tokens ============================ .. <description> This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:valuesToCheck", "``token[]``", "Array of tokens that are to be checked", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:isColor", "``bool[]``", "True values if the corresponding input value appears in the token list", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.TokensPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.TokensPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Tokens" "__tokens", "[""red"", ""green"", ""blue""]" "Categories", "tutorials" "Generated Class Name", "OgnTutorialTokensPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialStatePy.rst
.. _omni_graph_tutorials_StatePy_1: .. _omni_graph_tutorials_StatePy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Internal States :keywords: lang-en omnigraph node tutorials tutorials state-py Tutorial Python Node: Internal States ===================================== .. <description> This is a tutorial node. It makes use of internal state information to continuously increment an output. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:override", "``bool``", "When true get the output from the overrideValue, otherwise use the internal value", "False" "inputs:overrideValue", "``int64``", "Value to use instead of the monotonically increasing internal one when 'override' is true", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:monotonic", "``int64``", "Monotonically increasing output, set by internal state information", "0" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.StatePy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.StatePy.svg" "Has State?", "True" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Internal States" "Categories", "tutorials" "Generated Class Name", "OgnTutorialStatePyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCpuGpuExtendedPy.rst
.. _omni_graph_tutorials_CpuGpuExtendedPy_1: .. _omni_graph_tutorials_CpuGpuExtendedPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: CPU/GPU Extended Attributes :keywords: lang-en omnigraph node tutorials tutorials cpu-gpu-extended-py Tutorial Python Node: CPU/GPU Extended Attributes ================================================= .. <description> This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtended.ogn, except is is implemented in Python. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "CPU Input Attribute (*inputs:cpuData*)", "``any``", "Input attribute whose data always lives on the CPU", "None" "Results To GPU (*inputs:gpu*)", "``bool``", "If true then put the sum on the GPU, otherwise put it on the CPU", "False" "GPU Input Attribute (*inputs:gpuData*)", "``any``", "Input attribute whose data always lives on the GPU", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Sum (*outputs:cpuGpuSum*)", "``any``", "This is the attribute with the selected data. If the 'gpu' attribute is set to true then this attribute's contents will be entirely on the GPU, otherwise it will be on the CPU.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CpuGpuExtendedPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CpuGpuExtendedPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "tags", "tutorial,extended,gpu" "uiName", "Tutorial Python Node: CPU/GPU Extended Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCpuGpuExtendedPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialBundleAddAttributesPy.rst
.. _omni_graph_tutorials_BundleAddAttributesPy_1: .. _omni_graph_tutorials_BundleAddAttributesPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Bundle Add Attributes :keywords: lang-en omnigraph node tutorials tutorials bundle-add-attributes-py Tutorial Python Node: Bundle Add Attributes =========================================== .. <description> This is a Python tutorial node. It exercises functionality for adding and removing attributes on output bundles. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:addedAttributeNames", "``token[]``", "Names for the attribute types to be added. The size of this array must match the size of the 'typesToAdd' array to be legal.", "[]" "inputs:removedAttributeNames", "``token[]``", "Names for the attribute types to be removed. Non-existent attributes will be ignored.", "[]" "Attribute Types To Add (*inputs:typesToAdd*)", "``token[]``", "List of type descriptions to add to the bundle. The strings in this list correspond to the strings that represent the attribute types in the .ogn file (e.g. float[3][], colord[3], bool", "[]" "inputs:useBatchedAPI", "``bool``", "Controls whether or not to used batched APIS for adding/removing attributes", "False" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Constructed Bundle (*outputs:bundle*)", "``bundle``", "This is the bundle with all attributes added by compute.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.BundleAddAttributesPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.BundleAddAttributesPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Bundle Add Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialBundleAddAttributesPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialTupleData.rst
.. _omni_tutorials_TupleData_1: .. _omni_tutorials_TupleData: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Tuple Attributes :keywords: lang-en omnigraph node tutorials threadsafe tutorials tuple-data Tutorial Node: Tuple Attributes =============================== .. <description> This is a tutorial node. It creates both an input and output attribute of some of the supported tuple types. The values are modified in a simple way so that the compute can be tested. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a_double2", "``double[2]``", "This is an attribute with two double values", "[1.1, 2.2]" "inputs:a_double3", "``double[3]``", "This is an attribute with three double values", "[1.1, 2.2, 3.3]" "inputs:a_float2", "``float[2]``", "This is an attribute with two float values", "[4.4, 5.5]" "inputs:a_float3", "``float[3]``", "This is an attribute with three float values", "[6.6, 7.7, 8.8]" "inputs:a_half2", "``half[2]``", "This is an attribute with two 16-bit float values", "[7.0, 8.0]" "inputs:a_int2", "``int[2]``", "This is an attribute with two 32-bit integer values", "[10, 11]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:a_double2", "``double[2]``", "This is a computed attribute with two double values", "None" "outputs:a_double3", "``double[3]``", "This is a computed attribute with three double values", "None" "outputs:a_float2", "``float[2]``", "This is a computed attribute with two float values", "None" "outputs:a_float3", "``float[3]``", "This is a computed attribute with three float values", "None" "outputs:a_half2", "``half[2]``", "This is a computed attribute with two 16-bit float values", "None" "outputs:a_int2", "``int[2]``", "This is a computed attribute with two 32-bit integer values", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.tutorials.TupleData" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.tutorials.TupleData.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Tuple Attributes" "tags", "tuple,tutorial,internal" "Categories", "tutorials" "Generated Class Name", "OgnTutorialTupleDataDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialOverrideType.rst
.. _omni_graph_tutorials_OverrideType_1: .. _omni_graph_tutorials_OverrideType: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Overriding C++ Data Types :keywords: lang-en omnigraph node tutorials threadsafe tutorials override-type Tutorial Node: Overriding C++ Data Types ======================================== .. <description> This is a tutorial node. It has an input and output of type float[3], an input and output of type double[3], and a type override specification that lets the node use Carbonite types for the generated data on the float[3] attributes only. Ordinarily all of the types would be defined in a seperate configuration file so that it can be shared for a project. In that case the type definition build flag would also be used so that this information does not have to be embedded in every .ogn file in the project. It is placed directly in the file here solely for instructional purposes. The compute is just a rotation of components from x->y, y->z, and z->x, for each input type. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Input value with a standard double type (*inputs:data*)", "``double[3]``", "The value to rotate", "[0.0, 0.0, 0.0]" "Input value with a modified float type (*inputs:typedData*)", "``float[3]``", "The value to rotate", "[0.0, 0.0, 0.0]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Output value with a standard double type (*outputs:data*)", "``double[3]``", "The rotated version of inputs::data", "None" "Output value with a modified float type (*outputs:typedData*)", "``float[3]``", "The rotated version of inputs::typedData", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.OverrideType" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.OverrideType.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Overriding C++ Data Types" "Categories", "tutorials" "Generated Class Name", "OgnTutorialOverrideTypeDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialGenericMathNode.rst
.. _omni_graph_tutorials_GenericMathNode_1: .. _omni_graph_tutorials_GenericMathNode: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Generic Math Node :keywords: lang-en omnigraph node tutorials tutorials generic-math-node Tutorial Python Node: Generic Math Node ======================================= .. <description> This is a tutorial node. It is functionally equivalent to the built-in Multiply node, but written in python as a practical demonstration of using extended attributes to write math nodes that work with any numeric types, including arrays and tuples. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "A (*inputs:a*)", "``['colord[3]', 'colord[3][]', 'colord[4]', 'colord[4][]', 'colorf[3]', 'colorf[3][]', 'colorf[4]', 'colorf[4][]', 'colorh[3]', 'colorh[3][]', 'colorh[4]', 'colorh[4][]', 'double', 'double[2]', 'double[2][]', 'double[3]', 'double[3][]', 'double[4]', 'double[4][]', 'double[]', 'float', 'float[2]', 'float[2][]', 'float[3]', 'float[3][]', 'float[4]', 'float[4][]', 'float[]', 'frame[4]', 'frame[4][]', 'half', 'half[2]', 'half[2][]', 'half[3]', 'half[3][]', 'half[4]', 'half[4][]', 'half[]', 'int', 'int64', 'int64[]', 'int[2]', 'int[2][]', 'int[3]', 'int[3][]', 'int[4]', 'int[4][]', 'int[]', 'matrixd[3]', 'matrixd[3][]', 'matrixd[4]', 'matrixd[4][]', 'normald[3]', 'normald[3][]', 'normalf[3]', 'normalf[3][]', 'normalh[3]', 'normalh[3][]', 'pointd[3]', 'pointd[3][]', 'pointf[3]', 'pointf[3][]', 'pointh[3]', 'pointh[3][]', 'quatd[4]', 'quatd[4][]', 'quatf[4]', 'quatf[4][]', 'quath[4]', 'quath[4][]', 'texcoordd[2]', 'texcoordd[2][]', 'texcoordd[3]', 'texcoordd[3][]', 'texcoordf[2]', 'texcoordf[2][]', 'texcoordf[3]', 'texcoordf[3][]', 'texcoordh[2]', 'texcoordh[2][]', 'texcoordh[3]', 'texcoordh[3][]', 'timecode', 'timecode[]', 'transform[4]', 'transform[4][]', 'uchar', 'uchar[]', 'uint', 'uint64', 'uint64[]', 'uint[]', 'vectord[3]', 'vectord[3][]', 'vectorf[3]', 'vectorf[3][]', 'vectorh[3]', 'vectorh[3][]']``", "First number to multiply", "None" "B (*inputs:b*)", "``['colord[3]', 'colord[3][]', 'colord[4]', 'colord[4][]', 'colorf[3]', 'colorf[3][]', 'colorf[4]', 'colorf[4][]', 'colorh[3]', 'colorh[3][]', 'colorh[4]', 'colorh[4][]', 'double', 'double[2]', 'double[2][]', 'double[3]', 'double[3][]', 'double[4]', 'double[4][]', 'double[]', 'float', 'float[2]', 'float[2][]', 'float[3]', 'float[3][]', 'float[4]', 'float[4][]', 'float[]', 'frame[4]', 'frame[4][]', 'half', 'half[2]', 'half[2][]', 'half[3]', 'half[3][]', 'half[4]', 'half[4][]', 'half[]', 'int', 'int64', 'int64[]', 'int[2]', 'int[2][]', 'int[3]', 'int[3][]', 'int[4]', 'int[4][]', 'int[]', 'matrixd[3]', 'matrixd[3][]', 'matrixd[4]', 'matrixd[4][]', 'normald[3]', 'normald[3][]', 'normalf[3]', 'normalf[3][]', 'normalh[3]', 'normalh[3][]', 'pointd[3]', 'pointd[3][]', 'pointf[3]', 'pointf[3][]', 'pointh[3]', 'pointh[3][]', 'quatd[4]', 'quatd[4][]', 'quatf[4]', 'quatf[4][]', 'quath[4]', 'quath[4][]', 'texcoordd[2]', 'texcoordd[2][]', 'texcoordd[3]', 'texcoordd[3][]', 'texcoordf[2]', 'texcoordf[2][]', 'texcoordf[3]', 'texcoordf[3][]', 'texcoordh[2]', 'texcoordh[2][]', 'texcoordh[3]', 'texcoordh[3][]', 'timecode', 'timecode[]', 'transform[4]', 'transform[4][]', 'uchar', 'uchar[]', 'uint', 'uint64', 'uint64[]', 'uint[]', 'vectord[3]', 'vectord[3][]', 'vectorf[3]', 'vectorf[3][]', 'vectorh[3]', 'vectorh[3][]']``", "Second number to multiply", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Product (*outputs:product*)", "``['colord[3]', 'colord[3][]', 'colord[4]', 'colord[4][]', 'colorf[3]', 'colorf[3][]', 'colorf[4]', 'colorf[4][]', 'colorh[3]', 'colorh[3][]', 'colorh[4]', 'colorh[4][]', 'double', 'double[2]', 'double[2][]', 'double[3]', 'double[3][]', 'double[4]', 'double[4][]', 'double[]', 'float', 'float[2]', 'float[2][]', 'float[3]', 'float[3][]', 'float[4]', 'float[4][]', 'float[]', 'frame[4]', 'frame[4][]', 'half', 'half[2]', 'half[2][]', 'half[3]', 'half[3][]', 'half[4]', 'half[4][]', 'half[]', 'int', 'int64', 'int64[]', 'int[2]', 'int[2][]', 'int[3]', 'int[3][]', 'int[4]', 'int[4][]', 'int[]', 'matrixd[3]', 'matrixd[3][]', 'matrixd[4]', 'matrixd[4][]', 'normald[3]', 'normald[3][]', 'normalf[3]', 'normalf[3][]', 'normalh[3]', 'normalh[3][]', 'pointd[3]', 'pointd[3][]', 'pointf[3]', 'pointf[3][]', 'pointh[3]', 'pointh[3][]', 'quatd[4]', 'quatd[4][]', 'quatf[4]', 'quatf[4][]', 'quath[4]', 'quath[4][]', 'texcoordd[2]', 'texcoordd[2][]', 'texcoordd[3]', 'texcoordd[3][]', 'texcoordf[2]', 'texcoordf[2][]', 'texcoordf[3]', 'texcoordf[3][]', 'texcoordh[2]', 'texcoordh[2][]', 'texcoordh[3]', 'texcoordh[3][]', 'timecode', 'timecode[]', 'transform[4]', 'transform[4][]', 'uchar', 'uchar[]', 'uint', 'uint64', 'uint64[]', 'uint[]', 'vectord[3]', 'vectord[3][]', 'vectorf[3]', 'vectorf[3][]', 'vectorh[3]', 'vectorh[3][]']``", "Product of the two numbers", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.GenericMathNode" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.GenericMathNode.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Generic Math Node" "Categories", "tutorials" "Generated Class Name", "OgnTutorialGenericMathNodeDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialSimpleDataPy.rst
.. _omni_graph_tutorials_SimpleDataPy_1: .. _omni_graph_tutorials_SimpleDataPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Attributes With Simple Data :keywords: lang-en omnigraph node tutorials tutorials simple-data-py Tutorial Python Node: Attributes With Simple Data ================================================= .. <description> This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values. It is the same as node omni.graph.tutorials.SimpleData, except it is implemented in Python instead of C++. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Simple Boolean Input (*inputs:a_bool*)", "``bool``", "This is an attribute of type boolean", "True" "inputs:a_constant_input", "``int``", "This is an input attribute whose value can be set but can only be connected as a source.", "0" "", "*outputOnly*", "1", "" "inputs:a_double", "``double``", "This is an attribute of type 64 bit floating point", "0" "inputs:a_float", "``float``", "This is an attribute of type 32 bit floating point", "0" "inputs:a_half", "``half``", "This is an attribute of type 16 bit float", "0.0" "inputs:a_int", "``int``", "This is an attribute of type 32 bit integer", "0" "inputs:a_int64", "``int64``", "This is an attribute of type 64 bit integer", "0" "inputs:a_objectId", "``objectId``", "This is an attribute of type objectId", "0" "inputs:a_path", "``path``", "This is an attribute of type path", "" "inputs:a_string", "``string``", "This is an attribute of type string", "helloString" "inputs:a_token", "``token``", "This is an attribute of type interned string with fast comparison and hashing", "helloToken" "inputs:a_uchar", "``uchar``", "This is an attribute of type unsigned 8 bit integer", "0" "inputs:a_uint", "``uint``", "This is an attribute of type unsigned 32 bit integer", "0" "inputs:a_uint64", "``uint64``", "This is an attribute of type unsigned 64 bit integer", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:a_a_boolUiName", "``string``", "Computed attribute containing the UI name of input a_bool", "None" "outputs:a_bool", "``bool``", "This is a computed attribute of type boolean", "None" "outputs:a_double", "``double``", "This is a computed attribute of type 64 bit floating point", "None" "outputs:a_float", "``float``", "This is a computed attribute of type 32 bit floating point", "None" "outputs:a_half", "``half``", "This is a computed attribute of type 16 bit float", "None" "outputs:a_int", "``int``", "This is a computed attribute of type 32 bit integer", "None" "outputs:a_int64", "``int64``", "This is a computed attribute of type 64 bit integer", "None" "outputs:a_nodeTypeUiName", "``string``", "Computed attribute containing the UI name of this node type", "None" "outputs:a_objectId", "``objectId``", "This is a computed attribute of type objectId", "None" "outputs:a_path", "``path``", "This is a computed attribute of type path", "/Child" "outputs:a_string", "``string``", "This is a computed attribute of type string", "This string is empty" "outputs:a_token", "``token``", "This is a computed attribute of type interned string with fast comparison and hashing", "None" "outputs:a_uchar", "``uchar``", "This is a computed attribute of type unsigned 8 bit integer", "None" "outputs:a_uint", "``uint``", "This is a computed attribute of type unsigned 32 bit integer", "None" "outputs:a_uint64", "``uint64``", "This is a computed attribute of type unsigned 64 bit integer", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.SimpleDataPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.SimpleDataPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Attributes With Simple Data" "__iconColor", "#FF00FF00" "__iconBackgroundColor", "#7FFF0000" "__iconBorderColor", "#FF0000FF" "Categories", "tutorials" "Generated Class Name", "OgnTutorialSimpleDataPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialSIMDAdd.rst
.. _omni_graph_tutorials_TutorialSIMDFloatAdd_1: .. _omni_graph_tutorials_TutorialSIMDFloatAdd: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: SIMD Add :keywords: lang-en omnigraph node tutorials tutorials tutorial-s-i-m-d-float-add Tutorial Node: SIMD Add ======================= .. <description> Add 2 floats together using SIMD instruction set .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a", "``float``", "first input operand", "0.0" "inputs:b", "``float``", "second input operand", "0.0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:result", "``float``", "the sum of a and b", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.TutorialSIMDFloatAdd" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.TutorialSIMDFloatAdd.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: SIMD Add" "Categories", "tutorials" "Generated Class Name", "OgnTutorialSIMDAddDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialTokens.rst
.. _omni_graph_tutorials_Tokens_1: .. _omni_graph_tutorials_Tokens: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Tokens :keywords: lang-en omnigraph node tutorials threadsafe tutorials tokens Tutorial Node: Tokens ===================== .. <description> This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:valuesToCheck", "``token[]``", "Array of tokens that are to be checked", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:isColor", "``bool[]``", "True values if the corresponding input value appears in the token list", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.Tokens" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.Tokens.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Tokens" "__tokens", "[""red"", ""green"", ""blue""]" "Categories", "tutorials" "Generated Class Name", "OgnTutorialTokensDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCpuGpuData.rst
.. _omni_graph_tutorials_CpuGpuData_1: .. _omni_graph_tutorials_CpuGpuData: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Attributes With CPU/GPU Data :keywords: lang-en omnigraph node tutorials tutorials cpu-gpu-data Tutorial Node: Attributes With CPU/GPU Data =========================================== .. <description> This is a tutorial node. It illustrates how to access data whose memory location, CPU or GPU, is determined at runtime in the compute method. The data types are the same as for the purely CPU and purely GPU tutorials, it is only the access method that changes. The input 'is_gpu' determines where the data of the other attributes can be accessed. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a", "``float``", "First value to be added in algorithm 1", "0.0" "inputs:b", "``float``", "Second value to be added in algorithm 1", "0.0" "inputs:is_gpu", "``bool``", "Runtime switch determining where the data for the other attributes lives.", "False" "inputs:multiplier", "``float[3]``", "Amplitude of the expansion for the input points in algorithm 2", "[1.0, 1.0, 1.0]" "inputs:points", "``float[3][]``", "Points to be moved by algorithm 2", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:points", "``float[3][]``", "Final positions of points from algorithm 2", "None" "outputs:sum", "``float``", "Sum of the two inputs from algorithm 1", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CpuGpuData" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CpuGpuData.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "any" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Attributes With CPU/GPU Data" "__memoryType", "any" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCpuGpuDataDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialExtendedTypesPy.rst
.. _omni_graph_tutorials_ExtendedTypesPy_1: .. _omni_graph_tutorials_ExtendedTypesPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Extended Attribute Types :keywords: lang-en omnigraph node tutorials tutorials extended-types-py Tutorial Python Node: Extended Attribute Types ============================================== .. <description> This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types. It is identical to OgnTutorialExtendedTypes.ogn, except the language of implementation is selected to be python. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Flexible Values (*inputs:flexible*)", "``['float[3][]', 'token']``", "Flexible data type input", "None" "Float Or Token (*inputs:floatOrToken*)", "``['float', 'token']``", "Attribute that can either be a float value or a token value", "None" "To Negate (*inputs:toNegate*)", "``['bool[]', 'float[]']``", "Attribute that can either be an array of booleans or an array of floats", "None" "Tuple Values (*inputs:tuple*)", "``any``", "Variable size/type tuple values", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Doubled Input Value (*outputs:doubledResult*)", "``any``", "If the input 'floatOrToken' is a float this is 2x the value. If it is a token this contains the input token repeated twice.", "None" "Inverted Flexible Values (*outputs:flexible*)", "``['float[3][]', 'token']``", "Flexible data type output", "None" "Negated Array Values (*outputs:negatedResult*)", "``['bool[]', 'float[]']``", "Result of negating the data from the 'toNegate' input", "None" "Negative Tuple Values (*outputs:tuple*)", "``any``", "Negated values of the tuple input", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.ExtendedTypesPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.ExtendedTypesPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Extended Attribute Types" "Categories", "tutorials" "Generated Class Name", "OgnTutorialExtendedTypesPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialStateAttributesPy.rst
.. _omni_graph_tutorials_StateAttributesPy_1: .. _omni_graph_tutorials_StateAttributesPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: State Attributes :keywords: lang-en omnigraph node tutorials tutorials state-attributes-py Tutorial Python Node: State Attributes ====================================== .. <description> This is a tutorial node. It exercises state attributes to remember data from on evaluation to the next. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:ignored", "``bool``", "Ignore me", "False" State ----- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "state:monotonic", "``int``", "The monotonically increasing output value, reset to 0 when the reset value is true", "None" "state:reset", "``bool``", "If true then the inputs are ignored and outputs are set to default values, then this flag is set to false for subsequent evaluations.", "True" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.StateAttributesPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.StateAttributesPy.svg" "Has State?", "True" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: State Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialStateAttributesPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialDefaults.rst
.. _omni_graph_tutorials_Defaults_1: .. _omni_graph_tutorials_Defaults: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Defaults :keywords: lang-en omnigraph node tutorials threadsafe tutorials defaults Tutorial Node: Defaults ======================= .. <description> This is a tutorial node. It will move the values of inputs to corresponding outputs. Inputs all have unspecified, and therefore empty, default values. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a_array", "``float[]``", "This is an attribute of type array of floats", "[]" "inputs:a_bool", "``bool``", "This is an attribute of type boolean", "False" "inputs:a_double", "``double``", "This is an attribute of type 64 bit floating point", "0.0" "inputs:a_float", "``float``", "This is an attribute of type 32 bit floating point", "0.0" "inputs:a_half", "``half``", "This is an attribute of type 16 bit floating point", "0.0" "inputs:a_int", "``int``", "This is an attribute of type 32 bit integer", "0" "inputs:a_int2", "``int[2]``", "This is an attribute of type 2-tuple of integers", "[0, 0]" "inputs:a_int64", "``int64``", "This is an attribute of type 64 bit integer", "0" "inputs:a_matrix", "``matrixd[2]``", "This is an attribute of type 2x2 matrix", "[[1.0, 0.0], [0.0, 1.0]]" "inputs:a_string", "``string``", "This is an attribute of type string", "" "inputs:a_token", "``token``", "This is an attribute of type interned string with fast comparison and hashing", "" "inputs:a_uchar", "``uchar``", "This is an attribute of type unsigned 8 bit integer", "0" "inputs:a_uint", "``uint``", "This is an attribute of type unsigned 32 bit integer", "0" "inputs:a_uint64", "``uint64``", "This is an attribute of type unsigned 64 bit integer", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:a_array", "``float[]``", "This is a computed attribute of type array of floats", "None" "outputs:a_bool", "``bool``", "This is a computed attribute of type boolean", "None" "outputs:a_double", "``double``", "This is a computed attribute of type 64 bit floating point", "None" "outputs:a_float", "``float``", "This is a computed attribute of type 32 bit floating point", "None" "outputs:a_half", "``half``", "This is a computed attribute of type 16 bit floating point", "None" "outputs:a_int", "``int``", "This is a computed attribute of type 32 bit integer", "None" "outputs:a_int2", "``int[2]``", "This is a computed attribute of type 2-tuple of integers", "None" "outputs:a_int64", "``int64``", "This is a computed attribute of type 64 bit integer", "None" "outputs:a_matrix", "``matrixd[2]``", "This is a computed attribute of type 2x2 matrix", "None" "outputs:a_string", "``string``", "This is a computed attribute of type string", "None" "outputs:a_token", "``token``", "This is a computed attribute of type interned string with fast comparison and hashing", "None" "outputs:a_uchar", "``uchar``", "This is a computed attribute of type unsigned 8 bit integer", "None" "outputs:a_uint", "``uint``", "This is a computed attribute of type unsigned 32 bit integer", "None" "outputs:a_uint64", "``uint64``", "This is a computed attribute of type unsigned 64 bit integer", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.Defaults" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.Defaults.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Defaults" "Categories", "tutorials" "Generated Class Name", "OgnTutorialDefaultsDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCudaData.rst
.. _omni_graph_tutorials_CudaData_1: .. _omni_graph_tutorials_CudaData: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Attributes With CUDA Data :keywords: lang-en omnigraph node tutorials threadsafe tutorials cuda-data Tutorial Node: Attributes With CUDA Data ======================================== .. <description> This is a tutorial node. It performs different functions on the GPU to illustrate different types of data access. The first adds inputs 'a' and 'b' to yield output 'sum', all of which are on the GPU. The second is a sample expansion deformation that multiplies every point on a set of input points, stored on the GPU, by a constant value, stored on the CPU, to yield a set of output points, also on the GPU. The third is an assortment of different data types illustrating how different data is passed to the GPU. This particular node uses CUDA for its GPU computations, as indicated in the memory type value. Normal use case for GPU compute is large amounts of data. For testing purposes this node only handles a very small amount but the principle is the same. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a", "``float``", "First value to be added in algorithm 1", "0.0" "inputs:b", "``float``", "Second value to be added in algorithm 1", "0.0" "inputs:color", "``colord[3]``", "Input with three doubles as a color for algorithm 3", "[1.0, 0.5, 1.0]" "inputs:half", "``half``", "Input of type half for algorithm 3", "1.0" "inputs:matrix", "``matrixd[4]``", "Input with 16 doubles interpreted as a double-precision 4d matrix", "[[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]]" "inputs:multiplier", "``float[3]``", "Amplitude of the expansion for the input points in algorithm 2", "[1.0, 1.0, 1.0]" "inputs:points", "``float[3][]``", "Points to be moved by algorithm 2", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:color", "``colord[3]``", "Output with three doubles as a color for algorithm 3", "None" "outputs:half", "``half``", "Output of type half for algorithm 3", "None" "outputs:matrix", "``matrixd[4]``", "Output with 16 doubles interpreted as a double-precision 4d matrix", "None" "outputs:points", "``float[3][]``", "Final positions of points from algorithm 2", "None" "outputs:sum", "``float``", "Sum of the two inputs from algorithm 1", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CudaData" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CudaData.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cuda" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Attributes With CUDA Data" "__memoryType", "cuda" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCudaDataDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCudaDataCpuPy.rst
.. _omni_graph_tutorials_CudaCpuArraysPy_1: .. _omni_graph_tutorials_CudaCpuArraysPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Python Tutorial Node: Attributes With CUDA Array Pointers In Cpu Memory :keywords: lang-en omnigraph node tutorials tutorials cuda-cpu-arrays-py Python Tutorial Node: Attributes With CUDA Array Pointers In Cpu Memory ======================================================================= .. <description> This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device. Both plain attribute and bundle attribute extraction are shown. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:multiplier", "``float[3]``", "Amplitude of the expansion for the input points", "[1.0, 1.0, 1.0]" "inputs:points", "``float[3][]``", "Array of points to be moved", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:outBundle", "``bundle``", "Bundle containing a copy of the output points", "None" "outputs:points", "``float[3][]``", "Final positions of points", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CudaCpuArraysPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CudaCpuArraysPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cuda" "Generated Code Exclusions", "None" "__memoryType", "cuda" "uiName", "Python Tutorial Node: Attributes With CUDA Array Pointers In Cpu Memory" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCudaDataCpuPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialBundleDataPy.rst
.. _omni_graph_tutorials_BundleDataPy_1: .. _omni_graph_tutorials_BundleDataPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Bundle Data :keywords: lang-en omnigraph node tutorials tutorials bundle-data-py Tutorial Python Node: Bundle Data ================================= .. <description> This is a tutorial node. It exercises functionality for access of data within bundle attributes. The configuration is the same as omni.graph.tutorials.BundleData except that the implementation language is Python .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Input Bundle (*inputs:bundle*)", "``bundle``", "Bundle whose contents are modified for passing to the output", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Output Bundle (*outputs:bundle*)", "``bundle``", "This is the bundle with values of known types doubled.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.BundleDataPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.BundleDataPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Bundle Data" "Categories", "tutorials" "Generated Class Name", "OgnTutorialBundleDataPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialRoleData.rst
.. _omni_graph_tutorials_RoleData_1: .. _omni_graph_tutorials_RoleData: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Role-Based Attributes :keywords: lang-en omnigraph node tutorials threadsafe tutorials role-data Tutorial Node: Role-Based Attributes ==================================== .. <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. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a_color3d", "``colord[3]``", "This is an attribute interpreted as a double-precision 3d color", "[0.0, 0.0, 0.0]" "inputs:a_color3f", "``colorf[3]``", "This is an attribute interpreted as a single-precision 3d color", "[0.0, 0.0, 0.0]" "inputs:a_color3h", "``colorh[3]``", "This is an attribute interpreted as a half-precision 3d color", "[0.0, 0.0, 0.0]" "inputs:a_color4d", "``colord[4]``", "This is an attribute interpreted as a double-precision 4d color", "[0.0, 0.0, 0.0, 0.0]" "inputs:a_color4f", "``colorf[4]``", "This is an attribute interpreted as a single-precision 4d color", "[0.0, 0.0, 0.0, 0.0]" "inputs:a_color4h", "``colorh[4]``", "This is an attribute interpreted as a half-precision 4d color", "[0.0, 0.0, 0.0, 0.0]" "inputs:a_frame", "``frame[4]``", "This is an attribute interpreted as a coordinate frame", "[[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]]" "inputs:a_matrix2d", "``matrixd[2]``", "This is an attribute interpreted as a double-precision 2d matrix", "[[1.0, 0.0], [0.0, 1.0]]" "inputs:a_matrix3d", "``matrixd[3]``", "This is an attribute interpreted as a double-precision 3d matrix", "[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]" "inputs:a_matrix4d", "``matrixd[4]``", "This is an attribute interpreted as a double-precision 4d matrix", "[[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]]" "inputs:a_normal3d", "``normald[3]``", "This is an attribute interpreted as a double-precision 3d normal", "[0.0, 0.0, 0.0]" "inputs:a_normal3f", "``normalf[3]``", "This is an attribute interpreted as a single-precision 3d normal", "[0.0, 0.0, 0.0]" "inputs:a_normal3h", "``normalh[3]``", "This is an attribute interpreted as a half-precision 3d normal", "[0.0, 0.0, 0.0]" "inputs:a_point3d", "``pointd[3]``", "This is an attribute interpreted as a double-precision 3d point", "[0.0, 0.0, 0.0]" "inputs:a_point3f", "``pointf[3]``", "This is an attribute interpreted as a single-precision 3d point", "[0.0, 0.0, 0.0]" "inputs:a_point3h", "``pointh[3]``", "This is an attribute interpreted as a half-precision 3d point", "[0.0, 0.0, 0.0]" "inputs:a_quatd", "``quatd[4]``", "This is an attribute interpreted as a double-precision 4d quaternion", "[0.0, 0.0, 0.0, 0.0]" "inputs:a_quatf", "``quatf[4]``", "This is an attribute interpreted as a single-precision 4d quaternion", "[0.0, 0.0, 0.0, 0.0]" "inputs:a_quath", "``quath[4]``", "This is an attribute interpreted as a half-precision 4d quaternion", "[0.0, 0.0, 0.0, 0.0]" "inputs:a_texcoord2d", "``texcoordd[2]``", "This is an attribute interpreted as a double-precision 2d texcoord", "[0.0, 0.0]" "inputs:a_texcoord2f", "``texcoordf[2]``", "This is an attribute interpreted as a single-precision 2d texcoord", "[0.0, 0.0]" "inputs:a_texcoord2h", "``texcoordh[2]``", "This is an attribute interpreted as a half-precision 2d texcoord", "[0.0, 0.0]" "inputs:a_texcoord3d", "``texcoordd[3]``", "This is an attribute interpreted as a double-precision 3d texcoord", "[0.0, 0.0, 0.0]" "inputs:a_texcoord3f", "``texcoordf[3]``", "This is an attribute interpreted as a single-precision 3d texcoord", "[0.0, 0.0, 0.0]" "inputs:a_texcoord3h", "``texcoordh[3]``", "This is an attribute interpreted as a half-precision 3d texcoord", "[0.0, 0.0, 0.0]" "inputs:a_timecode", "``timecode``", "This is a computed attribute interpreted as a timecode", "1.0" "inputs:a_vector3d", "``vectord[3]``", "This is an attribute interpreted as a double-precision 3d vector", "[0.0, 0.0, 0.0]" "inputs:a_vector3f", "``vectorf[3]``", "This is an attribute interpreted as a single-precision 3d vector", "[0.0, 0.0, 0.0]" "inputs:a_vector3h", "``vectorh[3]``", "This is an attribute interpreted as a half-precision 3d vector", "[0.0, 0.0, 0.0]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:a_color3d", "``colord[3]``", "This is a computed attribute interpreted as a double-precision 3d color", "None" "outputs:a_color3f", "``colorf[3]``", "This is a computed attribute interpreted as a single-precision 3d color", "None" "outputs:a_color3h", "``colorh[3]``", "This is a computed attribute interpreted as a half-precision 3d color", "None" "outputs:a_color4d", "``colord[4]``", "This is a computed attribute interpreted as a double-precision 4d color", "None" "outputs:a_color4f", "``colorf[4]``", "This is a computed attribute interpreted as a single-precision 4d color", "None" "outputs:a_color4h", "``colorh[4]``", "This is a computed attribute interpreted as a half-precision 4d color", "None" "outputs:a_frame", "``frame[4]``", "This is a computed attribute interpreted as a coordinate frame", "None" "outputs:a_matrix2d", "``matrixd[2]``", "This is a computed attribute interpreted as a double-precision 2d matrix", "None" "outputs:a_matrix3d", "``matrixd[3]``", "This is a computed attribute interpreted as a double-precision 3d matrix", "None" "outputs:a_matrix4d", "``matrixd[4]``", "This is a computed attribute interpreted as a double-precision 4d matrix", "None" "outputs:a_normal3d", "``normald[3]``", "This is a computed attribute interpreted as a double-precision 3d normal", "None" "outputs:a_normal3f", "``normalf[3]``", "This is a computed attribute interpreted as a single-precision 3d normal", "None" "outputs:a_normal3h", "``normalh[3]``", "This is a computed attribute interpreted as a half-precision 3d normal", "None" "outputs:a_point3d", "``pointd[3]``", "This is a computed attribute interpreted as a double-precision 3d point", "None" "outputs:a_point3f", "``pointf[3]``", "This is a computed attribute interpreted as a single-precision 3d point", "None" "outputs:a_point3h", "``pointh[3]``", "This is a computed attribute interpreted as a half-precision 3d point", "None" "outputs:a_quatd", "``quatd[4]``", "This is a computed attribute interpreted as a double-precision 4d quaternion", "None" "outputs:a_quatf", "``quatf[4]``", "This is a computed attribute interpreted as a single-precision 4d quaternion", "None" "outputs:a_quath", "``quath[4]``", "This is a computed attribute interpreted as a half-precision 4d quaternion", "None" "outputs:a_texcoord2d", "``texcoordd[2]``", "This is a computed attribute interpreted as a double-precision 2d texcoord", "None" "outputs:a_texcoord2f", "``texcoordf[2]``", "This is a computed attribute interpreted as a single-precision 2d texcoord", "None" "outputs:a_texcoord2h", "``texcoordh[2]``", "This is a computed attribute interpreted as a half-precision 2d texcoord", "None" "outputs:a_texcoord3d", "``texcoordd[3]``", "This is a computed attribute interpreted as a double-precision 3d texcoord", "None" "outputs:a_texcoord3f", "``texcoordf[3]``", "This is a computed attribute interpreted as a single-precision 3d texcoord", "None" "outputs:a_texcoord3h", "``texcoordh[3]``", "This is a computed attribute interpreted as a half-precision 3d texcoord", "None" "outputs:a_timecode", "``timecode``", "This is a computed attribute interpreted as a timecode", "None" "outputs:a_vector3d", "``vectord[3]``", "This is a computed attribute interpreted as a double-precision 3d vector", "None" "outputs:a_vector3f", "``vectorf[3]``", "This is a computed attribute interpreted as a single-precision 3d vector", "None" "outputs:a_vector3h", "``vectorh[3]``", "This is a computed attribute interpreted as a half-precision 3d vector", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.RoleData" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.RoleData.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Role-Based Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialRoleDataDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialDynamicAttributes.rst
.. _omni_graph_tutorials_DynamicAttributes_1: .. _omni_graph_tutorials_DynamicAttributes: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Dynamic Attributes :keywords: lang-en omnigraph node tutorials threadsafe tutorials dynamic-attributes Tutorial Node: Dynamic Attributes ================================= .. <description> This is a C++ node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001). .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:value", "``uint``", "Original value to be modified.", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:result", "``uint``", "Modified value", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.DynamicAttributes" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.DynamicAttributes.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Dynamic Attributes" "__tokens", "{""firstBit"": ""inputs:firstBit"", ""secondBit"": ""inputs:secondBit"", ""invert"": ""inputs:invert""}" "Categories", "tutorials" "Generated Class Name", "OgnTutorialDynamicAttributesDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialVectorizedABIPassthrough.rst
.. _omni_graph_tutorials_TutorialVectorizedABIPassThrough_1: .. _omni_graph_tutorials_TutorialVectorizedABIPassThrough: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Vectorized Passthrough via ABI :keywords: lang-en omnigraph node tutorials tutorials tutorial-vectorized-a-b-i-pass-through Tutorial Node: Vectorized Passthrough via ABI ============================================= .. <description> Simple passthrough node that copy its input to its output in a vectorized way .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:value", "``float``", "input value", "0.0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:value", "``float``", "output value", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.TutorialVectorizedABIPassThrough" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.TutorialVectorizedABIPassThrough.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Vectorized Passthrough via ABI" "Categories", "tutorials" "Generated Class Name", "OgnTutorialVectorizedABIPassthroughDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialVectorizedPassthrough.rst
.. _omni_graph_tutorials_TutorialVectorizedPassThrough_1: .. _omni_graph_tutorials_TutorialVectorizedPassThrough: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Vectorized Passthrough :keywords: lang-en omnigraph node tutorials tutorials tutorial-vectorized-pass-through Tutorial Node: Vectorized Passthrough ===================================== .. <description> Simple passthrough node that copy its input to its output in a vectorized way .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:value", "``float``", "input value", "0.0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:value", "``float``", "output value", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.TutorialVectorizedPassThrough" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.TutorialVectorizedPassThrough.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Vectorized Passthrough" "Categories", "tutorials" "Generated Class Name", "OgnTutorialVectorizedPassthroughDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialComplexDataPy.rst
.. _omni_graph_tutorials_ComplexDataPy_1: .. _omni_graph_tutorials_ComplexDataPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Attributes With Arrays of Tuples :keywords: lang-en omnigraph node tutorials tutorials complex-data-py Tutorial Python Node: Attributes With Arrays of Tuples ====================================================== .. <description> This is a tutorial node written in Python. It will compute the point3f array by multiplying each element of the float array by the three element vector in the multiplier. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a_inputArray", "``float[]``", "Input array", "[]" "inputs:a_vectorMultiplier", "``float[3]``", "Vector multiplier", "[1.0, 2.0, 3.0]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:a_productArray", "``pointf[3][]``", "Output array", "[]" "outputs:a_tokenArray", "``token[]``", "String representations of the input array", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.ComplexDataPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.ComplexDataPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Attributes With Arrays of Tuples" "Categories", "tutorials" "Generated Class Name", "OgnTutorialComplexDataPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCpuGpuExtended.rst
.. _omni_graph_tutorials_CpuGpuExtended_1: .. _omni_graph_tutorials_CpuGpuExtended: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: CPU/GPU Extended Attributes :keywords: lang-en omnigraph node tutorials tutorials cpu-gpu-extended Tutorial Node: CPU/GPU Extended Attributes ========================================== .. <description> This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtendedPy.ogn, except is is implemented in C++. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "CPU Input Attribute (*inputs:cpuData*)", "``any``", "Input attribute whose data always lives on the CPU", "None" "Results To GPU (*inputs:gpu*)", "``bool``", "If true then put the sum on the GPU, otherwise put it on the CPU", "False" "GPU Input Attribute (*inputs:gpuData*)", "``any``", "Input attribute whose data always lives on the GPU", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Sum (*outputs:cpuGpuSum*)", "``any``", "This is the attribute with the selected data. If the 'gpu' attribute is set to true then this attribute's contents will be entirely on the GPU, otherwise it will be on the CPU.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CpuGpuExtended" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CpuGpuExtended.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "tags", "tutorial,extended,gpu" "uiName", "Tutorial Node: CPU/GPU Extended Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCpuGpuExtendedDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialBundles.rst
.. _omni_graph_tutorials_BundleManipulation_1: .. _omni_graph_tutorials_BundleManipulation: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Bundle Manipulation :keywords: lang-en omnigraph node tutorials tutorials bundle-manipulation Tutorial Node: Bundle Manipulation ================================== .. <description> This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Filtered Bundle (*inputs:filteredBundle*)", "``bundle``", "Bundle whose contents are filtered before being added to the output", "None" "inputs:filters", "``token[]``", "List of filter names to be applied to the filteredBundle. Any filter name appearing in this list will be applied to members of that bundle and only those passing all filters will be added to the output bundle. Legal filter values are 'big' (arrays of size > 10), 'x' (attributes whose name contains the letter x), and 'int' (attributes whose base type is integer).", "[]" "Full Bundle (*inputs:fullBundle*)", "``bundle``", "Bundle whose contents are passed to the output in their entirety", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:combinedBundle", "``bundle``", "This is the union of fullBundle and filtered members of the filteredBundle.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.BundleManipulation" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.BundleManipulation.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Bundle Manipulation" "Categories", "tutorials" "Generated Class Name", "OgnTutorialBundlesDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialTupleArrays.rst
.. _omni_graph_tutorials_TupleArrays_1: .. _omni_graph_tutorials_TupleArrays: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Attributes With Arrays of Tuples :keywords: lang-en omnigraph node tutorials threadsafe tutorials tuple-arrays Tutorial Node: Attributes With Arrays of Tuples =============================================== .. <description> This is a tutorial node. It will compute the float array 'result' as the elementwise dot product of the input arrays 'a' and 'b'. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:a", "``float[3][]``", "First array", "[]" "inputs:b", "``float[3][]``", "Second array", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:result", "``float[]``", "Dot-product array", "[]" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.TupleArrays" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.TupleArrays.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Attributes With Arrays of Tuples" "Categories", "tutorials" "Generated Class Name", "OgnTutorialTupleArraysDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialBundleData.rst
.. _omni_graph_tutorials_BundleData_1: .. _omni_graph_tutorials_BundleData: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Bundle Data :keywords: lang-en omnigraph node tutorials tutorials bundle-data Tutorial Node: Bundle Data ========================== .. <description> This is a tutorial node. It exercises functionality for access of data within bundle attributes. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Input Bundle (*inputs:bundle*)", "``bundle``", "Bundle whose contents are modified for passing to the output", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:bundle", "``bundle``", "This is the bundle with values of known types doubled.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.BundleData" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.BundleData.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Bundle Data" "Categories", "tutorials" "Generated Class Name", "OgnTutorialBundleDataDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialState.rst
.. _omni_graph_tutorials_State_1: .. _omni_graph_tutorials_State: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Internal States :keywords: lang-en omnigraph node tutorials threadsafe tutorials state Tutorial Node: Internal States ============================== .. <description> This is a tutorial node. It makes use of internal state information to continuously increment an output. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Enable Override (*inputs:override*)", "``bool``", "When true get the output from the overrideValue, otherwise use the internal value", "False" "Override Value (*inputs:overrideValue*)", "``int64``", "Value to use instead of the monotonically increasing internal one when 'override' is true", "0" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "State-Based Output (*outputs:monotonic*)", "``int64``", "Monotonically increasing output, set by internal state information", "0" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.State" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.State.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Internal States" "Categories", "tutorials" "Generated Class Name", "OgnTutorialStateDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialArrayData.rst
.. _omni_graph_tutorials_ArrayData_1: .. _omni_graph_tutorials_ArrayData: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Array Attributes :keywords: lang-en omnigraph node tutorials threadsafe tutorials array-data Tutorial Node: Array Attributes =============================== .. <description> This is a tutorial node. It will compute the array 'result' as the input array 'original' with every element multiplied by the constant 'multiplier'. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:gates", "``bool[]``", "Boolean mask telling which elements of the array should be multiplied", "[]" "inputs:info", "``token[]``", "List of strings providing commentary", "['There', 'is', 'no', 'data']" "inputs:multiplier", "``float``", "Multiplier of the array elements", "1.0" "inputs:original", "``float[]``", "Array to be multiplied", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:infoSize", "``int``", "Number of letters in all strings in the info input", "None" "outputs:negativeValues", "``bool[]``", "Array of booleans set to true if the corresponding 'result' is negative", "None" "outputs:result", "``float[]``", "Multiplied array", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.ArrayData" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.ArrayData.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Array Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialArrayDataDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCpuGpuBundles.rst
.. _omni_graph_tutorials_CpuGpuBundles_1: .. _omni_graph_tutorials_CpuGpuBundles: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: CPU/GPU Bundles :keywords: lang-en omnigraph node tutorials tutorials cpu-gpu-bundles Tutorial Node: CPU/GPU Bundles ============================== .. <description> This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes their dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundlesPy.ogn, except it is implemented in C++. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "CPU Input Bundle (*inputs:cpuBundle*)", "``bundle``", "Input bundle whose data always lives on the CPU", "None" "Results To GPU (*inputs:gpu*)", "``bool``", "If true then copy gpuBundle onto the output, otherwise copy cpuBundle", "False" "GPU Input Bundle (*inputs:gpuBundle*)", "``bundle``", "Input bundle whose data always lives on the GPU", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Constructed Bundle (*outputs:cpuGpuBundle*)", "``bundle``", "This is the bundle with the merged data. If the 'gpu' attribute is set to true then this bundle's contents will be entirely on the GPU, otherwise they will be on the CPU.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CpuGpuBundles" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CpuGpuBundles.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "tags", "tutorial,bundle,gpu" "uiName", "Tutorial Node: CPU/GPU Bundles" "__tokens", "[""points"", ""dotProducts""]" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCpuGpuBundlesDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialBundleAddAttributes.rst
.. _omni_graph_tutorials_BundleAddAttributes_1: .. _omni_graph_tutorials_BundleAddAttributes: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Bundle Add Attributes :keywords: lang-en omnigraph node tutorials tutorials bundle-add-attributes Tutorial Node: Bundle Add Attributes ==================================== .. <description> This is a tutorial node. It exercises functionality for adding and removing attributes on output bundles. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:addedAttributeNames", "``token[]``", "Names for the attribute types to be added. The size of this array must match the size of the 'typesToAdd' array to be legal.", "[]" "inputs:removedAttributeNames", "``token[]``", "Names for the attribute types to be removed. Non-existent attributes will be ignored.", "[]" "Attribute Types To Add (*inputs:typesToAdd*)", "``token[]``", "List of type descriptions to add to the bundle. The strings in this list correspond to the strings that represent the attribute types in the .ogn file (e.g. float[3][], colord[3], bool", "[]" "inputs:useBatchedAPI", "``bool``", "Controls whether or not to used batched APIS for adding/removing attributes", "False" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Constructed Bundle (*outputs:bundle*)", "``bundle``", "This is the bundle with all attributes added by compute.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.BundleAddAttributes" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.BundleAddAttributes.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Bundle Add Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialBundleAddAttributesDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialBundlesPy.rst
.. _omni_graph_tutorials_BundleManipulationPy_1: .. _omni_graph_tutorials_BundleManipulationPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: Bundle Manipulation :keywords: lang-en omnigraph node tutorials tutorials bundle-manipulation-py Tutorial Python Node: Bundle Manipulation ========================================= .. <description> This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents. The configuration is the same as omni.graph.tutorials.BundleManipulation except that the implementation language is Python .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Filtered Bundle (*inputs:filteredBundle*)", "``bundle``", "Bundle whose contents are filtered before being added to the output", "None" "inputs:filters", "``token[]``", "List of filter names to be applied to the filteredBundle. Any filter name appearing in this list will be applied to members of that bundle and only those passing all filters will be added to the output bundle. Legal filter values are 'big' (arrays of size > 10), 'x' (attributes whose name contains the letter x), and 'int' (attributes whose base type is integer).", "[]" "Full Bundle (*inputs:fullBundle*)", "``bundle``", "Bundle whose contents are passed to the output in their entirety", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:combinedBundle", "``bundle``", "This is the union of fullBundle and filtered members of the filteredBundle.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.BundleManipulationPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.BundleManipulationPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: Bundle Manipulation" "Categories", "tutorials" "Generated Class Name", "OgnTutorialBundlesPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialExtendedTypes.rst
.. _omni_graph_tutorials_ExtendedTypes_1: .. _omni_graph_tutorials_ExtendedTypes: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Extended Attribute Types :keywords: lang-en omnigraph node tutorials threadsafe tutorials extended-types Tutorial Node: Extended Attribute Types ======================================= .. <description> This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Flexible Values (*inputs:flexible*)", "``['float[3][]', 'token']``", "Flexible data type input", "None" "Float Or Token (*inputs:floatOrToken*)", "``['float', 'token']``", "Attribute that can either be a float value or a token value", "None" "To Negate (*inputs:toNegate*)", "``['bool[]', 'float[]']``", "Attribute that can either be an array of booleans or an array of floats", "None" "Tuple Values (*inputs:tuple*)", "``any``", "Variable size/type tuple values", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Doubled Input Value (*outputs:doubledResult*)", "``any``", "If the input 'simpleInput' is a float this is 2x the value. If it is a token this contains the input token repeated twice.", "None" "Inverted Flexible Values (*outputs:flexible*)", "``['float[3][]', 'token']``", "Flexible data type output", "None" "Negated Array Values (*outputs:negatedResult*)", "``['bool[]', 'float[]']``", "Result of negating the data from the 'toNegate' input", "None" "Negative Tuple Values (*outputs:tuple*)", "``any``", "Negated values of the tuple input", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.ExtendedTypes" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.ExtendedTypes.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Extended Attribute Types" "Categories", "tutorials" "Generated Class Name", "OgnTutorialExtendedTypesDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialABI.rst
.. _omni_graph_tutorials_Abi_1: .. _omni_graph_tutorials_Abi: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: ABI Overrides :keywords: lang-en omnigraph node tutorials,tutorial:abi tutorials abi Tutorial Node: ABI Overrides ============================ .. <description> This tutorial node shows how to override ABI methods on your node. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:namespace:a_bool", "``bool``", "The input is any boolean value", "True" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:namespace:a_bool", "``bool``", "The output is computed as the negation of the input", "True" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.Abi" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.Abi.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "python" "uiName", "Tutorial Node: ABI Overrides" "Categories", "tutorials,tutorial:abi" "__categoryDescriptions", "tutorial:abi,Tutorial nodes that override the ABI functions" "Generated Class Name", "OgnTutorialABIDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCpuGpuBundlesPy.rst
.. _omni_graph_tutorials_CpuGpuBundlesPy_1: .. _omni_graph_tutorials_CpuGpuBundlesPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: CPU/GPU Bundles :keywords: lang-en omnigraph node tutorials tutorials cpu-gpu-bundles-py Tutorial Python Node: CPU/GPU Bundles ===================================== .. <description> This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes the dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundles.ogn, except is is implemented in Python. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "CPU Input Bundle (*inputs:cpuBundle*)", "``bundle``", "Input bundle whose data always lives on the CPU", "None" "Results To GPU (*inputs:gpu*)", "``bool``", "If true then copy gpuBundle onto the output, otherwise copy cpuBundle", "False" "GPU Input Bundle (*inputs:gpuBundle*)", "``bundle``", "Input bundle whose data always lives on the GPU", "None" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Constructed Bundle (*outputs:cpuGpuBundle*)", "``bundle``", "This is the bundle with the merged data. If the 'gpu' attribute is set to true then this bundle's contents will be entirely on the GPU, otherwise it will be on the CPU.", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CpuGpuBundlesPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CpuGpuBundlesPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "tags", "tutorial,bundle,gpu" "uiName", "Tutorial Python Node: CPU/GPU Bundles" "__tokens", "[""points"", ""dotProducts""]" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCpuGpuBundlesPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialCudaDataCpu.rst
.. _omni_graph_tutorials_CudaCpuArrays_1: .. _omni_graph_tutorials_CudaCpuArrays: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: Attributes With CUDA Array Pointers In Cpu Memory :keywords: lang-en omnigraph node tutorials tutorials cuda-cpu-arrays Tutorial Node: Attributes With CUDA Array Pointers In Cpu Memory ================================================================ .. <description> This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "inputs:multiplier", "``float[3]``", "Amplitude of the expansion for the input points", "[1.0, 1.0, 1.0]" "inputs:points", "``float[3][]``", "Array of points to be moved", "[]" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:points", "``float[3][]``", "Final positions of points", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.CudaCpuArrays" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.CudaCpuArrays.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cuda" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: Attributes With CUDA Array Pointers In Cpu Memory" "__memoryType", "cuda" "Categories", "tutorials" "Generated Class Name", "OgnTutorialCudaDataCpuDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialEmpty.rst
.. _omni_graph_tutorials_Empty_1: .. _omni_graph_tutorials_Empty: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Node: No Attributes :keywords: lang-en omnigraph node tutorials threadsafe tutorials empty Tutorial Node: No Attributes ============================ .. <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. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.Empty" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.Empty.svg" "Has State?", "False" "Implementation Language", "C++" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Node: No Attributes" "Categories", "tutorials" "Generated Class Name", "OgnTutorialEmptyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/ogn/docs/OgnTutorialABIPy.rst
.. _omni_graph_tutorials_AbiPy_1: .. _omni_graph_tutorials_AbiPy: .. ================================================================================ .. THIS PAGE IS AUTO-GENERATED. DO NOT MANUALLY EDIT. .. ================================================================================ :orphan: .. meta:: :title: Tutorial Python Node: ABI Overrides :keywords: lang-en omnigraph node tutorials,tutorial:abiPy tutorials abi-py Tutorial Python Node: ABI Overrides =================================== .. <description> This tutorial node shows how to override ABI methods on your Python node. The algorithm of the node converts an RGB color into HSV components. .. </description> Installation ------------ To use this node enable :ref:`omni.graph.tutorials<ext_omni_graph_tutorials>` in the Extension Manager. Inputs ------ .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "Color To Convert (*inputs:color*)", "``colord[3]``", "The color to be converted", "[0.0, 0.0, 0.0]" "", "*multipleValues*", "value1,value2,value3", "" Outputs ------- .. csv-table:: :header: "Name", "Type", "Descripton", "Default" :widths: 20, 20, 50, 10 "outputs:h", "``double``", "The hue component of the input color", "None" "outputs:s", "``double``", "The saturation component of the input color", "None" "outputs:v", "``double``", "The value component of the input color", "None" Metadata -------- .. csv-table:: :header: "Name", "Value" :widths: 30,70 "Unique ID", "omni.graph.tutorials.AbiPy" "Version", "1" "Extension", "omni.graph.tutorials" "Icon", "ogn/icons/omni.graph.tutorials.AbiPy.svg" "Has State?", "False" "Implementation Language", "Python" "Default Memory Type", "cpu" "Generated Code Exclusions", "None" "uiName", "Tutorial Python Node: ABI Overrides" "Categories", "tutorials,tutorial:abiPy" "__categoryDescriptions", "tutorial:abiPy,Tutorial nodes that override the Python ABI functions" "Generated Class Name", "OgnTutorialABIPyDatabase" "Python Module", "omni.graph.tutorials"
omniverse-code/kit/exts/omni.graph.tutorials/PACKAGE-LICENSES/omni.graph.tutorials-LICENSE.md
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.
omniverse-code/kit/exts/omni.graph.tutorials/config/extension.toml
[package] title = "OmniGraph Tutorials" version = "1.3.3" category = "Graph" readme = "docs/README.md" changelog = "docs/CHANGELOG.md" description = "Contains a collection of tutorials on constructing OmniGraph nodes." repository = "" keywords = ["kit", "omnigraph", "core", "tutorials"] # Main Python module, available as "import omni.graph.tutorials" [[python.module]] name = "omni.graph.tutorials" # Watch the .ogn files for hot reloading (only works for Python files) [fswatcher.patterns] include = ["*.ogn", "*.py"] exclude = ["Ogn*Database.py"] # Other extensions on which this one relies [dependencies] "omni.graph" = {} "omni.graph.nodes" = {} "omni.graph.tools" = {} "omni.kit.test" = {} "omni.kit.stage_templates" = {} "omni.usd" = {} "omni.kit.pipapi" = {} [python.pipapi] requirements = ["numpy"] # SWIPAT filed under: http://nvbugs/3193231 [[native.plugin]] path = "bin/*.plugin" recursive = false [[test]] timeout = 300 stdoutFailPatterns.exclude = [ # Exclude carb.events leak that only shows up locally "*[Error] [carb.events.plugin]*PooledAllocator*", ] pythonTests.unreliable = [ "*test_bundle_gpu_py", # OM-50554 "*test_setting_in_ogn_python_api", # OM-55532 ] [documentation] deps = [ ["kit-sdk", "_build/docs/kit-sdk/latest"], # WAR to include omni.graph refs until that workflow is moved ] pages = [ "docs/Overview.md", "docs/CHANGELOG.md", ]
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/__init__.py
"""There is no public API to this module.""" __all__ = [] from ._impl.extension import _PublicExtension # noqa: F401
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialTupleArraysDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.TupleArrays This is a tutorial node. It will compute the float array 'result' as the elementwise dot product of the input arrays 'a' and 'b'. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialTupleArraysDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.TupleArrays Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.b Outputs: outputs.result """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a', 'float3[]', 0, None, 'First array', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('inputs:b', 'float3[]', 0, None, 'Second array', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('outputs:result', 'float[]', 0, None, 'Dot-product array', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a(self): data_view = og.AttributeValueHelper(self._attributes.a) return data_view.get() @a.setter def a(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a) data_view = og.AttributeValueHelper(self._attributes.a) data_view.set(value) self.a_size = data_view.get_array_size() @property def b(self): data_view = og.AttributeValueHelper(self._attributes.b) return data_view.get() @b.setter def b(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.b) data_view = og.AttributeValueHelper(self._attributes.b) data_view.set(value) self.b_size = data_view.get_array_size() def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.result_size = 0 self._batchedWriteValues = { } @property def result(self): data_view = og.AttributeValueHelper(self._attributes.result) return data_view.get(reserved_element_count=self.result_size) @result.setter def result(self, value): data_view = og.AttributeValueHelper(self._attributes.result) data_view.set(value) self.result_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialTupleArraysDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialTupleArraysDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialTupleArraysDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialBundlesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.BundleManipulation This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents. """ import carb import numpy import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialBundlesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.BundleManipulation Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.filteredBundle inputs.filters inputs.fullBundle Outputs: outputs.combinedBundle """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:filteredBundle', 'bundle', 0, 'Filtered Bundle', 'Bundle whose contents are filtered before being added to the output', {}, True, None, False, ''), ('inputs:filters', 'token[]', 0, None, "List of filter names to be applied to the filteredBundle. Any filter name\nappearing in this list will be applied to members of that bundle and only those\npassing all filters will be added to the output bundle. Legal filter values are\n'big' (arrays of size > 10), 'x' (attributes whose name contains the letter x), \nand 'int' (attributes whose base type is integer).", {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('inputs:fullBundle', 'bundle', 0, 'Full Bundle', 'Bundle whose contents are passed to the output in their entirety', {}, True, None, False, ''), ('outputs:combinedBundle', 'bundle', 0, None, 'This is the union of fullBundle and filtered members of the filteredBundle.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.filteredBundle = og.AttributeRole.BUNDLE role_data.inputs.fullBundle = og.AttributeRole.BUNDLE role_data.outputs.combinedBundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def filteredBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.filteredBundle""" return self.__bundles.filteredBundle @property def filters(self): data_view = og.AttributeValueHelper(self._attributes.filters) return data_view.get() @filters.setter def filters(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.filters) data_view = og.AttributeValueHelper(self._attributes.filters) data_view.set(value) self.filters_size = data_view.get_array_size() @property def fullBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.fullBundle""" return self.__bundles.fullBundle def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def combinedBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.combinedBundle""" return self.__bundles.combinedBundle @combinedBundle.setter def combinedBundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.combinedBundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.combinedBundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialBundlesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialBundlesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialBundlesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialVectorizedPassthroughDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.TutorialVectorizedPassThrough Simple passthrough node that copy its input to its output in a vectorized way """ import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialVectorizedPassthroughDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.TutorialVectorizedPassThrough Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.value Outputs: outputs.value """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:value', 'float', 0, None, 'input value', {}, True, 0.0, False, ''), ('outputs:value', 'float', 0, None, 'output value', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def value(self): data_view = og.AttributeValueHelper(self._attributes.value) return data_view.get() @value.setter def value(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.value) data_view = og.AttributeValueHelper(self._attributes.value) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def value(self): data_view = og.AttributeValueHelper(self._attributes.value) return data_view.get() @value.setter def value(self, value): data_view = og.AttributeValueHelper(self._attributes.value) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialVectorizedPassthroughDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialVectorizedPassthroughDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialVectorizedPassthroughDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCpuGpuExtendedPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CpuGpuExtendedPy This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtended.ogn, except is is implemented in Python. """ from typing import Any import carb import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCpuGpuExtendedPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CpuGpuExtendedPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.cpuData inputs.gpu inputs.gpuData Outputs: outputs.cpuGpuSum """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:cpuData', 'any', 2, 'CPU Input Attribute', 'Input attribute whose data always lives on the CPU', {}, True, None, False, ''), ('inputs:gpu', 'bool', 0, 'Results To GPU', 'If true then put the sum on the GPU, otherwise put it on the CPU', {}, True, False, False, ''), ('inputs:gpuData', 'any', 2, 'GPU Input Attribute', 'Input attribute whose data always lives on the GPU', {ogn.MetadataKeys.MEMORY_TYPE: 'cuda'}, True, None, False, ''), ('outputs:cpuGpuSum', 'any', 2, 'Sum', "This is the attribute with the selected data. If the 'gpu' attribute is set to true then this\nattribute's contents will be entirely on the GPU, otherwise it will be on the CPU.", {ogn.MetadataKeys.MEMORY_TYPE: 'any'}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"gpu", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.gpu] self._batchedReadValues = [False] @property def cpuData(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.cpuData""" return og.RuntimeAttribute(self._attributes.cpuData.get_attribute_data(), self._context, True) @cpuData.setter def cpuData(self, value_to_set: Any): """Assign another attribute's value to outputs.cpuData""" if isinstance(value_to_set, og.RuntimeAttribute): self.cpuData.value = value_to_set.value else: self.cpuData.value = value_to_set @property def gpuData(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.gpuData""" return og.RuntimeAttribute(self._attributes.gpuData.get_attribute_data(), self._context, True) @gpuData.setter def gpuData(self, value_to_set: Any): """Assign another attribute's value to outputs.gpuData""" if isinstance(value_to_set, og.RuntimeAttribute): self.gpuData.value = value_to_set.value else: self.gpuData.value = value_to_set @property def gpu(self): return self._batchedReadValues[0] @gpu.setter def gpu(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def cpuGpuSum(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.cpuGpuSum""" return og.RuntimeAttribute(self._attributes.cpuGpuSum.get_attribute_data(), self._context, False) @cpuGpuSum.setter def cpuGpuSum(self, value_to_set: Any): """Assign another attribute's value to outputs.cpuGpuSum""" if isinstance(value_to_set, og.RuntimeAttribute): self.cpuGpuSum.value = value_to_set.value else: self.cpuGpuSum.value = value_to_set def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCpuGpuExtendedPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCpuGpuExtendedPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCpuGpuExtendedPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.CpuGpuExtendedPy' @staticmethod def compute(context, node): def database_valid(): if db.inputs.cpuData.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:cpuData is not resolved, compute skipped') return False if db.inputs.gpuData.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:gpuData is not resolved, compute skipped') return False if db.outputs.cpuGpuSum.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute outputs:cpuGpuSum is not resolved, compute skipped') return False return True try: per_node_data = OgnTutorialCpuGpuExtendedPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialCpuGpuExtendedPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialCpuGpuExtendedPyDatabase(node) try: compute_function = getattr(OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialCpuGpuExtendedPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialCpuGpuExtendedPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialCpuGpuExtendedPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialCpuGpuExtendedPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.TAGS, "tutorial,extended,gpu") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: CPU/GPU Extended Attributes") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtended.ogn, except is is implemented in Python.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.CpuGpuExtendedPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialCpuGpuExtendedPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialCpuGpuExtendedPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialCpuGpuExtendedPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.CpuGpuExtendedPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCudaDataDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CudaData This is a tutorial node. It performs different functions on the GPU to illustrate different types of data access. The first adds inputs 'a' and 'b' to yield output 'sum', all of which are on the GPU. The second is a sample expansion deformation that multiplies every point on a set of input points, stored on the GPU, by a constant value, stored on the CPU, to yield a set of output points, also on the GPU. The third is an assortment of different data types illustrating how different data is passed to the GPU. This particular node uses CUDA for its GPU computations, as indicated in the memory type value. Normal use case for GPU compute is large amounts of data. For testing purposes this node only handles a very small amount but the principle is the same. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCudaDataDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CudaData Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.b inputs.color inputs.half inputs.matrix inputs.multiplier inputs.points Outputs: outputs.color outputs.half outputs.matrix outputs.points outputs.sum """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a', 'float', 0, None, 'First value to be added in algorithm 1', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''), ('inputs:b', 'float', 0, None, 'Second value to be added in algorithm 1', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''), ('inputs:color', 'color3d', 0, None, 'Input with three doubles as a color for algorithm 3', {ogn.MetadataKeys.DEFAULT: '[1.0, 0.5, 1.0]'}, True, [1.0, 0.5, 1.0], False, ''), ('inputs:half', 'half', 0, None, 'Input of type half for algorithm 3', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('inputs:matrix', 'matrix4d', 0, None, 'Input with 16 doubles interpreted as a double-precision 4d matrix', {ogn.MetadataKeys.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]]'}, True, [[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]], False, ''), ('inputs:multiplier', 'float3', 0, None, 'Amplitude of the expansion for the input points in algorithm 2', {ogn.MetadataKeys.MEMORY_TYPE: 'cpu', ogn.MetadataKeys.DEFAULT: '[1.0, 1.0, 1.0]'}, True, [1.0, 1.0, 1.0], False, ''), ('inputs:points', 'float3[]', 0, None, 'Points to be moved by algorithm 2', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('outputs:color', 'color3d', 0, None, 'Output with three doubles as a color for algorithm 3', {}, True, None, False, ''), ('outputs:half', 'half', 0, None, 'Output of type half for algorithm 3', {}, True, None, False, ''), ('outputs:matrix', 'matrix4d', 0, None, 'Output with 16 doubles interpreted as a double-precision 4d matrix', {}, True, None, False, ''), ('outputs:points', 'float3[]', 0, None, 'Final positions of points from algorithm 2', {}, True, None, False, ''), ('outputs:sum', 'float', 0, None, 'Sum of the two inputs from algorithm 1', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.color = og.AttributeRole.COLOR role_data.inputs.matrix = og.AttributeRole.MATRIX role_data.outputs.color = og.AttributeRole.COLOR role_data.outputs.matrix = og.AttributeRole.MATRIX return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a(self): data_view = og.AttributeValueHelper(self._attributes.a) return data_view.get(on_gpu=True) @a.setter def a(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a) data_view = og.AttributeValueHelper(self._attributes.a) data_view.set(value, on_gpu=True) @property def b(self): data_view = og.AttributeValueHelper(self._attributes.b) return data_view.get(on_gpu=True) @b.setter def b(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.b) data_view = og.AttributeValueHelper(self._attributes.b) data_view.set(value, on_gpu=True) @property def color(self): data_view = og.AttributeValueHelper(self._attributes.color) return data_view.get(on_gpu=True) @color.setter def color(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.color) data_view = og.AttributeValueHelper(self._attributes.color) data_view.set(value, on_gpu=True) @property def half(self): data_view = og.AttributeValueHelper(self._attributes.half) return data_view.get(on_gpu=True) @half.setter def half(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.half) data_view = og.AttributeValueHelper(self._attributes.half) data_view.set(value, on_gpu=True) @property def matrix(self): data_view = og.AttributeValueHelper(self._attributes.matrix) return data_view.get(on_gpu=True) @matrix.setter def matrix(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.matrix) data_view = og.AttributeValueHelper(self._attributes.matrix) data_view.set(value, on_gpu=True) @property def multiplier(self): data_view = og.AttributeValueHelper(self._attributes.multiplier) return data_view.get() @multiplier.setter def multiplier(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.multiplier) data_view = og.AttributeValueHelper(self._attributes.multiplier) data_view.set(value) @property def points(self): data_view = og.AttributeValueHelper(self._attributes.points) return data_view.get(on_gpu=True) @points.setter def points(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.points) data_view = og.AttributeValueHelper(self._attributes.points) data_view.set(value, on_gpu=True) self.points_size = data_view.get_array_size() def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.points_size = None self._batchedWriteValues = { } @property def color(self): data_view = og.AttributeValueHelper(self._attributes.color) return data_view.get(on_gpu=True) @color.setter def color(self, value): data_view = og.AttributeValueHelper(self._attributes.color) data_view.set(value, on_gpu=True) @property def half(self): data_view = og.AttributeValueHelper(self._attributes.half) return data_view.get(on_gpu=True) @half.setter def half(self, value): data_view = og.AttributeValueHelper(self._attributes.half) data_view.set(value, on_gpu=True) @property def matrix(self): data_view = og.AttributeValueHelper(self._attributes.matrix) return data_view.get(on_gpu=True) @matrix.setter def matrix(self, value): data_view = og.AttributeValueHelper(self._attributes.matrix) data_view.set(value, on_gpu=True) @property def points(self): data_view = og.AttributeValueHelper(self._attributes.points) return data_view.get(reserved_element_count=self.points_size, on_gpu=True) @points.setter def points(self, value): data_view = og.AttributeValueHelper(self._attributes.points) data_view.set(value, on_gpu=True) self.points_size = data_view.get_array_size() @property def sum(self): data_view = og.AttributeValueHelper(self._attributes.sum) return data_view.get(on_gpu=True) @sum.setter def sum(self, value): data_view = og.AttributeValueHelper(self._attributes.sum) data_view.set(value, on_gpu=True) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCudaDataDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCudaDataDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCudaDataDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCpuGpuDataDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CpuGpuData This is a tutorial node. It illustrates how to access data whose memory location, CPU or GPU, is determined at runtime in the compute method. The data types are the same as for the purely CPU and purely GPU tutorials, it is only the access method that changes. The input 'is_gpu' determines where the data of the other attributes can be accessed. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCpuGpuDataDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CpuGpuData Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.b inputs.is_gpu inputs.multiplier inputs.points Outputs: outputs.points outputs.sum """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a', 'float', 0, None, 'First value to be added in algorithm 1', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''), ('inputs:b', 'float', 0, None, 'Second value to be added in algorithm 1', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''), ('inputs:is_gpu', 'bool', 0, None, 'Runtime switch determining where the data for the other attributes lives.', {ogn.MetadataKeys.MEMORY_TYPE: 'cpu', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:multiplier', 'float3', 0, None, 'Amplitude of the expansion for the input points in algorithm 2', {ogn.MetadataKeys.DEFAULT: '[1.0, 1.0, 1.0]'}, True, [1.0, 1.0, 1.0], False, ''), ('inputs:points', 'float3[]', 0, None, 'Points to be moved by algorithm 2', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('outputs:points', 'float3[]', 0, None, 'Final positions of points from algorithm 2', {}, True, None, False, ''), ('outputs:sum', 'float', 0, None, 'Sum of the two inputs from algorithm 1', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] class __a: def __init__(self, parent): self._parent = parent @property def cpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.a) return data_view.get() @cpu.setter def cpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.cpu) data_view = og.AttributeValueHelper(self._parent._attributes.cpu) data_view.set(value) @property def gpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.a) return data_view.get(on_gpu=True) @gpu.setter def gpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.gpu) data_view = og.AttributeValueHelper(self._parent._attributes.gpu) data_view.set(value) @property def a(self): return self.__class__.__a(self) class __b: def __init__(self, parent): self._parent = parent @property def cpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.b) return data_view.get() @cpu.setter def cpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.cpu) data_view = og.AttributeValueHelper(self._parent._attributes.cpu) data_view.set(value) @property def gpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.b) return data_view.get(on_gpu=True) @gpu.setter def gpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.gpu) data_view = og.AttributeValueHelper(self._parent._attributes.gpu) data_view.set(value) @property def b(self): return self.__class__.__b(self) @property def is_gpu(self): data_view = og.AttributeValueHelper(self._attributes.is_gpu) return data_view.get() @is_gpu.setter def is_gpu(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.is_gpu) data_view = og.AttributeValueHelper(self._attributes.is_gpu) data_view.set(value) class __multiplier: def __init__(self, parent): self._parent = parent @property def cpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.multiplier) return data_view.get() @cpu.setter def cpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.cpu) data_view = og.AttributeValueHelper(self._parent._attributes.cpu) data_view.set(value) @property def gpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.multiplier) return data_view.get(on_gpu=True) @gpu.setter def gpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.gpu) data_view = og.AttributeValueHelper(self._parent._attributes.gpu) data_view.set(value) @property def multiplier(self): return self.__class__.__multiplier(self) class __points: def __init__(self, parent): self._parent = parent @property def cpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.points) return data_view.get() @cpu.setter def cpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.cpu) data_view = og.AttributeValueHelper(self._parent._attributes.cpu) data_view.set(value) self._parent.cpu_size = data_view.get_array_size() @property def gpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.points) return data_view.get(on_gpu=True) @gpu.setter def gpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.gpu) data_view = og.AttributeValueHelper(self._parent._attributes.gpu) data_view.set(value) self._parent.gpu_size = data_view.get_array_size() @property def points(self): return self.__class__.__points(self) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.points_size = None self._batchedWriteValues = { } class __points: def __init__(self, parent): self._parent = parent @property def cpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.points) return data_view.get(reserved_element_count=self._parent.points_size) @cpu.setter def cpu(self, value): data_view = og.AttributeValueHelper(self._parent._attributes.cpu) data_view.set(value) self._parent.cpu_size = data_view.get_array_size() @property def gpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.points) return data_view.get(reserved_element_count=self._parent.points_size, on_gpu=True) @gpu.setter def gpu(self, value): data_view = og.AttributeValueHelper(self._parent._attributes.gpu) data_view.set(value) self._parent.gpu_size = data_view.get_array_size() @property def points(self): return self.__class__.__points(self) class __sum: def __init__(self, parent): self._parent = parent @property def cpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.sum) return data_view.get() @cpu.setter def cpu(self, value): data_view = og.AttributeValueHelper(self._parent._attributes.cpu) data_view.set(value) @property def gpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.sum) return data_view.get(on_gpu=True) @gpu.setter def gpu(self, value): data_view = og.AttributeValueHelper(self._parent._attributes.gpu) data_view.set(value) @property def sum(self): return self.__class__.__sum(self) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCpuGpuDataDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCpuGpuDataDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCpuGpuDataDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialDynamicAttributesPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.DynamicAttributesPy This is a Python node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001). """ import carb import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialDynamicAttributesPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.DynamicAttributesPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.value Outputs: outputs.result Predefined Tokens: tokens.firstBit tokens.secondBit tokens.invert """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:value', 'uint', 0, None, 'Original value to be modified.', {}, True, 0, False, ''), ('outputs:result', 'uint', 0, None, 'Modified value', {}, True, None, False, ''), ]) class tokens: firstBit = "inputs:firstBit" secondBit = "inputs:secondBit" invert = "inputs:invert" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"value", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.value] self._batchedReadValues = [0] @property def value(self): return self._batchedReadValues[0] @value.setter def value(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"result", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def result(self): value = self._batchedWriteValues.get(self._attributes.result) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.result) return data_view.get() @result.setter def result(self, value): self._batchedWriteValues[self._attributes.result] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialDynamicAttributesPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialDynamicAttributesPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialDynamicAttributesPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.DynamicAttributesPy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialDynamicAttributesPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialDynamicAttributesPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialDynamicAttributesPyDatabase(node) try: compute_function = getattr(OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialDynamicAttributesPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialDynamicAttributesPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialDynamicAttributesPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialDynamicAttributesPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Dynamic Attributes") node_type.set_metadata(ogn.MetadataKeys.TOKENS, "{\"firstBit\": \"inputs:firstBit\", \"secondBit\": \"inputs:secondBit\", \"invert\": \"inputs:invert\"}") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a Python node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001).") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.DynamicAttributesPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialDynamicAttributesPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialDynamicAttributesPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialDynamicAttributesPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.DynamicAttributesPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCpuGpuBundlesPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CpuGpuBundlesPy This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes the dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundles.ogn, except is is implemented in Python. """ import carb import sys import traceback import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCpuGpuBundlesPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CpuGpuBundlesPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.cpuBundle inputs.gpu inputs.gpuBundle Outputs: outputs.cpuGpuBundle Predefined Tokens: tokens.points tokens.dotProducts """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:cpuBundle', 'bundle', 0, 'CPU Input Bundle', 'Input bundle whose data always lives on the CPU', {}, True, None, False, ''), ('inputs:gpu', 'bool', 0, 'Results To GPU', 'If true then copy gpuBundle onto the output, otherwise copy cpuBundle', {}, True, False, False, ''), ('inputs:gpuBundle', 'bundle', 0, 'GPU Input Bundle', 'Input bundle whose data always lives on the GPU', {ogn.MetadataKeys.MEMORY_TYPE: 'cuda'}, True, None, False, ''), ('outputs:cpuGpuBundle', 'bundle', 0, 'Constructed Bundle', "This is the bundle with the merged data. If the 'gpu' attribute is set to true then this\nbundle's contents will be entirely on the GPU, otherwise it will be on the CPU.", {ogn.MetadataKeys.MEMORY_TYPE: 'any'}, True, None, False, ''), ]) class tokens: points = "points" dotProducts = "dotProducts" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.cpuBundle = og.AttributeRole.BUNDLE role_data.inputs.gpuBundle = og.AttributeRole.BUNDLE role_data.outputs.cpuGpuBundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"gpu", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, ['inputs:gpuBundle'], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [self._attributes.gpu] self._batchedReadValues = [False] @property def cpuBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.cpuBundle""" return self.__bundles.cpuBundle @property def gpuBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.gpuBundle""" return self.__bundles.gpuBundle @property def gpu(self): return self._batchedReadValues[0] @gpu.setter def gpu(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, ['outputs_cpuGpuBundle'], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def cpuGpuBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.cpuGpuBundle""" return self.__bundles.cpuGpuBundle @cpuGpuBundle.setter def cpuGpuBundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.cpuGpuBundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.cpuGpuBundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCpuGpuBundlesPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCpuGpuBundlesPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCpuGpuBundlesPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.CpuGpuBundlesPy' @staticmethod def compute(context, node): def database_valid(): if not db.inputs.cpuBundle.valid: db.log_warning('Required bundle inputs.cpuBundle is invalid or not connected, compute skipped') return False if not db.inputs.gpuBundle.valid: db.log_warning('Required bundle inputs.gpuBundle is invalid or not connected, compute skipped') return False if not db.outputs.cpuGpuBundle.valid: db.log_error('Required bundle outputs.cpuGpuBundle is invalid, compute skipped') return False return True try: per_node_data = OgnTutorialCpuGpuBundlesPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialCpuGpuBundlesPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialCpuGpuBundlesPyDatabase(node) try: compute_function = getattr(OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialCpuGpuBundlesPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialCpuGpuBundlesPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialCpuGpuBundlesPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialCpuGpuBundlesPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.TAGS, "tutorial,bundle,gpu") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: CPU/GPU Bundles") node_type.set_metadata(ogn.MetadataKeys.TOKENS, "[\"points\", \"dotProducts\"]") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes the dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundles.ogn, except is is implemented in Python.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.CpuGpuBundlesPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialCpuGpuBundlesPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialCpuGpuBundlesPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialCpuGpuBundlesPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.CpuGpuBundlesPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialStateAttributesPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.StateAttributesPy This is a tutorial node. It exercises state attributes to remember data from on evaluation to the next. """ import carb import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialStateAttributesPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.StateAttributesPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.ignored State: state.monotonic state.reset """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:ignored', 'bool', 0, None, 'Ignore me', {}, True, False, False, ''), ('state:monotonic', 'int', 0, None, 'The monotonically increasing output value, reset to 0 when the reset value is true', {}, True, None, False, ''), ('state:reset', 'bool', 0, None, 'If true then the inputs are ignored and outputs are set to default values, then this\nflag is set to false for subsequent evaluations.', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"ignored", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.ignored] self._batchedReadValues = [False] @property def ignored(self): return self._batchedReadValues[0] @ignored.setter def ignored(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) @property def monotonic(self): data_view = og.AttributeValueHelper(self._attributes.monotonic) return data_view.get() @monotonic.setter def monotonic(self, value): data_view = og.AttributeValueHelper(self._attributes.monotonic) data_view.set(value) @property def reset(self): data_view = og.AttributeValueHelper(self._attributes.reset) return data_view.get() @reset.setter def reset(self, value): data_view = og.AttributeValueHelper(self._attributes.reset) data_view.set(value) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialStateAttributesPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialStateAttributesPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialStateAttributesPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.StateAttributesPy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialStateAttributesPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialStateAttributesPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialStateAttributesPyDatabase(node) try: compute_function = getattr(OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialStateAttributesPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialStateAttributesPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialStateAttributesPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialStateAttributesPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: State Attributes") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It exercises state attributes to remember data from on evaluation to the next.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.StateAttributesPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialStateAttributesPyDatabase.INTERFACE.add_to_node_type(node_type) node_type.set_has_state(True) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialStateAttributesPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialStateAttributesPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.StateAttributesPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialBundlesPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.BundleManipulationPy This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents. The configuration is the same as omni.graph.tutorials.BundleManipulation except that the implementation language is Python """ import carb import numpy import sys import traceback import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialBundlesPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.BundleManipulationPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.filteredBundle inputs.filters inputs.fullBundle Outputs: outputs.combinedBundle """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:filteredBundle', 'bundle', 0, 'Filtered Bundle', 'Bundle whose contents are filtered before being added to the output', {}, True, None, False, ''), ('inputs:filters', 'token[]', 0, None, "List of filter names to be applied to the filteredBundle. Any filter name\nappearing in this list will be applied to members of that bundle and only those\npassing all filters will be added to the output bundle. Legal filter values are\n'big' (arrays of size > 10), 'x' (attributes whose name contains the letter x), \nand 'int' (attributes whose base type is integer).", {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('inputs:fullBundle', 'bundle', 0, 'Full Bundle', 'Bundle whose contents are passed to the output in their entirety', {}, True, None, False, ''), ('outputs:combinedBundle', 'bundle', 0, None, 'This is the union of fullBundle and filtered members of the filteredBundle.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.filteredBundle = og.AttributeRole.BUNDLE role_data.inputs.fullBundle = og.AttributeRole.BUNDLE role_data.outputs.combinedBundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def filteredBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.filteredBundle""" return self.__bundles.filteredBundle @property def filters(self): data_view = og.AttributeValueHelper(self._attributes.filters) return data_view.get() @filters.setter def filters(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.filters) data_view = og.AttributeValueHelper(self._attributes.filters) data_view.set(value) self.filters_size = data_view.get_array_size() @property def fullBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.fullBundle""" return self.__bundles.fullBundle def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def combinedBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.combinedBundle""" return self.__bundles.combinedBundle @combinedBundle.setter def combinedBundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.combinedBundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.combinedBundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialBundlesPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialBundlesPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialBundlesPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.BundleManipulationPy' @staticmethod def compute(context, node): def database_valid(): if not db.inputs.filteredBundle.valid: db.log_warning('Required bundle inputs.filteredBundle is invalid or not connected, compute skipped') return False if not db.inputs.fullBundle.valid: db.log_warning('Required bundle inputs.fullBundle is invalid or not connected, compute skipped') return False if not db.outputs.combinedBundle.valid: db.log_error('Required bundle outputs.combinedBundle is invalid, compute skipped') return False return True try: per_node_data = OgnTutorialBundlesPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialBundlesPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialBundlesPyDatabase(node) try: compute_function = getattr(OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialBundlesPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialBundlesPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialBundlesPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialBundlesPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Bundle Manipulation") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It exercises functionality for the manipulation of bundle attribute contents. The configuration is the same as omni.graph.tutorials.BundleManipulation except that the implementation language is Python") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.BundleManipulationPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialBundlesPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialBundlesPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialBundlesPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.BundleManipulationPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialRoleDataDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.RoleData 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. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialRoleDataDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.RoleData Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a_color3d inputs.a_color3f inputs.a_color3h inputs.a_color4d inputs.a_color4f inputs.a_color4h inputs.a_frame inputs.a_matrix2d inputs.a_matrix3d inputs.a_matrix4d inputs.a_normal3d inputs.a_normal3f inputs.a_normal3h inputs.a_point3d inputs.a_point3f inputs.a_point3h inputs.a_quatd inputs.a_quatf inputs.a_quath inputs.a_texcoord2d inputs.a_texcoord2f inputs.a_texcoord2h inputs.a_texcoord3d inputs.a_texcoord3f inputs.a_texcoord3h inputs.a_timecode inputs.a_vector3d inputs.a_vector3f inputs.a_vector3h Outputs: outputs.a_color3d outputs.a_color3f outputs.a_color3h outputs.a_color4d outputs.a_color4f outputs.a_color4h outputs.a_frame outputs.a_matrix2d outputs.a_matrix3d outputs.a_matrix4d outputs.a_normal3d outputs.a_normal3f outputs.a_normal3h outputs.a_point3d outputs.a_point3f outputs.a_point3h outputs.a_quatd outputs.a_quatf outputs.a_quath outputs.a_texcoord2d outputs.a_texcoord2f outputs.a_texcoord2h outputs.a_texcoord3d outputs.a_texcoord3f outputs.a_texcoord3h outputs.a_timecode outputs.a_vector3d outputs.a_vector3f outputs.a_vector3h """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a_color3d', 'color3d', 0, None, 'This is an attribute interpreted as a double-precision 3d color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_color3f', 'color3f', 0, None, 'This is an attribute interpreted as a single-precision 3d color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_color3h', 'color3h', 0, None, 'This is an attribute interpreted as a half-precision 3d color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_color4d', 'color4d', 0, None, 'This is an attribute interpreted as a double-precision 4d color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0, 0.0], False, ''), ('inputs:a_color4f', 'color4f', 0, None, 'This is an attribute interpreted as a single-precision 4d color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0, 0.0], False, ''), ('inputs:a_color4h', 'color4h', 0, None, 'This is an attribute interpreted as a half-precision 4d color', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0, 0.0], False, ''), ('inputs:a_frame', 'frame4d', 0, None, 'This is an attribute interpreted as a coordinate frame', {ogn.MetadataKeys.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]]'}, True, [[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]], False, ''), ('inputs:a_matrix2d', 'matrix2d', 0, None, 'This is an attribute interpreted as a double-precision 2d matrix', {ogn.MetadataKeys.DEFAULT: '[[1.0, 0.0], [0.0, 1.0]]'}, True, [[1.0, 0.0], [0.0, 1.0]], False, ''), ('inputs:a_matrix3d', 'matrix3d', 0, None, 'This is an attribute interpreted as a double-precision 3d matrix', {ogn.MetadataKeys.DEFAULT: '[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]'}, True, [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], False, ''), ('inputs:a_matrix4d', 'matrix4d', 0, None, 'This is an attribute interpreted as a double-precision 4d matrix', {ogn.MetadataKeys.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]]'}, True, [[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]], False, ''), ('inputs:a_normal3d', 'normal3d', 0, None, 'This is an attribute interpreted as a double-precision 3d normal', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_normal3f', 'normal3f', 0, None, 'This is an attribute interpreted as a single-precision 3d normal', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_normal3h', 'normal3h', 0, None, 'This is an attribute interpreted as a half-precision 3d normal', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_point3d', 'point3d', 0, None, 'This is an attribute interpreted as a double-precision 3d point', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_point3f', 'point3f', 0, None, 'This is an attribute interpreted as a single-precision 3d point', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_point3h', 'point3h', 0, None, 'This is an attribute interpreted as a half-precision 3d point', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_quatd', 'quatd', 0, None, 'This is an attribute interpreted as a double-precision 4d quaternion', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0, 0.0], False, ''), ('inputs:a_quatf', 'quatf', 0, None, 'This is an attribute interpreted as a single-precision 4d quaternion', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0, 0.0], False, ''), ('inputs:a_quath', 'quath', 0, None, 'This is an attribute interpreted as a half-precision 4d quaternion', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0, 0.0], False, ''), ('inputs:a_texcoord2d', 'texCoord2d', 0, None, 'This is an attribute interpreted as a double-precision 2d texcoord', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0]'}, True, [0.0, 0.0], False, ''), ('inputs:a_texcoord2f', 'texCoord2f', 0, None, 'This is an attribute interpreted as a single-precision 2d texcoord', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0]'}, True, [0.0, 0.0], False, ''), ('inputs:a_texcoord2h', 'texCoord2h', 0, None, 'This is an attribute interpreted as a half-precision 2d texcoord', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0]'}, True, [0.0, 0.0], False, ''), ('inputs:a_texcoord3d', 'texCoord3d', 0, None, 'This is an attribute interpreted as a double-precision 3d texcoord', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_texcoord3f', 'texCoord3f', 0, None, 'This is an attribute interpreted as a single-precision 3d texcoord', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_texcoord3h', 'texCoord3h', 0, None, 'This is an attribute interpreted as a half-precision 3d texcoord', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_timecode', 'timecode', 0, None, 'This is a computed attribute interpreted as a timecode', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('inputs:a_vector3d', 'vector3d', 0, None, 'This is an attribute interpreted as a double-precision 3d vector', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_vector3f', 'vector3f', 0, None, 'This is an attribute interpreted as a single-precision 3d vector', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:a_vector3h', 'vector3h', 0, None, 'This is an attribute interpreted as a half-precision 3d vector', {ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('outputs:a_color3d', 'color3d', 0, None, 'This is a computed attribute interpreted as a double-precision 3d color', {}, True, None, False, ''), ('outputs:a_color3f', 'color3f', 0, None, 'This is a computed attribute interpreted as a single-precision 3d color', {}, True, None, False, ''), ('outputs:a_color3h', 'color3h', 0, None, 'This is a computed attribute interpreted as a half-precision 3d color', {}, True, None, False, ''), ('outputs:a_color4d', 'color4d', 0, None, 'This is a computed attribute interpreted as a double-precision 4d color', {}, True, None, False, ''), ('outputs:a_color4f', 'color4f', 0, None, 'This is a computed attribute interpreted as a single-precision 4d color', {}, True, None, False, ''), ('outputs:a_color4h', 'color4h', 0, None, 'This is a computed attribute interpreted as a half-precision 4d color', {}, True, None, False, ''), ('outputs:a_frame', 'frame4d', 0, None, 'This is a computed attribute interpreted as a coordinate frame', {}, True, None, False, ''), ('outputs:a_matrix2d', 'matrix2d', 0, None, 'This is a computed attribute interpreted as a double-precision 2d matrix', {}, True, None, False, ''), ('outputs:a_matrix3d', 'matrix3d', 0, None, 'This is a computed attribute interpreted as a double-precision 3d matrix', {}, True, None, False, ''), ('outputs:a_matrix4d', 'matrix4d', 0, None, 'This is a computed attribute interpreted as a double-precision 4d matrix', {}, True, None, False, ''), ('outputs:a_normal3d', 'normal3d', 0, None, 'This is a computed attribute interpreted as a double-precision 3d normal', {}, True, None, False, ''), ('outputs:a_normal3f', 'normal3f', 0, None, 'This is a computed attribute interpreted as a single-precision 3d normal', {}, True, None, False, ''), ('outputs:a_normal3h', 'normal3h', 0, None, 'This is a computed attribute interpreted as a half-precision 3d normal', {}, True, None, False, ''), ('outputs:a_point3d', 'point3d', 0, None, 'This is a computed attribute interpreted as a double-precision 3d point', {}, True, None, False, ''), ('outputs:a_point3f', 'point3f', 0, None, 'This is a computed attribute interpreted as a single-precision 3d point', {}, True, None, False, ''), ('outputs:a_point3h', 'point3h', 0, None, 'This is a computed attribute interpreted as a half-precision 3d point', {}, True, None, False, ''), ('outputs:a_quatd', 'quatd', 0, None, 'This is a computed attribute interpreted as a double-precision 4d quaternion', {}, True, None, False, ''), ('outputs:a_quatf', 'quatf', 0, None, 'This is a computed attribute interpreted as a single-precision 4d quaternion', {}, True, None, False, ''), ('outputs:a_quath', 'quath', 0, None, 'This is a computed attribute interpreted as a half-precision 4d quaternion', {}, True, None, False, ''), ('outputs:a_texcoord2d', 'texCoord2d', 0, None, 'This is a computed attribute interpreted as a double-precision 2d texcoord', {}, True, None, False, ''), ('outputs:a_texcoord2f', 'texCoord2f', 0, None, 'This is a computed attribute interpreted as a single-precision 2d texcoord', {}, True, None, False, ''), ('outputs:a_texcoord2h', 'texCoord2h', 0, None, 'This is a computed attribute interpreted as a half-precision 2d texcoord', {}, True, None, False, ''), ('outputs:a_texcoord3d', 'texCoord3d', 0, None, 'This is a computed attribute interpreted as a double-precision 3d texcoord', {}, True, None, False, ''), ('outputs:a_texcoord3f', 'texCoord3f', 0, None, 'This is a computed attribute interpreted as a single-precision 3d texcoord', {}, True, None, False, ''), ('outputs:a_texcoord3h', 'texCoord3h', 0, None, 'This is a computed attribute interpreted as a half-precision 3d texcoord', {}, True, None, False, ''), ('outputs:a_timecode', 'timecode', 0, None, 'This is a computed attribute interpreted as a timecode', {}, True, None, False, ''), ('outputs:a_vector3d', 'vector3d', 0, None, 'This is a computed attribute interpreted as a double-precision 3d vector', {}, True, None, False, ''), ('outputs:a_vector3f', 'vector3f', 0, None, 'This is a computed attribute interpreted as a single-precision 3d vector', {}, True, None, False, ''), ('outputs:a_vector3h', 'vector3h', 0, None, 'This is a computed attribute interpreted as a half-precision 3d vector', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.a_color3d = og.AttributeRole.COLOR role_data.inputs.a_color3f = og.AttributeRole.COLOR role_data.inputs.a_color3h = og.AttributeRole.COLOR role_data.inputs.a_color4d = og.AttributeRole.COLOR role_data.inputs.a_color4f = og.AttributeRole.COLOR role_data.inputs.a_color4h = og.AttributeRole.COLOR role_data.inputs.a_frame = og.AttributeRole.FRAME role_data.inputs.a_matrix2d = og.AttributeRole.MATRIX role_data.inputs.a_matrix3d = og.AttributeRole.MATRIX role_data.inputs.a_matrix4d = og.AttributeRole.MATRIX role_data.inputs.a_normal3d = og.AttributeRole.NORMAL role_data.inputs.a_normal3f = og.AttributeRole.NORMAL role_data.inputs.a_normal3h = og.AttributeRole.NORMAL role_data.inputs.a_point3d = og.AttributeRole.POSITION role_data.inputs.a_point3f = og.AttributeRole.POSITION role_data.inputs.a_point3h = og.AttributeRole.POSITION role_data.inputs.a_quatd = og.AttributeRole.QUATERNION role_data.inputs.a_quatf = og.AttributeRole.QUATERNION role_data.inputs.a_quath = og.AttributeRole.QUATERNION role_data.inputs.a_texcoord2d = og.AttributeRole.TEXCOORD role_data.inputs.a_texcoord2f = og.AttributeRole.TEXCOORD role_data.inputs.a_texcoord2h = og.AttributeRole.TEXCOORD role_data.inputs.a_texcoord3d = og.AttributeRole.TEXCOORD role_data.inputs.a_texcoord3f = og.AttributeRole.TEXCOORD role_data.inputs.a_texcoord3h = og.AttributeRole.TEXCOORD role_data.inputs.a_timecode = og.AttributeRole.TIMECODE role_data.inputs.a_vector3d = og.AttributeRole.VECTOR role_data.inputs.a_vector3f = og.AttributeRole.VECTOR role_data.inputs.a_vector3h = og.AttributeRole.VECTOR role_data.outputs.a_color3d = og.AttributeRole.COLOR role_data.outputs.a_color3f = og.AttributeRole.COLOR role_data.outputs.a_color3h = og.AttributeRole.COLOR role_data.outputs.a_color4d = og.AttributeRole.COLOR role_data.outputs.a_color4f = og.AttributeRole.COLOR role_data.outputs.a_color4h = og.AttributeRole.COLOR role_data.outputs.a_frame = og.AttributeRole.FRAME role_data.outputs.a_matrix2d = og.AttributeRole.MATRIX role_data.outputs.a_matrix3d = og.AttributeRole.MATRIX role_data.outputs.a_matrix4d = og.AttributeRole.MATRIX role_data.outputs.a_normal3d = og.AttributeRole.NORMAL role_data.outputs.a_normal3f = og.AttributeRole.NORMAL role_data.outputs.a_normal3h = og.AttributeRole.NORMAL role_data.outputs.a_point3d = og.AttributeRole.POSITION role_data.outputs.a_point3f = og.AttributeRole.POSITION role_data.outputs.a_point3h = og.AttributeRole.POSITION role_data.outputs.a_quatd = og.AttributeRole.QUATERNION role_data.outputs.a_quatf = og.AttributeRole.QUATERNION role_data.outputs.a_quath = og.AttributeRole.QUATERNION role_data.outputs.a_texcoord2d = og.AttributeRole.TEXCOORD role_data.outputs.a_texcoord2f = og.AttributeRole.TEXCOORD role_data.outputs.a_texcoord2h = og.AttributeRole.TEXCOORD role_data.outputs.a_texcoord3d = og.AttributeRole.TEXCOORD role_data.outputs.a_texcoord3f = og.AttributeRole.TEXCOORD role_data.outputs.a_texcoord3h = og.AttributeRole.TEXCOORD role_data.outputs.a_timecode = og.AttributeRole.TIMECODE role_data.outputs.a_vector3d = og.AttributeRole.VECTOR role_data.outputs.a_vector3f = og.AttributeRole.VECTOR role_data.outputs.a_vector3h = og.AttributeRole.VECTOR return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a_color3d(self): data_view = og.AttributeValueHelper(self._attributes.a_color3d) return data_view.get() @a_color3d.setter def a_color3d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_color3d) data_view = og.AttributeValueHelper(self._attributes.a_color3d) data_view.set(value) @property def a_color3f(self): data_view = og.AttributeValueHelper(self._attributes.a_color3f) return data_view.get() @a_color3f.setter def a_color3f(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_color3f) data_view = og.AttributeValueHelper(self._attributes.a_color3f) data_view.set(value) @property def a_color3h(self): data_view = og.AttributeValueHelper(self._attributes.a_color3h) return data_view.get() @a_color3h.setter def a_color3h(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_color3h) data_view = og.AttributeValueHelper(self._attributes.a_color3h) data_view.set(value) @property def a_color4d(self): data_view = og.AttributeValueHelper(self._attributes.a_color4d) return data_view.get() @a_color4d.setter def a_color4d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_color4d) data_view = og.AttributeValueHelper(self._attributes.a_color4d) data_view.set(value) @property def a_color4f(self): data_view = og.AttributeValueHelper(self._attributes.a_color4f) return data_view.get() @a_color4f.setter def a_color4f(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_color4f) data_view = og.AttributeValueHelper(self._attributes.a_color4f) data_view.set(value) @property def a_color4h(self): data_view = og.AttributeValueHelper(self._attributes.a_color4h) return data_view.get() @a_color4h.setter def a_color4h(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_color4h) data_view = og.AttributeValueHelper(self._attributes.a_color4h) data_view.set(value) @property def a_frame(self): data_view = og.AttributeValueHelper(self._attributes.a_frame) return data_view.get() @a_frame.setter def a_frame(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_frame) data_view = og.AttributeValueHelper(self._attributes.a_frame) data_view.set(value) @property def a_matrix2d(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix2d) return data_view.get() @a_matrix2d.setter def a_matrix2d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_matrix2d) data_view = og.AttributeValueHelper(self._attributes.a_matrix2d) data_view.set(value) @property def a_matrix3d(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix3d) return data_view.get() @a_matrix3d.setter def a_matrix3d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_matrix3d) data_view = og.AttributeValueHelper(self._attributes.a_matrix3d) data_view.set(value) @property def a_matrix4d(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix4d) return data_view.get() @a_matrix4d.setter def a_matrix4d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_matrix4d) data_view = og.AttributeValueHelper(self._attributes.a_matrix4d) data_view.set(value) @property def a_normal3d(self): data_view = og.AttributeValueHelper(self._attributes.a_normal3d) return data_view.get() @a_normal3d.setter def a_normal3d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_normal3d) data_view = og.AttributeValueHelper(self._attributes.a_normal3d) data_view.set(value) @property def a_normal3f(self): data_view = og.AttributeValueHelper(self._attributes.a_normal3f) return data_view.get() @a_normal3f.setter def a_normal3f(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_normal3f) data_view = og.AttributeValueHelper(self._attributes.a_normal3f) data_view.set(value) @property def a_normal3h(self): data_view = og.AttributeValueHelper(self._attributes.a_normal3h) return data_view.get() @a_normal3h.setter def a_normal3h(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_normal3h) data_view = og.AttributeValueHelper(self._attributes.a_normal3h) data_view.set(value) @property def a_point3d(self): data_view = og.AttributeValueHelper(self._attributes.a_point3d) return data_view.get() @a_point3d.setter def a_point3d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_point3d) data_view = og.AttributeValueHelper(self._attributes.a_point3d) data_view.set(value) @property def a_point3f(self): data_view = og.AttributeValueHelper(self._attributes.a_point3f) return data_view.get() @a_point3f.setter def a_point3f(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_point3f) data_view = og.AttributeValueHelper(self._attributes.a_point3f) data_view.set(value) @property def a_point3h(self): data_view = og.AttributeValueHelper(self._attributes.a_point3h) return data_view.get() @a_point3h.setter def a_point3h(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_point3h) data_view = og.AttributeValueHelper(self._attributes.a_point3h) data_view.set(value) @property def a_quatd(self): data_view = og.AttributeValueHelper(self._attributes.a_quatd) return data_view.get() @a_quatd.setter def a_quatd(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_quatd) data_view = og.AttributeValueHelper(self._attributes.a_quatd) data_view.set(value) @property def a_quatf(self): data_view = og.AttributeValueHelper(self._attributes.a_quatf) return data_view.get() @a_quatf.setter def a_quatf(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_quatf) data_view = og.AttributeValueHelper(self._attributes.a_quatf) data_view.set(value) @property def a_quath(self): data_view = og.AttributeValueHelper(self._attributes.a_quath) return data_view.get() @a_quath.setter def a_quath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_quath) data_view = og.AttributeValueHelper(self._attributes.a_quath) data_view.set(value) @property def a_texcoord2d(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2d) return data_view.get() @a_texcoord2d.setter def a_texcoord2d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_texcoord2d) data_view = og.AttributeValueHelper(self._attributes.a_texcoord2d) data_view.set(value) @property def a_texcoord2f(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2f) return data_view.get() @a_texcoord2f.setter def a_texcoord2f(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_texcoord2f) data_view = og.AttributeValueHelper(self._attributes.a_texcoord2f) data_view.set(value) @property def a_texcoord2h(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2h) return data_view.get() @a_texcoord2h.setter def a_texcoord2h(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_texcoord2h) data_view = og.AttributeValueHelper(self._attributes.a_texcoord2h) data_view.set(value) @property def a_texcoord3d(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3d) return data_view.get() @a_texcoord3d.setter def a_texcoord3d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_texcoord3d) data_view = og.AttributeValueHelper(self._attributes.a_texcoord3d) data_view.set(value) @property def a_texcoord3f(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3f) return data_view.get() @a_texcoord3f.setter def a_texcoord3f(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_texcoord3f) data_view = og.AttributeValueHelper(self._attributes.a_texcoord3f) data_view.set(value) @property def a_texcoord3h(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3h) return data_view.get() @a_texcoord3h.setter def a_texcoord3h(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_texcoord3h) data_view = og.AttributeValueHelper(self._attributes.a_texcoord3h) data_view.set(value) @property def a_timecode(self): data_view = og.AttributeValueHelper(self._attributes.a_timecode) return data_view.get() @a_timecode.setter def a_timecode(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_timecode) data_view = og.AttributeValueHelper(self._attributes.a_timecode) data_view.set(value) @property def a_vector3d(self): data_view = og.AttributeValueHelper(self._attributes.a_vector3d) return data_view.get() @a_vector3d.setter def a_vector3d(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_vector3d) data_view = og.AttributeValueHelper(self._attributes.a_vector3d) data_view.set(value) @property def a_vector3f(self): data_view = og.AttributeValueHelper(self._attributes.a_vector3f) return data_view.get() @a_vector3f.setter def a_vector3f(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_vector3f) data_view = og.AttributeValueHelper(self._attributes.a_vector3f) data_view.set(value) @property def a_vector3h(self): data_view = og.AttributeValueHelper(self._attributes.a_vector3h) return data_view.get() @a_vector3h.setter def a_vector3h(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_vector3h) data_view = og.AttributeValueHelper(self._attributes.a_vector3h) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def a_color3d(self): data_view = og.AttributeValueHelper(self._attributes.a_color3d) return data_view.get() @a_color3d.setter def a_color3d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_color3d) data_view.set(value) @property def a_color3f(self): data_view = og.AttributeValueHelper(self._attributes.a_color3f) return data_view.get() @a_color3f.setter def a_color3f(self, value): data_view = og.AttributeValueHelper(self._attributes.a_color3f) data_view.set(value) @property def a_color3h(self): data_view = og.AttributeValueHelper(self._attributes.a_color3h) return data_view.get() @a_color3h.setter def a_color3h(self, value): data_view = og.AttributeValueHelper(self._attributes.a_color3h) data_view.set(value) @property def a_color4d(self): data_view = og.AttributeValueHelper(self._attributes.a_color4d) return data_view.get() @a_color4d.setter def a_color4d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_color4d) data_view.set(value) @property def a_color4f(self): data_view = og.AttributeValueHelper(self._attributes.a_color4f) return data_view.get() @a_color4f.setter def a_color4f(self, value): data_view = og.AttributeValueHelper(self._attributes.a_color4f) data_view.set(value) @property def a_color4h(self): data_view = og.AttributeValueHelper(self._attributes.a_color4h) return data_view.get() @a_color4h.setter def a_color4h(self, value): data_view = og.AttributeValueHelper(self._attributes.a_color4h) data_view.set(value) @property def a_frame(self): data_view = og.AttributeValueHelper(self._attributes.a_frame) return data_view.get() @a_frame.setter def a_frame(self, value): data_view = og.AttributeValueHelper(self._attributes.a_frame) data_view.set(value) @property def a_matrix2d(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix2d) return data_view.get() @a_matrix2d.setter def a_matrix2d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_matrix2d) data_view.set(value) @property def a_matrix3d(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix3d) return data_view.get() @a_matrix3d.setter def a_matrix3d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_matrix3d) data_view.set(value) @property def a_matrix4d(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix4d) return data_view.get() @a_matrix4d.setter def a_matrix4d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_matrix4d) data_view.set(value) @property def a_normal3d(self): data_view = og.AttributeValueHelper(self._attributes.a_normal3d) return data_view.get() @a_normal3d.setter def a_normal3d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_normal3d) data_view.set(value) @property def a_normal3f(self): data_view = og.AttributeValueHelper(self._attributes.a_normal3f) return data_view.get() @a_normal3f.setter def a_normal3f(self, value): data_view = og.AttributeValueHelper(self._attributes.a_normal3f) data_view.set(value) @property def a_normal3h(self): data_view = og.AttributeValueHelper(self._attributes.a_normal3h) return data_view.get() @a_normal3h.setter def a_normal3h(self, value): data_view = og.AttributeValueHelper(self._attributes.a_normal3h) data_view.set(value) @property def a_point3d(self): data_view = og.AttributeValueHelper(self._attributes.a_point3d) return data_view.get() @a_point3d.setter def a_point3d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_point3d) data_view.set(value) @property def a_point3f(self): data_view = og.AttributeValueHelper(self._attributes.a_point3f) return data_view.get() @a_point3f.setter def a_point3f(self, value): data_view = og.AttributeValueHelper(self._attributes.a_point3f) data_view.set(value) @property def a_point3h(self): data_view = og.AttributeValueHelper(self._attributes.a_point3h) return data_view.get() @a_point3h.setter def a_point3h(self, value): data_view = og.AttributeValueHelper(self._attributes.a_point3h) data_view.set(value) @property def a_quatd(self): data_view = og.AttributeValueHelper(self._attributes.a_quatd) return data_view.get() @a_quatd.setter def a_quatd(self, value): data_view = og.AttributeValueHelper(self._attributes.a_quatd) data_view.set(value) @property def a_quatf(self): data_view = og.AttributeValueHelper(self._attributes.a_quatf) return data_view.get() @a_quatf.setter def a_quatf(self, value): data_view = og.AttributeValueHelper(self._attributes.a_quatf) data_view.set(value) @property def a_quath(self): data_view = og.AttributeValueHelper(self._attributes.a_quath) return data_view.get() @a_quath.setter def a_quath(self, value): data_view = og.AttributeValueHelper(self._attributes.a_quath) data_view.set(value) @property def a_texcoord2d(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2d) return data_view.get() @a_texcoord2d.setter def a_texcoord2d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2d) data_view.set(value) @property def a_texcoord2f(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2f) return data_view.get() @a_texcoord2f.setter def a_texcoord2f(self, value): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2f) data_view.set(value) @property def a_texcoord2h(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2h) return data_view.get() @a_texcoord2h.setter def a_texcoord2h(self, value): data_view = og.AttributeValueHelper(self._attributes.a_texcoord2h) data_view.set(value) @property def a_texcoord3d(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3d) return data_view.get() @a_texcoord3d.setter def a_texcoord3d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3d) data_view.set(value) @property def a_texcoord3f(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3f) return data_view.get() @a_texcoord3f.setter def a_texcoord3f(self, value): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3f) data_view.set(value) @property def a_texcoord3h(self): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3h) return data_view.get() @a_texcoord3h.setter def a_texcoord3h(self, value): data_view = og.AttributeValueHelper(self._attributes.a_texcoord3h) data_view.set(value) @property def a_timecode(self): data_view = og.AttributeValueHelper(self._attributes.a_timecode) return data_view.get() @a_timecode.setter def a_timecode(self, value): data_view = og.AttributeValueHelper(self._attributes.a_timecode) data_view.set(value) @property def a_vector3d(self): data_view = og.AttributeValueHelper(self._attributes.a_vector3d) return data_view.get() @a_vector3d.setter def a_vector3d(self, value): data_view = og.AttributeValueHelper(self._attributes.a_vector3d) data_view.set(value) @property def a_vector3f(self): data_view = og.AttributeValueHelper(self._attributes.a_vector3f) return data_view.get() @a_vector3f.setter def a_vector3f(self, value): data_view = og.AttributeValueHelper(self._attributes.a_vector3f) data_view.set(value) @property def a_vector3h(self): data_view = og.AttributeValueHelper(self._attributes.a_vector3h) return data_view.get() @a_vector3h.setter def a_vector3h(self, value): data_view = og.AttributeValueHelper(self._attributes.a_vector3h) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialRoleDataDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialRoleDataDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialRoleDataDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialTokensPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.TokensPy This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list. """ import carb import numpy import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialTokensPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.TokensPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.valuesToCheck Outputs: outputs.isColor Predefined Tokens: tokens.red tokens.green tokens.blue """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:valuesToCheck', 'token[]', 0, None, 'Array of tokens that are to be checked', {}, True, [], False, ''), ('outputs:isColor', 'bool[]', 0, None, 'True values if the corresponding input value appears in the token list', {}, True, None, False, ''), ]) class tokens: red = "red" green = "green" blue = "blue" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def valuesToCheck(self): data_view = og.AttributeValueHelper(self._attributes.valuesToCheck) return data_view.get() @valuesToCheck.setter def valuesToCheck(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.valuesToCheck) data_view = og.AttributeValueHelper(self._attributes.valuesToCheck) data_view.set(value) self.valuesToCheck_size = data_view.get_array_size() def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.isColor_size = None self._batchedWriteValues = { } @property def isColor(self): data_view = og.AttributeValueHelper(self._attributes.isColor) return data_view.get(reserved_element_count=self.isColor_size) @isColor.setter def isColor(self, value): data_view = og.AttributeValueHelper(self._attributes.isColor) data_view.set(value) self.isColor_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialTokensPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialTokensPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialTokensPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.TokensPy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialTokensPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialTokensPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialTokensPyDatabase(node) try: compute_function = getattr(OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialTokensPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialTokensPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialTokensPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialTokensPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Tokens") node_type.set_metadata(ogn.MetadataKeys.TOKENS, "[\"red\", \"green\", \"blue\"]") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.TokensPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialTokensPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialTokensPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialTokensPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.TokensPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialOverrideTypeDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.OverrideType This is a tutorial node. It has an input and output of type float[3], an input and output of type double[3], and a type override specification that lets the node use Carbonite types for the generated data on the float[3] attributes only. Ordinarily all of the types would be defined in a seperate configuration file so that it can be shared for a project. In that case the type definition build flag would also be used so that this information does not have to be embedded in every .ogn file in the project. It is placed directly in the file here solely for instructional purposes. The compute is just a rotation of components from x->y, y->z, and z->x, for each input type. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialOverrideTypeDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.OverrideType Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.data inputs.typedData Outputs: outputs.data outputs.typedData """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:data', 'double3', 0, 'Input value with a standard double type', 'The value to rotate', {}, True, [0.0, 0.0, 0.0], False, ''), ('inputs:typedData', 'float3', 0, 'Input value with a modified float type', 'The value to rotate', {}, True, [0.0, 0.0, 0.0], False, ''), ('outputs:data', 'double3', 0, 'Output value with a standard double type', 'The rotated version of inputs::data', {}, True, None, False, ''), ('outputs:typedData', 'float3', 0, 'Output value with a modified float type', 'The rotated version of inputs::typedData', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def data(self): data_view = og.AttributeValueHelper(self._attributes.data) return data_view.get() @data.setter def data(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.data) data_view = og.AttributeValueHelper(self._attributes.data) data_view.set(value) @property def typedData(self): data_view = og.AttributeValueHelper(self._attributes.typedData) return data_view.get() @typedData.setter def typedData(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.typedData) data_view = og.AttributeValueHelper(self._attributes.typedData) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def data(self): data_view = og.AttributeValueHelper(self._attributes.data) return data_view.get() @data.setter def data(self, value): data_view = og.AttributeValueHelper(self._attributes.data) data_view.set(value) @property def typedData(self): data_view = og.AttributeValueHelper(self._attributes.typedData) return data_view.get() @typedData.setter def typedData(self, value): data_view = og.AttributeValueHelper(self._attributes.typedData) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialOverrideTypeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialOverrideTypeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialOverrideTypeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialBundleDataDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.BundleData This is a tutorial node. It exercises functionality for access of data within bundle attributes. """ import carb import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialBundleDataDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.BundleData Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.bundle Outputs: outputs.bundle """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:bundle', 'bundle', 0, 'Input Bundle', 'Bundle whose contents are modified for passing to the output', {}, True, None, False, ''), ('outputs:bundle', 'bundle', 0, None, 'This is the bundle with values of known types doubled.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.bundle = og.AttributeRole.BUNDLE role_data.outputs.bundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.bundle""" return self.__bundles.bundle def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.bundle""" return self.__bundles.bundle @bundle.setter def bundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.bundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.bundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialBundleDataDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialBundleDataDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialBundleDataDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialEmptyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.Empty 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. """ import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialEmptyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.Empty Class Members: node: Node being evaluated """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialEmptyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialEmptyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialEmptyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialStateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.State This is a tutorial node. It makes use of internal state information to continuously increment an output. """ import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialStateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.State Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.override inputs.overrideValue Outputs: outputs.monotonic """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:override', 'bool', 0, 'Enable Override', 'When true get the output from the overrideValue, otherwise use the internal value', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:overrideValue', 'int64', 0, 'Override Value', "Value to use instead of the monotonically increasing internal one when 'override' is true", {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('outputs:monotonic', 'int64', 0, 'State-Based Output', 'Monotonically increasing output, set by internal state information', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def override(self): data_view = og.AttributeValueHelper(self._attributes.override) return data_view.get() @override.setter def override(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.override) data_view = og.AttributeValueHelper(self._attributes.override) data_view.set(value) @property def overrideValue(self): data_view = og.AttributeValueHelper(self._attributes.overrideValue) return data_view.get() @overrideValue.setter def overrideValue(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.overrideValue) data_view = og.AttributeValueHelper(self._attributes.overrideValue) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def monotonic(self): data_view = og.AttributeValueHelper(self._attributes.monotonic) return data_view.get() @monotonic.setter def monotonic(self, value): data_view = og.AttributeValueHelper(self._attributes.monotonic) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialStateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialStateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialStateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialDynamicAttributesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.DynamicAttributes This is a C++ node that exercises the ability to add and remove database attribute accessors for dynamic attributes. When the dynamic attribute is added the property will exist and be able to get/set the attribute values. When it does not the property will not exist. The dynamic attribute names are found in the tokens below. If neither exist then the input value is copied to the output directly. If 'firstBit' exists then the 'firstBit'th bit of the input is x-ored for the copy. If 'secondBit' exists then the 'secondBit'th bit of the input is x-ored for the copy. (Recall bitwise match xor(0,0)=0, xor(0,1)=1, xor(1,0)=1, and xor(1,1)=0.) For example, if 'firstBit' is present and set to 1 then the bitmask will be b0010, where bit 1 is set. If the input is 7, or b0111, then the xor operation will flip bit 1, yielding b0101, or 5 as the result. If on the next run 'secondBit' is also present and set to 2 then its bitmask will be b0100, where bit 2 is set. The input of 7 (b0111) flips bit 1 because firstBit=1 and flips bit 2 because secondBit=2, yielding a final result of 1 (b0001). """ import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialDynamicAttributesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.DynamicAttributes Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.value Outputs: outputs.result Predefined Tokens: tokens.firstBit tokens.secondBit tokens.invert """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:value', 'uint', 0, None, 'Original value to be modified.', {}, True, 0, False, ''), ('outputs:result', 'uint', 0, None, 'Modified value', {}, True, None, False, ''), ]) class tokens: firstBit = "inputs:firstBit" secondBit = "inputs:secondBit" invert = "inputs:invert" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def value(self): data_view = og.AttributeValueHelper(self._attributes.value) return data_view.get() @value.setter def value(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.value) data_view = og.AttributeValueHelper(self._attributes.value) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def result(self): data_view = og.AttributeValueHelper(self._attributes.result) return data_view.get() @result.setter def result(self, value): data_view = og.AttributeValueHelper(self._attributes.result) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialDynamicAttributesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialDynamicAttributesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialDynamicAttributesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCudaDataCpuPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CudaCpuArraysPy This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device. Both plain attribute and bundle attribute extraction are shown. """ import carb import numpy import sys import traceback import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCudaDataCpuPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CudaCpuArraysPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.multiplier inputs.points Outputs: outputs.outBundle outputs.points """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:multiplier', 'float3', 0, None, 'Amplitude of the expansion for the input points', {ogn.MetadataKeys.DEFAULT: '[1.0, 1.0, 1.0]'}, True, [1.0, 1.0, 1.0], False, ''), ('inputs:points', 'float3[]', 0, None, 'Array of points to be moved', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('outputs:outBundle', 'bundle', 0, None, 'Bundle containing a copy of the output points', {ogn.MetadataKeys.MEMORY_TYPE: 'any'}, True, None, False, ''), ('outputs:points', 'float3[]', 0, None, 'Final positions of points', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.outBundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def multiplier(self): data_view = og.AttributeValueHelper(self._attributes.multiplier) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU return data_view.get(on_gpu=True) @multiplier.setter def multiplier(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.multiplier) data_view = og.AttributeValueHelper(self._attributes.multiplier) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU data_view.set(value, on_gpu=True) @property def points(self): data_view = og.AttributeValueHelper(self._attributes.points) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU return data_view.get(on_gpu=True) @points.setter def points(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.points) data_view = og.AttributeValueHelper(self._attributes.points) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU data_view.set(value, on_gpu=True) self.points_size = data_view.get_array_size() def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, ['outputs_outBundle'], read_only=False, gpu_ptr_kinds={"outputs_outBundle": og.PtrToPtrKind.CPU}) self.points_size = None self._batchedWriteValues = { } @property def outBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.outBundle""" return self.__bundles.outBundle @outBundle.setter def outBundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.outBundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.outBundle.bundle = bundle @property def points(self): data_view = og.AttributeValueHelper(self._attributes.points) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU return data_view.get(reserved_element_count=self.points_size, on_gpu=True) @points.setter def points(self, value): data_view = og.AttributeValueHelper(self._attributes.points) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU data_view.set(value, on_gpu=True) self.points_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCudaDataCpuPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCudaDataCpuPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCudaDataCpuPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.CudaCpuArraysPy' @staticmethod def compute(context, node): def database_valid(): if not db.outputs.outBundle.valid: db.log_error('Required bundle outputs.outBundle is invalid, compute skipped') return False return True try: per_node_data = OgnTutorialCudaDataCpuPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialCudaDataCpuPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialCudaDataCpuPyDatabase(node) try: compute_function = getattr(OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialCudaDataCpuPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialCudaDataCpuPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialCudaDataCpuPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialCudaDataCpuPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Python Tutorial Node: Attributes With CUDA Array Pointers In Cpu Memory") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device. Both plain attribute and bundle attribute extraction are shown.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") node_type.set_metadata(ogn.MetadataKeys.MEMORY_TYPE, "cuda") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.CudaCpuArraysPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialCudaDataCpuPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialCudaDataCpuPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialCudaDataCpuPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.CudaCpuArraysPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialDefaultsDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.Defaults This is a tutorial node. It will move the values of inputs to corresponding outputs. Inputs all have unspecified, and therefore empty, default values. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialDefaultsDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.Defaults Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a_array inputs.a_bool inputs.a_double inputs.a_float inputs.a_half inputs.a_int inputs.a_int2 inputs.a_int64 inputs.a_matrix inputs.a_string inputs.a_token inputs.a_uchar inputs.a_uint inputs.a_uint64 Outputs: outputs.a_array outputs.a_bool outputs.a_double outputs.a_float outputs.a_half outputs.a_int outputs.a_int2 outputs.a_int64 outputs.a_matrix outputs.a_string outputs.a_token outputs.a_uchar outputs.a_uint outputs.a_uint64 """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a_array', 'float[]', 0, None, 'This is an attribute of type array of floats', {}, True, [], False, ''), ('inputs:a_bool', 'bool', 0, None, 'This is an attribute of type boolean', {}, True, False, False, ''), ('inputs:a_double', 'double', 0, None, 'This is an attribute of type 64 bit floating point', {}, True, 0.0, False, ''), ('inputs:a_float', 'float', 0, None, 'This is an attribute of type 32 bit floating point', {}, True, 0.0, False, ''), ('inputs:a_half', 'half', 0, None, 'This is an attribute of type 16 bit floating point', {}, True, 0.0, False, ''), ('inputs:a_int', 'int', 0, None, 'This is an attribute of type 32 bit integer', {}, True, 0, False, ''), ('inputs:a_int2', 'int2', 0, None, 'This is an attribute of type 2-tuple of integers', {}, True, [0, 0], False, ''), ('inputs:a_int64', 'int64', 0, None, 'This is an attribute of type 64 bit integer', {}, True, 0, False, ''), ('inputs:a_matrix', 'matrix2d', 0, None, 'This is an attribute of type 2x2 matrix', {}, True, [[1.0, 0.0], [0.0, 1.0]], False, ''), ('inputs:a_string', 'string', 0, None, 'This is an attribute of type string', {}, True, "", False, ''), ('inputs:a_token', 'token', 0, None, 'This is an attribute of type interned string with fast comparison and hashing', {}, True, "", False, ''), ('inputs:a_uchar', 'uchar', 0, None, 'This is an attribute of type unsigned 8 bit integer', {}, True, 0, False, ''), ('inputs:a_uint', 'uint', 0, None, 'This is an attribute of type unsigned 32 bit integer', {}, True, 0, False, ''), ('inputs:a_uint64', 'uint64', 0, None, 'This is an attribute of type unsigned 64 bit integer', {}, True, 0, False, ''), ('outputs:a_array', 'float[]', 0, None, 'This is a computed attribute of type array of floats', {}, True, None, False, ''), ('outputs:a_bool', 'bool', 0, None, 'This is a computed attribute of type boolean', {}, True, None, False, ''), ('outputs:a_double', 'double', 0, None, 'This is a computed attribute of type 64 bit floating point', {}, True, None, False, ''), ('outputs:a_float', 'float', 0, None, 'This is a computed attribute of type 32 bit floating point', {}, True, None, False, ''), ('outputs:a_half', 'half', 0, None, 'This is a computed attribute of type 16 bit floating point', {}, True, None, False, ''), ('outputs:a_int', 'int', 0, None, 'This is a computed attribute of type 32 bit integer', {}, True, None, False, ''), ('outputs:a_int2', 'int2', 0, None, 'This is a computed attribute of type 2-tuple of integers', {}, True, None, False, ''), ('outputs:a_int64', 'int64', 0, None, 'This is a computed attribute of type 64 bit integer', {}, True, None, False, ''), ('outputs:a_matrix', 'matrix2d', 0, None, 'This is a computed attribute of type 2x2 matrix', {}, True, None, False, ''), ('outputs:a_string', 'string', 0, None, 'This is a computed attribute of type string', {}, True, None, False, ''), ('outputs:a_token', 'token', 0, None, 'This is a computed attribute of type interned string with fast comparison and hashing', {}, True, None, False, ''), ('outputs:a_uchar', 'uchar', 0, None, 'This is a computed attribute of type unsigned 8 bit integer', {}, True, None, False, ''), ('outputs:a_uint', 'uint', 0, None, 'This is a computed attribute of type unsigned 32 bit integer', {}, True, None, False, ''), ('outputs:a_uint64', 'uint64', 0, None, 'This is a computed attribute of type unsigned 64 bit integer', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.a_matrix = og.AttributeRole.MATRIX role_data.inputs.a_string = og.AttributeRole.TEXT role_data.outputs.a_matrix = og.AttributeRole.MATRIX role_data.outputs.a_string = og.AttributeRole.TEXT return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a_array(self): data_view = og.AttributeValueHelper(self._attributes.a_array) return data_view.get() @a_array.setter def a_array(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_array) data_view = og.AttributeValueHelper(self._attributes.a_array) data_view.set(value) self.a_array_size = data_view.get_array_size() @property def a_bool(self): data_view = og.AttributeValueHelper(self._attributes.a_bool) return data_view.get() @a_bool.setter def a_bool(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_bool) data_view = og.AttributeValueHelper(self._attributes.a_bool) data_view.set(value) @property def a_double(self): data_view = og.AttributeValueHelper(self._attributes.a_double) return data_view.get() @a_double.setter def a_double(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_double) data_view = og.AttributeValueHelper(self._attributes.a_double) data_view.set(value) @property def a_float(self): data_view = og.AttributeValueHelper(self._attributes.a_float) return data_view.get() @a_float.setter def a_float(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_float) data_view = og.AttributeValueHelper(self._attributes.a_float) data_view.set(value) @property def a_half(self): data_view = og.AttributeValueHelper(self._attributes.a_half) return data_view.get() @a_half.setter def a_half(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_half) data_view = og.AttributeValueHelper(self._attributes.a_half) data_view.set(value) @property def a_int(self): data_view = og.AttributeValueHelper(self._attributes.a_int) return data_view.get() @a_int.setter def a_int(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_int) data_view = og.AttributeValueHelper(self._attributes.a_int) data_view.set(value) @property def a_int2(self): data_view = og.AttributeValueHelper(self._attributes.a_int2) return data_view.get() @a_int2.setter def a_int2(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_int2) data_view = og.AttributeValueHelper(self._attributes.a_int2) data_view.set(value) @property def a_int64(self): data_view = og.AttributeValueHelper(self._attributes.a_int64) return data_view.get() @a_int64.setter def a_int64(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_int64) data_view = og.AttributeValueHelper(self._attributes.a_int64) data_view.set(value) @property def a_matrix(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix) return data_view.get() @a_matrix.setter def a_matrix(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_matrix) data_view = og.AttributeValueHelper(self._attributes.a_matrix) data_view.set(value) @property def a_string(self): data_view = og.AttributeValueHelper(self._attributes.a_string) return data_view.get() @a_string.setter def a_string(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_string) data_view = og.AttributeValueHelper(self._attributes.a_string) data_view.set(value) self.a_string_size = data_view.get_array_size() @property def a_token(self): data_view = og.AttributeValueHelper(self._attributes.a_token) return data_view.get() @a_token.setter def a_token(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_token) data_view = og.AttributeValueHelper(self._attributes.a_token) data_view.set(value) @property def a_uchar(self): data_view = og.AttributeValueHelper(self._attributes.a_uchar) return data_view.get() @a_uchar.setter def a_uchar(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_uchar) data_view = og.AttributeValueHelper(self._attributes.a_uchar) data_view.set(value) @property def a_uint(self): data_view = og.AttributeValueHelper(self._attributes.a_uint) return data_view.get() @a_uint.setter def a_uint(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_uint) data_view = og.AttributeValueHelper(self._attributes.a_uint) data_view.set(value) @property def a_uint64(self): data_view = og.AttributeValueHelper(self._attributes.a_uint64) return data_view.get() @a_uint64.setter def a_uint64(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_uint64) data_view = og.AttributeValueHelper(self._attributes.a_uint64) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.a_array_size = None self.a_string_size = None self._batchedWriteValues = { } @property def a_array(self): data_view = og.AttributeValueHelper(self._attributes.a_array) return data_view.get(reserved_element_count=self.a_array_size) @a_array.setter def a_array(self, value): data_view = og.AttributeValueHelper(self._attributes.a_array) data_view.set(value) self.a_array_size = data_view.get_array_size() @property def a_bool(self): data_view = og.AttributeValueHelper(self._attributes.a_bool) return data_view.get() @a_bool.setter def a_bool(self, value): data_view = og.AttributeValueHelper(self._attributes.a_bool) data_view.set(value) @property def a_double(self): data_view = og.AttributeValueHelper(self._attributes.a_double) return data_view.get() @a_double.setter def a_double(self, value): data_view = og.AttributeValueHelper(self._attributes.a_double) data_view.set(value) @property def a_float(self): data_view = og.AttributeValueHelper(self._attributes.a_float) return data_view.get() @a_float.setter def a_float(self, value): data_view = og.AttributeValueHelper(self._attributes.a_float) data_view.set(value) @property def a_half(self): data_view = og.AttributeValueHelper(self._attributes.a_half) return data_view.get() @a_half.setter def a_half(self, value): data_view = og.AttributeValueHelper(self._attributes.a_half) data_view.set(value) @property def a_int(self): data_view = og.AttributeValueHelper(self._attributes.a_int) return data_view.get() @a_int.setter def a_int(self, value): data_view = og.AttributeValueHelper(self._attributes.a_int) data_view.set(value) @property def a_int2(self): data_view = og.AttributeValueHelper(self._attributes.a_int2) return data_view.get() @a_int2.setter def a_int2(self, value): data_view = og.AttributeValueHelper(self._attributes.a_int2) data_view.set(value) @property def a_int64(self): data_view = og.AttributeValueHelper(self._attributes.a_int64) return data_view.get() @a_int64.setter def a_int64(self, value): data_view = og.AttributeValueHelper(self._attributes.a_int64) data_view.set(value) @property def a_matrix(self): data_view = og.AttributeValueHelper(self._attributes.a_matrix) return data_view.get() @a_matrix.setter def a_matrix(self, value): data_view = og.AttributeValueHelper(self._attributes.a_matrix) data_view.set(value) @property def a_string(self): data_view = og.AttributeValueHelper(self._attributes.a_string) return data_view.get(reserved_element_count=self.a_string_size) @a_string.setter def a_string(self, value): data_view = og.AttributeValueHelper(self._attributes.a_string) data_view.set(value) self.a_string_size = data_view.get_array_size() @property def a_token(self): data_view = og.AttributeValueHelper(self._attributes.a_token) return data_view.get() @a_token.setter def a_token(self, value): data_view = og.AttributeValueHelper(self._attributes.a_token) data_view.set(value) @property def a_uchar(self): data_view = og.AttributeValueHelper(self._attributes.a_uchar) return data_view.get() @a_uchar.setter def a_uchar(self, value): data_view = og.AttributeValueHelper(self._attributes.a_uchar) data_view.set(value) @property def a_uint(self): data_view = og.AttributeValueHelper(self._attributes.a_uint) return data_view.get() @a_uint.setter def a_uint(self, value): data_view = og.AttributeValueHelper(self._attributes.a_uint) data_view.set(value) @property def a_uint64(self): data_view = og.AttributeValueHelper(self._attributes.a_uint64) return data_view.get() @a_uint64.setter def a_uint64(self, value): data_view = og.AttributeValueHelper(self._attributes.a_uint64) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialDefaultsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialDefaultsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialDefaultsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialComplexDataPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.ComplexDataPy This is a tutorial node written in Python. It will compute the point3f array by multiplying each element of the float array by the three element vector in the multiplier. """ import carb import numpy import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialComplexDataPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.ComplexDataPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a_inputArray inputs.a_vectorMultiplier Outputs: outputs.a_productArray outputs.a_tokenArray """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a_inputArray', 'float[]', 0, None, 'Input array', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('inputs:a_vectorMultiplier', 'float3', 0, None, 'Vector multiplier', {ogn.MetadataKeys.DEFAULT: '[1.0, 2.0, 3.0]'}, True, [1.0, 2.0, 3.0], False, ''), ('outputs:a_productArray', 'point3f[]', 0, None, 'Output array', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('outputs:a_tokenArray', 'token[]', 0, None, 'String representations of the input array', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.a_productArray = og.AttributeRole.POSITION return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"a_vectorMultiplier", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.a_vectorMultiplier] self._batchedReadValues = [[1.0, 2.0, 3.0]] @property def a_inputArray(self): data_view = og.AttributeValueHelper(self._attributes.a_inputArray) return data_view.get() @a_inputArray.setter def a_inputArray(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_inputArray) data_view = og.AttributeValueHelper(self._attributes.a_inputArray) data_view.set(value) self.a_inputArray_size = data_view.get_array_size() @property def a_vectorMultiplier(self): return self._batchedReadValues[0] @a_vectorMultiplier.setter def a_vectorMultiplier(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.a_productArray_size = 0 self.a_tokenArray_size = None self._batchedWriteValues = { } @property def a_productArray(self): data_view = og.AttributeValueHelper(self._attributes.a_productArray) return data_view.get(reserved_element_count=self.a_productArray_size) @a_productArray.setter def a_productArray(self, value): data_view = og.AttributeValueHelper(self._attributes.a_productArray) data_view.set(value) self.a_productArray_size = data_view.get_array_size() @property def a_tokenArray(self): data_view = og.AttributeValueHelper(self._attributes.a_tokenArray) return data_view.get(reserved_element_count=self.a_tokenArray_size) @a_tokenArray.setter def a_tokenArray(self, value): data_view = og.AttributeValueHelper(self._attributes.a_tokenArray) data_view.set(value) self.a_tokenArray_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialComplexDataPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialComplexDataPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialComplexDataPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.ComplexDataPy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialComplexDataPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialComplexDataPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialComplexDataPyDatabase(node) try: compute_function = getattr(OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialComplexDataPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialComplexDataPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialComplexDataPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialComplexDataPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Attributes With Arrays of Tuples") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node written in Python. It will compute the point3f array by multiplying each element of the float array by the three element vector in the multiplier.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.ComplexDataPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialComplexDataPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialComplexDataPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialComplexDataPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.ComplexDataPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialBundleAddAttributesPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.BundleAddAttributesPy This is a Python tutorial node. It exercises functionality for adding and removing attributes on output bundles. """ import carb import numpy import sys import traceback import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialBundleAddAttributesPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.BundleAddAttributesPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.addedAttributeNames inputs.removedAttributeNames inputs.typesToAdd inputs.useBatchedAPI Outputs: outputs.bundle """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:addedAttributeNames', 'token[]', 0, None, "Names for the attribute types to be added. The size of this array must match the size\nof the 'typesToAdd' array to be legal.", {}, True, [], False, ''), ('inputs:removedAttributeNames', 'token[]', 0, None, 'Names for the attribute types to be removed. Non-existent attributes will be ignored.', {}, True, [], False, ''), ('inputs:typesToAdd', 'token[]', 0, 'Attribute Types To Add', 'List of type descriptions to add to the bundle. The strings in this list correspond to the\nstrings that represent the attribute types in the .ogn file (e.g. float[3][], colord[3], bool', {}, True, [], False, ''), ('inputs:useBatchedAPI', 'bool', 0, None, 'Controls whether or not to used batched APIS for adding/removing attributes', {}, True, False, False, ''), ('outputs:bundle', 'bundle', 0, 'Constructed Bundle', 'This is the bundle with all attributes added by compute.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.bundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"useBatchedAPI", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.useBatchedAPI] self._batchedReadValues = [False] @property def addedAttributeNames(self): data_view = og.AttributeValueHelper(self._attributes.addedAttributeNames) return data_view.get() @addedAttributeNames.setter def addedAttributeNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.addedAttributeNames) data_view = og.AttributeValueHelper(self._attributes.addedAttributeNames) data_view.set(value) self.addedAttributeNames_size = data_view.get_array_size() @property def removedAttributeNames(self): data_view = og.AttributeValueHelper(self._attributes.removedAttributeNames) return data_view.get() @removedAttributeNames.setter def removedAttributeNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.removedAttributeNames) data_view = og.AttributeValueHelper(self._attributes.removedAttributeNames) data_view.set(value) self.removedAttributeNames_size = data_view.get_array_size() @property def typesToAdd(self): data_view = og.AttributeValueHelper(self._attributes.typesToAdd) return data_view.get() @typesToAdd.setter def typesToAdd(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.typesToAdd) data_view = og.AttributeValueHelper(self._attributes.typesToAdd) data_view.set(value) self.typesToAdd_size = data_view.get_array_size() @property def useBatchedAPI(self): return self._batchedReadValues[0] @useBatchedAPI.setter def useBatchedAPI(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.bundle""" return self.__bundles.bundle @bundle.setter def bundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.bundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.bundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialBundleAddAttributesPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialBundleAddAttributesPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialBundleAddAttributesPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.BundleAddAttributesPy' @staticmethod def compute(context, node): def database_valid(): if not db.outputs.bundle.valid: db.log_error('Required bundle outputs.bundle is invalid, compute skipped') return False return True try: per_node_data = OgnTutorialBundleAddAttributesPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialBundleAddAttributesPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialBundleAddAttributesPyDatabase(node) try: compute_function = getattr(OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialBundleAddAttributesPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialBundleAddAttributesPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialBundleAddAttributesPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialBundleAddAttributesPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Bundle Add Attributes") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a Python tutorial node. It exercises functionality for adding and removing attributes on output bundles.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.BundleAddAttributesPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialBundleAddAttributesPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialBundleAddAttributesPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialBundleAddAttributesPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.BundleAddAttributesPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialABIPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.AbiPy This tutorial node shows how to override ABI methods on your Python node. The algorithm of the node converts an RGB color into HSV components. """ import carb import numpy import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialABIPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.AbiPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.color Outputs: outputs.h outputs.s outputs.v """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:color', 'color3d', 0, 'Color To Convert', 'The color to be converted', {'multipleValues': 'value1,value2,value3', ogn.MetadataKeys.DEFAULT: '[0.0, 0.0, 0.0]'}, True, [0.0, 0.0, 0.0], False, ''), ('outputs:h', 'double', 0, None, 'The hue component of the input color', {}, True, None, False, ''), ('outputs:s', 'double', 0, None, 'The saturation component of the input color', {}, True, None, False, ''), ('outputs:v', 'double', 0, None, 'The value component of the input color', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.color = og.AttributeRole.COLOR return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"color", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.color] self._batchedReadValues = [[0.0, 0.0, 0.0]] @property def color(self): return self._batchedReadValues[0] @color.setter def color(self, value): self._batchedReadValues[0] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"h", "s", "v", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def h(self): value = self._batchedWriteValues.get(self._attributes.h) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.h) return data_view.get() @h.setter def h(self, value): self._batchedWriteValues[self._attributes.h] = value @property def s(self): value = self._batchedWriteValues.get(self._attributes.s) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.s) return data_view.get() @s.setter def s(self, value): self._batchedWriteValues[self._attributes.s] = value @property def v(self): value = self._batchedWriteValues.get(self._attributes.v) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.v) return data_view.get() @v.setter def v(self, value): self._batchedWriteValues[self._attributes.v] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialABIPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialABIPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialABIPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialABIPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.AbiPy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialABIPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialABIPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialABIPyDatabase(node) try: compute_function = getattr(OgnTutorialABIPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialABIPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialABIPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialABIPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialABIPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialABIPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialABIPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialABIPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialABIPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialABIPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: ABI Overrides") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials,tutorial:abiPy") node_type.set_metadata(ogn.MetadataKeys.CATEGORY_DESCRIPTIONS, "tutorial:abiPy,Tutorial nodes that override the Python ABI functions") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This tutorial node shows how to override ABI methods on your Python node. The algorithm of the node converts an RGB color into HSV components.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.AbiPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialABIPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialABIPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialABIPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialABIPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.AbiPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialGenericMathNodeDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.GenericMathNode This is a tutorial node. It is functionally equivalent to the built-in Multiply node, but written in python as a practical demonstration of using extended attributes to write math nodes that work with any numeric types, including arrays and tuples. """ from typing import Any import carb import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialGenericMathNodeDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.GenericMathNode Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.b Outputs: outputs.product """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],frame[4],frame[4][],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],int,int64,int64[],int[2],int[2][],int[3],int[3][],int[4],int[4][],int[],matrixd[3],matrixd[3][],matrixd[4],matrixd[4][],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],transform[4],transform[4][],uchar,uchar[],uint,uint64,uint64[],uint[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'A', 'First number to multiply', {}, True, None, False, ''), ('inputs:b', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],frame[4],frame[4][],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],int,int64,int64[],int[2],int[2][],int[3],int[3][],int[4],int[4][],int[],matrixd[3],matrixd[3][],matrixd[4],matrixd[4][],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],transform[4],transform[4][],uchar,uchar[],uint,uint64,uint64[],uint[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'B', 'Second number to multiply', {}, True, None, False, ''), ('outputs:product', 'colord[3],colord[3][],colord[4],colord[4][],colorf[3],colorf[3][],colorf[4],colorf[4][],colorh[3],colorh[3][],colorh[4],colorh[4][],double,double[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],frame[4],frame[4][],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],int,int64,int64[],int[2],int[2][],int[3],int[3][],int[4],int[4][],int[],matrixd[3],matrixd[3][],matrixd[4],matrixd[4][],normald[3],normald[3][],normalf[3],normalf[3][],normalh[3],normalh[3][],pointd[3],pointd[3][],pointf[3],pointf[3][],pointh[3],pointh[3][],quatd[4],quatd[4][],quatf[4],quatf[4][],quath[4],quath[4][],texcoordd[2],texcoordd[2][],texcoordd[3],texcoordd[3][],texcoordf[2],texcoordf[2][],texcoordf[3],texcoordf[3][],texcoordh[2],texcoordh[2][],texcoordh[3],texcoordh[3][],timecode,timecode[],transform[4],transform[4][],uchar,uchar[],uint,uint64,uint64[],uint[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Product', 'Product of the two numbers', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.a""" return og.RuntimeAttribute(self._attributes.a.get_attribute_data(), self._context, True) @a.setter def a(self, value_to_set: Any): """Assign another attribute's value to outputs.a""" if isinstance(value_to_set, og.RuntimeAttribute): self.a.value = value_to_set.value else: self.a.value = value_to_set @property def b(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.b""" return og.RuntimeAttribute(self._attributes.b.get_attribute_data(), self._context, True) @b.setter def b(self, value_to_set: Any): """Assign another attribute's value to outputs.b""" if isinstance(value_to_set, og.RuntimeAttribute): self.b.value = value_to_set.value else: self.b.value = value_to_set def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def product(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.product""" return og.RuntimeAttribute(self._attributes.product.get_attribute_data(), self._context, False) @product.setter def product(self, value_to_set: Any): """Assign another attribute's value to outputs.product""" if isinstance(value_to_set, og.RuntimeAttribute): self.product.value = value_to_set.value else: self.product.value = value_to_set def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialGenericMathNodeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialGenericMathNodeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialGenericMathNodeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.GenericMathNode' @staticmethod def compute(context, node): def database_valid(): if db.inputs.a.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:a is not resolved, compute skipped') return False if db.inputs.b.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:b is not resolved, compute skipped') return False if db.outputs.product.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute outputs:product is not resolved, compute skipped') return False return True try: per_node_data = OgnTutorialGenericMathNodeDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialGenericMathNodeDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialGenericMathNodeDatabase(node) try: compute_function = getattr(OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialGenericMathNodeDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialGenericMathNodeDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialGenericMathNodeDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialGenericMathNodeDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Generic Math Node") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It is functionally equivalent to the built-in Multiply node, but written in python as a practical demonstration of using extended attributes to write math nodes that work with any numeric types, including arrays and tuples.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.GenericMathNode.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialGenericMathNodeDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialGenericMathNodeDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialGenericMathNodeDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.GenericMathNode")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialTupleDataDatabase.py
"""Support for simplified access to data on nodes of type omni.tutorials.TupleData This is a tutorial node. It creates both an input and output attribute of some of the supported tuple types. The values are modified in a simple way so that the compute can be tested. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialTupleDataDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.tutorials.TupleData Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a_double2 inputs.a_double3 inputs.a_float2 inputs.a_float3 inputs.a_half2 inputs.a_int2 Outputs: outputs.a_double2 outputs.a_double3 outputs.a_float2 outputs.a_float3 outputs.a_half2 outputs.a_int2 """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a_double2', 'double2', 0, None, 'This is an attribute with two double values', {ogn.MetadataKeys.DEFAULT: '[1.1, 2.2]'}, True, [1.1, 2.2], False, ''), ('inputs:a_double3', 'double3', 0, None, 'This is an attribute with three double values', {ogn.MetadataKeys.DEFAULT: '[1.1, 2.2, 3.3]'}, True, [1.1, 2.2, 3.3], False, ''), ('inputs:a_float2', 'float2', 0, None, 'This is an attribute with two float values', {ogn.MetadataKeys.DEFAULT: '[4.4, 5.5]'}, True, [4.4, 5.5], False, ''), ('inputs:a_float3', 'float3', 0, None, 'This is an attribute with three float values', {ogn.MetadataKeys.DEFAULT: '[6.6, 7.7, 8.8]'}, True, [6.6, 7.7, 8.8], False, ''), ('inputs:a_half2', 'half2', 0, None, 'This is an attribute with two 16-bit float values', {ogn.MetadataKeys.DEFAULT: '[7.0, 8.0]'}, True, [7.0, 8.0], False, ''), ('inputs:a_int2', 'int2', 0, None, 'This is an attribute with two 32-bit integer values', {ogn.MetadataKeys.DEFAULT: '[10, 11]'}, True, [10, 11], False, ''), ('outputs:a_double2', 'double2', 0, None, 'This is a computed attribute with two double values', {}, True, None, False, ''), ('outputs:a_double3', 'double3', 0, None, 'This is a computed attribute with three double values', {}, True, None, False, ''), ('outputs:a_float2', 'float2', 0, None, 'This is a computed attribute with two float values', {}, True, None, False, ''), ('outputs:a_float3', 'float3', 0, None, 'This is a computed attribute with three float values', {}, True, None, False, ''), ('outputs:a_half2', 'half2', 0, None, 'This is a computed attribute with two 16-bit float values', {}, True, None, False, ''), ('outputs:a_int2', 'int2', 0, None, 'This is a computed attribute with two 32-bit integer values', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a_double2(self): data_view = og.AttributeValueHelper(self._attributes.a_double2) return data_view.get() @a_double2.setter def a_double2(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_double2) data_view = og.AttributeValueHelper(self._attributes.a_double2) data_view.set(value) @property def a_double3(self): data_view = og.AttributeValueHelper(self._attributes.a_double3) return data_view.get() @a_double3.setter def a_double3(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_double3) data_view = og.AttributeValueHelper(self._attributes.a_double3) data_view.set(value) @property def a_float2(self): data_view = og.AttributeValueHelper(self._attributes.a_float2) return data_view.get() @a_float2.setter def a_float2(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_float2) data_view = og.AttributeValueHelper(self._attributes.a_float2) data_view.set(value) @property def a_float3(self): data_view = og.AttributeValueHelper(self._attributes.a_float3) return data_view.get() @a_float3.setter def a_float3(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_float3) data_view = og.AttributeValueHelper(self._attributes.a_float3) data_view.set(value) @property def a_half2(self): data_view = og.AttributeValueHelper(self._attributes.a_half2) return data_view.get() @a_half2.setter def a_half2(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_half2) data_view = og.AttributeValueHelper(self._attributes.a_half2) data_view.set(value) @property def a_int2(self): data_view = og.AttributeValueHelper(self._attributes.a_int2) return data_view.get() @a_int2.setter def a_int2(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_int2) data_view = og.AttributeValueHelper(self._attributes.a_int2) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def a_double2(self): data_view = og.AttributeValueHelper(self._attributes.a_double2) return data_view.get() @a_double2.setter def a_double2(self, value): data_view = og.AttributeValueHelper(self._attributes.a_double2) data_view.set(value) @property def a_double3(self): data_view = og.AttributeValueHelper(self._attributes.a_double3) return data_view.get() @a_double3.setter def a_double3(self, value): data_view = og.AttributeValueHelper(self._attributes.a_double3) data_view.set(value) @property def a_float2(self): data_view = og.AttributeValueHelper(self._attributes.a_float2) return data_view.get() @a_float2.setter def a_float2(self, value): data_view = og.AttributeValueHelper(self._attributes.a_float2) data_view.set(value) @property def a_float3(self): data_view = og.AttributeValueHelper(self._attributes.a_float3) return data_view.get() @a_float3.setter def a_float3(self, value): data_view = og.AttributeValueHelper(self._attributes.a_float3) data_view.set(value) @property def a_half2(self): data_view = og.AttributeValueHelper(self._attributes.a_half2) return data_view.get() @a_half2.setter def a_half2(self, value): data_view = og.AttributeValueHelper(self._attributes.a_half2) data_view.set(value) @property def a_int2(self): data_view = og.AttributeValueHelper(self._attributes.a_int2) return data_view.get() @a_int2.setter def a_int2(self, value): data_view = og.AttributeValueHelper(self._attributes.a_int2) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialTupleDataDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialTupleDataDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialTupleDataDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialVectorizedABIPassthroughDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.TutorialVectorizedABIPassThrough Simple passthrough node that copy its input to its output in a vectorized way """ import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialVectorizedABIPassthroughDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.TutorialVectorizedABIPassThrough Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.value Outputs: outputs.value """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:value', 'float', 0, None, 'input value', {}, True, 0.0, False, ''), ('outputs:value', 'float', 0, None, 'output value', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def value(self): data_view = og.AttributeValueHelper(self._attributes.value) return data_view.get() @value.setter def value(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.value) data_view = og.AttributeValueHelper(self._attributes.value) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def value(self): data_view = og.AttributeValueHelper(self._attributes.value) return data_view.get() @value.setter def value(self, value): data_view = og.AttributeValueHelper(self._attributes.value) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialVectorizedABIPassthroughDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialVectorizedABIPassthroughDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialVectorizedABIPassthroughDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialBundleDataPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.BundleDataPy This is a tutorial node. It exercises functionality for access of data within bundle attributes. The configuration is the same as omni.graph.tutorials.BundleData except that the implementation language is Python """ import carb import sys import traceback import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialBundleDataPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.BundleDataPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.bundle Outputs: outputs.bundle """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:bundle', 'bundle', 0, 'Input Bundle', 'Bundle whose contents are modified for passing to the output', {}, True, None, False, ''), ('outputs:bundle', 'bundle', 0, 'Output Bundle', 'This is the bundle with values of known types doubled.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.bundle = og.AttributeRole.BUNDLE role_data.outputs.bundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.bundle""" return self.__bundles.bundle def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.bundle""" return self.__bundles.bundle @bundle.setter def bundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.bundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.bundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialBundleDataPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialBundleDataPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialBundleDataPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.BundleDataPy' @staticmethod def compute(context, node): def database_valid(): if not db.inputs.bundle.valid: db.log_warning('Required bundle inputs.bundle is invalid or not connected, compute skipped') return False if not db.outputs.bundle.valid: db.log_error('Required bundle outputs.bundle is invalid, compute skipped') return False return True try: per_node_data = OgnTutorialBundleDataPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialBundleDataPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialBundleDataPyDatabase(node) try: compute_function = getattr(OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialBundleDataPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialBundleDataPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialBundleDataPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialBundleDataPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Bundle Data") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It exercises functionality for access of data within bundle attributes. The configuration is the same as omni.graph.tutorials.BundleData except that the implementation language is Python") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.BundleDataPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialBundleDataPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialBundleDataPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialBundleDataPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.BundleDataPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialExtendedTypesPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.ExtendedTypesPy This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types. It is identical to OgnTutorialExtendedTypes.ogn, except the language of implementation is selected to be python. """ from typing import Any import carb import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialExtendedTypesPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.ExtendedTypesPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.flexible inputs.floatOrToken inputs.toNegate inputs.tuple Outputs: outputs.doubledResult outputs.flexible outputs.negatedResult outputs.tuple """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:flexible', 'float[3][],token', 1, 'Flexible Values', 'Flexible data type input', {}, True, None, False, ''), ('inputs:floatOrToken', 'float,token', 1, 'Float Or Token', 'Attribute that can either be a float value or a token value', {}, True, None, False, ''), ('inputs:toNegate', 'bool[],float[]', 1, 'To Negate', 'Attribute that can either be an array of booleans or an array of floats', {}, True, None, False, ''), ('inputs:tuple', 'any', 2, 'Tuple Values', 'Variable size/type tuple values', {}, True, None, False, ''), ('outputs:doubledResult', 'any', 2, 'Doubled Input Value', "If the input 'floatOrToken' is a float this is 2x the value.\nIf it is a token this contains the input token repeated twice.", {}, True, None, False, ''), ('outputs:flexible', 'float[3][],token', 1, 'Inverted Flexible Values', 'Flexible data type output', {}, True, None, False, ''), ('outputs:negatedResult', 'bool[],float[]', 1, 'Negated Array Values', "Result of negating the data from the 'toNegate' input", {}, True, None, False, ''), ('outputs:tuple', 'any', 2, 'Negative Tuple Values', 'Negated values of the tuple input', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def flexible(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.flexible""" return og.RuntimeAttribute(self._attributes.flexible.get_attribute_data(), self._context, True) @flexible.setter def flexible(self, value_to_set: Any): """Assign another attribute's value to outputs.flexible""" if isinstance(value_to_set, og.RuntimeAttribute): self.flexible.value = value_to_set.value else: self.flexible.value = value_to_set @property def floatOrToken(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.floatOrToken""" return og.RuntimeAttribute(self._attributes.floatOrToken.get_attribute_data(), self._context, True) @floatOrToken.setter def floatOrToken(self, value_to_set: Any): """Assign another attribute's value to outputs.floatOrToken""" if isinstance(value_to_set, og.RuntimeAttribute): self.floatOrToken.value = value_to_set.value else: self.floatOrToken.value = value_to_set @property def toNegate(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.toNegate""" return og.RuntimeAttribute(self._attributes.toNegate.get_attribute_data(), self._context, True) @toNegate.setter def toNegate(self, value_to_set: Any): """Assign another attribute's value to outputs.toNegate""" if isinstance(value_to_set, og.RuntimeAttribute): self.toNegate.value = value_to_set.value else: self.toNegate.value = value_to_set @property def tuple(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.tuple""" return og.RuntimeAttribute(self._attributes.tuple.get_attribute_data(), self._context, True) @tuple.setter def tuple(self, value_to_set: Any): """Assign another attribute's value to outputs.tuple""" if isinstance(value_to_set, og.RuntimeAttribute): self.tuple.value = value_to_set.value else: self.tuple.value = value_to_set def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def doubledResult(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.doubledResult""" return og.RuntimeAttribute(self._attributes.doubledResult.get_attribute_data(), self._context, False) @doubledResult.setter def doubledResult(self, value_to_set: Any): """Assign another attribute's value to outputs.doubledResult""" if isinstance(value_to_set, og.RuntimeAttribute): self.doubledResult.value = value_to_set.value else: self.doubledResult.value = value_to_set @property def flexible(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.flexible""" return og.RuntimeAttribute(self._attributes.flexible.get_attribute_data(), self._context, False) @flexible.setter def flexible(self, value_to_set: Any): """Assign another attribute's value to outputs.flexible""" if isinstance(value_to_set, og.RuntimeAttribute): self.flexible.value = value_to_set.value else: self.flexible.value = value_to_set @property def negatedResult(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.negatedResult""" return og.RuntimeAttribute(self._attributes.negatedResult.get_attribute_data(), self._context, False) @negatedResult.setter def negatedResult(self, value_to_set: Any): """Assign another attribute's value to outputs.negatedResult""" if isinstance(value_to_set, og.RuntimeAttribute): self.negatedResult.value = value_to_set.value else: self.negatedResult.value = value_to_set @property def tuple(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.tuple""" return og.RuntimeAttribute(self._attributes.tuple.get_attribute_data(), self._context, False) @tuple.setter def tuple(self, value_to_set: Any): """Assign another attribute's value to outputs.tuple""" if isinstance(value_to_set, og.RuntimeAttribute): self.tuple.value = value_to_set.value else: self.tuple.value = value_to_set def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialExtendedTypesPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialExtendedTypesPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialExtendedTypesPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.ExtendedTypesPy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialExtendedTypesPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialExtendedTypesPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialExtendedTypesPyDatabase(node) try: compute_function = getattr(OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialExtendedTypesPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialExtendedTypesPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialExtendedTypesPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialExtendedTypesPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Extended Attribute Types") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types. It is identical to OgnTutorialExtendedTypes.ogn, except the language of implementation is selected to be python.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.ExtendedTypesPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialExtendedTypesPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialExtendedTypesPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialExtendedTypesPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.ExtendedTypesPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCpuGpuExtendedDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CpuGpuExtended This is a tutorial node. It exercises functionality for accessing data in extended attributes that are on the GPU as well as those whose CPU/GPU location is decided at runtime. The compute adds the two inputs 'gpuData' and 'cpuData' together, placing the result in `cpuGpuSum`, whose memory location is determined by the 'gpu' flag. This node is identical to OgnTutorialCpuGpuExtendedPy.ogn, except is is implemented in C++. """ from typing import Any import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCpuGpuExtendedDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CpuGpuExtended Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.cpuData inputs.gpu inputs.gpuData Outputs: outputs.cpuGpuSum """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:cpuData', 'any', 2, 'CPU Input Attribute', 'Input attribute whose data always lives on the CPU', {}, True, None, False, ''), ('inputs:gpu', 'bool', 0, 'Results To GPU', 'If true then put the sum on the GPU, otherwise put it on the CPU', {}, True, False, False, ''), ('inputs:gpuData', 'any', 2, 'GPU Input Attribute', 'Input attribute whose data always lives on the GPU', {ogn.MetadataKeys.MEMORY_TYPE: 'cuda'}, True, None, False, ''), ('outputs:cpuGpuSum', 'any', 2, 'Sum', "This is the attribute with the selected data. If the 'gpu' attribute is set to true then this\nattribute's contents will be entirely on the GPU, otherwise it will be on the CPU.", {ogn.MetadataKeys.MEMORY_TYPE: 'any'}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def cpuData(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.cpuData""" return og.RuntimeAttribute(self._attributes.cpuData.get_attribute_data(), self._context, True) @cpuData.setter def cpuData(self, value_to_set: Any): """Assign another attribute's value to outputs.cpuData""" if isinstance(value_to_set, og.RuntimeAttribute): self.cpuData.value = value_to_set.value else: self.cpuData.value = value_to_set @property def gpu(self): data_view = og.AttributeValueHelper(self._attributes.gpu) return data_view.get() @gpu.setter def gpu(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gpu) data_view = og.AttributeValueHelper(self._attributes.gpu) data_view.set(value) @property def gpuData(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.gpuData""" return og.RuntimeAttribute(self._attributes.gpuData.get_attribute_data(), self._context, True) @gpuData.setter def gpuData(self, value_to_set: Any): """Assign another attribute's value to outputs.gpuData""" if isinstance(value_to_set, og.RuntimeAttribute): self.gpuData.value = value_to_set.value else: self.gpuData.value = value_to_set def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def cpuGpuSum(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.cpuGpuSum""" return og.RuntimeAttribute(self._attributes.cpuGpuSum.get_attribute_data(), self._context, False) @cpuGpuSum.setter def cpuGpuSum(self, value_to_set: Any): """Assign another attribute's value to outputs.cpuGpuSum""" if isinstance(value_to_set, og.RuntimeAttribute): self.cpuGpuSum.value = value_to_set.value else: self.cpuGpuSum.value = value_to_set def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCpuGpuExtendedDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCpuGpuExtendedDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCpuGpuExtendedDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialSimpleDataDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.SimpleData This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values. """ import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialSimpleDataDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.SimpleData Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a_bool inputs.a_constant_input inputs.a_double inputs.a_float inputs.a_half inputs.a_int inputs.a_int64 inputs.a_objectId inputs.a_path inputs.a_string inputs.a_token inputs.unsigned_a_uchar inputs.unsigned_a_uint inputs.unsigned_a_uint64 Outputs: outputs.a_bool outputs.a_double outputs.a_float outputs.a_half outputs.a_int outputs.a_int64 outputs.a_objectId outputs.a_path outputs.a_string outputs.a_token outputs.unsigned_a_uchar outputs.unsigned_a_uint outputs.unsigned_a_uint64 """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a_bool', 'bool', 0, 'Sample Boolean Input', 'This is an attribute of type boolean', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:a_constant_input', 'int', 0, None, 'This is an input attribute whose value can be set but can only be connected as a source.', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, 0, False, ''), ('inputs:a_double', 'double', 0, None, 'This is an attribute of type 64 bit floating point', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_float', 'float', 0, None, 'This is an attribute of type 32 bit floating point', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_half', 'half', 0, 'Sample Half Precision Input', 'This is an attribute of type 16 bit float', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''), ('inputs:a_int', 'int', 0, None, 'This is an attribute of type 32 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_int64', 'int64', 0, None, 'This is an attribute of type 64 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_objectId', 'objectId', 0, None, 'This is an attribute of type objectId', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_path', 'path', 0, None, 'This is an attribute of type path', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:a_string', 'string', 0, None, 'This is an attribute of type string', {ogn.MetadataKeys.DEFAULT: '"helloString"'}, True, "helloString", False, ''), ('inputs:a_token', 'token', 0, None, 'This is an attribute of type interned string with fast comparison and hashing', {ogn.MetadataKeys.DEFAULT: '"helloToken"'}, True, "helloToken", False, ''), ('inputs:unsigned:a_uchar', 'uchar', 0, None, 'This is an attribute of type unsigned 8 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:unsigned:a_uint', 'uint', 0, None, 'This is an attribute of type unsigned 32 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:unsigned:a_uint64', 'uint64', 0, None, 'This is an attribute of type unsigned 64 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('outputs:a_bool', 'bool', 0, 'Sample Boolean Output', 'This is a computed attribute of type boolean', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('outputs:a_double', 'double', 0, None, 'This is a computed attribute of type 64 bit floating point', {ogn.MetadataKeys.DEFAULT: '5.0'}, True, 5.0, False, ''), ('outputs:a_float', 'float', 0, None, 'This is a computed attribute of type 32 bit floating point', {ogn.MetadataKeys.DEFAULT: '4.0'}, True, 4.0, False, ''), ('outputs:a_half', 'half', 0, 'Sample Half Precision Output', 'This is a computed attribute of type 16 bit float', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('outputs:a_int', 'int', 0, None, 'This is a computed attribute of type 32 bit integer', {ogn.MetadataKeys.DEFAULT: '2'}, True, 2, False, ''), ('outputs:a_int64', 'int64', 0, None, 'This is a computed attribute of type 64 bit integer', {ogn.MetadataKeys.DEFAULT: '3'}, True, 3, False, ''), ('outputs:a_objectId', 'objectId', 0, None, 'This is a computed attribute of type objectId', {ogn.MetadataKeys.DEFAULT: '8'}, True, 8, False, ''), ('outputs:a_path', 'path', 0, None, 'This is a computed attribute of type path', {ogn.MetadataKeys.DEFAULT: '"/"'}, True, "/", False, ''), ('outputs:a_string', 'string', 0, None, 'This is a computed attribute of type string', {ogn.MetadataKeys.DEFAULT: '"seven"'}, True, "seven", False, ''), ('outputs:a_token', 'token', 0, None, 'This is a computed attribute of type interned string with fast comparison and hashing', {ogn.MetadataKeys.DEFAULT: '"six"'}, True, "six", False, ''), ('outputs:unsigned:a_uchar', 'uchar', 0, None, 'This is a computed attribute of type unsigned 8 bit integer', {ogn.MetadataKeys.DEFAULT: '9'}, True, 9, False, ''), ('outputs:unsigned:a_uint', 'uint', 0, None, 'This is a computed attribute of type unsigned 32 bit integer', {ogn.MetadataKeys.DEFAULT: '10'}, True, 10, False, ''), ('outputs:unsigned:a_uint64', 'uint64', 0, None, 'This is a computed attribute of type unsigned 64 bit integer', {ogn.MetadataKeys.DEFAULT: '11'}, True, 11, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.a_objectId = og.AttributeRole.OBJECT_ID role_data.inputs.a_path = og.AttributeRole.PATH role_data.inputs.a_string = og.AttributeRole.TEXT role_data.outputs.a_objectId = og.AttributeRole.OBJECT_ID role_data.outputs.a_path = og.AttributeRole.PATH role_data.outputs.a_string = og.AttributeRole.TEXT return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a_bool(self): data_view = og.AttributeValueHelper(self._attributes.a_bool) return data_view.get() @a_bool.setter def a_bool(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_bool) data_view = og.AttributeValueHelper(self._attributes.a_bool) data_view.set(value) @property def a_constant_input(self): data_view = og.AttributeValueHelper(self._attributes.a_constant_input) return data_view.get() @a_constant_input.setter def a_constant_input(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_constant_input) data_view = og.AttributeValueHelper(self._attributes.a_constant_input) data_view.set(value) @property def a_double(self): data_view = og.AttributeValueHelper(self._attributes.a_double) return data_view.get() @a_double.setter def a_double(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_double) data_view = og.AttributeValueHelper(self._attributes.a_double) data_view.set(value) @property def a_float(self): data_view = og.AttributeValueHelper(self._attributes.a_float) return data_view.get() @a_float.setter def a_float(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_float) data_view = og.AttributeValueHelper(self._attributes.a_float) data_view.set(value) @property def a_half(self): data_view = og.AttributeValueHelper(self._attributes.a_half) return data_view.get() @a_half.setter def a_half(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_half) data_view = og.AttributeValueHelper(self._attributes.a_half) data_view.set(value) @property def a_int(self): data_view = og.AttributeValueHelper(self._attributes.a_int) return data_view.get() @a_int.setter def a_int(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_int) data_view = og.AttributeValueHelper(self._attributes.a_int) data_view.set(value) @property def a_int64(self): data_view = og.AttributeValueHelper(self._attributes.a_int64) return data_view.get() @a_int64.setter def a_int64(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_int64) data_view = og.AttributeValueHelper(self._attributes.a_int64) data_view.set(value) @property def a_objectId(self): data_view = og.AttributeValueHelper(self._attributes.a_objectId) return data_view.get() @a_objectId.setter def a_objectId(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_objectId) data_view = og.AttributeValueHelper(self._attributes.a_objectId) data_view.set(value) @property def a_path(self): data_view = og.AttributeValueHelper(self._attributes.a_path) return data_view.get() @a_path.setter def a_path(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_path) data_view = og.AttributeValueHelper(self._attributes.a_path) data_view.set(value) self.a_path_size = data_view.get_array_size() @property def a_string(self): data_view = og.AttributeValueHelper(self._attributes.a_string) return data_view.get() @a_string.setter def a_string(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_string) data_view = og.AttributeValueHelper(self._attributes.a_string) data_view.set(value) self.a_string_size = data_view.get_array_size() @property def a_token(self): data_view = og.AttributeValueHelper(self._attributes.a_token) return data_view.get() @a_token.setter def a_token(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a_token) data_view = og.AttributeValueHelper(self._attributes.a_token) data_view.set(value) @property def unsigned_a_uchar(self): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uchar) return data_view.get() @unsigned_a_uchar.setter def unsigned_a_uchar(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.unsigned_a_uchar) data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uchar) data_view.set(value) @property def unsigned_a_uint(self): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint) return data_view.get() @unsigned_a_uint.setter def unsigned_a_uint(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.unsigned_a_uint) data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint) data_view.set(value) @property def unsigned_a_uint64(self): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint64) return data_view.get() @unsigned_a_uint64.setter def unsigned_a_uint64(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.unsigned_a_uint64) data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint64) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.a_path_size = 1 self.a_string_size = 5 self._batchedWriteValues = { } @property def a_bool(self): data_view = og.AttributeValueHelper(self._attributes.a_bool) return data_view.get() @a_bool.setter def a_bool(self, value): data_view = og.AttributeValueHelper(self._attributes.a_bool) data_view.set(value) @property def a_double(self): data_view = og.AttributeValueHelper(self._attributes.a_double) return data_view.get() @a_double.setter def a_double(self, value): data_view = og.AttributeValueHelper(self._attributes.a_double) data_view.set(value) @property def a_float(self): data_view = og.AttributeValueHelper(self._attributes.a_float) return data_view.get() @a_float.setter def a_float(self, value): data_view = og.AttributeValueHelper(self._attributes.a_float) data_view.set(value) @property def a_half(self): data_view = og.AttributeValueHelper(self._attributes.a_half) return data_view.get() @a_half.setter def a_half(self, value): data_view = og.AttributeValueHelper(self._attributes.a_half) data_view.set(value) @property def a_int(self): data_view = og.AttributeValueHelper(self._attributes.a_int) return data_view.get() @a_int.setter def a_int(self, value): data_view = og.AttributeValueHelper(self._attributes.a_int) data_view.set(value) @property def a_int64(self): data_view = og.AttributeValueHelper(self._attributes.a_int64) return data_view.get() @a_int64.setter def a_int64(self, value): data_view = og.AttributeValueHelper(self._attributes.a_int64) data_view.set(value) @property def a_objectId(self): data_view = og.AttributeValueHelper(self._attributes.a_objectId) return data_view.get() @a_objectId.setter def a_objectId(self, value): data_view = og.AttributeValueHelper(self._attributes.a_objectId) data_view.set(value) @property def a_path(self): data_view = og.AttributeValueHelper(self._attributes.a_path) return data_view.get(reserved_element_count=self.a_path_size) @a_path.setter def a_path(self, value): data_view = og.AttributeValueHelper(self._attributes.a_path) data_view.set(value) self.a_path_size = data_view.get_array_size() @property def a_string(self): data_view = og.AttributeValueHelper(self._attributes.a_string) return data_view.get(reserved_element_count=self.a_string_size) @a_string.setter def a_string(self, value): data_view = og.AttributeValueHelper(self._attributes.a_string) data_view.set(value) self.a_string_size = data_view.get_array_size() @property def a_token(self): data_view = og.AttributeValueHelper(self._attributes.a_token) return data_view.get() @a_token.setter def a_token(self, value): data_view = og.AttributeValueHelper(self._attributes.a_token) data_view.set(value) @property def unsigned_a_uchar(self): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uchar) return data_view.get() @unsigned_a_uchar.setter def unsigned_a_uchar(self, value): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uchar) data_view.set(value) @property def unsigned_a_uint(self): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint) return data_view.get() @unsigned_a_uint.setter def unsigned_a_uint(self, value): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint) data_view.set(value) @property def unsigned_a_uint64(self): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint64) return data_view.get() @unsigned_a_uint64.setter def unsigned_a_uint64(self, value): data_view = og.AttributeValueHelper(self._attributes.unsigned_a_uint64) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialSimpleDataDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialSimpleDataDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialSimpleDataDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialExtendedTypesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.ExtendedTypes This is a tutorial node. It exercises functionality for the manipulation of the extended attribute types. """ from typing import Any import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialExtendedTypesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.ExtendedTypes Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.flexible inputs.floatOrToken inputs.toNegate inputs.tuple Outputs: outputs.doubledResult outputs.flexible outputs.negatedResult outputs.tuple """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:flexible', 'float[3][],token', 1, 'Flexible Values', 'Flexible data type input', {}, True, None, False, ''), ('inputs:floatOrToken', 'float,token', 1, 'Float Or Token', 'Attribute that can either be a float value or a token value', {}, True, None, False, ''), ('inputs:toNegate', 'bool[],float[]', 1, 'To Negate', 'Attribute that can either be an array of booleans or an array of floats', {}, True, None, False, ''), ('inputs:tuple', 'any', 2, 'Tuple Values', 'Variable size/type tuple values', {}, True, None, False, ''), ('outputs:doubledResult', 'any', 2, 'Doubled Input Value', "If the input 'simpleInput' is a float this is 2x the value.\nIf it is a token this contains the input token repeated twice.", {}, True, None, False, ''), ('outputs:flexible', 'float[3][],token', 1, 'Inverted Flexible Values', 'Flexible data type output', {}, True, None, False, ''), ('outputs:negatedResult', 'bool[],float[]', 1, 'Negated Array Values', "Result of negating the data from the 'toNegate' input", {}, True, None, False, ''), ('outputs:tuple', 'any', 2, 'Negative Tuple Values', 'Negated values of the tuple input', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def flexible(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.flexible""" return og.RuntimeAttribute(self._attributes.flexible.get_attribute_data(), self._context, True) @flexible.setter def flexible(self, value_to_set: Any): """Assign another attribute's value to outputs.flexible""" if isinstance(value_to_set, og.RuntimeAttribute): self.flexible.value = value_to_set.value else: self.flexible.value = value_to_set @property def floatOrToken(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.floatOrToken""" return og.RuntimeAttribute(self._attributes.floatOrToken.get_attribute_data(), self._context, True) @floatOrToken.setter def floatOrToken(self, value_to_set: Any): """Assign another attribute's value to outputs.floatOrToken""" if isinstance(value_to_set, og.RuntimeAttribute): self.floatOrToken.value = value_to_set.value else: self.floatOrToken.value = value_to_set @property def toNegate(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.toNegate""" return og.RuntimeAttribute(self._attributes.toNegate.get_attribute_data(), self._context, True) @toNegate.setter def toNegate(self, value_to_set: Any): """Assign another attribute's value to outputs.toNegate""" if isinstance(value_to_set, og.RuntimeAttribute): self.toNegate.value = value_to_set.value else: self.toNegate.value = value_to_set @property def tuple(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.tuple""" return og.RuntimeAttribute(self._attributes.tuple.get_attribute_data(), self._context, True) @tuple.setter def tuple(self, value_to_set: Any): """Assign another attribute's value to outputs.tuple""" if isinstance(value_to_set, og.RuntimeAttribute): self.tuple.value = value_to_set.value else: self.tuple.value = value_to_set def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def doubledResult(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.doubledResult""" return og.RuntimeAttribute(self._attributes.doubledResult.get_attribute_data(), self._context, False) @doubledResult.setter def doubledResult(self, value_to_set: Any): """Assign another attribute's value to outputs.doubledResult""" if isinstance(value_to_set, og.RuntimeAttribute): self.doubledResult.value = value_to_set.value else: self.doubledResult.value = value_to_set @property def flexible(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.flexible""" return og.RuntimeAttribute(self._attributes.flexible.get_attribute_data(), self._context, False) @flexible.setter def flexible(self, value_to_set: Any): """Assign another attribute's value to outputs.flexible""" if isinstance(value_to_set, og.RuntimeAttribute): self.flexible.value = value_to_set.value else: self.flexible.value = value_to_set @property def negatedResult(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.negatedResult""" return og.RuntimeAttribute(self._attributes.negatedResult.get_attribute_data(), self._context, False) @negatedResult.setter def negatedResult(self, value_to_set: Any): """Assign another attribute's value to outputs.negatedResult""" if isinstance(value_to_set, og.RuntimeAttribute): self.negatedResult.value = value_to_set.value else: self.negatedResult.value = value_to_set @property def tuple(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.tuple""" return og.RuntimeAttribute(self._attributes.tuple.get_attribute_data(), self._context, False) @tuple.setter def tuple(self, value_to_set: Any): """Assign another attribute's value to outputs.tuple""" if isinstance(value_to_set, og.RuntimeAttribute): self.tuple.value = value_to_set.value else: self.tuple.value = value_to_set def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialExtendedTypesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialExtendedTypesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialExtendedTypesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialSIMDAddDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.TutorialSIMDFloatAdd Add 2 floats together using SIMD instruction set """ import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialSIMDAddDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.TutorialSIMDFloatAdd Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.b Outputs: outputs.result """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a', 'float', 0, None, 'first input operand', {}, True, 0.0, False, ''), ('inputs:b', 'float', 0, None, 'second input operand', {}, True, 0.0, False, ''), ('outputs:result', 'float', 0, None, 'the sum of a and b', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def a(self): data_view = og.AttributeValueHelper(self._attributes.a) return data_view.get() @a.setter def a(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.a) data_view = og.AttributeValueHelper(self._attributes.a) data_view.set(value) @property def b(self): data_view = og.AttributeValueHelper(self._attributes.b) return data_view.get() @b.setter def b(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.b) data_view = og.AttributeValueHelper(self._attributes.b) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def result(self): data_view = og.AttributeValueHelper(self._attributes.result) return data_view.get() @result.setter def result(self, value): data_view = og.AttributeValueHelper(self._attributes.result) data_view.set(value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialSIMDAddDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialSIMDAddDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialSIMDAddDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialBundleAddAttributesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.BundleAddAttributes This is a tutorial node. It exercises functionality for adding and removing attributes on output bundles. """ import carb import numpy import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialBundleAddAttributesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.BundleAddAttributes Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.addedAttributeNames inputs.removedAttributeNames inputs.typesToAdd inputs.useBatchedAPI Outputs: outputs.bundle """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:addedAttributeNames', 'token[]', 0, None, "Names for the attribute types to be added. The size of this array must match the size\nof the 'typesToAdd' array to be legal.", {}, True, [], False, ''), ('inputs:removedAttributeNames', 'token[]', 0, None, 'Names for the attribute types to be removed. Non-existent attributes will be ignored.', {}, True, [], False, ''), ('inputs:typesToAdd', 'token[]', 0, 'Attribute Types To Add', 'List of type descriptions to add to the bundle. The strings in this list correspond to the\nstrings that represent the attribute types in the .ogn file (e.g. float[3][], colord[3], bool', {}, True, [], False, ''), ('inputs:useBatchedAPI', 'bool', 0, None, 'Controls whether or not to used batched APIS for adding/removing attributes', {}, True, False, False, ''), ('outputs:bundle', 'bundle', 0, 'Constructed Bundle', 'This is the bundle with all attributes added by compute.', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.outputs.bundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def addedAttributeNames(self): data_view = og.AttributeValueHelper(self._attributes.addedAttributeNames) return data_view.get() @addedAttributeNames.setter def addedAttributeNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.addedAttributeNames) data_view = og.AttributeValueHelper(self._attributes.addedAttributeNames) data_view.set(value) self.addedAttributeNames_size = data_view.get_array_size() @property def removedAttributeNames(self): data_view = og.AttributeValueHelper(self._attributes.removedAttributeNames) return data_view.get() @removedAttributeNames.setter def removedAttributeNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.removedAttributeNames) data_view = og.AttributeValueHelper(self._attributes.removedAttributeNames) data_view.set(value) self.removedAttributeNames_size = data_view.get_array_size() @property def typesToAdd(self): data_view = og.AttributeValueHelper(self._attributes.typesToAdd) return data_view.get() @typesToAdd.setter def typesToAdd(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.typesToAdd) data_view = og.AttributeValueHelper(self._attributes.typesToAdd) data_view.set(value) self.typesToAdd_size = data_view.get_array_size() @property def useBatchedAPI(self): data_view = og.AttributeValueHelper(self._attributes.useBatchedAPI) return data_view.get() @useBatchedAPI.setter def useBatchedAPI(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useBatchedAPI) data_view = og.AttributeValueHelper(self._attributes.useBatchedAPI) data_view.set(value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, [], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def bundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.bundle""" return self.__bundles.bundle @bundle.setter def bundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.bundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.bundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialBundleAddAttributesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialBundleAddAttributesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialBundleAddAttributesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialStatePyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.StatePy This is a tutorial node. It makes use of internal state information to continuously increment an output. """ import carb import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialStatePyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.StatePy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.override inputs.overrideValue Outputs: outputs.monotonic """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:override', 'bool', 0, None, 'When true get the output from the overrideValue, otherwise use the internal value', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:overrideValue', 'int64', 0, None, "Value to use instead of the monotonically increasing internal one when 'override' is true", {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('outputs:monotonic', 'int64', 0, None, 'Monotonically increasing output, set by internal state information', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"override", "overrideValue", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.override, self._attributes.overrideValue] self._batchedReadValues = [False, 0] @property def override(self): return self._batchedReadValues[0] @override.setter def override(self, value): self._batchedReadValues[0] = value @property def overrideValue(self): return self._batchedReadValues[1] @overrideValue.setter def overrideValue(self, value): self._batchedReadValues[1] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"monotonic", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedWriteValues = { } @property def monotonic(self): value = self._batchedWriteValues.get(self._attributes.monotonic) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.monotonic) return data_view.get() @monotonic.setter def monotonic(self, value): self._batchedWriteValues[self._attributes.monotonic] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialStatePyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialStatePyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialStatePyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialStatePyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.StatePy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialStatePyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialStatePyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialStatePyDatabase(node) try: compute_function = getattr(OgnTutorialStatePyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialStatePyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialStatePyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialStatePyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialStatePyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialStatePyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialStatePyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialStatePyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialStatePyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialStatePyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Internal States") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It makes use of internal state information to continuously increment an output.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.StatePy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialStatePyDatabase.INTERFACE.add_to_node_type(node_type) node_type.set_has_state(True) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialStatePyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialStatePyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialStatePyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.StatePy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialArrayDataDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.ArrayData This is a tutorial node. It will compute the array 'result' as the input array 'original' with every element multiplied by the constant 'multiplier'. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialArrayDataDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.ArrayData Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gates inputs.info inputs.multiplier inputs.original Outputs: outputs.infoSize outputs.negativeValues outputs.result """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:gates', 'bool[]', 0, None, 'Boolean mask telling which elements of the array should be multiplied', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('inputs:info', 'token[]', 0, None, 'List of strings providing commentary', {ogn.MetadataKeys.DEFAULT: '["There", "is", "no", "data"]'}, True, ['There', 'is', 'no', 'data'], False, ''), ('inputs:multiplier', 'float', 0, None, 'Multiplier of the array elements', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('inputs:original', 'float[]', 0, None, 'Array to be multiplied', {ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('outputs:infoSize', 'int', 0, None, 'Number of letters in all strings in the info input', {}, True, None, False, ''), ('outputs:negativeValues', 'bool[]', 0, None, "Array of booleans set to true if the corresponding 'result' is negative", {}, True, None, False, ''), ('outputs:result', 'float[]', 0, None, 'Multiplied array', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def gates(self): data_view = og.AttributeValueHelper(self._attributes.gates) return data_view.get() @gates.setter def gates(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gates) data_view = og.AttributeValueHelper(self._attributes.gates) data_view.set(value) self.gates_size = data_view.get_array_size() @property def info(self): data_view = og.AttributeValueHelper(self._attributes.info) return data_view.get() @info.setter def info(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.info) data_view = og.AttributeValueHelper(self._attributes.info) data_view.set(value) self.info_size = data_view.get_array_size() @property def multiplier(self): data_view = og.AttributeValueHelper(self._attributes.multiplier) return data_view.get() @multiplier.setter def multiplier(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.multiplier) data_view = og.AttributeValueHelper(self._attributes.multiplier) data_view.set(value) @property def original(self): data_view = og.AttributeValueHelper(self._attributes.original) return data_view.get() @original.setter def original(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.original) data_view = og.AttributeValueHelper(self._attributes.original) data_view.set(value) self.original_size = data_view.get_array_size() def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.negativeValues_size = None self.result_size = None self._batchedWriteValues = { } @property def infoSize(self): data_view = og.AttributeValueHelper(self._attributes.infoSize) return data_view.get() @infoSize.setter def infoSize(self, value): data_view = og.AttributeValueHelper(self._attributes.infoSize) data_view.set(value) @property def negativeValues(self): data_view = og.AttributeValueHelper(self._attributes.negativeValues) return data_view.get(reserved_element_count=self.negativeValues_size) @negativeValues.setter def negativeValues(self, value): data_view = og.AttributeValueHelper(self._attributes.negativeValues) data_view.set(value) self.negativeValues_size = data_view.get_array_size() @property def result(self): data_view = og.AttributeValueHelper(self._attributes.result) return data_view.get(reserved_element_count=self.result_size) @result.setter def result(self, value): data_view = og.AttributeValueHelper(self._attributes.result) data_view.set(value) self.result_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialArrayDataDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialArrayDataDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialArrayDataDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCpuGpuBundlesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CpuGpuBundles This is a tutorial node. It exercises functionality for accessing data in bundles that are on the GPU as well as bundles whose CPU/GPU location is decided at runtime. The compute looks for bundled attributes named 'points' and, if they are found, computes their dot products. If the bundle on the output contains an integer array type named 'dotProducts' then the results are placed there, otherwise a new attribute of that name and type is created on the output bundle to hold the results. This node is identical to OgnTutorialCpuGpuBundlesPy.ogn, except it is implemented in C++. """ import carb import carb import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCpuGpuBundlesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CpuGpuBundles Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.cpuBundle inputs.gpu inputs.gpuBundle Outputs: outputs.cpuGpuBundle Predefined Tokens: tokens.points tokens.dotProducts """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:cpuBundle', 'bundle', 0, 'CPU Input Bundle', 'Input bundle whose data always lives on the CPU', {}, True, None, False, ''), ('inputs:gpu', 'bool', 0, 'Results To GPU', 'If true then copy gpuBundle onto the output, otherwise copy cpuBundle', {}, True, False, False, ''), ('inputs:gpuBundle', 'bundle', 0, 'GPU Input Bundle', 'Input bundle whose data always lives on the GPU', {ogn.MetadataKeys.MEMORY_TYPE: 'cuda'}, True, None, False, ''), ('outputs:cpuGpuBundle', 'bundle', 0, 'Constructed Bundle', "This is the bundle with the merged data. If the 'gpu' attribute is set to true then this\nbundle's contents will be entirely on the GPU, otherwise they will be on the CPU.", {ogn.MetadataKeys.MEMORY_TYPE: 'any'}, True, None, False, ''), ]) class tokens: points = "points" dotProducts = "dotProducts" @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.cpuBundle = og.AttributeRole.BUNDLE role_data.inputs.gpuBundle = og.AttributeRole.BUNDLE role_data.outputs.cpuGpuBundle = og.AttributeRole.BUNDLE return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, ['inputs:gpuBundle'], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def cpuBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.cpuBundle""" return self.__bundles.cpuBundle @property def gpu(self): data_view = og.AttributeValueHelper(self._attributes.gpu) return data_view.get() @gpu.setter def gpu(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.gpu) data_view = og.AttributeValueHelper(self._attributes.gpu) data_view.set(value) @property def gpuBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.gpuBundle""" return self.__bundles.gpuBundle def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.__bundles = og.BundleContainer(context, node, attributes, ['outputs_cpuGpuBundle'], read_only=False, gpu_ptr_kinds={}) self._batchedWriteValues = { } @property def cpuGpuBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.cpuGpuBundle""" return self.__bundles.cpuGpuBundle @cpuGpuBundle.setter def cpuGpuBundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.cpuGpuBundle with a new bundle""" if not isinstance(bundle, og.BundleContents): carb.log_error("Only bundle attributes can be assigned to another bundle attribute") self.__bundles.cpuGpuBundle.bundle = bundle def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCpuGpuBundlesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCpuGpuBundlesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCpuGpuBundlesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialTokensDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.Tokens This is a tutorial node. It exercises the feature of providing hardcoded token values in the database after a node type has been initialized. It sets output booleans to the truth value of whether corresponding inputs appear in the hardcoded token list. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialTokensDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.Tokens Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.valuesToCheck Outputs: outputs.isColor Predefined Tokens: tokens.red tokens.green tokens.blue """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:valuesToCheck', 'token[]', 0, None, 'Array of tokens that are to be checked', {}, True, [], False, ''), ('outputs:isColor', 'bool[]', 0, None, 'True values if the corresponding input value appears in the token list', {}, True, None, False, ''), ]) class tokens: red = "red" green = "green" blue = "blue" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def valuesToCheck(self): data_view = og.AttributeValueHelper(self._attributes.valuesToCheck) return data_view.get() @valuesToCheck.setter def valuesToCheck(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.valuesToCheck) data_view = og.AttributeValueHelper(self._attributes.valuesToCheck) data_view.set(value) self.valuesToCheck_size = data_view.get_array_size() def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.isColor_size = None self._batchedWriteValues = { } @property def isColor(self): data_view = og.AttributeValueHelper(self._attributes.isColor) return data_view.get(reserved_element_count=self.isColor_size) @isColor.setter def isColor(self, value): data_view = og.AttributeValueHelper(self._attributes.isColor) data_view.set(value) self.isColor_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialTokensDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialTokensDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialTokensDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialCudaDataCpuDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.CudaCpuArrays This is a tutorial node. It illustrates the alternative method of extracting pointers to GPU array data in which the pointer returned is a CPU pointer and can be dereferenced on the CPU side. Without the cudaPointers value set that pointer would be a GPU pointer to an array of GPU pointers and could only be dereferenced on the device. """ import carb import numpy import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialCudaDataCpuDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.CudaCpuArrays Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.multiplier inputs.points Outputs: outputs.points """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:multiplier', 'float3', 0, None, 'Amplitude of the expansion for the input points', {ogn.MetadataKeys.DEFAULT: '[1.0, 1.0, 1.0]'}, True, [1.0, 1.0, 1.0], False, ''), ('inputs:points', 'float3[]', 0, None, 'Array of points to be moved', {ogn.MetadataKeys.MEMORY_TYPE: 'any', ogn.MetadataKeys.DEFAULT: '[]'}, True, [], False, ''), ('outputs:points', 'float3[]', 0, None, 'Final positions of points', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def multiplier(self): data_view = og.AttributeValueHelper(self._attributes.multiplier) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU return data_view.get(on_gpu=True) @multiplier.setter def multiplier(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.multiplier) data_view = og.AttributeValueHelper(self._attributes.multiplier) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU data_view.set(value, on_gpu=True) class __points: def __init__(self, parent): self._parent = parent @property def cpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.points) return data_view.get() @cpu.setter def cpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.cpu) data_view = og.AttributeValueHelper(self._parent._attributes.cpu) data_view.set(value) self._parent.cpu_size = data_view.get_array_size() @property def gpu(self): data_view = og.AttributeValueHelper(self._parent._attributes.points) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU return data_view.get(on_gpu=True) @gpu.setter def gpu(self, value): if self._parent._setting_locked: raise og.ReadOnlyError(self._parent._attributes.gpu) data_view = og.AttributeValueHelper(self._parent._attributes.gpu) data_view.set(value) self._parent.gpu_size = data_view.get_array_size() @property def points(self): return self.__class__.__points(self) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = { } """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.points_size = None self._batchedWriteValues = { } @property def points(self): data_view = og.AttributeValueHelper(self._attributes.points) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU return data_view.get(reserved_element_count=self.points_size, on_gpu=True) @points.setter def points(self, value): data_view = og.AttributeValueHelper(self._attributes.points) data_view.gpu_ptr_kind = og.PtrToPtrKind.CPU data_view.set(value, on_gpu=True) self.points_size = data_view.get_array_size() def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialCudaDataCpuDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialCudaDataCpuDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialCudaDataCpuDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/OgnTutorialSimpleDataPyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.tutorials.SimpleDataPy This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values. It is the same as node omni.graph.tutorials.SimpleData, except it is implemented in Python instead of C++. """ import carb import sys import traceback import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTutorialSimpleDataPyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.tutorials.SimpleDataPy Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a_bool inputs.a_constant_input inputs.a_double inputs.a_float inputs.a_half inputs.a_int inputs.a_int64 inputs.a_objectId inputs.a_path inputs.a_string inputs.a_token inputs.a_uchar inputs.a_uint inputs.a_uint64 Outputs: outputs.a_a_boolUiName outputs.a_bool outputs.a_double outputs.a_float outputs.a_half outputs.a_int outputs.a_int64 outputs.a_nodeTypeUiName outputs.a_objectId outputs.a_path outputs.a_string outputs.a_token outputs.a_uchar outputs.a_uint outputs.a_uint64 """ # Imprint the generator and target ABI versions in the file for JIT generation GENERATOR_VERSION = (1, 41, 3) TARGET_VERSION = (2, 139, 12) # This is an internal object that provides per-class storage of a per-node data dictionary PER_NODE_DATA = {} # This is an internal object that describes unchanging attributes in a generic way # The values in this list are in no particular order, as a per-attribute tuple # Name, Type, ExtendedTypeIndex, UiName, Description, Metadata, # Is_Required, DefaultValue, Is_Deprecated, DeprecationMsg # You should not need to access any of this data directly, use the defined database interfaces INTERFACE = og.Database._get_interface([ ('inputs:a_bool', 'bool', 0, 'Simple Boolean Input', 'This is an attribute of type boolean', {ogn.MetadataKeys.DEFAULT: 'true'}, False, True, False, ''), ('inputs:a_constant_input', 'int', 0, None, 'This is an input attribute whose value can be set but can only be connected as a source.', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, 0, False, ''), ('inputs:a_double', 'double', 0, None, 'This is an attribute of type 64 bit floating point', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_float', 'float', 0, None, 'This is an attribute of type 32 bit floating point', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_half', 'half', 0, None, 'This is an attribute of type 16 bit float', {ogn.MetadataKeys.DEFAULT: '0.0'}, True, 0.0, False, ''), ('inputs:a_int', 'int', 0, None, 'This is an attribute of type 32 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_int64', 'int64', 0, None, 'This is an attribute of type 64 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_objectId', 'objectId', 0, None, 'This is an attribute of type objectId', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_path', 'path', 0, None, 'This is an attribute of type path', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:a_string', 'string', 0, None, 'This is an attribute of type string', {ogn.MetadataKeys.DEFAULT: '"helloString"'}, True, "helloString", False, ''), ('inputs:a_token', 'token', 0, None, 'This is an attribute of type interned string with fast comparison and hashing', {ogn.MetadataKeys.DEFAULT: '"helloToken"'}, True, "helloToken", False, ''), ('inputs:a_uchar', 'uchar', 0, None, 'This is an attribute of type unsigned 8 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_uint', 'uint', 0, None, 'This is an attribute of type unsigned 32 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('inputs:a_uint64', 'uint64', 0, None, 'This is an attribute of type unsigned 64 bit integer', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('outputs:a_a_boolUiName', 'string', 0, None, 'Computed attribute containing the UI name of input a_bool', {}, True, None, False, ''), ('outputs:a_bool', 'bool', 0, None, 'This is a computed attribute of type boolean', {}, True, None, False, ''), ('outputs:a_double', 'double', 0, None, 'This is a computed attribute of type 64 bit floating point', {}, True, None, False, ''), ('outputs:a_float', 'float', 0, None, 'This is a computed attribute of type 32 bit floating point', {}, True, None, False, ''), ('outputs:a_half', 'half', 0, None, 'This is a computed attribute of type 16 bit float', {}, True, None, False, ''), ('outputs:a_int', 'int', 0, None, 'This is a computed attribute of type 32 bit integer', {}, True, None, False, ''), ('outputs:a_int64', 'int64', 0, None, 'This is a computed attribute of type 64 bit integer', {}, True, None, False, ''), ('outputs:a_nodeTypeUiName', 'string', 0, None, 'Computed attribute containing the UI name of this node type', {}, True, None, False, ''), ('outputs:a_objectId', 'objectId', 0, None, 'This is a computed attribute of type objectId', {}, True, None, False, ''), ('outputs:a_path', 'path', 0, None, 'This is a computed attribute of type path', {ogn.MetadataKeys.DEFAULT: '"/Child"'}, True, "/Child", False, ''), ('outputs:a_string', 'string', 0, None, 'This is a computed attribute of type string', {ogn.MetadataKeys.DEFAULT: '"This string is empty"'}, True, "This string is empty", False, ''), ('outputs:a_token', 'token', 0, None, 'This is a computed attribute of type interned string with fast comparison and hashing', {}, True, None, False, ''), ('outputs:a_uchar', 'uchar', 0, None, 'This is a computed attribute of type unsigned 8 bit integer', {}, True, None, False, ''), ('outputs:a_uint', 'uint', 0, None, 'This is a computed attribute of type unsigned 32 bit integer', {}, True, None, False, ''), ('outputs:a_uint64', 'uint64', 0, None, 'This is a computed attribute of type unsigned 64 bit integer', {}, True, None, False, ''), ]) @classmethod def _populate_role_data(cls): """Populate a role structure with the non-default roles on this node type""" role_data = super()._populate_role_data() role_data.inputs.a_objectId = og.AttributeRole.OBJECT_ID role_data.inputs.a_path = og.AttributeRole.PATH role_data.inputs.a_string = og.AttributeRole.TEXT role_data.outputs.a_a_boolUiName = og.AttributeRole.TEXT role_data.outputs.a_nodeTypeUiName = og.AttributeRole.TEXT role_data.outputs.a_objectId = og.AttributeRole.OBJECT_ID role_data.outputs.a_path = og.AttributeRole.PATH role_data.outputs.a_string = og.AttributeRole.TEXT return role_data class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"a_bool", "a_constant_input", "a_double", "a_float", "a_half", "a_int", "a_int64", "a_objectId", "a_path", "a_string", "a_token", "a_uchar", "a_uint", "a_uint64", "_setting_locked", "_batchedReadAttributes", "_batchedReadValues"} """Helper class that creates natural hierarchical access to input attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self._batchedReadAttributes = [self._attributes.a_bool, self._attributes.a_constant_input, self._attributes.a_double, self._attributes.a_float, self._attributes.a_half, self._attributes.a_int, self._attributes.a_int64, self._attributes.a_objectId, self._attributes.a_path, self._attributes.a_string, self._attributes.a_token, self._attributes.a_uchar, self._attributes.a_uint, self._attributes.a_uint64] self._batchedReadValues = [True, 0, 0, 0, 0.0, 0, 0, 0, "", "helloString", "helloToken", 0, 0, 0] @property def a_bool(self): return self._batchedReadValues[0] @a_bool.setter def a_bool(self, value): self._batchedReadValues[0] = value @property def a_constant_input(self): return self._batchedReadValues[1] @a_constant_input.setter def a_constant_input(self, value): self._batchedReadValues[1] = value @property def a_double(self): return self._batchedReadValues[2] @a_double.setter def a_double(self, value): self._batchedReadValues[2] = value @property def a_float(self): return self._batchedReadValues[3] @a_float.setter def a_float(self, value): self._batchedReadValues[3] = value @property def a_half(self): return self._batchedReadValues[4] @a_half.setter def a_half(self, value): self._batchedReadValues[4] = value @property def a_int(self): return self._batchedReadValues[5] @a_int.setter def a_int(self, value): self._batchedReadValues[5] = value @property def a_int64(self): return self._batchedReadValues[6] @a_int64.setter def a_int64(self, value): self._batchedReadValues[6] = value @property def a_objectId(self): return self._batchedReadValues[7] @a_objectId.setter def a_objectId(self, value): self._batchedReadValues[7] = value @property def a_path(self): return self._batchedReadValues[8] @a_path.setter def a_path(self, value): self._batchedReadValues[8] = value @property def a_string(self): return self._batchedReadValues[9] @a_string.setter def a_string(self, value): self._batchedReadValues[9] = value @property def a_token(self): return self._batchedReadValues[10] @a_token.setter def a_token(self, value): self._batchedReadValues[10] = value @property def a_uchar(self): return self._batchedReadValues[11] @a_uchar.setter def a_uchar(self, value): self._batchedReadValues[11] = value @property def a_uint(self): return self._batchedReadValues[12] @a_uint.setter def a_uint(self, value): self._batchedReadValues[12] = value @property def a_uint64(self): return self._batchedReadValues[13] @a_uint64.setter def a_uint64(self, value): self._batchedReadValues[13] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _prefetch(self): readAttributes = self._batchedReadAttributes newValues = _og._prefetch_input_attributes_data(readAttributes) if len(readAttributes) == len(newValues): self._batchedReadValues = newValues class ValuesForOutputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"a_a_boolUiName", "a_bool", "a_double", "a_float", "a_half", "a_int", "a_int64", "a_nodeTypeUiName", "a_objectId", "a_path", "a_string", "a_token", "a_uchar", "a_uint", "a_uint64", "_batchedWriteValues"} """Helper class that creates natural hierarchical access to output attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) self.a_a_boolUiName_size = None self.a_nodeTypeUiName_size = None self.a_path_size = 6 self.a_string_size = 20 self._batchedWriteValues = { } @property def a_a_boolUiName(self): value = self._batchedWriteValues.get(self._attributes.a_a_boolUiName) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_a_boolUiName) return data_view.get() @a_a_boolUiName.setter def a_a_boolUiName(self, value): self._batchedWriteValues[self._attributes.a_a_boolUiName] = value @property def a_bool(self): value = self._batchedWriteValues.get(self._attributes.a_bool) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_bool) return data_view.get() @a_bool.setter def a_bool(self, value): self._batchedWriteValues[self._attributes.a_bool] = value @property def a_double(self): value = self._batchedWriteValues.get(self._attributes.a_double) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_double) return data_view.get() @a_double.setter def a_double(self, value): self._batchedWriteValues[self._attributes.a_double] = value @property def a_float(self): value = self._batchedWriteValues.get(self._attributes.a_float) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_float) return data_view.get() @a_float.setter def a_float(self, value): self._batchedWriteValues[self._attributes.a_float] = value @property def a_half(self): value = self._batchedWriteValues.get(self._attributes.a_half) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_half) return data_view.get() @a_half.setter def a_half(self, value): self._batchedWriteValues[self._attributes.a_half] = value @property def a_int(self): value = self._batchedWriteValues.get(self._attributes.a_int) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_int) return data_view.get() @a_int.setter def a_int(self, value): self._batchedWriteValues[self._attributes.a_int] = value @property def a_int64(self): value = self._batchedWriteValues.get(self._attributes.a_int64) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_int64) return data_view.get() @a_int64.setter def a_int64(self, value): self._batchedWriteValues[self._attributes.a_int64] = value @property def a_nodeTypeUiName(self): value = self._batchedWriteValues.get(self._attributes.a_nodeTypeUiName) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_nodeTypeUiName) return data_view.get() @a_nodeTypeUiName.setter def a_nodeTypeUiName(self, value): self._batchedWriteValues[self._attributes.a_nodeTypeUiName] = value @property def a_objectId(self): value = self._batchedWriteValues.get(self._attributes.a_objectId) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_objectId) return data_view.get() @a_objectId.setter def a_objectId(self, value): self._batchedWriteValues[self._attributes.a_objectId] = value @property def a_path(self): value = self._batchedWriteValues.get(self._attributes.a_path) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_path) return data_view.get() @a_path.setter def a_path(self, value): self._batchedWriteValues[self._attributes.a_path] = value @property def a_string(self): value = self._batchedWriteValues.get(self._attributes.a_string) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_string) return data_view.get() @a_string.setter def a_string(self, value): self._batchedWriteValues[self._attributes.a_string] = value @property def a_token(self): value = self._batchedWriteValues.get(self._attributes.a_token) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_token) return data_view.get() @a_token.setter def a_token(self, value): self._batchedWriteValues[self._attributes.a_token] = value @property def a_uchar(self): value = self._batchedWriteValues.get(self._attributes.a_uchar) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_uchar) return data_view.get() @a_uchar.setter def a_uchar(self, value): self._batchedWriteValues[self._attributes.a_uchar] = value @property def a_uint(self): value = self._batchedWriteValues.get(self._attributes.a_uint) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_uint) return data_view.get() @a_uint.setter def a_uint(self, value): self._batchedWriteValues[self._attributes.a_uint] = value @property def a_uint64(self): value = self._batchedWriteValues.get(self._attributes.a_uint64) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.a_uint64) return data_view.get() @a_uint64.setter def a_uint64(self, value): self._batchedWriteValues[self._attributes.a_uint64] = value def __getattr__(self, item: str): if item in self.LOCAL_PROPERTY_NAMES: return object.__getattribute__(self, item) else: return super().__getattr__(item) def __setattr__(self, item: str, new_value): if item in self.LOCAL_PROPERTY_NAMES: object.__setattr__(self, item, new_value) else: super().__setattr__(item, new_value) def _commit(self): _og._commit_output_attributes_data(self._batchedWriteValues) self._batchedWriteValues = { } class ValuesForState(og.DynamicAttributeAccess): """Helper class that creates natural hierarchical access to state attributes""" def __init__(self, node: og.Node, attributes, dynamic_attributes: og.DynamicAttributeInterface): """Initialize simplified access for the attribute data""" context = node.get_graph().get_default_graph_context() super().__init__(context, node, attributes, dynamic_attributes) def __init__(self, node): super().__init__(node) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_INPUT) self.inputs = OgnTutorialSimpleDataPyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTutorialSimpleDataPyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTutorialSimpleDataPyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes) class abi: """Class defining the ABI interface for the node type""" @staticmethod def get_node_type(): get_node_type_function = getattr(OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.tutorials.SimpleDataPy' @staticmethod def compute(context, node): def database_valid(): return True try: per_node_data = OgnTutorialSimpleDataPyDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnTutorialSimpleDataPyDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnTutorialSimpleDataPyDatabase(node) try: compute_function = getattr(OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS, 'compute', None) if callable(compute_function) and compute_function.__code__.co_argcount > 1: return compute_function(context, node) db.inputs._prefetch() db.inputs._setting_locked = True with og.in_compute(): return OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS.compute(db) except Exception as error: stack_trace = "".join(traceback.format_tb(sys.exc_info()[2].tb_next)) db.log_error(f'Assertion raised in compute - {error}\n{stack_trace}', add_context=False) finally: db.inputs._setting_locked = False db.outputs._commit() return False @staticmethod def initialize(context, node): OgnTutorialSimpleDataPyDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnTutorialSimpleDataPyDatabase.PER_NODE_DATA[node.node_id()] def on_connection_or_disconnection(*args): per_node_data['_db'] = None node.register_on_connected_callback(on_connection_or_disconnection) node.register_on_disconnected_callback(on_connection_or_disconnection) @staticmethod def release(node): release_function = getattr(OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnTutorialSimpleDataPyDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnTutorialSimpleDataPyDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS, 'update_node_version', None) if callable(update_node_version_function): return update_node_version_function(context, node, old_version, new_version) return False @staticmethod def initialize_type(node_type): initialize_type_function = getattr(OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS, 'initialize_type', None) needs_initializing = True if callable(initialize_type_function): needs_initializing = initialize_type_function(node_type) if needs_initializing: node_type.set_metadata(ogn.MetadataKeys.EXTENSION, "omni.graph.tutorials") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Tutorial Python Node: Attributes With Simple Data") node_type.set_metadata(ogn.MetadataKeys.ICON_COLOR, "#FF00FF00") node_type.set_metadata(ogn.MetadataKeys.ICON_BACKGROUND_COLOR, "#7FFF0000") node_type.set_metadata(ogn.MetadataKeys.ICON_BORDER_COLOR, "#FF0000FF") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "tutorials") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This is a tutorial node. It creates both an input and output attribute of every simple supported data type. The values are modified in a simple way so that the compute modifies values. It is the same as node omni.graph.tutorials.SimpleData, except it is implemented in Python instead of C++.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.tutorials}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.tutorials.SimpleDataPy.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnTutorialSimpleDataPyDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS, 'on_connection_type_resolve', None) if callable(on_connection_type_resolve_function): on_connection_type_resolve_function(node) NODE_TYPE_CLASS = None @staticmethod def register(node_type_class): OgnTutorialSimpleDataPyDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnTutorialSimpleDataPyDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.tutorials.SimpleDataPy")
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial2/tutorial2.rst
.. _ogn_tutorial_simpleData: Tutorial 2 - Simple Data Node ============================= The simple data node creates one input attribute and one output attribute of each of the simple types, where "simple" refers to data types that have a single component and are not arrays. (e.g. "float" is simple, "float[3]" is not, nor is "float[]"). See also :ref:`ogn_tutorial_simpleDataPy` for a similar example in Python. OgnTutorialSimpleData.ogn ------------------------- The *ogn* file shows the implementation of a node named "omni.graph.tutorials.SimpleData", which has one input and one output attribute of each simple type. .. literalinclude:: OgnTutorialSimpleData.ogn :linenos: :language: json OgnTutorialSimpleData.cpp ------------------------- The *cpp* file contains the implementation of the compute method, which modifies each of the inputs in a simple way to create outputs that have different values. .. literalinclude:: OgnTutorialSimpleData.cpp :linenos: :language: c++ Note how the attribute values are available through the OgnTutorialSimpleDataDatabase class. The generated interface creates access methods for every attribute, named for the attribute itself. Inputs will be returned as const references, outputs will be returned as non-const references. Attribute Data -------------- Two types of attribute data are created, which help with ease of access and of use - the attribute name lookup information, and the attribute type definition. Attribute data is accessed via a name-based lookup. This is not particularly efficient, so to facilitate this process the attribute name is translated into a fast access token. In addition, the information about the attribute's type and default value is constant for all nodes of the same type so that is stored as well, in static data. Normally you would use an *auto* declaration for attribute types. Sometimes you want to pass around attribute data so it is helpful to have access to the attribute's data type. In the generated code a ``using namespace`` is set up to provide a very simple syntax for accessing the attribute's metadata from within the node: .. code-block:: c++ std::cout << "Attribute name is " << inputs::a_bool.m_name << std::endl; std::cout << "Attribute type is " << inputs::a_bool.m_dataType << std::endl; extern "C" void processAttribute(inputs::a_bool_t& value); // Equivalent to extern "C" void processAttribute(bool& value); Attribute Data Access --------------------- The attributes are automatically namespaced with *inputs* and *outputs*. In the USD file the attribute names will appear as *inputs:XXX* or *outputs:XXX*. In the C++ interface the colon is illegal so a contained struct is used to make use of the period equivalent, as *inputs.XXX* or *outputs.XXX*. The minimum information provided by these wrapper classes is a reference to the underlying data, accessed by ``operator()``. For this class, these are the types it provides: +--------------------+--------------------+ | Database Function | Returned Type | +====================+====================+ | inputs.a_bool() | const bool& | +--------------------+--------------------+ | inputs.a_half() | const pxr::GfHalf& | +--------------------+--------------------+ | inputs.a_int() | const int& | +--------------------+--------------------+ | inputs.a_int64() | const int64_t& | +--------------------+--------------------+ | inputs.a_float() | const float& | +--------------------+--------------------+ | inputs.a_double() | const double& | +--------------------+--------------------+ | inputs.a_path() | const std::string& | +--------------------+--------------------+ | inputs.a_string() | const std::string& | +--------------------+--------------------+ | inputs.a_token() | const NameToken& | +--------------------+--------------------+ | outputs.a_bool() | bool& | +--------------------+--------------------+ | outputs.a_half() | pxr::GfHalf& | +--------------------+--------------------+ | outputs.a_int() | int& | +--------------------+--------------------+ | outputs.a_int64() | int64_t& | +--------------------+--------------------+ | outputs.a_float() | float& | +--------------------+--------------------+ | outputs.a_double() | double& | +--------------------+--------------------+ | outputs.a_string() | std::string& | +--------------------+--------------------+ | outputs.a_token() | NameToken& | +--------------------+--------------------+ The data returned are all references to the real data in the FlatCache, our managed memory store, pointed to the correct location at evaluation time. Note how input attributes return *const* data while output attributes do not. This reinforces the restriction that input data should never be written to, as it would cause graph synchronization problems. The type *pxr::GfHalf* is an implementation of a 16-bit floating point value, though any other may also be used with a runtime cast of the value. *omni::graph::core::NameToken* is a simple token through which a unique string can be looked up at runtime. Helpers ------- A few helpers are provided in the database class definition to help make coding with it more natural. initializeType ++++++++++++++ Function signature ``static void initializeType(const NodeTypeObj& nodeTypeObj)`` is an implementation of the ABI function that is called once for each node type, initializing such things as its mandatory attributes and their default values. validate ++++++++ Function signature ``bool validate()``. If any of the mandatory attributes do not have values then the generated code will exit early with an error message and not actually call the node's compute method. token +++++ Function signature ``NameToken token(const char* tokenName)``. Provides a simple conversion from a string to the unique token representing that string, for fast comparison of strings and for use with the attributes whose data types are *token*. Compute Status Logging ++++++++++++++++++++++ Two helper functions are providing in the database class to help provide more information when the compute method of a node has failed. Two methods are provided, both taking printf-like variable sets of parameters. ``void logError(Args...)`` is used when the compute has run into some inconsistent or unexpected data, such as two input arrays that are supposed to have the same size but do not, like the normals and vertexes on a mesh. ``void logWarning(Args...)`` can be used when the compute has hit an unusual case but can still provide a consistent output for it, for example the deformation of an empty mesh would result in an empty mesh and a warning since that is not a typical use for the node. typedefs ++++++++ Although not part of the database class per se, a typedef alias is created for every attribute so that you can use its type directly without knowing the detailed type; a midway point between exact types and *auto*. The main use for such types might be passing attribute data between functions. Here are the corresponding typedef names for each of the attributes: +--------------------+--------------------+ | Typedef Alias | Actual Type | +====================+====================+ | inputs.a_bool_t | const bool& | +--------------------+--------------------+ | inputs.a_half_t | const pxr::GfHalf& | +--------------------+--------------------+ | inputs.a_int_t | const int& | +--------------------+--------------------+ | inputs.a_int64_t | const int64_t& | +--------------------+--------------------+ | inputs.a_float_t | const float& | +--------------------+--------------------+ | inputs.a_double_t | const double& | +--------------------+--------------------+ | inputs.a_token_t | const NameToken& | +--------------------+--------------------+ | outputs.a_bool_t | bool& | +--------------------+--------------------+ | outputs.a_half_t | pxr::GfHalf& | +--------------------+--------------------+ | outputs.a_int_t | int& | +--------------------+--------------------+ | outputs.a_int64_t | int64_t& | +--------------------+--------------------+ | outputs.a_float_t | float& | +--------------------+--------------------+ | outputs.a_double_t | double& | +--------------------+--------------------+ | outputs.a_token_t | NameToken& | +--------------------+--------------------+ Notice the similarity between this table and the one above. The typedef name is formed by adding the extension *_t* to the attribute accessor name, similar to C++ standard type naming conventions. The typedef should always correspond to the return value of the attribute's ``operator()``. Direct ABI Access +++++++++++++++++ All of the generated database classes provide access to the underlying *INodeType* ABI for those rare situations where you want to access the ABI directly. There are two methods provided, which correspond to the objects passed in to the ABI compute method. Context function signature ``const GraphContextObj& abi_context() const``, for accessing the underlying OmniGraph evaluation context and its interface. Node function signature ``const NodeObj& nodeObj abi_node() const``, for accessing the underlying OmniGraph node object and its interface. In addition, the attribute ABI objects are extracted into a shared structure so that they can be accessed in a manner similar to the attribute data. For example ``db.attributes.inputs.a_bool()`` returns the `AttributeObj` that refers to the input attribute named `a_bool`. It can be used to directly call ABI functions when required, though again it should be emphasized that this will be a rare occurrence - all of the common operations can be performed more easily using the database interfaces. Node Computation Tests ---------------------- The "tests" section of the .ogn file contains a list of tests consisting of a description and attribute values, both inputs and outputs, that will be used for the test. The test runs by setting all of the named input attributes to their values, running the compute, then comparing the resulting output attribute values against those specified by the test. For example to test the computation of the boolean attribute, whose output is the negation of the input, these two test values could be specified: .. code::json { "tests": [ { "description": "Check that true becomes false", "inputs": { "a_bool": true }, "outputs": { "a_bool": false } } ] } The "description" field is optional, though highly recommended to aid in debugging which tests are failing. Any unspecified inputs take their default value, and any unspecified outputs do not get checked after the compute. For simple attribute lists an abbreviated version of the syntax can be used, where the inputs and outputs get their fully namespaced names so that there is no need for the "inputs" and "outputs" objects. .. code::json { "tests": [ { "description": "Check that false becomes true", "inputs:a_bool": false, "outputs:a_bool": true } ] }
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial2/OgnTutorialSimpleData.ogn
{ "SimpleData" : { "version": 1, "categories": "tutorials", "scheduling": ["threadsafe"], "description": [ "This is a tutorial node. It creates both an input and output attribute of every simple", "supported data type. The values are modified in a simple way so that the compute modifies values." ], "$uiNameMetadata": "The value of the 'uiName' metadata can also be expressed at the top level as well", "uiName": "Tutorial Node: Attributes With Simple Data", "inputs": { "a_bool": { "type": "bool", "metadata": { "$comment": "Metadata can also be added at the attribute level", "uiName": "Sample Boolean Input" }, "description": ["This is an attribute of type boolean"], "default": true }, "a_half": { "type": "half", "$uiNameMetadata": "Like the node uiName metadata, the attribute uiName metadata also has a shortform", "uiName": "Sample Half Precision Input", "description": ["This is an attribute of type 16 bit float"], "$comment": "0 is used as the decimal portion due to reduced precision of this type", "default": 0.0 }, "a_int": { "type": "int", "description": ["This is an attribute of type 32 bit integer"], "default": 0 }, "a_int64": { "type": "int64", "description": ["This is an attribute of type 64 bit integer"], "default": 0 }, "a_float": { "type": "float", "description": ["This is an attribute of type 32 bit floating point"], "default": 0 }, "a_double": { "type": "double", "description": ["This is an attribute of type 64 bit floating point"], "default": 0 }, "a_token": { "type": "token", "description": ["This is an attribute of type interned string with fast comparison and hashing"], "default": "helloToken" }, "a_path": { "type": "path", "description": ["This is an attribute of type path"], "default": "" }, "a_string": { "type": "string", "description": ["This is an attribute of type string"], "default": "helloString" }, "a_objectId": { "type": "objectId", "description": ["This is an attribute of type objectId"], "default": 0 }, "unsigned:a_uchar": { "type": "uchar", "description": ["This is an attribute of type unsigned 8 bit integer"], "default": 0 }, "unsigned:a_uint": { "type": "uint", "description": ["This is an attribute of type unsigned 32 bit integer"], "default": 0 }, "unsigned:a_uint64": { "type": "uint64", "description": ["This is an attribute of type unsigned 64 bit integer"], "default": 0 }, "a_constant_input": { "type": "int", "description": ["This is an input attribute whose value can be set but can only be connected as a source."], "metadata": { "outputOnly": "1" } } }, "outputs": { "a_bool": { "type": "bool", "uiName": "Sample Boolean Output", "description": ["This is a computed attribute of type boolean"], "default": false }, "a_half": { "type": "half", "uiName": "Sample Half Precision Output", "description": ["This is a computed attribute of type 16 bit float"], "default": 1.0 }, "a_int": { "type": "int", "description": ["This is a computed attribute of type 32 bit integer"], "default": 2 }, "a_int64": { "type": "int64", "description": ["This is a computed attribute of type 64 bit integer"], "default": 3 }, "a_float": { "type": "float", "description": ["This is a computed attribute of type 32 bit floating point"], "default": 4.0 }, "a_double": { "type": "double", "description": ["This is a computed attribute of type 64 bit floating point"], "default": 5.0 }, "a_token": { "type": "token", "description": ["This is a computed attribute of type interned string with fast comparison and hashing"], "default": "six" }, "a_path": { "type": "path", "description": ["This is a computed attribute of type path"], "default": "/" }, "a_string": { "type": "string", "description": ["This is a computed attribute of type string"], "default": "seven" }, "a_objectId": { "type": "objectId", "description": ["This is a computed attribute of type objectId"], "default": 8 }, "unsigned:a_uchar": { "type": "uchar", "description": ["This is a computed attribute of type unsigned 8 bit integer"], "default": 9 }, "unsigned:a_uint": { "type": "uint", "description": ["This is a computed attribute of type unsigned 32 bit integer"], "default": 10 }, "unsigned:a_uint64": { "type": "uint64", "description": ["This is a computed attribute of type unsigned 64 bit integer"], "default": 11 } }, "tests": [ { "$comment": ["Each test has a description of the test and a set of input and output values. ", "The test runs by setting all of the specified inputs on the node to their values, ", "running the compute, then comparing the computed outputs against the values ", "specified in the test. Only the inputs in the list are set; others will use their ", "default values. Only the outputs in the list are checked; others are ignored."], "description": "Check that false becomes true", "inputs:a_bool": false, "outputs:a_bool": true }, { "$comment": "This is a more verbose format of test data that provides a different grouping of values", "description": "Check that true becomes false", "inputs": { "a_bool": true }, "outputs": { "a_bool": false } }, { "$comment": "Even though these computations are all independent they can be checked in a single test.", "description": "Check all attributes against their expected values", "inputs:a_bool": false, "outputs:a_bool": true, "inputs:a_double": 1.1, "outputs:a_double": 2.1, "inputs:a_float": 3.3, "outputs:a_float": 4.3, "inputs:a_half": 5.0, "outputs:a_half": 6.0, "inputs:a_int": 7, "outputs:a_int": 8, "inputs:a_int64": 9, "outputs:a_int64": 10, "inputs:a_token": "helloToken", "outputs:a_token": "worldToken", "inputs:a_string": "helloString", "outputs:a_string": "worldString", "inputs:a_objectId": 5, "outputs:a_objectId": 6, "inputs:unsigned:a_uchar": 11, "outputs:unsigned:a_uchar": 12, "inputs:unsigned:a_uint": 13, "outputs:unsigned:a_uint": 14, "inputs:unsigned:a_uint64": 15, "outputs:unsigned:a_uint64": 16 }, { "$comment": "Make sure embedded quotes in a string functon correctly", "inputs:a_token": "hello'Token", "outputs:a_token": "world'Token", "inputs:a_string": "hello\"String", "outputs:a_string": "world\"String" }, { "$comment": "Make sure the path append does the right thing", "inputs:a_path": "/World/Domination", "outputs:a_path": "/World/Domination/Child" }, { "$comment": "Check that strings and tokens get correct defaults", "outputs:a_token": "worldToken", "outputs:a_string": "worldString" } ] } }
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial2/OgnTutorialSimpleData.cpp
// Copyright (c) 2020-2021, 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 <OgnTutorialSimpleDataDatabase.h> #include <string> // Even though the path is stored as a string this tutorial will use the SdfPath API to manipulate it #include <pxr/usd/sdf/path.h> // This class exercises access to the DataModel through the generated database class for all simple data types // It's a good practice to namespace your nodes, so that they are guaranteed to be unique. Using this practice // you can shorten your class names as well. This class could have equally been named "OgnSimpleData", since // the "Tutorial" part of it is just another incarnation of the namespace. namespace omni { namespace graph { namespace core { namespace tutorial { class OgnTutorialSimpleData { public: static bool compute(OgnTutorialSimpleDataDatabase& db) { // Inside the database the contained object "inputs" holds the data references for all input attributes and the // contained object "outputs" holds the data references for all output attributes. // Each of the attribute accessors are named for the name of the attribute, with the ":" replaced by "_". // The colon is used in USD as a convention for creating namespaces so it's safe to replace it without // modifying the meaning. The "inputs:" and "outputs:" prefixes in the generated attributes are matched // by the container names. // // For example attribute "inputs:translate:x" would be accessible as "db.inputs.translate_x" and attribute // "outputs:matrix" would be accessible as "db.outputs.matrix". // The "compute" of this method modifies each attribute in a subtle way so that a test can be written // to verify the operation of the node. See the .ogn file for a description of tests. db.outputs.a_bool() = !db.inputs.a_bool(); db.outputs.a_half() = 1.0f + db.inputs.a_half(); db.outputs.a_int() = 1 + db.inputs.a_int(); db.outputs.a_int64() = 1 + db.inputs.a_int64(); db.outputs.a_double() = 1.0 + db.inputs.a_double(); db.outputs.a_float() = 1.0f + db.inputs.a_float(); db.outputs.a_objectId() = 1 + db.inputs.a_objectId(); // The namespace separator ":" has special meaning in C++ so it is replaced by "_" when it appears in names // Attribute "outputs:unsigned:a_uchar" becomes "outputs.unsigned_a_uchar". db.outputs.unsigned_a_uchar() = 1 + db.inputs.unsigned_a_uchar(); db.outputs.unsigned_a_uint() = 1 + db.inputs.unsigned_a_uint(); db.outputs.unsigned_a_uint64() = 1 + db.inputs.unsigned_a_uint64(); // Internally the string type is more akin to a std::string_view, not available until C++17. // The data is a pair of (const char*, size_t), but the interface provided through the accessor is // castable to a std::string. // // This code shows the recommended way to use it, extracting inputs into a std::string for manipulation and // then assigning outputs from the results. Using the referenced object directly could cause a lot of // unnecessary fabric allocations. (i.e. avoid auto& outputStringView = db.outputs.a_string()) std::string outputString(db.inputs.a_string()); if (outputString.length() > 0) { auto foundStringAt = outputString.find("hello"); if (foundStringAt != std::string::npos) { outputString.replace(foundStringAt, 5, "world"); } db.outputs.a_string() = outputString; } else { db.outputs.a_string() = ""; } // The token interface is made available in the database as well, for convenience. // By calling "db.stringToToken()" you can look up the token ID of a given string. // There is also a symmetrical "db.tokenToString()" for going the other way. std::string outputTokenString = db.tokenToString(db.inputs.a_token()); if (outputTokenString.length() > 0) { auto foundTokenAt = outputTokenString.find("hello"); if (foundTokenAt != std::string::npos) { outputTokenString.replace(foundTokenAt, 5, "world"); db.outputs.a_token() = db.stringToToken(outputTokenString.c_str()); } } else { db.outputs.a_token() = db.stringToToken(""); } // Path just gets a new child named "Child". There's not requirement that the path point to anything // that exists in the scene so any string will work here. // std::string outputPath = (std::string)db.inputs.a_path(); // In the implementation the string is manipulated directly, as it does not care if the SdfPath is valid or // not. If you want to manipulate it using the pxr::SdfPath API this is how you could do it: // // pxr::SdfPath sdfPath{outputPath}; // pxr::TfToken childToken{asTfToken(db.stringToToken("/Child"))}; // if (sdfPath.IsValid()) // { // db.outputs.a_path() = sdfPath.AppendChild(childToken).GetString(); // } // outputPath += "/Child"; db.outputs.a_path() = outputPath; // Drop down to the ABI to find attribute metadata, currently not available through the database auto& nodeObj = db.abi_node(); auto attributeObj = nodeObj.iNode->getAttribute(nodeObj, "inputs:a_bool"); // The hardcoded metadata keyword is available through the node auto uiName = attributeObj.iAttribute->getMetadata(attributeObj, kOgnMetadataUiName); std::string expectedUiName{ "Sample Boolean Input" }; CARB_ASSERT(uiName && (expectedUiName == uiName)); // Confirm that the piece of metadata that differentiates objectId from regular uint64 is in place auto objectIdAttributeObj = nodeObj.iNode->getAttribute(nodeObj, "inputs:a_objectId"); auto objectIdMetadata = attributeObj.iAttribute->getMetadata(objectIdAttributeObj, kOgnMetadataObjectId); CARB_ASSERT(objectIdMetadata); return true; } }; // namespaces are closed after the registration macro, to ensure the correct class is registered REGISTER_OGN_NODE() } // namespace tutorial } // namespace core } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial20/OgnTutorialTokens.cpp
// Copyright (c) 2021, 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 <OgnTutorialTokensDatabase.h> class OgnTutorialTokens { public: static bool compute(OgnTutorialTokensDatabase& db) { const auto& valuesToCheck = db.inputs.valuesToCheck(); auto& isColor = db.outputs.isColor(); isColor.resize( valuesToCheck.size() ); if (valuesToCheck.size() == 0) { return true; } // Walk the list of inputs, setting the corresponding output to true if and only if the input is in // the list of allowable tokens. size_t index{ 0 }; for (const auto& inputValue : valuesToCheck) { // When the database is available you can use it to access the token values directly. When it is not // you can access them statically (e.g. OgnTutorialTokensDatabase.token.red) if ((inputValue == db.tokens.red) || (inputValue == db.tokens.green) || (inputValue == db.tokens.blue)) { isColor[index] = true; } else { isColor[index] = false; } index++; } return true; } }; REGISTER_OGN_NODE()
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial20/OgnTutorialTokensPy.py
""" Implementation of a node handling hardcoded tokens. Tokens are a fixed set of strings, usually used for things like keywords and enum names. In C++ tokens are more efficient than strings for lookup as they are represented as a single long integer. The Python access methods are set up the same way, though at present there is no differentiation between strings and tokens in Python code. """ class OgnTutorialTokensPy: """Exercise access to hardcoded tokens""" @staticmethod def compute(db) -> bool: """ Run through a list of input tokens and set booleans in a corresponding output array indicating if the token appears in the list of hardcoded color names. """ values_to_check = db.inputs.valuesToCheck # When assigning the entire array the size does not have to be set in advance db.outputs.isColor = [value in [db.tokens.red, db.tokens.green, db.tokens.blue] for value in values_to_check] return True
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial20/OgnTutorialTokensPy.ogn
{ "TokensPy": { "version": 1, "categories": "tutorials", "description": ["This is a tutorial node. It exercises the feature of providing hardcoded token values", "in the database after a node type has been initialized. It sets output booleans to the", "truth value of whether corresponding inputs appear in the hardcoded token list." ], "language": "python", "uiName": "Tutorial Python Node: Tokens", "inputs": { "valuesToCheck": { "type": "token[]", "description": "Array of tokens that are to be checked" } }, "outputs": { "isColor": { "type": "bool[]", "description": "True values if the corresponding input value appears in the token list" } }, "$comment": [ "The tokens can be a list or a dictionary. If a list then the token string is also the name of the", "variable in the database through which they can be accessed. If a dictionary then the key is the", "name of the access variable and the value is the actual token string. Use a list if your token values", "are all legal variable names in your node's implementation language (C++ or Python)." ], "tokens": ["red", "green", "blue"], "tests": [ { "inputs:valuesToCheck": ["red", "Red", "magenta", "green", "cyan", "blue", "yellow"], "outputs:isColor": [true, false, false, true, false, true, false] } ] } }
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial20/OgnTutorialTokens.ogn
{ "Tokens": { "version": 1, "categories": "tutorials", "scheduling": ["threadsafe"], "description": ["This is a tutorial node. It exercises the feature of providing hardcoded token values", "in the database after a node type has been initialized. It sets output booleans to the", "truth value of whether corresponding inputs appear in the hardcoded token list." ], "uiName": "Tutorial Node: Tokens", "inputs": { "valuesToCheck": { "type": "token[]", "description": "Array of tokens that are to be checked" } }, "outputs": { "isColor": { "type": "bool[]", "description": "True values if the corresponding input value appears in the token list" } }, "$comment": [ "The tokens can be a list or a dictionary. If a list then the token string is also the name of the", "variable in the database through which they can be accessed. If a dictionary then the key is the", "name of the access variable and the value is the actual token string. Use a list if your token values", "are all legal variable names in your node's implementation language (C++ or Python)." ], "tokens": ["red", "green", "blue"], "tests": [ { "inputs:valuesToCheck": ["red", "Red", "magenta", "green", "cyan", "blue", "yellow"], "outputs:isColor": [true, false, false, true, false, true, false] } ] } }
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial20/tutorial20.rst
.. _ogn_tutorial_tokens: Tutorial 20 - Tokens ==================== Tokens are a method of providing fast access to strings that have fixed contents. All strings with the same contents can be translated into the same shared token. Token comparison is as fast as integer comparisons, rather than the more expensive string comparisons you would need for a general string. One example of where they are useful is in having a fixed set of allowable values for an input string. For example you might choose a color channel by selecting from the names "red", "green", and "blue", or you might know that a mesh bundle's contents always use the attribute names "normals", "points", and "faces". Tokens can be accessed through the database methods ``tokenToString()`` and ``stringToToken()``. Using the ``tokens`` keyword in a .ogn file merely provides a shortcut to always having certain tokens available. In the color case then if you have a token input containing the color your comparison code changes from this: .. code-block:: c++ const auto& colorToken = db.inputs.colorToken(); if (colorToken == db.stringToToken("red")) { // do red stuff } else if (colorToken == db.stringToToken("green")) { // do green stuff } else if (colorToken == db.stringToToken("blue")) { // do blue stuff } to this, which has much faster comparison times: .. code-block:: c++ const auto& colorToken = db.inputs.colorToken(); if (colorToken == db.tokens.red) { // do red stuff } else if (colorToken == db.tokens.green) { // do green stuff } else if (colorToken == db.tokens.blue) { // do blue stuff } In Python there isn't a first-class object that is a token but the same token access is provided for consistency: .. code-block:: python color_token = db.inputs.colorToken if color_token == db.tokens.red: # do red stuff elif color_token == db.tokens.green: # do green stuff elif color_token == db.tokens.blue: # do blue stuff OgnTutorialTokens.ogn --------------------- The *ogn* file shows the implementation of a node named "omni.graph.tutorials.Tokens", which contains some hardcoded tokens to use in the compute method. .. literalinclude:: OgnTutorialTokens.ogn :linenos: :language: json OgnTutorialTokens.cpp --------------------- The *cpp* file contains the implementation of the compute method. It illustrates how to access the hardcoded tokens to avoid writing the boilerplate code yourself. .. literalinclude:: OgnTutorialTokens.cpp :linenos: :language: c++ OgnTutorialTokensPy.py ---------------------- The *py* file contains the implementation of the compute method in Python. The .ogn file is the same as the above, except for the addition of the implementation language key ``"language": "python"``. The compute follows the same algorithm as the *cpp* equivalent. .. literalinclude:: OgnTutorialTokensPy.py :linenos: :language: python
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial7/OgnTutorialRoleData.ogn
{ "RoleData" : { "version": 1, "categories": "tutorials", "scheduling": ["threadsafe"], "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] } ] } }
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial7/tutorial7.rst
.. _ogn_tutorial_roleData: 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. .. literalinclude:: OgnTutorialRoleData.ogn :linenos: :language: json 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. .. literalinclude:: OgnTutorialRoleData.cpp :linenos: :language: c++ 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 :ref:`ogn_attribute_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: .. code-block:: c++ static bool compute(OgnTutorialRoleDataDatabase& db) { if (db.inputs.a_color3d.role == eColor ) { processValueAsAColor( db.inputs.a_color3d() ); } }
omniverse-code/kit/exts/omni.graph.tutorials/omni/graph/tutorials/ogn/tutorials/tutorial7/OgnTutorialRoleData.cpp
// 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()