file_path
stringlengths
21
224
content
stringlengths
0
80.8M
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnMakeVector2Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.MakeVector2 Merge 2 input values into a single output vector. If the inputs are arrays, the output will be an array of vectors. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnMakeVector2Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.MakeVector2 Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.x inputs.y Outputs: 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:x', 'double,double[],float,float[],half,half[],int,int[]', 1, 'X', 'The first component of the vector', {}, True, None, False, ''), ('inputs:y', 'double,double[],float,float[],half,half[],int,int[]', 1, 'Y', 'The second component of the vector', {}, True, None, False, ''), ('outputs:tuple', 'double[2],double[2][],float[2],float[2][],half[2],half[2][],int[2],int[2][]', 1, 'Vector', 'Output vector(s)', {}, 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 x(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.x""" return og.RuntimeAttribute(self._attributes.x.get_attribute_data(), self._context, True) @x.setter def x(self, value_to_set: Any): """Assign another attribute's value to outputs.x""" if isinstance(value_to_set, og.RuntimeAttribute): self.x.value = value_to_set.value else: self.x.value = value_to_set @property def y(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.y""" return og.RuntimeAttribute(self._attributes.y.get_attribute_data(), self._context, True) @y.setter def y(self, value_to_set: Any): """Assign another attribute's value to outputs.y""" if isinstance(value_to_set, og.RuntimeAttribute): self.y.value = value_to_set.value else: self.y.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 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 = OgnMakeVector2Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnMakeVector2Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnMakeVector2Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnCosDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Cos Trigonometric operation cosine of one input in degrees. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnCosDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Cos 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', 'double,double[],float,float[],half,half[],timecode', 1, None, 'Angle in degrees whose cosine value is to be found', {}, True, None, False, ''), ('outputs:value', 'double,double[],float,float[],half,half[],timecode', 1, 'Result', 'The cosine value of the input angle in degrees', {}, 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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 = OgnCosDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnCosDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnCosDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRandomNumericDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.RandomNumeric Generates a random numeric value in a range, using a uniform distribution. The range is specified with two inputs: minimum and maximum. These inputs can be numbers, vectors, tuples or arrays of these. If one input has a higher dimension than the other, then the input with lower dimension will be repeated to match the dimension of the other input (broadcasting). """ from typing import Any 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 OgnRandomNumericDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.RandomNumeric Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.isNoise inputs.max inputs.min inputs.seed inputs.useSeed Outputs: outputs.execOut outputs.random State: state.gen """ # 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:execIn', 'execution', 0, None, 'The input execution port to output a new random value', {}, True, None, False, ''), ('inputs:isNoise', 'bool', 0, 'Is Noise Function', 'Turn this node into a noise generator function\nFor a given seed, it will then always output the same number(s)', {ogn.MetadataKeys.HIDDEN: 'true', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:max', '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, 'Maximum', 'The maximum of the random range,\ninclusive of integral numbers\nexclusive for real numbers.\nCan be a number, vector, tuple, or array of these.\nThe default value is double 1.', {}, False, None, False, ''), ('inputs:min', '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, 'Minimum', 'The minimum of the random range (inclusive).\nCan be a number, vector, tuple, or array of these.\nThe default value is double 0.', {}, False, None, False, ''), ('inputs:seed', 'uint64', 0, 'Seed', 'The seed of the random generator.', {}, False, None, False, ''), ('inputs:useSeed', 'bool', 0, 'Use seed', 'Use the custom seed instead of a random one', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('outputs:execOut', 'execution', 0, None, 'The output execution port', {}, True, None, False, ''), ('outputs:random', '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, 'Random Numeric', 'The random numeric value that was generated', {}, True, None, False, ''), ('state:gen', 'matrix3d', 0, None, 'Random number generator internal state (abusing matrix3d because it is large enough).', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.outputs.execOut = og.AttributeRole.EXECUTION role_data.state.gen = 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def isNoise(self): data_view = og.AttributeValueHelper(self._attributes.isNoise) return data_view.get() @isNoise.setter def isNoise(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.isNoise) data_view = og.AttributeValueHelper(self._attributes.isNoise) data_view.set(value) @property def max(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.max""" return og.RuntimeAttribute(self._attributes.max.get_attribute_data(), self._context, True) @max.setter def max(self, value_to_set: Any): """Assign another attribute's value to outputs.max""" if isinstance(value_to_set, og.RuntimeAttribute): self.max.value = value_to_set.value else: self.max.value = value_to_set @property def min(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.min""" return og.RuntimeAttribute(self._attributes.min.get_attribute_data(), self._context, True) @min.setter def min(self, value_to_set: Any): """Assign another attribute's value to outputs.min""" if isinstance(value_to_set, og.RuntimeAttribute): self.min.value = value_to_set.value else: self.min.value = value_to_set @property def seed(self): data_view = og.AttributeValueHelper(self._attributes.seed) return data_view.get() @seed.setter def seed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.seed) data_view = og.AttributeValueHelper(self._attributes.seed) data_view.set(value) @property def useSeed(self): data_view = og.AttributeValueHelper(self._attributes.useSeed) return data_view.get() @useSeed.setter def useSeed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useSeed) data_view = og.AttributeValueHelper(self._attributes.useSeed) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) data_view.set(value) @property def random(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.random""" return og.RuntimeAttribute(self._attributes.random.get_attribute_data(), self._context, False) @random.setter def random(self, value_to_set: Any): """Assign another attribute's value to outputs.random""" if isinstance(value_to_set, og.RuntimeAttribute): self.random.value = value_to_set.value else: self.random.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) @property def gen(self): data_view = og.AttributeValueHelper(self._attributes.gen) return data_view.get() @gen.setter def gen(self, value): data_view = og.AttributeValueHelper(self._attributes.gen) 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 = OgnRandomNumericDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnRandomNumericDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnRandomNumericDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnAppendPathDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.AppendPath Generates a path token by appending the given relative path token to the given root or prim path token """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnAppendPathDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.AppendPath Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.path inputs.suffix Outputs: outputs.path State: state.path state.suffix """ # 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:path', 'token,token[]', 1, None, 'The path token(s) to be appended to. Must be a base or prim path (ex. /World)', {}, True, None, False, ''), ('inputs:suffix', 'token', 0, None, 'The prim or prim-property path to append (ex. Cube or Cube.attr)', {}, True, "", False, ''), ('outputs:path', 'token,token[]', 1, None, 'The new path token(s) (ex. /World/Cube or /World/Cube.attr)', {}, True, None, False, ''), ('state:path', 'token', 0, None, 'Snapshot of previously seen path', {}, True, None, False, ''), ('state:suffix', 'token', 0, None, 'Snapshot of previously seen suffix', {}, 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 path(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.path""" return og.RuntimeAttribute(self._attributes.path.get_attribute_data(), self._context, True) @path.setter def path(self, value_to_set: Any): """Assign another attribute's value to outputs.path""" if isinstance(value_to_set, og.RuntimeAttribute): self.path.value = value_to_set.value else: self.path.value = value_to_set @property def suffix(self): data_view = og.AttributeValueHelper(self._attributes.suffix) return data_view.get() @suffix.setter def suffix(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.suffix) data_view = og.AttributeValueHelper(self._attributes.suffix) 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 path(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.path""" return og.RuntimeAttribute(self._attributes.path.get_attribute_data(), self._context, False) @path.setter def path(self, value_to_set: Any): """Assign another attribute's value to outputs.path""" if isinstance(value_to_set, og.RuntimeAttribute): self.path.value = value_to_set.value else: self.path.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) @property def path(self): data_view = og.AttributeValueHelper(self._attributes.path) return data_view.get() @path.setter def path(self, value): data_view = og.AttributeValueHelper(self._attributes.path) data_view.set(value) @property def suffix(self): data_view = og.AttributeValueHelper(self._attributes.suffix) return data_view.get() @suffix.setter def suffix(self, value): data_view = og.AttributeValueHelper(self._attributes.suffix) 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 = OgnAppendPathDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnAppendPathDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnAppendPathDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnStopAllSoundDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.StopAllSound Stop playing all sounds """ 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 OgnStopAllSoundDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.StopAllSound Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn Outputs: outputs.execOut """ # 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:execIn', 'execution', 0, None, 'The input execution', {}, True, None, False, ''), ('outputs:execOut', 'execution', 0, None, 'The output execution', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.outputs.execOut = og.AttributeRole.EXECUTION 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) 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 = OgnStopAllSoundDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnStopAllSoundDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnStopAllSoundDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnMatrixMultiplyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.MatrixMultiply Computes the matrix product of the inputs. Inputs must be compatible. Also accepts tuples (treated as vectors) as inputs. Tuples in input A will be treated as row vectors. Tuples in input B will be treated as column vectors. Arrays of inputs will be computed element-wise with broadcasting if necessary. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnMatrixMultiplyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.MatrixMultiply Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.b Outputs: outputs.output """ # 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[4],colorf[3],colorf[4],colorh[3],colorh[4],double[2],double[2][],double[3],double[3][],double[4],double[4][],float[2],float[2][],float[3],float[3][],float[4],float[4][],frame[4],half[2],half[2][],half[3],half[3][],half[4],half[4][],matrixd[3],matrixd[3][],matrixd[4],matrixd[4][],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],transform[4],vectord[3],vectorf[3],vectorh[3]', 1, 'A', 'First matrix or row vector to multiply', {}, True, None, False, ''), ('inputs:b', 'colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double[2],double[2][],double[3],double[3][],double[4],double[4][],float[2],float[2][],float[3],float[3][],float[4],float[4][],frame[4],half[2],half[2][],half[3],half[3][],half[4],half[4][],matrixd[3],matrixd[3][],matrixd[4],matrixd[4][],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],transform[4],vectord[3],vectorf[3],vectorh[3]', 1, 'B', 'Second matrix or column vector to multiply', {}, True, None, False, ''), ('outputs:output', 'colord[3],colord[4],colorf[3],colorf[4],colorh[3],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],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],matrixd[3],matrixd[3][],matrixd[4],matrixd[4][],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],transform[4],vectord[3],vectorf[3],vectorh[3]', 1, 'Product', 'Product of the two matrices', {}, 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 output(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.output""" return og.RuntimeAttribute(self._attributes.output.get_attribute_data(), self._context, False) @output.setter def output(self, value_to_set: Any): """Assign another attribute's value to outputs.output""" if isinstance(value_to_set, og.RuntimeAttribute): self.output.value = value_to_set.value else: self.output.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 = OgnMatrixMultiplyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnMatrixMultiplyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnMatrixMultiplyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnDotProductDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.DotProduct Compute the dot product of two (arrays of) vectors. If two arrays of vectors are provided, then the dot product will be taken element-wise. Inputs must be the same shape """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnDotProductDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.DotProduct 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[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'A', 'The first vector in the dot product', {}, 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[2],double[2][],double[3],double[3][],double[4],double[4][],double[],float[2],float[2][],float[3],float[3][],float[4],float[4][],float[],half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'B', 'The second vector in the dot product', {}, True, None, False, ''), ('outputs:product', 'double,double[],float,float[],half,half[],timecode', 1, 'Product', 'The resulting product', {}, 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 = OgnDotProductDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnDotProductDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnDotProductDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetVariantNamesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetVariantNames Get variant names from a variantSet on a prim """ import carb import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetVariantNamesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetVariantNames Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim inputs.variantSetName Outputs: outputs.variantNames """ # 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:prim', 'target', 0, None, 'The prim with the variantSet', {}, True, [], False, ''), ('inputs:variantSetName', 'token', 0, None, 'The variantSet name', {}, True, "", False, ''), ('outputs:variantNames', 'token[]', 0, None, 'List of variant names', {}, 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.prim = og.AttributeRole.TARGET 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 prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def variantSetName(self): data_view = og.AttributeValueHelper(self._attributes.variantSetName) return data_view.get() @variantSetName.setter def variantSetName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.variantSetName) data_view = og.AttributeValueHelper(self._attributes.variantSetName) 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.variantNames_size = None self._batchedWriteValues = { } @property def variantNames(self): data_view = og.AttributeValueHelper(self._attributes.variantNames) return data_view.get(reserved_element_count=self.variantNames_size) @variantNames.setter def variantNames(self, value): data_view = og.AttributeValueHelper(self._attributes.variantNames) data_view.set(value) self.variantNames_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 = OgnGetVariantNamesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetVariantNamesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetVariantNamesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRandomGaussianDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.RandomGaussian Generates a random numeric value using a Gaussian (aka normal) distribution. The shape can be controlled with two inputs: mean and standard deviation. These inputs can be numbers, vectors, tuples or arrays of these. If one input has a higher dimension than the other, then the input with lower dimension will be repeated to match the dimension of the other input (broadcasting). """ from typing import Any 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 OgnRandomGaussianDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.RandomGaussian Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.isNoise inputs.mean inputs.seed inputs.stdev inputs.useLog inputs.useSeed Outputs: outputs.execOut outputs.random State: state.gen """ # 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:execIn', 'execution', 0, None, 'The input execution port to output a new random value', {}, True, None, False, ''), ('inputs:isNoise', 'bool', 0, 'Is noise function', 'Turn this node into a noise generator function\nFor a given seed, it will then always output the same number(s)', {ogn.MetadataKeys.HIDDEN: 'true', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:mean', '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[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Mean', 'The mean of the normal distribution.\nCan be a number, vector, tuple, or array of these.\nThe default value is double 0.', {}, False, None, False, ''), ('inputs:seed', 'uint64', 0, 'Seed', 'The seed of the random generator.', {}, False, None, False, ''), ('inputs:stdev', '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[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Standard Deviation', 'The standard deviation of the normal distribution.\nCan be a number, vector, tuple, or array of these.\nThe default value is double 1.', {}, False, None, False, ''), ('inputs:useLog', 'bool', 0, 'Use log-normal', 'Use a log-normal distribution instead', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:useSeed', 'bool', 0, 'Use seed', 'Use the custom seed instead of a random one', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('outputs:execOut', 'execution', 0, None, 'The output execution port', {}, True, None, False, ''), ('outputs:random', '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[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Random Gaussian', 'The random Gaussian value that was generated', {}, True, None, False, ''), ('state:gen', 'matrix3d', 0, None, 'Random number generator internal state (abusing matrix3d because it is large enough)', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.outputs.execOut = og.AttributeRole.EXECUTION role_data.state.gen = 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def isNoise(self): data_view = og.AttributeValueHelper(self._attributes.isNoise) return data_view.get() @isNoise.setter def isNoise(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.isNoise) data_view = og.AttributeValueHelper(self._attributes.isNoise) data_view.set(value) @property def mean(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.mean""" return og.RuntimeAttribute(self._attributes.mean.get_attribute_data(), self._context, True) @mean.setter def mean(self, value_to_set: Any): """Assign another attribute's value to outputs.mean""" if isinstance(value_to_set, og.RuntimeAttribute): self.mean.value = value_to_set.value else: self.mean.value = value_to_set @property def seed(self): data_view = og.AttributeValueHelper(self._attributes.seed) return data_view.get() @seed.setter def seed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.seed) data_view = og.AttributeValueHelper(self._attributes.seed) data_view.set(value) @property def stdev(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.stdev""" return og.RuntimeAttribute(self._attributes.stdev.get_attribute_data(), self._context, True) @stdev.setter def stdev(self, value_to_set: Any): """Assign another attribute's value to outputs.stdev""" if isinstance(value_to_set, og.RuntimeAttribute): self.stdev.value = value_to_set.value else: self.stdev.value = value_to_set @property def useLog(self): data_view = og.AttributeValueHelper(self._attributes.useLog) return data_view.get() @useLog.setter def useLog(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useLog) data_view = og.AttributeValueHelper(self._attributes.useLog) data_view.set(value) @property def useSeed(self): data_view = og.AttributeValueHelper(self._attributes.useSeed) return data_view.get() @useSeed.setter def useSeed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useSeed) data_view = og.AttributeValueHelper(self._attributes.useSeed) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) data_view.set(value) @property def random(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.random""" return og.RuntimeAttribute(self._attributes.random.get_attribute_data(), self._context, False) @random.setter def random(self, value_to_set: Any): """Assign another attribute's value to outputs.random""" if isinstance(value_to_set, og.RuntimeAttribute): self.random.value = value_to_set.value else: self.random.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) @property def gen(self): data_view = og.AttributeValueHelper(self._attributes.gen) return data_view.get() @gen.setter def gen(self, value): data_view = og.AttributeValueHelper(self._attributes.gen) 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 = OgnRandomGaussianDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnRandomGaussianDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnRandomGaussianDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnNotDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.BooleanNot Inverts a bool or bool array """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnNotDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.BooleanNot Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.valueIn Outputs: outputs.valueOut """ # 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:valueIn', 'bool,bool[]', 1, None, 'bool or bool array to invert', {}, True, None, False, ''), ('outputs:valueOut', 'bool,bool[]', 1, None, 'inverted bool or bool 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 valueIn(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.valueIn""" return og.RuntimeAttribute(self._attributes.valueIn.get_attribute_data(), self._context, True) @valueIn.setter def valueIn(self, value_to_set: Any): """Assign another attribute's value to outputs.valueIn""" if isinstance(value_to_set, og.RuntimeAttribute): self.valueIn.value = value_to_set.value else: self.valueIn.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 valueOut(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.valueOut""" return og.RuntimeAttribute(self._attributes.valueOut.get_attribute_data(), self._context, False) @valueOut.setter def valueOut(self, value_to_set: Any): """Assign another attribute's value to outputs.valueOut""" if isinstance(value_to_set, og.RuntimeAttribute): self.valueOut.value = value_to_set.value else: self.valueOut.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 = OgnNotDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnNotDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnNotDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetPrimsAtPathDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetPrimsAtPath This node computes a prim path from either a single or an array of pth tokens. """ from typing import Any import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetPrimsAtPathDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetPrimsAtPath Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.path Outputs: outputs.prims State: state.path """ # 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:path', 'token,token[]', 1, None, 'A token or token array to compute representing a path.', {}, True, None, False, ''), ('outputs:prims', 'target', 0, None, 'The output prim paths', {}, True, [], False, ''), ('state:path', 'token', 0, None, 'Snapshot of previously seen path', {}, 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.prims = og.AttributeRole.TARGET 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 path(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.path""" return og.RuntimeAttribute(self._attributes.path.get_attribute_data(), self._context, True) @path.setter def path(self, value_to_set: Any): """Assign another attribute's value to outputs.path""" if isinstance(value_to_set, og.RuntimeAttribute): self.path.value = value_to_set.value else: self.path.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.prims_size = None self._batchedWriteValues = { } @property def prims(self): data_view = og.AttributeValueHelper(self._attributes.prims) return data_view.get(reserved_element_count=self.prims_size) @prims.setter def prims(self, value): data_view = og.AttributeValueHelper(self._attributes.prims) data_view.set(value) self.prims_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) @property def path(self): data_view = og.AttributeValueHelper(self._attributes.path) return data_view.get() @path.setter def path(self, value): data_view = og.AttributeValueHelper(self._attributes.path) 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 = OgnGetPrimsAtPathDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetPrimsAtPathDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetPrimsAtPathDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnFindPrimsDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.FindPrims Finds Prims on the stage which match the given criteria """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnFindPrimsDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.FindPrims Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.ignoreSystemPrims inputs.namePrefix inputs.pathPattern inputs.recursive inputs.requiredAttributes inputs.requiredRelationship inputs.requiredRelationshipTarget inputs.requiredTarget inputs.rootPrim inputs.rootPrimPath inputs.type Outputs: outputs.primPaths outputs.prims State: state.ignoreSystemPrims state.inputType state.namePrefix state.pathPattern state.recursive state.requiredAttributes state.requiredRelationship state.requiredRelationshipTarget state.requiredTarget state.rootPrim state.rootPrimPath """ # 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:ignoreSystemPrims', 'bool', 0, None, "Ignore system prims such as omni graph nodes that shouldn't be considered during the import.", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:namePrefix', 'token', 0, 'Prim Name Prefix', 'Only prims with a name starting with the given prefix will be returned.', {}, True, "", False, ''), ('inputs:pathPattern', 'token', 0, 'Prim Path Pattern', "A list of wildcard patterns used to match the prim paths\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['/Cube0', '/Cube1', '/Box']\n '*' - match any\n '* ^/Box' - match any, but exclude '/Box'\n '* ^/Cube*' - match any, but exclude '/Cube0' and '/Cube1'", {}, True, "", False, ''), ('inputs:recursive', 'bool', 0, None, 'False means only consider children of the root prim, True means all prims in the hierarchy', {}, True, False, False, ''), ('inputs:requiredAttributes', 'string', 0, 'Attribute Names', 'A space-separated list of attribute names that are required to be present on matched prims', {}, True, "", False, ''), ('inputs:requiredRelationship', 'token', 0, 'Relationship Name', 'The name of a relationship which must have a target specified by requiredRelationshipTarget or requiredTarget', {}, True, "", False, ''), ('inputs:requiredRelationshipTarget', 'path', 0, 'Relationship Prim Path', 'The path that must be a target of the requiredRelationship', {}, True, "", True, 'Use requiredTarget instead'), ('inputs:requiredTarget', 'target', 0, 'Relationship Prim', 'The target of the requiredRelationship', {}, True, [], False, ''), ('inputs:rootPrim', 'target', 0, 'Root Prim', 'Only children of the given prim will be considered. If rootPrim is specified, rootPrimPath will be ignored.', {}, True, [], False, ''), ('inputs:rootPrimPath', 'token', 0, 'Root Prim Path', 'Only children of the given prim will be considered. Empty will search the whole stage.', {}, True, "", True, 'Use rootPrim input attribute instead'), ('inputs:type', 'token', 0, 'Prim Type Pattern', "A list of wildcard patterns used to match the prim types that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['Mesh', 'Cone', 'Cube']\n '*' - match any\n '* ^Mesh' - match any, but exclude 'Mesh'\n '* ^Cone ^Cube' - match any, but exclude 'Cone' and 'Cube'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('outputs:primPaths', 'token[]', 0, None, 'A list of Prim paths as tokens which match the given type', {}, True, None, False, ''), ('outputs:prims', 'target', 0, None, 'A list of Prim paths which match the given type', {}, True, [], False, ''), ('state:ignoreSystemPrims', 'bool', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:inputType', 'token', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:namePrefix', 'token', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:pathPattern', 'token', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:recursive', 'bool', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:requiredAttributes', 'string', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:requiredRelationship', 'token', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:requiredRelationshipTarget', 'string', 0, None, 'last corresponding input seen', {}, True, None, False, ''), ('state:requiredTarget', 'target', 0, None, 'last corresponding input seen', {}, True, [], False, ''), ('state:rootPrim', 'target', 0, None, 'last corresponding input seen', {}, True, [], False, ''), ('state:rootPrimPath', 'token', 0, None, 'last corresponding input seen', {}, 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.requiredAttributes = og.AttributeRole.TEXT role_data.inputs.requiredRelationshipTarget = og.AttributeRole.PATH role_data.inputs.requiredTarget = og.AttributeRole.TARGET role_data.inputs.rootPrim = og.AttributeRole.TARGET role_data.outputs.prims = og.AttributeRole.TARGET role_data.state.requiredAttributes = og.AttributeRole.TEXT role_data.state.requiredRelationshipTarget = og.AttributeRole.TEXT role_data.state.requiredTarget = og.AttributeRole.TARGET role_data.state.rootPrim = og.AttributeRole.TARGET 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 ignoreSystemPrims(self): data_view = og.AttributeValueHelper(self._attributes.ignoreSystemPrims) return data_view.get() @ignoreSystemPrims.setter def ignoreSystemPrims(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.ignoreSystemPrims) data_view = og.AttributeValueHelper(self._attributes.ignoreSystemPrims) data_view.set(value) @property def namePrefix(self): data_view = og.AttributeValueHelper(self._attributes.namePrefix) return data_view.get() @namePrefix.setter def namePrefix(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.namePrefix) data_view = og.AttributeValueHelper(self._attributes.namePrefix) data_view.set(value) @property def pathPattern(self): data_view = og.AttributeValueHelper(self._attributes.pathPattern) return data_view.get() @pathPattern.setter def pathPattern(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.pathPattern) data_view = og.AttributeValueHelper(self._attributes.pathPattern) data_view.set(value) @property def recursive(self): data_view = og.AttributeValueHelper(self._attributes.recursive) return data_view.get() @recursive.setter def recursive(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.recursive) data_view = og.AttributeValueHelper(self._attributes.recursive) data_view.set(value) @property def requiredAttributes(self): data_view = og.AttributeValueHelper(self._attributes.requiredAttributes) return data_view.get() @requiredAttributes.setter def requiredAttributes(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.requiredAttributes) data_view = og.AttributeValueHelper(self._attributes.requiredAttributes) data_view.set(value) self.requiredAttributes_size = data_view.get_array_size() @property def requiredRelationship(self): data_view = og.AttributeValueHelper(self._attributes.requiredRelationship) return data_view.get() @requiredRelationship.setter def requiredRelationship(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.requiredRelationship) data_view = og.AttributeValueHelper(self._attributes.requiredRelationship) data_view.set(value) @property def requiredRelationshipTarget(self): data_view = og.AttributeValueHelper(self._attributes.requiredRelationshipTarget) return data_view.get() @requiredRelationshipTarget.setter def requiredRelationshipTarget(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.requiredRelationshipTarget) data_view = og.AttributeValueHelper(self._attributes.requiredRelationshipTarget) data_view.set(value) self.requiredRelationshipTarget_size = data_view.get_array_size() @property def requiredTarget(self): data_view = og.AttributeValueHelper(self._attributes.requiredTarget) return data_view.get() @requiredTarget.setter def requiredTarget(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.requiredTarget) data_view = og.AttributeValueHelper(self._attributes.requiredTarget) data_view.set(value) self.requiredTarget_size = data_view.get_array_size() @property def rootPrim(self): data_view = og.AttributeValueHelper(self._attributes.rootPrim) return data_view.get() @rootPrim.setter def rootPrim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.rootPrim) data_view = og.AttributeValueHelper(self._attributes.rootPrim) data_view.set(value) self.rootPrim_size = data_view.get_array_size() @property def rootPrimPath(self): data_view = og.AttributeValueHelper(self._attributes.rootPrimPath) return data_view.get() @rootPrimPath.setter def rootPrimPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.rootPrimPath) data_view = og.AttributeValueHelper(self._attributes.rootPrimPath) data_view.set(value) @property def type(self): data_view = og.AttributeValueHelper(self._attributes.type) return data_view.get() @type.setter def type(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.type) data_view = og.AttributeValueHelper(self._attributes.type) 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.primPaths_size = None self.prims_size = None self._batchedWriteValues = { } @property def primPaths(self): data_view = og.AttributeValueHelper(self._attributes.primPaths) return data_view.get(reserved_element_count=self.primPaths_size) @primPaths.setter def primPaths(self, value): data_view = og.AttributeValueHelper(self._attributes.primPaths) data_view.set(value) self.primPaths_size = data_view.get_array_size() @property def prims(self): data_view = og.AttributeValueHelper(self._attributes.prims) return data_view.get(reserved_element_count=self.prims_size) @prims.setter def prims(self, value): data_view = og.AttributeValueHelper(self._attributes.prims) data_view.set(value) self.prims_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) self.requiredAttributes_size = None self.requiredRelationshipTarget_size = None self.requiredTarget_size = None self.rootPrim_size = None @property def ignoreSystemPrims(self): data_view = og.AttributeValueHelper(self._attributes.ignoreSystemPrims) return data_view.get() @ignoreSystemPrims.setter def ignoreSystemPrims(self, value): data_view = og.AttributeValueHelper(self._attributes.ignoreSystemPrims) data_view.set(value) @property def inputType(self): data_view = og.AttributeValueHelper(self._attributes.inputType) return data_view.get() @inputType.setter def inputType(self, value): data_view = og.AttributeValueHelper(self._attributes.inputType) data_view.set(value) @property def namePrefix(self): data_view = og.AttributeValueHelper(self._attributes.namePrefix) return data_view.get() @namePrefix.setter def namePrefix(self, value): data_view = og.AttributeValueHelper(self._attributes.namePrefix) data_view.set(value) @property def pathPattern(self): data_view = og.AttributeValueHelper(self._attributes.pathPattern) return data_view.get() @pathPattern.setter def pathPattern(self, value): data_view = og.AttributeValueHelper(self._attributes.pathPattern) data_view.set(value) @property def recursive(self): data_view = og.AttributeValueHelper(self._attributes.recursive) return data_view.get() @recursive.setter def recursive(self, value): data_view = og.AttributeValueHelper(self._attributes.recursive) data_view.set(value) @property def requiredAttributes(self): data_view = og.AttributeValueHelper(self._attributes.requiredAttributes) self.requiredAttributes_size = data_view.get_array_size() return data_view.get() @requiredAttributes.setter def requiredAttributes(self, value): data_view = og.AttributeValueHelper(self._attributes.requiredAttributes) data_view.set(value) self.requiredAttributes_size = data_view.get_array_size() @property def requiredRelationship(self): data_view = og.AttributeValueHelper(self._attributes.requiredRelationship) return data_view.get() @requiredRelationship.setter def requiredRelationship(self, value): data_view = og.AttributeValueHelper(self._attributes.requiredRelationship) data_view.set(value) @property def requiredRelationshipTarget(self): data_view = og.AttributeValueHelper(self._attributes.requiredRelationshipTarget) self.requiredRelationshipTarget_size = data_view.get_array_size() return data_view.get() @requiredRelationshipTarget.setter def requiredRelationshipTarget(self, value): data_view = og.AttributeValueHelper(self._attributes.requiredRelationshipTarget) data_view.set(value) self.requiredRelationshipTarget_size = data_view.get_array_size() @property def requiredTarget(self): data_view = og.AttributeValueHelper(self._attributes.requiredTarget) self.requiredTarget_size = data_view.get_array_size() return data_view.get() @requiredTarget.setter def requiredTarget(self, value): data_view = og.AttributeValueHelper(self._attributes.requiredTarget) data_view.set(value) self.requiredTarget_size = data_view.get_array_size() @property def rootPrim(self): data_view = og.AttributeValueHelper(self._attributes.rootPrim) self.rootPrim_size = data_view.get_array_size() return data_view.get() @rootPrim.setter def rootPrim(self, value): data_view = og.AttributeValueHelper(self._attributes.rootPrim) data_view.set(value) self.rootPrim_size = data_view.get_array_size() @property def rootPrimPath(self): data_view = og.AttributeValueHelper(self._attributes.rootPrimPath) return data_view.get() @rootPrimPath.setter def rootPrimPath(self, value): data_view = og.AttributeValueHelper(self._attributes.rootPrimPath) 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 = OgnFindPrimsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnFindPrimsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnFindPrimsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnIsPrimActiveDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.IsPrimActive Query if a Prim is active or not in the stage. """ import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnIsPrimActiveDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.IsPrimActive Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim inputs.primTarget Outputs: outputs.active """ # 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:prim', 'path', 0, 'Prim Path', 'The prim path to be queried', {}, True, "", True, 'Use primTarget instead'), ('inputs:primTarget', 'target', 0, 'Prim', 'The prim to be queried', {}, True, [], False, ''), ('outputs:active', 'bool', 0, None, 'Whether the prim is active or not', {}, 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.prim = og.AttributeRole.PATH role_data.inputs.primTarget = og.AttributeRole.TARGET 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 prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primTarget(self): data_view = og.AttributeValueHelper(self._attributes.primTarget) return data_view.get() @primTarget.setter def primTarget(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primTarget) data_view = og.AttributeValueHelper(self._attributes.primTarget) data_view.set(value) self.primTarget_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._batchedWriteValues = { } @property def active(self): data_view = og.AttributeValueHelper(self._attributes.active) return data_view.get() @active.setter def active(self, value): data_view = og.AttributeValueHelper(self._attributes.active) 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 = OgnIsPrimActiveDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnIsPrimActiveDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnIsPrimActiveDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRandomUnitQuaternionDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.RandomUnitQuaternion Generates a random unit quaternion with uniform distribution. """ 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 OgnRandomUnitQuaternionDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.RandomUnitQuaternion Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.isNoise inputs.seed inputs.useSeed Outputs: outputs.execOut outputs.random State: state.gen """ # 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:execIn', 'execution', 0, None, 'The input execution port to output a new random value', {}, True, None, False, ''), ('inputs:isNoise', 'bool', 0, 'Is noise function', 'Turn this node into a noise generator function\nFor a given seed, it will then always output the same number(s)', {ogn.MetadataKeys.HIDDEN: 'true', ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:seed', 'uint64', 0, 'Seed', 'The seed of the random generator.', {}, False, None, False, ''), ('inputs:useSeed', 'bool', 0, 'Use seed', 'Use the custom seed instead of a random one', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('outputs:execOut', 'execution', 0, None, 'The output execution port', {}, True, None, False, ''), ('outputs:random', 'quatf', 0, 'Random Unit Quaternion', 'The random unit quaternion that was generated', {}, True, None, False, ''), ('state:gen', 'matrix3d', 0, None, 'Random number generator internal state (abusing matrix3d because it is large enough)', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.outputs.execOut = og.AttributeRole.EXECUTION role_data.outputs.random = og.AttributeRole.QUATERNION role_data.state.gen = 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def isNoise(self): data_view = og.AttributeValueHelper(self._attributes.isNoise) return data_view.get() @isNoise.setter def isNoise(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.isNoise) data_view = og.AttributeValueHelper(self._attributes.isNoise) data_view.set(value) @property def seed(self): data_view = og.AttributeValueHelper(self._attributes.seed) return data_view.get() @seed.setter def seed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.seed) data_view = og.AttributeValueHelper(self._attributes.seed) data_view.set(value) @property def useSeed(self): data_view = og.AttributeValueHelper(self._attributes.useSeed) return data_view.get() @useSeed.setter def useSeed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useSeed) data_view = og.AttributeValueHelper(self._attributes.useSeed) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) data_view.set(value) @property def random(self): data_view = og.AttributeValueHelper(self._attributes.random) return data_view.get() @random.setter def random(self, value): data_view = og.AttributeValueHelper(self._attributes.random) 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) @property def gen(self): data_view = og.AttributeValueHelper(self._attributes.gen) return data_view.get() @gen.setter def gen(self, value): data_view = og.AttributeValueHelper(self._attributes.gen) 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 = OgnRandomUnitQuaternionDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnRandomUnitQuaternionDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnRandomUnitQuaternionDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadKeyboardStateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ReadKeyboardState Reads the current state of the keyboard """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadKeyboardStateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadKeyboardState Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.key Outputs: outputs.altOut outputs.ctrlOut outputs.isPressed outputs.shiftOut Predefined Tokens: tokens.A tokens.B tokens.C tokens.D tokens.E tokens.F tokens.G tokens.H tokens.I tokens.J tokens.K tokens.L tokens.M tokens.N tokens.O tokens.P tokens.Q tokens.R tokens.S tokens.T tokens.U tokens.V tokens.W tokens.X tokens.Y tokens.Z tokens.Apostrophe tokens.Backslash tokens.Backspace tokens.CapsLock tokens.Comma tokens.Del tokens.Down tokens.End tokens.Enter tokens.Equal tokens.Escape tokens.F1 tokens.F10 tokens.F11 tokens.F12 tokens.F2 tokens.F3 tokens.F4 tokens.F5 tokens.F6 tokens.F7 tokens.F8 tokens.F9 tokens.GraveAccent tokens.Home tokens.Insert tokens.Key0 tokens.Key1 tokens.Key2 tokens.Key3 tokens.Key4 tokens.Key5 tokens.Key6 tokens.Key7 tokens.Key8 tokens.Key9 tokens.Left tokens.LeftAlt tokens.LeftBracket tokens.LeftControl tokens.LeftShift tokens.LeftSuper tokens.Menu tokens.Minus tokens.NumLock tokens.Numpad0 tokens.Numpad1 tokens.Numpad2 tokens.Numpad3 tokens.Numpad4 tokens.Numpad5 tokens.Numpad6 tokens.Numpad7 tokens.Numpad8 tokens.Numpad9 tokens.NumpadAdd tokens.NumpadDel tokens.NumpadDivide tokens.NumpadEnter tokens.NumpadEqual tokens.NumpadMultiply tokens.NumpadSubtract tokens.PageDown tokens.PageUp tokens.Pause tokens.Period tokens.PrintScreen tokens.Right tokens.RightAlt tokens.RightBracket tokens.RightControl tokens.RightShift tokens.RightSuper tokens.ScrollLock tokens.Semicolon tokens.Slash tokens.Space tokens.Tab tokens.Up """ # 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:key', 'token', 0, 'Key', 'The key to check the state of', {'displayGroup': 'parameters', ogn.MetadataKeys.ALLOWED_TOKENS: 'A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Apostrophe,Backslash,Backspace,CapsLock,Comma,Del,Down,End,Enter,Equal,Escape,F1,F10,F11,F12,F2,F3,F4,F5,F6,F7,F8,F9,GraveAccent,Home,Insert,Key0,Key1,Key2,Key3,Key4,Key5,Key6,Key7,Key8,Key9,Left,LeftAlt,LeftBracket,LeftControl,LeftShift,LeftSuper,Menu,Minus,NumLock,Numpad0,Numpad1,Numpad2,Numpad3,Numpad4,Numpad5,Numpad6,Numpad7,Numpad8,Numpad9,NumpadAdd,NumpadDel,NumpadDivide,NumpadEnter,NumpadEqual,NumpadMultiply,NumpadSubtract,PageDown,PageUp,Pause,Period,PrintScreen,Right,RightAlt,RightBracket,RightControl,RightShift,RightSuper,ScrollLock,Semicolon,Slash,Space,Tab,Up', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Apostrophe", "Backslash", "Backspace", "CapsLock", "Comma", "Del", "Down", "End", "Enter", "Equal", "Escape", "F1", "F10", "F11", "F12", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "GraveAccent", "Home", "Insert", "Key0", "Key1", "Key2", "Key3", "Key4", "Key5", "Key6", "Key7", "Key8", "Key9", "Left", "LeftAlt", "LeftBracket", "LeftControl", "LeftShift", "LeftSuper", "Menu", "Minus", "NumLock", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadAdd", "NumpadDel", "NumpadDivide", "NumpadEnter", "NumpadEqual", "NumpadMultiply", "NumpadSubtract", "PageDown", "PageUp", "Pause", "Period", "PrintScreen", "Right", "RightAlt", "RightBracket", "RightControl", "RightShift", "RightSuper", "ScrollLock", "Semicolon", "Slash", "Space", "Tab", "Up"]', ogn.MetadataKeys.DEFAULT: '"A"'}, True, "A", False, ''), ('outputs:altOut', 'bool', 0, 'Alt', 'True if Alt is held', {}, True, None, False, ''), ('outputs:ctrlOut', 'bool', 0, 'Ctrl', 'True if Ctrl is held', {}, True, None, False, ''), ('outputs:isPressed', 'bool', 0, None, 'True if the key is currently pressed, false otherwise', {}, True, None, False, ''), ('outputs:shiftOut', 'bool', 0, 'Shift', 'True if Shift is held', {}, True, None, False, ''), ]) class tokens: A = "A" B = "B" C = "C" D = "D" E = "E" F = "F" G = "G" H = "H" I = "I" J = "J" K = "K" L = "L" M = "M" N = "N" O = "O" P = "P" Q = "Q" R = "R" S = "S" T = "T" U = "U" V = "V" W = "W" X = "X" Y = "Y" Z = "Z" Apostrophe = "Apostrophe" Backslash = "Backslash" Backspace = "Backspace" CapsLock = "CapsLock" Comma = "Comma" Del = "Del" Down = "Down" End = "End" Enter = "Enter" Equal = "Equal" Escape = "Escape" F1 = "F1" F10 = "F10" F11 = "F11" F12 = "F12" F2 = "F2" F3 = "F3" F4 = "F4" F5 = "F5" F6 = "F6" F7 = "F7" F8 = "F8" F9 = "F9" GraveAccent = "GraveAccent" Home = "Home" Insert = "Insert" Key0 = "Key0" Key1 = "Key1" Key2 = "Key2" Key3 = "Key3" Key4 = "Key4" Key5 = "Key5" Key6 = "Key6" Key7 = "Key7" Key8 = "Key8" Key9 = "Key9" Left = "Left" LeftAlt = "LeftAlt" LeftBracket = "LeftBracket" LeftControl = "LeftControl" LeftShift = "LeftShift" LeftSuper = "LeftSuper" Menu = "Menu" Minus = "Minus" NumLock = "NumLock" Numpad0 = "Numpad0" Numpad1 = "Numpad1" Numpad2 = "Numpad2" Numpad3 = "Numpad3" Numpad4 = "Numpad4" Numpad5 = "Numpad5" Numpad6 = "Numpad6" Numpad7 = "Numpad7" Numpad8 = "Numpad8" Numpad9 = "Numpad9" NumpadAdd = "NumpadAdd" NumpadDel = "NumpadDel" NumpadDivide = "NumpadDivide" NumpadEnter = "NumpadEnter" NumpadEqual = "NumpadEqual" NumpadMultiply = "NumpadMultiply" NumpadSubtract = "NumpadSubtract" PageDown = "PageDown" PageUp = "PageUp" Pause = "Pause" Period = "Period" PrintScreen = "PrintScreen" Right = "Right" RightAlt = "RightAlt" RightBracket = "RightBracket" RightControl = "RightControl" RightShift = "RightShift" RightSuper = "RightSuper" ScrollLock = "ScrollLock" Semicolon = "Semicolon" Slash = "Slash" Space = "Space" Tab = "Tab" Up = "Up" 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 key(self): data_view = og.AttributeValueHelper(self._attributes.key) return data_view.get() @key.setter def key(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.key) data_view = og.AttributeValueHelper(self._attributes.key) 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 altOut(self): data_view = og.AttributeValueHelper(self._attributes.altOut) return data_view.get() @altOut.setter def altOut(self, value): data_view = og.AttributeValueHelper(self._attributes.altOut) data_view.set(value) @property def ctrlOut(self): data_view = og.AttributeValueHelper(self._attributes.ctrlOut) return data_view.get() @ctrlOut.setter def ctrlOut(self, value): data_view = og.AttributeValueHelper(self._attributes.ctrlOut) data_view.set(value) @property def isPressed(self): data_view = og.AttributeValueHelper(self._attributes.isPressed) return data_view.get() @isPressed.setter def isPressed(self, value): data_view = og.AttributeValueHelper(self._attributes.isPressed) data_view.set(value) @property def shiftOut(self): data_view = og.AttributeValueHelper(self._attributes.shiftOut) return data_view.get() @shiftOut.setter def shiftOut(self, value): data_view = og.AttributeValueHelper(self._attributes.shiftOut) 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 = OgnReadKeyboardStateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadKeyboardStateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadKeyboardStateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnWritePrimsV2Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.WritePrimsV2 Write back bundle(s) containing multiple prims to the stage. """ import usdrt 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 OgnWritePrimsV2Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.WritePrimsV2 Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.attrNamesToExport inputs.execIn inputs.layerIdentifier inputs.pathPattern inputs.prims inputs.primsBundle inputs.scatterUnderTargets inputs.typePattern inputs.usdWriteBack Outputs: outputs.execOut State: state.attrNamesToExport state.layerIdentifier state.pathPattern state.primBundleDirtyId state.scatterUnderTargets state.typePattern state.usdWriteBack """ # 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:attrNamesToExport', 'string', 0, 'Attribute Name Pattern', "A list of wildcard patterns used to match primitive attributes by name.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['xFormOp:translate', 'xformOp:scale','radius']\n '*' - match any\n 'xformOp:*' - matches 'xFormOp:translate' and 'xformOp:scale'\n '* ^radius' - match any, but exclude 'radius'\n '* ^xformOp*' - match any, but exclude 'xFormOp:translate', 'xformOp:scale'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('inputs:execIn', 'execution', 0, None, 'The input execution (for action graphs only)', {}, True, None, False, ''), ('inputs:layerIdentifier', 'token', 0, 'Layer Identifier', 'Identifier of the layer to export to. If empty, it\'ll be exported to the current edit target at the time of usd wirte back.\'\nThis is only used when "Persist To USD" is enabled.', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:pathPattern', 'string', 0, 'Prim Path Pattern', "A list of wildcard patterns used to match primitives by path.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['/Cube0', '/Cube1', '/Box']\n '*' - match any\n '* ^/Box' - match any, but exclude '/Box'\n '* ^/Cube*' - match any, but exclude '/Cube0' and '/Cube1'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('inputs:prims', 'target', 0, 'Prims', "Target(s) to which the prims in 'primsBundle' will be written to.\nThere is a 1:1 mapping between root prims paths in 'primsBundle' and the Target Prims targets\n*For advanced usage, if 'primsBundle' contains hierarchy, the unique common ancesor paths will have \n the 1:1 mapping to Target Prims targets, with the descendant paths remapped.\n*NOTE* See 'scatterUnderTargets' input for modified exporting behavior\n*WARNING* this can create new prims on the stage.\nIf attributes or prims are removed from 'primsBundle' in subsequent evaluation, they will be removed from targets as well.", {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, True, [], False, ''), ('inputs:primsBundle', 'bundle', 0, 'Prims Bundle', 'The bundle(s) of multiple prims to be written back.\nThe sourcePrimPath attribute is used to find the destination prim.', {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, True, None, False, ''), ('inputs:scatterUnderTargets', 'bool', 0, 'Scatter Under Targets', 'If true, the target prims become the parent prims that the bundled prims will be exported *UNDER*. \nIf multiple prims targets are provided, the primsBundle will be duplicated *UNDER* each \ntarget prims.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:typePattern', 'string', 0, 'Prim Type Pattern', "A list of wildcard patterns used to match primitives by type.\n\nSupported syntax of wildcard pattern:\n `*` - match an arbitrary number of any characters\n `?` - match any single character\n `^` - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['Mesh', 'Cone', 'Cube']\n '*' - match any\n '* ^Mesh' - match any, but exclude 'Mesh'\n '* ^Cone ^Cube' - match any, but exclude 'Cone' and 'Cube'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('inputs:usdWriteBack', 'bool', 0, 'Persist To USD', 'Whether or not the value should be written back to USD, or kept a Fabric only value', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('outputs:execOut', 'execution', 0, None, 'The output execution port (for action graphs only)', {}, True, None, False, ''), ('state:attrNamesToExport', 'string', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('state:layerIdentifier', 'token', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('state:pathPattern', 'string', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('state:primBundleDirtyId', 'uint64', 0, None, 'State from previous evaluation', {}, True, None, False, ''), ('state:scatterUnderTargets', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('state:typePattern', 'string', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('state:usdWriteBack', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, 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.attrNamesToExport = og.AttributeRole.TEXT role_data.inputs.execIn = og.AttributeRole.EXECUTION role_data.inputs.pathPattern = og.AttributeRole.TEXT role_data.inputs.prims = og.AttributeRole.TARGET role_data.inputs.primsBundle = og.AttributeRole.BUNDLE role_data.inputs.typePattern = og.AttributeRole.TEXT role_data.outputs.execOut = og.AttributeRole.EXECUTION role_data.state.attrNamesToExport = og.AttributeRole.TEXT role_data.state.pathPattern = og.AttributeRole.TEXT role_data.state.typePattern = 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.__bundles = og.BundleContainer(context, node, attributes, [], read_only=True, gpu_ptr_kinds={}) self._batchedReadAttributes = [] self._batchedReadValues = [] @property def attrNamesToExport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport) return data_view.get() @attrNamesToExport.setter def attrNamesToExport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrNamesToExport) data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport) data_view.set(value) self.attrNamesToExport_size = data_view.get_array_size() @property def execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def layerIdentifier(self): data_view = og.AttributeValueHelper(self._attributes.layerIdentifier) return data_view.get() @layerIdentifier.setter def layerIdentifier(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.layerIdentifier) data_view = og.AttributeValueHelper(self._attributes.layerIdentifier) data_view.set(value) @property def pathPattern(self): data_view = og.AttributeValueHelper(self._attributes.pathPattern) return data_view.get() @pathPattern.setter def pathPattern(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.pathPattern) data_view = og.AttributeValueHelper(self._attributes.pathPattern) data_view.set(value) self.pathPattern_size = data_view.get_array_size() @property def prims(self): data_view = og.AttributeValueHelper(self._attributes.prims) return data_view.get() @prims.setter def prims(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prims) data_view = og.AttributeValueHelper(self._attributes.prims) data_view.set(value) self.prims_size = data_view.get_array_size() @property def primsBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.primsBundle""" return self.__bundles.primsBundle @property def scatterUnderTargets(self): data_view = og.AttributeValueHelper(self._attributes.scatterUnderTargets) return data_view.get() @scatterUnderTargets.setter def scatterUnderTargets(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.scatterUnderTargets) data_view = og.AttributeValueHelper(self._attributes.scatterUnderTargets) data_view.set(value) @property def typePattern(self): data_view = og.AttributeValueHelper(self._attributes.typePattern) return data_view.get() @typePattern.setter def typePattern(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.typePattern) data_view = og.AttributeValueHelper(self._attributes.typePattern) data_view.set(value) self.typePattern_size = data_view.get_array_size() @property def usdWriteBack(self): data_view = og.AttributeValueHelper(self._attributes.usdWriteBack) return data_view.get() @usdWriteBack.setter def usdWriteBack(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usdWriteBack) data_view = og.AttributeValueHelper(self._attributes.usdWriteBack) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) 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) self.attrNamesToExport_size = 1 self.pathPattern_size = 1 self.typePattern_size = 1 @property def attrNamesToExport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport) self.attrNamesToExport_size = data_view.get_array_size() return data_view.get() @attrNamesToExport.setter def attrNamesToExport(self, value): data_view = og.AttributeValueHelper(self._attributes.attrNamesToExport) data_view.set(value) self.attrNamesToExport_size = data_view.get_array_size() @property def layerIdentifier(self): data_view = og.AttributeValueHelper(self._attributes.layerIdentifier) return data_view.get() @layerIdentifier.setter def layerIdentifier(self, value): data_view = og.AttributeValueHelper(self._attributes.layerIdentifier) data_view.set(value) @property def pathPattern(self): data_view = og.AttributeValueHelper(self._attributes.pathPattern) self.pathPattern_size = data_view.get_array_size() return data_view.get() @pathPattern.setter def pathPattern(self, value): data_view = og.AttributeValueHelper(self._attributes.pathPattern) data_view.set(value) self.pathPattern_size = data_view.get_array_size() @property def primBundleDirtyId(self): data_view = og.AttributeValueHelper(self._attributes.primBundleDirtyId) return data_view.get() @primBundleDirtyId.setter def primBundleDirtyId(self, value): data_view = og.AttributeValueHelper(self._attributes.primBundleDirtyId) data_view.set(value) @property def scatterUnderTargets(self): data_view = og.AttributeValueHelper(self._attributes.scatterUnderTargets) return data_view.get() @scatterUnderTargets.setter def scatterUnderTargets(self, value): data_view = og.AttributeValueHelper(self._attributes.scatterUnderTargets) data_view.set(value) @property def typePattern(self): data_view = og.AttributeValueHelper(self._attributes.typePattern) self.typePattern_size = data_view.get_array_size() return data_view.get() @typePattern.setter def typePattern(self, value): data_view = og.AttributeValueHelper(self._attributes.typePattern) data_view.set(value) self.typePattern_size = data_view.get_array_size() @property def usdWriteBack(self): data_view = og.AttributeValueHelper(self._attributes.usdWriteBack) return data_view.get() @usdWriteBack.setter def usdWriteBack(self, value): data_view = og.AttributeValueHelper(self._attributes.usdWriteBack) 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 = OgnWritePrimsV2Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnWritePrimsV2Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnWritePrimsV2Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnMakeArrayDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.MakeArray Makes an output array attribute from input values, in the order of the inputs. If 'arraySize' is less than 5, the top 'arraySize' elements will be taken. If 'arraySize' is greater than 5 element e will be repeated to fill the remaining space """ from typing import Any 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 OgnMakeArrayDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.MakeArray Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.arraySize inputs.b inputs.c inputs.d inputs.e Outputs: outputs.array """ # 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[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'Element 1', {}, True, None, False, ''), ('inputs:arraySize', 'int', 0, None, 'The size of the array to create', {}, True, 0, False, ''), ('inputs:b', 'colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'Element 2', {}, True, None, False, ''), ('inputs:c', 'colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'Element 3', {}, True, None, False, ''), ('inputs:d', 'colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'Element 4', {}, True, None, False, ''), ('inputs:e', 'colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'Element 5', {}, True, None, False, ''), ('outputs:array', 'colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, None, 'The array of copied values of inputs in the given order', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"arraySize", "_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.arraySize] self._batchedReadValues = [0] @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 @property def c(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.c""" return og.RuntimeAttribute(self._attributes.c.get_attribute_data(), self._context, True) @c.setter def c(self, value_to_set: Any): """Assign another attribute's value to outputs.c""" if isinstance(value_to_set, og.RuntimeAttribute): self.c.value = value_to_set.value else: self.c.value = value_to_set @property def d(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.d""" return og.RuntimeAttribute(self._attributes.d.get_attribute_data(), self._context, True) @d.setter def d(self, value_to_set: Any): """Assign another attribute's value to outputs.d""" if isinstance(value_to_set, og.RuntimeAttribute): self.d.value = value_to_set.value else: self.d.value = value_to_set @property def e(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.e""" return og.RuntimeAttribute(self._attributes.e.get_attribute_data(), self._context, True) @e.setter def e(self, value_to_set: Any): """Assign another attribute's value to outputs.e""" if isinstance(value_to_set, og.RuntimeAttribute): self.e.value = value_to_set.value else: self.e.value = value_to_set @property def arraySize(self): return self._batchedReadValues[0] @arraySize.setter def arraySize(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 array(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.array""" return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, False) @array.setter def array(self, value_to_set: Any): """Assign another attribute's value to outputs.array""" if isinstance(value_to_set, og.RuntimeAttribute): self.array.value = value_to_set.value else: self.array.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 = OgnMakeArrayDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnMakeArrayDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnMakeArrayDatabase.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(OgnMakeArrayDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.nodes.MakeArray' @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.inputs.c.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:c is not resolved, compute skipped') return False if db.inputs.d.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:d is not resolved, compute skipped') return False if db.inputs.e.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute inputs:e is not resolved, compute skipped') return False if db.outputs.array.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute outputs:array is not resolved, compute skipped') return False return True try: per_node_data = OgnMakeArrayDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnMakeArrayDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnMakeArrayDatabase(node) try: compute_function = getattr(OgnMakeArrayDatabase.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 OgnMakeArrayDatabase.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): OgnMakeArrayDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnMakeArrayDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnMakeArrayDatabase.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(OgnMakeArrayDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnMakeArrayDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnMakeArrayDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnMakeArrayDatabase.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(OgnMakeArrayDatabase.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.nodes") node_type.set_metadata(ogn.MetadataKeys.HIDDEN, "true") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Make Array") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "math:array") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Makes an output array attribute from input values, in the order of the inputs. If 'arraySize' is less than 5, the top 'arraySize' elements will be taken. If 'arraySize' is greater than 5 element e will be repeated to fill the remaining space") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnMakeArrayDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnMakeArrayDatabase.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): OgnMakeArrayDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnMakeArrayDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.nodes.MakeArray")
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnSinDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Sin Trigonometric operation sine of one input in degrees. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnSinDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Sin 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', 'double,double[],float,float[],half,half[],timecode', 1, None, 'Angle in degrees whose sine value is to be found', {}, True, None, False, ''), ('outputs:value', 'double,double[],float,float[],half,half[],timecode', 1, 'Result', 'The sine value of the input angle', {}, 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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 = OgnSinDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnSinDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnSinDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnWritePrimMaterialDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.WritePrimMaterial Given a path to a prim and a path to a material on the current USD stage, assigns the material to the prim. Gives an error if the given prim or material can not be found. """ import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnWritePrimMaterialDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.WritePrimMaterial Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.material inputs.materialPath inputs.prim inputs.primPath Outputs: outputs.execOut """ # 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:execIn', 'execution', 0, None, 'Input execution', {}, True, None, False, ''), ('inputs:material', 'target', 0, None, 'The material to be assigned to the prim', {}, True, [], False, ''), ('inputs:materialPath', 'path', 0, 'Material Path', 'The path of the material to be assigned to the prim', {}, True, "", True, 'Use material input instead'), ('inputs:prim', 'target', 0, None, 'Prim to be assigned a material.', {}, True, [], False, ''), ('inputs:primPath', 'path', 0, 'Prim Path', 'Path of the prim to be assigned a material.', {}, True, "", True, 'Use prim input instead'), ('outputs:execOut', 'execution', 0, None, 'Output execution', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.inputs.material = og.AttributeRole.TARGET role_data.inputs.materialPath = og.AttributeRole.PATH role_data.inputs.prim = og.AttributeRole.TARGET role_data.inputs.primPath = og.AttributeRole.PATH role_data.outputs.execOut = og.AttributeRole.EXECUTION 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def material(self): data_view = og.AttributeValueHelper(self._attributes.material) return data_view.get() @material.setter def material(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.material) data_view = og.AttributeValueHelper(self._attributes.material) data_view.set(value) self.material_size = data_view.get_array_size() @property def materialPath(self): data_view = og.AttributeValueHelper(self._attributes.materialPath) return data_view.get() @materialPath.setter def materialPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.materialPath) data_view = og.AttributeValueHelper(self._attributes.materialPath) data_view.set(value) self.materialPath_size = data_view.get_array_size() @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) self.primPath_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._batchedWriteValues = { } @property def execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) 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 = OgnWritePrimMaterialDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnWritePrimMaterialDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnWritePrimMaterialDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantPrimsDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantPrims Returns the paths of one or more targetd prims """ import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnConstantPrimsDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantPrims Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'target', 0, None, 'The input prim paths', {ogn.MetadataKeys.OUTPUT_ONLY: '1', ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, True, [], 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.value = og.AttributeRole.TARGET 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 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) self.value_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._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 = OgnConstantPrimsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantPrimsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantPrimsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnEachZeroDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.EachZero Outputs a boolean, or array of booleans, indicating which input values are zero within a specified tolerance. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnEachZeroDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.EachZero Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.tolerance inputs.value 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:tolerance', 'double', 0, 'Tolerance', 'How close the value must be to 0 to be considered "zero".', {}, True, 0.0, False, ''), ('inputs:value', '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, 'Value', 'Value(s) to check for zero.', {}, True, None, False, ''), ('outputs:result', 'bool,bool[]', 1, 'Result', "If 'value' is a scalar then 'result' will be a boolean set to true if 'value' is zero. If 'value' is non-scalar\n(array, tuple, matrix, etc) then 'result' will be an array of booleans, one for each element/component of the\ninput. If those elements are themselves non-scalar (e.g. an array of vectors) they will be considered zero only if\nall of the sub-elements are zero. For example, if 'value' is [3, 0, 1] then 'result' will be [true, false, true]\nbecause the second element is zero. But if 'value' is [[3, 0, 1], [-5, 4, 17]] then 'result' will\nbe [false, false] because neither of the two vectors is fully zero.", {}, 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 tolerance(self): data_view = og.AttributeValueHelper(self._attributes.tolerance) return data_view.get() @tolerance.setter def tolerance(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.tolerance) data_view = og.AttributeValueHelper(self._attributes.tolerance) data_view.set(value) @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnEachZeroDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnEachZeroDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnEachZeroDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetVariantSelectionDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetVariantSelection Get the variant selection on a prim """ import carb import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetVariantSelectionDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetVariantSelection Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim inputs.variantSetName Outputs: outputs.variantName """ # 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:prim', 'target', 0, None, 'The prim with the variantSet', {}, True, [], False, ''), ('inputs:variantSetName', 'token', 0, None, 'The variantSet name', {}, True, "", False, ''), ('outputs:variantName', 'token', 0, None, 'The variant name', {}, 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.prim = og.AttributeRole.TARGET 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 prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def variantSetName(self): data_view = og.AttributeValueHelper(self._attributes.variantSetName) return data_view.get() @variantSetName.setter def variantSetName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.variantSetName) data_view = og.AttributeValueHelper(self._attributes.variantSetName) 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 variantName(self): data_view = og.AttributeValueHelper(self._attributes.variantName) return data_view.get() @variantName.setter def variantName(self, value): data_view = og.AttributeValueHelper(self._attributes.variantName) 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 = OgnGetVariantSelectionDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetVariantSelectionDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetVariantSelectionDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetPrimLocalToWorldTransformDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetPrimLocalToWorldTransform Given a path to a prim on the current USD stage, return the the transformation matrix. that transforms a vector from the local frame to the global frame """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetPrimLocalToWorldTransformDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetPrimLocalToWorldTransform Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim inputs.primPath inputs.usePath Outputs: outputs.localToWorldTransform """ # 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:prim', 'target', 0, None, "The prim used as the local coordinate system when 'usePath' is false", {}, False, [], True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:primPath', 'token', 0, None, "The path of the prim used as the local coordinate system when 'usePath' is true", {}, True, "", False, ''), ('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:localToWorldTransform', 'matrix4d', 0, None, 'the local to world transformation matrix for the prim', {}, 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.prim = og.AttributeRole.TARGET role_data.outputs.localToWorldTransform = 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 prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) 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 localToWorldTransform(self): data_view = og.AttributeValueHelper(self._attributes.localToWorldTransform) return data_view.get() @localToWorldTransform.setter def localToWorldTransform(self, value): data_view = og.AttributeValueHelper(self._attributes.localToWorldTransform) 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 = OgnGetPrimLocalToWorldTransformDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetPrimLocalToWorldTransformDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetPrimLocalToWorldTransformDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnCopyAttrDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.CopyAttribute Copies all attributes from one input bundle and specified attributes from a second input bundle to the output bundle. """ 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 OgnCopyAttrDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.CopyAttribute Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.fullData inputs.inputAttrNames inputs.outputAttrNames inputs.partialData Outputs: outputs.data """ # 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:fullData', 'bundle', 0, 'Full Bundle To Copy', 'Collection of attributes to fully copy to the output', {}, True, None, False, ''), ('inputs:inputAttrNames', 'token', 0, 'Extracted Names For Partial Copy', 'Comma or space separated text, listing the names of attributes to copy from partialData', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:outputAttrNames', 'token', 0, 'New Names For Partial Copy', 'Comma or space separated text, listing the new names of attributes copied from partialData', {ogn.MetadataKeys.DEFAULT: '""'}, True, "", False, ''), ('inputs:partialData', 'bundle', 0, 'Partial Bundle To Copy', 'Collection of attributes from which to select named attributes', {}, False, None, False, ''), ('outputs:data', 'bundle', 0, 'Bundle Of Copied Attributes', "Collection of attributes consisting of all attributes from input 'fullData' and\nselected inputs from input 'partialData'", {}, 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.fullData = og.AttributeRole.BUNDLE role_data.inputs.partialData = og.AttributeRole.BUNDLE role_data.outputs.data = 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 fullData(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.fullData""" return self.__bundles.fullData @property def inputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.inputAttrNames) return data_view.get() @inputAttrNames.setter def inputAttrNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.inputAttrNames) data_view = og.AttributeValueHelper(self._attributes.inputAttrNames) data_view.set(value) @property def outputAttrNames(self): data_view = og.AttributeValueHelper(self._attributes.outputAttrNames) return data_view.get() @outputAttrNames.setter def outputAttrNames(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.outputAttrNames) data_view = og.AttributeValueHelper(self._attributes.outputAttrNames) data_view.set(value) @property def partialData(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.partialData""" return self.__bundles.partialData 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 data(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.data""" return self.__bundles.data @data.setter def data(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.data 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.data.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 = OgnCopyAttrDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnCopyAttrDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnCopyAttrDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnInterpolatorDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Interpolator Time sample interpolator """ 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 OgnInterpolatorDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Interpolator Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.knots inputs.param inputs.values 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:knots', 'float[]', 0, 'Knot Array', 'Array of knots on the time sample curve', {}, True, [], False, ''), ('inputs:param', 'float', 0, 'Interpolation Point', 'Time sample interpolation point', {}, True, 0.0, False, ''), ('inputs:values', 'float[]', 0, 'Value Array', 'Array of time sample values', {}, True, [], False, ''), ('outputs:value', 'float', 0, 'Interpolated Value', 'Value in the time samples, interpolated at the given parameter location', {}, 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 knots(self): data_view = og.AttributeValueHelper(self._attributes.knots) return data_view.get() @knots.setter def knots(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.knots) data_view = og.AttributeValueHelper(self._attributes.knots) data_view.set(value) self.knots_size = data_view.get_array_size() @property def param(self): data_view = og.AttributeValueHelper(self._attributes.param) return data_view.get() @param.setter def param(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.param) data_view = og.AttributeValueHelper(self._attributes.param) data_view.set(value) @property def values(self): data_view = og.AttributeValueHelper(self._attributes.values) return data_view.get() @values.setter def values(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.values) data_view = og.AttributeValueHelper(self._attributes.values) data_view.set(value) self.values_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._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 = OgnInterpolatorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnInterpolatorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnInterpolatorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTransformVectorDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.TransformVector Applies a transformation matrix to a row vector, returning the result. returns vector * matrix If the vector is one dimension smaller than the matrix (eg a 4x4 matrix and a 3d vector), The last component of the vector will be treated as a 1. The result is then projected back to a 3-vector. Supports mixed array inputs, eg a single matrix and an array of vectors. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTransformVectorDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.TransformVector Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.matrix inputs.vector 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:matrix', 'matrixd[3],matrixd[3][],matrixd[4],matrixd[4][]', 1, 'Matrix', 'The transformation matrix to be applied', {}, True, None, False, ''), ('inputs:vector', 'vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Vector', 'The row vector(s) to be translated', {}, True, None, False, ''), ('outputs:result', 'vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'Result', 'The transformed row vector(s)', {}, 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 matrix(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.matrix""" return og.RuntimeAttribute(self._attributes.matrix.get_attribute_data(), self._context, True) @matrix.setter def matrix(self, value_to_set: Any): """Assign another attribute's value to outputs.matrix""" if isinstance(value_to_set, og.RuntimeAttribute): self.matrix.value = value_to_set.value else: self.matrix.value = value_to_set @property def vector(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.vector""" return og.RuntimeAttribute(self._attributes.vector.get_attribute_data(), self._context, True) @vector.setter def vector(self, value_to_set: Any): """Assign another attribute's value to outputs.vector""" if isinstance(value_to_set, og.RuntimeAttribute): self.vector.value = value_to_set.value else: self.vector.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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnTransformVectorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTransformVectorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTransformVectorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnMakeVector4Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.MakeVector4 Merge 4 input values into a single output vector. If the inputs are arrays, the output will be an array of vectors. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnMakeVector4Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.MakeVector4 Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.w inputs.x inputs.y inputs.z Outputs: 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:w', 'double,double[],float,float[],half,half[],int,int[]', 1, 'W', 'The fourth component of the vector', {}, True, None, False, ''), ('inputs:x', 'double,double[],float,float[],half,half[],int,int[]', 1, 'X', 'The first component of the vector', {}, True, None, False, ''), ('inputs:y', 'double,double[],float,float[],half,half[],int,int[]', 1, 'Y', 'The second component of the vector', {}, True, None, False, ''), ('inputs:z', 'double,double[],float,float[],half,half[],int,int[]', 1, 'Z', 'The third component of the vector', {}, True, None, False, ''), ('outputs:tuple', 'double[4],double[4][],float[4],float[4][],half[4],half[4][],int[4],int[4][]', 1, 'Vector', 'Output 4-vector', {}, 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 w(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.w""" return og.RuntimeAttribute(self._attributes.w.get_attribute_data(), self._context, True) @w.setter def w(self, value_to_set: Any): """Assign another attribute's value to outputs.w""" if isinstance(value_to_set, og.RuntimeAttribute): self.w.value = value_to_set.value else: self.w.value = value_to_set @property def x(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.x""" return og.RuntimeAttribute(self._attributes.x.get_attribute_data(), self._context, True) @x.setter def x(self, value_to_set: Any): """Assign another attribute's value to outputs.x""" if isinstance(value_to_set, og.RuntimeAttribute): self.x.value = value_to_set.value else: self.x.value = value_to_set @property def y(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.y""" return og.RuntimeAttribute(self._attributes.y.get_attribute_data(), self._context, True) @y.setter def y(self, value_to_set: Any): """Assign another attribute's value to outputs.y""" if isinstance(value_to_set, og.RuntimeAttribute): self.y.value = value_to_set.value else: self.y.value = value_to_set @property def z(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.z""" return og.RuntimeAttribute(self._attributes.z.get_attribute_data(), self._context, True) @z.setter def z(self, value_to_set: Any): """Assign another attribute's value to outputs.z""" if isinstance(value_to_set, og.RuntimeAttribute): self.z.value = value_to_set.value else: self.z.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 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 = OgnMakeVector4Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnMakeVector4Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnMakeVector4Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnMakeTransformDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.MakeTransform Make a transformation matrix that performs a translation, rotation (in euler angles), and scale in that order """ 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 OgnMakeTransformDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.MakeTransform Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.rotationXYZ inputs.scale inputs.translation Outputs: outputs.transform """ # 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:rotationXYZ', 'vector3d', 0, None, 'The desired orientation in euler angles (XYZ)', {ogn.MetadataKeys.DEFAULT: '[0, 0, 0]'}, True, [0, 0, 0], False, ''), ('inputs:scale', 'vector3d', 0, None, 'The desired scaling factor about the X, Y, and Z axis respectively', {ogn.MetadataKeys.DEFAULT: '[1, 1, 1]'}, True, [1, 1, 1], False, ''), ('inputs:translation', 'vector3d', 0, None, 'the desired translation as a vector', {ogn.MetadataKeys.DEFAULT: '[0, 0, 0]'}, True, [0, 0, 0], False, ''), ('outputs:transform', 'matrix4d', 0, None, 'the resulting transformation matrix', {}, 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.rotationXYZ = og.AttributeRole.VECTOR role_data.inputs.scale = og.AttributeRole.VECTOR role_data.inputs.translation = og.AttributeRole.VECTOR role_data.outputs.transform = 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 rotationXYZ(self): data_view = og.AttributeValueHelper(self._attributes.rotationXYZ) return data_view.get() @rotationXYZ.setter def rotationXYZ(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.rotationXYZ) data_view = og.AttributeValueHelper(self._attributes.rotationXYZ) data_view.set(value) @property def scale(self): data_view = og.AttributeValueHelper(self._attributes.scale) return data_view.get() @scale.setter def scale(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.scale) data_view = og.AttributeValueHelper(self._attributes.scale) data_view.set(value) @property def translation(self): data_view = og.AttributeValueHelper(self._attributes.translation) return data_view.get() @translation.setter def translation(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.translation) data_view = og.AttributeValueHelper(self._attributes.translation) 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 transform(self): data_view = og.AttributeValueHelper(self._attributes.transform) return data_view.get() @transform.setter def transform(self, value): data_view = og.AttributeValueHelper(self._attributes.transform) 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 = OgnMakeTransformDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnMakeTransformDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnMakeTransformDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnBundleConstructorDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.BundleConstructor This node creates a bundle mirroring all of the dynamic input attributes that have been added to it. If no dynamic attributes exist then the bundle will be empty. See the 'InsertAttribute' node for something that can construct a bundle from existing connected attributes. """ 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 OgnBundleConstructorDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.BundleConstructor Class Members: node: Node being evaluated Attribute Value Properties: 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([ ('outputs:bundle', 'bundle', 0, 'Constructed Bundle', 'The bundle consisting of copies of all of the dynamic input attributes.', {}, 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 = [] 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 = OgnBundleConstructorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnBundleConstructorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnBundleConstructorDatabase.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(OgnBundleConstructorDatabase.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.nodes.BundleConstructor' @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 = OgnBundleConstructorDatabase.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnBundleConstructorDatabase(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnBundleConstructorDatabase(node) try: compute_function = getattr(OgnBundleConstructorDatabase.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 OgnBundleConstructorDatabase.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): OgnBundleConstructorDatabase._initialize_per_node_data(node) initialize_function = getattr(OgnBundleConstructorDatabase.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnBundleConstructorDatabase.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(OgnBundleConstructorDatabase.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnBundleConstructorDatabase._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnBundleConstructorDatabase._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnBundleConstructorDatabase.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(OgnBundleConstructorDatabase.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.nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Bundle Constructor") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "bundle") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "This node creates a bundle mirroring all of the dynamic input attributes that have been added to it. If no dynamic attributes exist then the bundle will be empty. See the 'InsertAttribute' node for something that can construct a bundle from existing connected attributes.") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") icon_path = carb.tokens.get_tokens_interface().resolve("${omni.graph.nodes}") icon_path = icon_path + '/' + "ogn/icons/omni.graph.nodes.BundleConstructor.svg" node_type.set_metadata(ogn.MetadataKeys.ICON_PATH, icon_path) OgnBundleConstructorDatabase.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnBundleConstructorDatabase.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): OgnBundleConstructorDatabase.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnBundleConstructorDatabase.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.nodes.BundleConstructor")
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnExtractAttrDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ExtractAttribute Copies a single attribute from an input bundle to an output attribute directly on the node if it exists in the input bundle and matches the type of the output attribute """ 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 OgnExtractAttrDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ExtractAttribute Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.attrName inputs.data Outputs: outputs.output """ # 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:attrName', 'token', 0, 'Attribute To Extract', 'Name of the attribute to look for in the bundle', {ogn.MetadataKeys.DEFAULT: '"points"'}, True, "points", False, ''), ('inputs:data', 'bundle', 0, 'Bundle For Extraction', 'Collection of attributes from which the named attribute is to be extracted', {}, True, None, False, ''), ('outputs:output', 'any', 2, 'Extracted Attribute', 'The single attribute extracted from the input bundle', {}, 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.data = 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 attrName(self): data_view = og.AttributeValueHelper(self._attributes.attrName) return data_view.get() @attrName.setter def attrName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrName) data_view = og.AttributeValueHelper(self._attributes.attrName) data_view.set(value) @property def data(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.data""" return self.__bundles.data 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 output(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.output""" return og.RuntimeAttribute(self._attributes.output.get_attribute_data(), self._context, False) @output.setter def output(self, value_to_set: Any): """Assign another attribute's value to outputs.output""" if isinstance(value_to_set, og.RuntimeAttribute): self.output.value = value_to_set.value else: self.output.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 = OgnExtractAttrDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnExtractAttrDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnExtractAttrDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnArrayRotateDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ArrayRotate Shifts the elements of an array by the specified number of steps to the right and wraps elements from one end to the other. A negative step will shift to the left. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnArrayRotateDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ArrayRotate Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.array inputs.steps Outputs: outputs.array """ # 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:array', 'bool[],colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, None, 'The array to be modified', {}, True, None, False, ''), ('inputs:steps', 'int', 0, None, 'The number of steps to shift, negative means shift left instead of right', {}, True, 0, False, ''), ('outputs:array', 'bool[],colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, None, 'The modified 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 array(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.array""" return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, True) @array.setter def array(self, value_to_set: Any): """Assign another attribute's value to outputs.array""" if isinstance(value_to_set, og.RuntimeAttribute): self.array.value = value_to_set.value else: self.array.value = value_to_set @property def steps(self): data_view = og.AttributeValueHelper(self._attributes.steps) return data_view.get() @steps.setter def steps(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.steps) data_view = og.AttributeValueHelper(self._attributes.steps) 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 array(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.array""" return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, False) @array.setter def array(self, value_to_set: Any): """Assign another attribute's value to outputs.array""" if isinstance(value_to_set, og.RuntimeAttribute): self.array.value = value_to_set.value else: self.array.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 = OgnArrayRotateDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnArrayRotateDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnArrayRotateDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnDivideDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Divide Computes the division of two values: A / B. The result is the same type as the numerator if the numerator is a decimal type. Otherwise the result is a double. Vectors can be divided only by a scaler, the result being a vector in the same direction with a scaled length. Note that there are combinations of inputs that can result in a loss of precision due to different value ranges. Division by zero is an error. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnDivideDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Divide 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', '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', 'The numerator A', {}, 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', 'The denominator B', {}, True, None, False, ''), ('outputs:result', '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, 'Result', 'Result of division', {}, 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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnDivideDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnDivideDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnDivideDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnIsZeroDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.IsZero Outputs a boolean indicating if all of the input values are zero within a specified tolerance. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnIsZeroDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.IsZero Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.tolerance inputs.value 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:tolerance', 'double', 0, 'Tolerance', 'How close the value must be to 0 to be considered "zero".', {}, True, 0.0, False, ''), ('inputs:value', '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, 'Value', 'Value(s) to check for zero.', {}, True, None, False, ''), ('outputs:result', 'bool', 0, 'Result', "If 'value' is a scalar then 'result' will be true if 'value' is zero. If 'value' is non-scalar\n(array, tuple, matrix, etc) then 'result' will be true if all of its elements/components are zero.", {}, 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 tolerance(self): data_view = og.AttributeValueHelper(self._attributes.tolerance) return data_view.get() @tolerance.setter def tolerance(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.tolerance) data_view = og.AttributeValueHelper(self._attributes.tolerance) data_view.set(value) @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 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 = OgnIsZeroDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnIsZeroDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnIsZeroDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimBundleDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrimBundle DEPRECATED - use ReadPrims! """ import carb import usdrt 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 OgnReadPrimBundleDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrimBundle Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.attrNamesToImport inputs.computeBoundingBox inputs.prim inputs.primPath inputs.usdTimecode inputs.usePath Outputs: outputs.primBundle State: state.attrNamesToImport state.computeBoundingBox state.primPath state.usdTimecode state.usePath """ # 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:attrNamesToImport', 'token', 0, 'Attributes To Import', "A list of wildcard patterns used to match the attribute names that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['points', 'faceVertexCount', 'faceVertexIndices', 'size']\n '*' - match any\n '* ^points' - match any, but exclude 'points'\n '* ^face*' - match any, but exclude 'faceVertexCount' and 'faceVertexIndices'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('inputs:computeBoundingBox', 'bool', 0, 'Compute Bounding Box', "For each primitive compute local bounding box and store them as 'bboxMinCorner', 'bboxMaxCorner' and 'bboxTransform' attributes.", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:prim', 'target', 0, None, "The prims to be read from when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, 'Prim Path', "The paths of the prims to be read from when 'usePath' is true", {ogn.MetadataKeys.DEFAULT: '""'}, False, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:usdTimecode', 'timecode', 0, 'Time', 'The time at which to evaluate the transform of the USD prim. A value of "NaN" indicates that the default USD time stamp should be used', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''), ('inputs:usePath', 'bool', 0, 'Use Path', "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:primBundle', 'bundle', 0, None, 'A bundle containing multiple prims as children.\nEach child contains data attributes and two additional token attributes named sourcePrimPath and sourcePrimType\nwhich contain the path and the type of the Prim being read', {}, True, None, False, ''), ('state:attrNamesToImport', 'uint64', 0, None, 'State from previous evaluation', {}, True, None, False, ''), ('state:computeBoundingBox', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('state:primPath', 'uint64', 0, None, 'State from previous evaluation', {}, True, None, False, ''), ('state:usdTimecode', 'timecode', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''), ('state:usePath', 'bool', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, 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.prim = og.AttributeRole.TARGET role_data.inputs.usdTimecode = og.AttributeRole.TIMECODE role_data.outputs.primBundle = og.AttributeRole.BUNDLE role_data.state.usdTimecode = og.AttributeRole.TIMECODE 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 attrNamesToImport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) return data_view.get() @attrNamesToImport.setter def attrNamesToImport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrNamesToImport) data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) data_view.set(value) @property def computeBoundingBox(self): data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox) return data_view.get() @computeBoundingBox.setter def computeBoundingBox(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.computeBoundingBox) data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox) data_view.set(value) @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) return data_view.get() @usdTimecode.setter def usdTimecode(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usdTimecode) data_view = og.AttributeValueHelper(self._attributes.usdTimecode) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) 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 primBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.primBundle""" return self.__bundles.primBundle @primBundle.setter def primBundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.primBundle 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.primBundle.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) @property def attrNamesToImport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) return data_view.get() @attrNamesToImport.setter def attrNamesToImport(self, value): data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) data_view.set(value) @property def computeBoundingBox(self): data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox) return data_view.get() @computeBoundingBox.setter def computeBoundingBox(self, value): data_view = og.AttributeValueHelper(self._attributes.computeBoundingBox) data_view.set(value) @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) return data_view.get() @usdTimecode.setter def usdTimecode(self, value): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): data_view = og.AttributeValueHelper(self._attributes.usePath) 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 = OgnReadPrimBundleDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadPrimBundleDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadPrimBundleDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnOrDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.BooleanOr Boolean OR on two or more inputs. If the inputs are arrays, OR operations will be performed pair-wise. The input sizes must match. If only one input is an array, the other input will be broadcast to the size of the array. Returns an array of booleans if either input is an array, otherwise returning a boolean. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnOrDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.BooleanOr 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', 'bool,bool[]', 1, None, 'Input A: bool or bool array.', {}, True, None, False, ''), ('inputs:b', 'bool,bool[]', 1, None, 'Input B: bool or bool array.', {}, True, None, False, ''), ('outputs:result', 'bool,bool[]', 1, 'Result', 'The result of the boolean OR - an array of booleans if either input is an array, otherwise a boolean.', {}, 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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnOrDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnOrDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnOrDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnWritePrimAttributeDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.WritePrimAttribute Given a path to a prim on the current USD stage and the name of an attribute on that prim, sets the value of that attribute. Does nothing if the given Prim or attribute can not be found. If the attribute is found but it is not a compatible type, an error will be issued. """ from typing import Any import carb import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnWritePrimAttributeDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.WritePrimAttribute Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.name inputs.prim inputs.primPath inputs.usdWriteBack inputs.usePath inputs.value Outputs: outputs.execOut State: state.correctlySetup state.destAttrib state.destPath state.destPathToken """ # 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:execIn', 'execution', 0, None, 'Input execution state', {}, True, None, False, ''), ('inputs:name', 'token', 0, 'Attribute Name', 'The name of the attribute to set on the specified prim', {}, True, "", False, ''), ('inputs:prim', 'target', 0, None, "The prim to be modified when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, None, "The path of the prim to be modified when 'usePath' is true", {}, True, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:usdWriteBack', 'bool', 0, 'Persist To USD', 'Whether or not the value should be written back to USD, or kept a Fabric only value', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:value', 'any', 2, None, 'The new value to be written', {}, True, None, False, ''), ('outputs:execOut', 'execution', 0, None, 'Output execution', {}, True, None, False, ''), ('state:correctlySetup', 'bool', 0, None, 'Wheter or not the instance is properly setup', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('state:destAttrib', 'uint64', 0, None, 'A TokenC to the destination attrib', {}, True, None, False, ''), ('state:destPath', 'uint64', 0, None, 'A PathC to the destination prim', {}, True, None, False, ''), ('state:destPathToken', 'uint64', 0, None, "The TokenC version of destPath'", {}, 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.execIn = og.AttributeRole.EXECUTION role_data.inputs.prim = og.AttributeRole.TARGET role_data.outputs.execOut = og.AttributeRole.EXECUTION 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def name(self): data_view = og.AttributeValueHelper(self._attributes.name) return data_view.get() @name.setter def name(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.name) data_view = og.AttributeValueHelper(self._attributes.name) data_view.set(value) @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usdWriteBack(self): data_view = og.AttributeValueHelper(self._attributes.usdWriteBack) return data_view.get() @usdWriteBack.setter def usdWriteBack(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usdWriteBack) data_view = og.AttributeValueHelper(self._attributes.usdWriteBack) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) data_view.set(value) @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) 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) @property def correctlySetup(self): data_view = og.AttributeValueHelper(self._attributes.correctlySetup) return data_view.get() @correctlySetup.setter def correctlySetup(self, value): data_view = og.AttributeValueHelper(self._attributes.correctlySetup) data_view.set(value) @property def destAttrib(self): data_view = og.AttributeValueHelper(self._attributes.destAttrib) return data_view.get() @destAttrib.setter def destAttrib(self, value): data_view = og.AttributeValueHelper(self._attributes.destAttrib) data_view.set(value) @property def destPath(self): data_view = og.AttributeValueHelper(self._attributes.destPath) return data_view.get() @destPath.setter def destPath(self, value): data_view = og.AttributeValueHelper(self._attributes.destPath) data_view.set(value) @property def destPathToken(self): data_view = og.AttributeValueHelper(self._attributes.destPathToken) return data_view.get() @destPathToken.setter def destPathToken(self, value): data_view = og.AttributeValueHelper(self._attributes.destPathToken) 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 = OgnWritePrimAttributeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnWritePrimAttributeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnWritePrimAttributeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetAttrNamesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetAttributeNames Retrieves the names of all of the attributes contained in the input bundle, optionally sorted. """ 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 OgnGetAttrNamesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetAttributeNames Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.data inputs.sort Outputs: outputs.output """ # 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', 'bundle', 0, 'Bundle To Examine', 'Collection of attributes from which to extract names', {}, True, None, False, ''), ('inputs:sort', 'bool', 0, 'Sort Output', 'If true, the names will be output in sorted order (default, for consistency).\nIf false, the order is not be guaranteed to be consistent between systems or over\ntime, so do not rely on the order downstream in this case.', {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('outputs:output', 'token[]', 0, 'Attribute Names', 'Names of all of the attributes contained in the input bundle', {}, 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.data = 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 data(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.data""" return self.__bundles.data @property def sort(self): data_view = og.AttributeValueHelper(self._attributes.sort) return data_view.get() @sort.setter def sort(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.sort) data_view = og.AttributeValueHelper(self._attributes.sort) 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.output_size = None self._batchedWriteValues = { } @property def output(self): data_view = og.AttributeValueHelper(self._attributes.output) return data_view.get(reserved_element_count=self.output_size) @output.setter def output(self, value): data_view = og.AttributeValueHelper(self._attributes.output) data_view.set(value) self.output_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 = OgnGetAttrNamesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetAttrNamesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetAttrNamesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnInterpolateToDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.InterpolateTo Function which iterpolates one step from a current value to a target value with a given speed. Vectors are interpolated component-wise. Interpolation can be applied to decimal types. The interpolation provides an eased approach to the target, adjust speed and exponent to tweak the curve. The formula is: result = current + (target - current) * (1 - clamp(0, speed * deltaSeconds, 1))^exp. For quaternions, the node performs a spherical linear interpolation (SLERP) with alpha = (1 - clamp(0, speed * deltaSeconds, 1))^exp """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnInterpolateToDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.InterpolateTo Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.current inputs.deltaSeconds inputs.exponent inputs.speed inputs.target 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:current', '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[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, None, 'The current value', {}, True, None, False, ''), ('inputs:deltaSeconds', 'double', 0, None, 'The step time for the interpolation (Seconds)', {}, True, 0.0, False, ''), ('inputs:exponent', 'float', 0, None, 'The blend exponent, which is the degree of the ease curve\n (1 = linear, 2 = quadratic, 3 = cubic, etc). ', {ogn.MetadataKeys.DEFAULT: '2.0'}, True, 2.0, False, ''), ('inputs:speed', 'double', 0, None, 'The peak speed of approach (Units / Second)', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('inputs:target', '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[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, None, 'The target value', {}, True, None, False, ''), ('outputs:result', '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, 'Result', 'The interpolated result', {}, 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 current(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.current""" return og.RuntimeAttribute(self._attributes.current.get_attribute_data(), self._context, True) @current.setter def current(self, value_to_set: Any): """Assign another attribute's value to outputs.current""" if isinstance(value_to_set, og.RuntimeAttribute): self.current.value = value_to_set.value else: self.current.value = value_to_set @property def deltaSeconds(self): data_view = og.AttributeValueHelper(self._attributes.deltaSeconds) return data_view.get() @deltaSeconds.setter def deltaSeconds(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.deltaSeconds) data_view = og.AttributeValueHelper(self._attributes.deltaSeconds) data_view.set(value) @property def exponent(self): data_view = og.AttributeValueHelper(self._attributes.exponent) return data_view.get() @exponent.setter def exponent(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.exponent) data_view = og.AttributeValueHelper(self._attributes.exponent) data_view.set(value) @property def speed(self): data_view = og.AttributeValueHelper(self._attributes.speed) return data_view.get() @speed.setter def speed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.speed) data_view = og.AttributeValueHelper(self._attributes.speed) data_view.set(value) @property def target(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.target""" return og.RuntimeAttribute(self._attributes.target.get_attribute_data(), self._context, True) @target.setter def target(self, value_to_set: Any): """Assign another attribute's value to outputs.target""" if isinstance(value_to_set, og.RuntimeAttribute): self.target.value = value_to_set.value else: self.target.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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnInterpolateToDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnInterpolateToDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnInterpolateToDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadSettingDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ReadSetting Node that reads a value from a kit application setting """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadSettingDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadSetting Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.settingPath 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:settingPath', 'string', 0, None, 'The path of the setting', {}, True, "", False, ''), ('outputs:value', 'bool,bool[],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[],token,token[],transform[4],transform[4][],uchar,uchar[],uint,uint64,uint64[],uint[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, None, 'The value of the setting that is returned', {}, 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.settingPath = 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 settingPath(self): data_view = og.AttributeValueHelper(self._attributes.settingPath) return data_view.get() @settingPath.setter def settingPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.settingPath) data_view = og.AttributeValueHelper(self._attributes.settingPath) data_view.set(value) self.settingPath_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._batchedWriteValues = { } @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 = OgnReadSettingDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadSettingDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadSettingDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGatherByPathDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GatherByPath Node to vectorize data by paths passed in via input. PROTOTYPE DO NOT USE. Requires GatherPrototype """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn import numpy class OgnGatherByPathDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GatherByPath Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.allAttributes inputs.attributes inputs.checkResyncAttributes inputs.forceExportToHistory inputs.hydraFastPath inputs.primPaths inputs.shouldWriteBack Outputs: outputs.gatherId outputs.gatheredPaths Predefined Tokens: tokens.Disabled tokens.World tokens.Local """ # 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:allAttributes', 'bool', 0, None, "When true, all USD attributes will be gathered. Otherwise those specified by 'attributes' will be gathered.", {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, False, ''), ('inputs:attributes', 'string', 0, None, 'A space-separated list of attribute names to be gathered when allAttributes is false', {}, True, '', False, ''), ('inputs:checkResyncAttributes', 'bool', 0, None, 'When true, the data vectorization will be updated when new attributes to the Prims are added.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:forceExportToHistory', 'bool', 0, None, 'When true, all USD gathered paths will be tagged for being exported to the history.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:hydraFastPath', 'token', 0, None, "When not 'Disabled', will extract USD Geometry transforms into Hydra fast-path attributes.\n'World' will add _worldPosition, _worldOrientation. 'Local' will add _localMatrix.", {ogn.MetadataKeys.ALLOWED_TOKENS: 'Disabled,World,Local', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '["Disabled", "World", "Local"]', ogn.MetadataKeys.DEFAULT: '"Disabled"'}, True, 'Disabled', False, ''), ('inputs:primPaths', 'token[]', 0, None, 'A list of Prim paths whose data should be vectorized', {}, True, [], False, ''), ('inputs:shouldWriteBack', 'bool', 0, 'Should Write Back To USD', 'Write the data back into USD if true.', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('outputs:gatherId', 'uint64', 0, None, 'The GatherId corresponding to this Gather, kInvalidGatherId if the Gather failed', {}, True, None, False, ''), ('outputs:gatheredPaths', 'token[]', 0, None, 'The list of gathered prim paths in gathered-order', {}, True, None, False, ''), ]) class tokens: Disabled = "Disabled" World = "World" Local = "Local" class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"allAttributes", "attributes", "checkResyncAttributes", "forceExportToHistory", "hydraFastPath", "shouldWriteBack", "_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.allAttributes, self._attributes.attributes, self._attributes.checkResyncAttributes, self._attributes.forceExportToHistory, self._attributes.hydraFastPath, self._attributes.shouldWriteBack] self._batchedReadValues = [True, "", False, False, "Disabled", False] @property def primPaths(self): data_view = og.AttributeValueHelper(self._attributes.primPaths) return data_view.get() @primPaths.setter def primPaths(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPaths) data_view = og.AttributeValueHelper(self._attributes.primPaths) data_view.set(value) self.primPaths_size = data_view.get_array_size() @property def allAttributes(self): return self._batchedReadValues[0] @allAttributes.setter def allAttributes(self, value): self._batchedReadValues[0] = value @property def attributes(self): return self._batchedReadValues[1] @attributes.setter def attributes(self, value): self._batchedReadValues[1] = value @property def checkResyncAttributes(self): return self._batchedReadValues[2] @checkResyncAttributes.setter def checkResyncAttributes(self, value): self._batchedReadValues[2] = value @property def forceExportToHistory(self): return self._batchedReadValues[3] @forceExportToHistory.setter def forceExportToHistory(self, value): self._batchedReadValues[3] = value @property def hydraFastPath(self): return self._batchedReadValues[4] @hydraFastPath.setter def hydraFastPath(self, value): self._batchedReadValues[4] = value @property def shouldWriteBack(self): return self._batchedReadValues[5] @shouldWriteBack.setter def shouldWriteBack(self, value): self._batchedReadValues[5] = 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 = {"gatherId", "_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.gatheredPaths_size = None self._batchedWriteValues = { } @property def gatheredPaths(self): data_view = og.AttributeValueHelper(self._attributes.gatheredPaths) return data_view.get(reserved_element_count=self.gatheredPaths_size) @gatheredPaths.setter def gatheredPaths(self, value): data_view = og.AttributeValueHelper(self._attributes.gatheredPaths) data_view.set(value) self.gatheredPaths_size = data_view.get_array_size() @property def gatherId(self): value = self._batchedWriteValues.get(self._attributes.gatherId) if value: return value else: data_view = og.AttributeValueHelper(self._attributes.gatherId) return data_view.get() @gatherId.setter def gatherId(self, value): self._batchedWriteValues[self._attributes.gatherId] = 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 = OgnGatherByPathDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGatherByPathDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGatherByPathDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnArrayLengthDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ArrayLength Outputs the length of a specified array attribute in an input bundle, or 1 if the attribute is not an array attribute """ 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 OgnArrayLengthDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ArrayLength Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.attrName inputs.data Outputs: outputs.length """ # 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:attrName', 'token', 0, 'Attribute Name', 'Name of the attribute whose array length will be queried', {ogn.MetadataKeys.DEFAULT: '"points"'}, True, "points", False, ''), ('inputs:data', 'bundle', 0, 'Attribute Bundle', 'Collection of attributes that may contain the named attribute', {}, True, None, False, ''), ('outputs:length', 'uint64', 0, 'Array Length', 'The length of the array attribute in the input bundle', {}, 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.data = 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 attrName(self): data_view = og.AttributeValueHelper(self._attributes.attrName) return data_view.get() @attrName.setter def attrName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrName) data_view = og.AttributeValueHelper(self._attributes.attrName) data_view.set(value) @property def data(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.data""" return self.__bundles.data 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 length(self): data_view = og.AttributeValueHelper(self._attributes.length) return data_view.get() @length.setter def length(self, value): data_view = og.AttributeValueHelper(self._attributes.length) 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 = OgnArrayLengthDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnArrayLengthDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnArrayLengthDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnIncrementDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Increment Add a double argument to any type (element-wise). This includes simple values, tuples, arrays, and arrays of tuples. The output type is always the same as the type of input:value. For example: tuple + double results a tuple. Chopping is used for approximation. For example: 4 + 3.2 will result 7. The default increment value is 1.0. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnIncrementDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Increment Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.increment inputs.value 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:increment', 'double', 0, 'Increment amount', 'The number added to the first operand', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('inputs:value', '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, 'Value', 'The operand that to be increased', {}, True, None, False, ''), ('outputs:result', '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, 'Result', 'Result of the increment', {}, 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 increment(self): data_view = og.AttributeValueHelper(self._attributes.increment) return data_view.get() @increment.setter def increment(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.increment) data_view = og.AttributeValueHelper(self._attributes.increment) data_view.set(value) @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnIncrementDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnIncrementDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnIncrementDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnRenderPostprocessEntryDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.RenderPostProcessEntry Entry point for RTX Renderer Postprocessing """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnRenderPostprocessEntryDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.RenderPostProcessEntry Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.sourceName Outputs: outputs.cudaMipmappedArray outputs.format outputs.height outputs.hydraTime outputs.mipCount outputs.simTime outputs.stream outputs.width """ # 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:sourceName', 'string', 0, None, 'Source name of the AOV', {ogn.MetadataKeys.DEFAULT: '"ldrColor"'}, True, "ldrColor", False, ''), ('outputs:cudaMipmappedArray', 'uint64', 0, 'cudaMipmappedArray', 'Pointer to the CUDA Mipmapped Array', {}, True, None, False, ''), ('outputs:format', 'uint64', 0, 'format', 'Format', {}, True, None, False, ''), ('outputs:height', 'uint', 0, 'height', 'Height', {}, True, None, False, ''), ('outputs:hydraTime', 'double', 0, 'hydraTime', 'Hydra time in stage', {}, True, None, False, ''), ('outputs:mipCount', 'uint', 0, 'mipCount', 'Mip Count', {}, True, None, False, ''), ('outputs:simTime', 'double', 0, 'simTime', 'Simulation time', {}, True, None, False, ''), ('outputs:stream', 'uint64', 0, 'stream', 'Pointer to the CUDA Stream', {}, True, None, False, ''), ('outputs:width', 'uint', 0, 'width', 'Width', {}, 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.sourceName = 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 sourceName(self): data_view = og.AttributeValueHelper(self._attributes.sourceName) return data_view.get() @sourceName.setter def sourceName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.sourceName) data_view = og.AttributeValueHelper(self._attributes.sourceName) data_view.set(value) self.sourceName_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._batchedWriteValues = { } @property def cudaMipmappedArray(self): data_view = og.AttributeValueHelper(self._attributes.cudaMipmappedArray) return data_view.get() @cudaMipmappedArray.setter def cudaMipmappedArray(self, value): data_view = og.AttributeValueHelper(self._attributes.cudaMipmappedArray) data_view.set(value) @property def format(self): data_view = og.AttributeValueHelper(self._attributes.format) return data_view.get() @format.setter def format(self, value): data_view = og.AttributeValueHelper(self._attributes.format) data_view.set(value) @property def height(self): data_view = og.AttributeValueHelper(self._attributes.height) return data_view.get() @height.setter def height(self, value): data_view = og.AttributeValueHelper(self._attributes.height) data_view.set(value) @property def hydraTime(self): data_view = og.AttributeValueHelper(self._attributes.hydraTime) return data_view.get() @hydraTime.setter def hydraTime(self, value): data_view = og.AttributeValueHelper(self._attributes.hydraTime) data_view.set(value) @property def mipCount(self): data_view = og.AttributeValueHelper(self._attributes.mipCount) return data_view.get() @mipCount.setter def mipCount(self, value): data_view = og.AttributeValueHelper(self._attributes.mipCount) data_view.set(value) @property def simTime(self): data_view = og.AttributeValueHelper(self._attributes.simTime) return data_view.get() @simTime.setter def simTime(self, value): data_view = og.AttributeValueHelper(self._attributes.simTime) data_view.set(value) @property def stream(self): data_view = og.AttributeValueHelper(self._attributes.stream) return data_view.get() @stream.setter def stream(self, value): data_view = og.AttributeValueHelper(self._attributes.stream) data_view.set(value) @property def width(self): data_view = og.AttributeValueHelper(self._attributes.width) return data_view.get() @width.setter def width(self, value): data_view = og.AttributeValueHelper(self._attributes.width) 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 = OgnRenderPostprocessEntryDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnRenderPostprocessEntryDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnRenderPostprocessEntryDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGpuInteropRenderProductEntryDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GpuInteropRenderProductEntry Entry node for post-processing hydra render results for a single view """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGpuInteropRenderProductEntryDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GpuInteropRenderProductEntry Class Members: node: Node being evaluated Attribute Value Properties: Outputs: outputs.exec outputs.gpu outputs.hydraTime outputs.rp outputs.simTime """ # 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([ ('outputs:exec', 'execution', 0, None, 'Trigger for scheduling dependencies', {}, True, None, False, ''), ('outputs:gpu', 'uint64', 0, 'gpuFoundations', 'Pointer to shared context containing gpu foundations', {}, True, None, False, ''), ('outputs:hydraTime', 'double', 0, 'hydraTime', 'Hydra time in stage', {}, True, None, False, ''), ('outputs:rp', 'uint64', 0, 'renderProduct', 'Pointer to render product for this view', {}, True, None, False, ''), ('outputs:simTime', 'double', 0, 'simTime', 'Simulation time', {}, 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.exec = og.AttributeRole.EXECUTION 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 = [] 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 exec(self): data_view = og.AttributeValueHelper(self._attributes.exec) return data_view.get() @exec.setter def exec(self, value): data_view = og.AttributeValueHelper(self._attributes.exec) data_view.set(value) @property def gpu(self): data_view = og.AttributeValueHelper(self._attributes.gpu) return data_view.get() @gpu.setter def gpu(self, value): data_view = og.AttributeValueHelper(self._attributes.gpu) data_view.set(value) @property def hydraTime(self): data_view = og.AttributeValueHelper(self._attributes.hydraTime) return data_view.get() @hydraTime.setter def hydraTime(self, value): data_view = og.AttributeValueHelper(self._attributes.hydraTime) data_view.set(value) @property def rp(self): data_view = og.AttributeValueHelper(self._attributes.rp) return data_view.get() @rp.setter def rp(self, value): data_view = og.AttributeValueHelper(self._attributes.rp) data_view.set(value) @property def simTime(self): data_view = og.AttributeValueHelper(self._attributes.simTime) return data_view.get() @simTime.setter def simTime(self, value): data_view = og.AttributeValueHelper(self._attributes.simTime) 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 = OgnGpuInteropRenderProductEntryDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGpuInteropRenderProductEntryDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGpuInteropRenderProductEntryDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTimelineStartDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.StartTimeline Starts playback of the main timeline at the current frame """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTimelineStartDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.StartTimeline Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn Outputs: outputs.execOut """ # 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:execIn', 'execution', 0, 'Execute In', 'The input that triggers the execution of this node.', {}, True, None, False, ''), ('outputs:execOut', 'execution', 0, 'Execute Out', 'The output that is triggered when this node executed.', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.outputs.execOut = og.AttributeRole.EXECUTION 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) 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 = OgnTimelineStartDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTimelineStartDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTimelineStartDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantInt2Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantInt2 Holds a 2-component int constant. """ 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 OgnConstantInt2Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantInt2 Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'int2', 0, 'Value', 'The constant value', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, [0, 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 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 = { } 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 = OgnConstantInt2Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantInt2Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantInt2Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimAttributeDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrimAttribute Given a path to a prim on the current USD stage and the name of an attribute on that prim, gets the value of that attribute, at the global timeline value. """ from typing import Any import carb import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnReadPrimAttributeDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrimAttribute Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.name inputs.prim inputs.primPath inputs.usdTimecode inputs.usePath Outputs: outputs.value State: state.correctlySetup state.importPath state.srcAttrib state.srcPath state.srcPathAsToken state.time """ # 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:name', 'token', 0, 'Attribute Name', 'The name of the attribute to get on the specified prim', {}, True, "", False, ''), ('inputs:prim', 'target', 0, None, "The prim to be read from when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, None, "The path of the prim to be modified when 'usePath' is true", {}, False, None, True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:usdTimecode', 'timecode', 0, 'Time', 'The time at which to evaluate the transform of the USD prim attribute. A value of "NaN" indicates that the default USD time stamp should be used', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''), ('inputs:usePath', 'bool', 0, None, "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:value', 'any', 2, None, 'The attribute value', {}, True, None, False, ''), ('state:correctlySetup', 'bool', 0, None, 'Wheter or not the instance is properly setup', {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('state:importPath', 'uint64', 0, None, 'Path at which data has been imported', {}, True, None, False, ''), ('state:srcAttrib', 'uint64', 0, None, 'A TokenC to the source attribute', {}, True, None, False, ''), ('state:srcPath', 'uint64', 0, None, 'A PathC to the source prim', {}, True, None, False, ''), ('state:srcPathAsToken', 'uint64', 0, None, 'A TokenC to the source prim', {}, True, None, False, ''), ('state:time', 'double', 0, None, 'The timecode at which we have imported the value', {}, 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.prim = og.AttributeRole.TARGET role_data.inputs.usdTimecode = og.AttributeRole.TIMECODE 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 name(self): data_view = og.AttributeValueHelper(self._attributes.name) return data_view.get() @name.setter def name(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.name) data_view = og.AttributeValueHelper(self._attributes.name) data_view.set(value) @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) return data_view.get() @usdTimecode.setter def usdTimecode(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usdTimecode) data_view = og.AttributeValueHelper(self._attributes.usdTimecode) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) 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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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) @property def correctlySetup(self): data_view = og.AttributeValueHelper(self._attributes.correctlySetup) return data_view.get() @correctlySetup.setter def correctlySetup(self, value): data_view = og.AttributeValueHelper(self._attributes.correctlySetup) data_view.set(value) @property def importPath(self): data_view = og.AttributeValueHelper(self._attributes.importPath) return data_view.get() @importPath.setter def importPath(self, value): data_view = og.AttributeValueHelper(self._attributes.importPath) data_view.set(value) @property def srcAttrib(self): data_view = og.AttributeValueHelper(self._attributes.srcAttrib) return data_view.get() @srcAttrib.setter def srcAttrib(self, value): data_view = og.AttributeValueHelper(self._attributes.srcAttrib) data_view.set(value) @property def srcPath(self): data_view = og.AttributeValueHelper(self._attributes.srcPath) return data_view.get() @srcPath.setter def srcPath(self, value): data_view = og.AttributeValueHelper(self._attributes.srcPath) data_view.set(value) @property def srcPathAsToken(self): data_view = og.AttributeValueHelper(self._attributes.srcPathAsToken) return data_view.get() @srcPathAsToken.setter def srcPathAsToken(self, value): data_view = og.AttributeValueHelper(self._attributes.srcPathAsToken) data_view.set(value) @property def time(self): data_view = og.AttributeValueHelper(self._attributes.time) return data_view.get() @time.setter def time(self, value): data_view = og.AttributeValueHelper(self._attributes.time) 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 = OgnReadPrimAttributeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadPrimAttributeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadPrimAttributeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetPrimDirectionVectorDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetPrimDirectionVector Given a prim, find its direction vectors (up vector, forward vector, right vector, etc.) """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetPrimDirectionVectorDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetPrimDirectionVector Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim inputs.primPath inputs.usePath Outputs: outputs.backwardVector outputs.downVector outputs.forwardVector outputs.leftVector outputs.rightVector outputs.upVector """ # 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:prim', 'target', 0, None, "The connection to the input prim - this attribute is used when 'usePath' is false", {}, False, [], False, ''), ('inputs:primPath', 'token', 0, None, "The path of the input prim - this attribute is used when 'usePath' is true", {}, True, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:usePath', 'bool', 0, None, "When true, it will use the 'primPath' attribute as the path to the prim, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'true'}, True, True, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:backwardVector', 'double3', 0, 'Backward Vector', 'The backward vector of the prim', {}, True, None, False, ''), ('outputs:downVector', 'double3', 0, 'Down Vector', 'The down vector of the prim', {}, True, None, False, ''), ('outputs:forwardVector', 'double3', 0, 'Forward Vector', 'The forward vector of the prim', {}, True, None, False, ''), ('outputs:leftVector', 'double3', 0, 'Left Vector', 'The left vector of the prim', {}, True, None, False, ''), ('outputs:rightVector', 'double3', 0, 'Right Vector', 'The right vector of the prim', {}, True, None, False, ''), ('outputs:upVector', 'double3', 0, 'Up Vector', 'The up vector of the prim', {}, 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.prim = og.AttributeRole.TARGET 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 prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) 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 backwardVector(self): data_view = og.AttributeValueHelper(self._attributes.backwardVector) return data_view.get() @backwardVector.setter def backwardVector(self, value): data_view = og.AttributeValueHelper(self._attributes.backwardVector) data_view.set(value) @property def downVector(self): data_view = og.AttributeValueHelper(self._attributes.downVector) return data_view.get() @downVector.setter def downVector(self, value): data_view = og.AttributeValueHelper(self._attributes.downVector) data_view.set(value) @property def forwardVector(self): data_view = og.AttributeValueHelper(self._attributes.forwardVector) return data_view.get() @forwardVector.setter def forwardVector(self, value): data_view = og.AttributeValueHelper(self._attributes.forwardVector) data_view.set(value) @property def leftVector(self): data_view = og.AttributeValueHelper(self._attributes.leftVector) return data_view.get() @leftVector.setter def leftVector(self, value): data_view = og.AttributeValueHelper(self._attributes.leftVector) data_view.set(value) @property def rightVector(self): data_view = og.AttributeValueHelper(self._attributes.rightVector) return data_view.get() @rightVector.setter def rightVector(self, value): data_view = og.AttributeValueHelper(self._attributes.rightVector) data_view.set(value) @property def upVector(self): data_view = og.AttributeValueHelper(self._attributes.upVector) return data_view.get() @upVector.setter def upVector(self, value): data_view = og.AttributeValueHelper(self._attributes.upVector) 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 = OgnGetPrimDirectionVectorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetPrimDirectionVectorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetPrimDirectionVectorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnNoiseDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Noise Sample values from a Perlin noise field. The noise field for any given seed is static: the same input position will always give the same result. This is useful in many areas, such as texturing and animation, where repeatability is essential. If you want a result that varies then you will need to vary either the position or the seed. For example, connecting the 'frame' output of an OnTick node to position will provide a noise result which varies from frame to frame. Perlin noise is locally smooth, meaning that small changes in the sample position will produce small changes in the resulting noise. Varying the seed value will produce a more chaotic result. Another characteristic of Perlin noise is that it is zero at the corners of each cell in the field. In practical terms this means that integral positions, such as 5.0 in a one-dimensional field or (3.0, -1.0) in a two-dimensional field, will return a result of 0.0. Thus, if the source of your sample positions provides only integral values then all of your results will be zero. To avoid this try offsetting your position values by a fractional amount, such as 0.5. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnNoiseDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Noise Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.position inputs.seed 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:position', 'float,float[2],float[2][],float[3],float[3][],float[4],float[4][],float[]', 1, None, 'Position(s) within the noise field to be sampled. For a given seed, the same position \nwill always return the same noise value.', {}, True, None, False, ''), ('inputs:seed', 'uint', 0, None, 'Seed for generating the noise field.', {ogn.MetadataKeys.DEFAULT: '0'}, True, 0, False, ''), ('outputs:result', 'float,float[]', 1, None, 'Value at the selected position(s) in the noise field.', {}, 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 position(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.position""" return og.RuntimeAttribute(self._attributes.position.get_attribute_data(), self._context, True) @position.setter def position(self, value_to_set: Any): """Assign another attribute's value to outputs.position""" if isinstance(value_to_set, og.RuntimeAttribute): self.position.value = value_to_set.value else: self.position.value = value_to_set @property def seed(self): data_view = og.AttributeValueHelper(self._attributes.seed) return data_view.get() @seed.setter def seed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.seed) data_view = og.AttributeValueHelper(self._attributes.seed) 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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnNoiseDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnNoiseDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnNoiseDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantFloat4Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantFloat4 Holds a 4-component float constant. """ 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 OgnConstantFloat4Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantFloat4 Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'float4', 0, 'Value', 'The constant value', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, [0.0, 0.0, 0.0, 0.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 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 = { } 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 = OgnConstantFloat4Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantFloat4Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantFloat4Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstructArrayDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstructArray Makes an output array attribute from input values, in the order of the inputs. If 'arraySize' is less than the number of input elements, the top 'arraySize' elements will be used. If 'arraySize' is greater than the number of input elements, the last input element will be repeated to fill the remaining space. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnConstructArrayDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstructArray Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.arraySize inputs.arrayType inputs.input0 Outputs: outputs.array Predefined Tokens: tokens.Auto tokens.Bool tokens.Double tokens.Float tokens.Half tokens.Int tokens.Int64 tokens.Token tokens.UChar tokens.UInt tokens.UInt64 tokens.Double_2 tokens.Double_3 tokens.Double_4 tokens.Double_9 tokens.Double_16 tokens.Float_2 tokens.Float_3 tokens.Float_4 tokens.Half_2 tokens.Half_3 tokens.Half_4 tokens.Int_2 tokens.Int_3 tokens.Int_4 """ # 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:arraySize', 'int', 0, None, 'The size of the array to create', {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.DEFAULT: '1'}, True, 1, False, ''), ('inputs:arrayType', 'token', 0, 'Array Type', "The type of the array ('auto' infers the type from the first connected and resolved input)", {ogn.MetadataKeys.LITERAL_ONLY: '1', ogn.MetadataKeys.ALLOWED_TOKENS: 'auto,bool[],double[],float[],half[],int[],int64[],token[],uchar[],uint[],uint64[],double[2][],double[3][],double[4][],matrixd[3][],matrixd[4][],float[2][],float[3][],float[4][],half[2][],half[3][],half[4][],int[2][],int[3][],int[4][]', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '{"Auto": "auto", "Bool": "bool[]", "Double": "double[]", "Float": "float[]", "Half": "half[]", "Int": "int[]", "Int64": "int64[]", "Token": "token[]", "UChar": "uchar[]", "UInt": "uint[]", "UInt64": "uint64[]", "Double_2": "double[2][]", "Double_3": "double[3][]", "Double_4": "double[4][]", "Double_9": "matrixd[3][]", "Double_16": "matrixd[4][]", "Float_2": "float[2][]", "Float_3": "float[3][]", "Float_4": "float[4][]", "Half_2": "half[2][]", "Half_3": "half[3][]", "Half_4": "half[4][]", "Int_2": "int[2][]", "Int_3": "int[3][]", "Int_4": "int[4][]"}', ogn.MetadataKeys.DEFAULT: '"auto"'}, True, "auto", False, ''), ('inputs:input0', 'any', 2, None, 'Input array element', {}, True, None, False, ''), ('outputs:array', 'any', 2, None, 'The array of copied values of inputs in the given order', {}, True, None, False, ''), ]) class tokens: Auto = "auto" Bool = "bool[]" Double = "double[]" Float = "float[]" Half = "half[]" Int = "int[]" Int64 = "int64[]" Token = "token[]" UChar = "uchar[]" UInt = "uint[]" UInt64 = "uint64[]" Double_2 = "double[2][]" Double_3 = "double[3][]" Double_4 = "double[4][]" Double_9 = "matrixd[3][]" Double_16 = "matrixd[4][]" Float_2 = "float[2][]" Float_3 = "float[3][]" Float_4 = "float[4][]" Half_2 = "half[2][]" Half_3 = "half[3][]" Half_4 = "half[4][]" Int_2 = "int[2][]" Int_3 = "int[3][]" Int_4 = "int[4][]" 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 arraySize(self): data_view = og.AttributeValueHelper(self._attributes.arraySize) return data_view.get() @arraySize.setter def arraySize(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.arraySize) data_view = og.AttributeValueHelper(self._attributes.arraySize) data_view.set(value) @property def arrayType(self): data_view = og.AttributeValueHelper(self._attributes.arrayType) return data_view.get() @arrayType.setter def arrayType(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.arrayType) data_view = og.AttributeValueHelper(self._attributes.arrayType) data_view.set(value) @property def input0(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.input0""" return og.RuntimeAttribute(self._attributes.input0.get_attribute_data(), self._context, True) @input0.setter def input0(self, value_to_set: Any): """Assign another attribute's value to outputs.input0""" if isinstance(value_to_set, og.RuntimeAttribute): self.input0.value = value_to_set.value else: self.input0.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 array(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.array""" return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, False) @array.setter def array(self, value_to_set: Any): """Assign another attribute's value to outputs.array""" if isinstance(value_to_set, og.RuntimeAttribute): self.array.value = value_to_set.value else: self.array.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 = OgnConstructArrayDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstructArrayDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstructArrayDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnReadPrimAttributesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ReadPrimAttributes Read Prim attributes and exposes them as dynamic attributes Does not produce output bundle. """ import usdrt 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 OgnReadPrimAttributesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ReadPrimAttributes Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.attrNamesToImport inputs.prim inputs.primPath inputs.usdTimecode inputs.usePath Outputs: outputs.primBundle State: state.attrNamesToImport state.primPath state.usdTimecode """ # 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:attrNamesToImport', 'string', 0, 'Attribute Name Pattern', "A list of wildcard patterns used to match the attribute names that are to be imported\n\nSupported syntax of wildcard pattern:\n '*' - match an arbitrary number of any characters\n '?' - match any single character\n '^' - (caret) is used to define a pattern that is to be excluded\n\nExample of wildcard patterns, input: ['points', 'faceVertexCount', 'faceVertexIndices', 'size']\n '*' - match any\n '* ^points' - match any, but exclude 'points'\n '* ^face*' - match any, but exclude 'faceVertexCount' and 'faceVertexIndices'", {ogn.MetadataKeys.DEFAULT: '"*"'}, True, "*", False, ''), ('inputs:prim', 'target', 0, None, "The prim to be read from when 'usePath' is false", {}, True, [], False, ''), ('inputs:primPath', 'path', 0, 'Prim Path', "The path of the prim to be read from when 'usePath' is true", {ogn.MetadataKeys.DEFAULT: '""'}, False, "", True, 'Use prim input with a GetPrimsAtPath node instead'), ('inputs:usdTimecode', 'timecode', 0, 'Time', 'The time at which to evaluate the transform of the USD prim. A value of "NaN" indicates that the default USD time stamp should be used', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), False, ''), ('inputs:usePath', 'bool', 0, 'Use Path', "When true, the 'primPath' attribute is used as the path to the prim being read, otherwise it will read the connection at the 'prim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, True, 'Use prim input with a GetPrimsAtPath node instead'), ('outputs:primBundle', 'bundle', 0, None, 'A bundle of the target Prim attributes.\nIn addition to the data attributes, there are token attributes named sourcePrimPath and sourcePrimType\nwhich contains the path of the Prim being read', {ogn.MetadataKeys.HIDDEN: 'true', ogn.MetadataKeys.LITERAL_ONLY: '1'}, True, None, False, ''), ('state:attrNamesToImport', 'string', 0, None, 'State from previous evaluation', {}, True, None, False, ''), ('state:primPath', 'uint64', 0, None, 'State from previous evaluation', {}, True, None, False, ''), ('state:usdTimecode', 'timecode', 0, None, 'State from previous evaluation', {ogn.MetadataKeys.DEFAULT: '"NaN"'}, True, float("NaN"), 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.attrNamesToImport = og.AttributeRole.TEXT role_data.inputs.prim = og.AttributeRole.TARGET role_data.inputs.primPath = og.AttributeRole.PATH role_data.inputs.usdTimecode = og.AttributeRole.TIMECODE role_data.outputs.primBundle = og.AttributeRole.BUNDLE role_data.state.attrNamesToImport = og.AttributeRole.TEXT role_data.state.usdTimecode = og.AttributeRole.TIMECODE 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 attrNamesToImport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) return data_view.get() @attrNamesToImport.setter def attrNamesToImport(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrNamesToImport) data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) data_view.set(value) self.attrNamesToImport_size = data_view.get_array_size() @property def prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.primPath) data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) self.primPath_size = data_view.get_array_size() @property def usdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) return data_view.get() @usdTimecode.setter def usdTimecode(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usdTimecode) data_view = og.AttributeValueHelper(self._attributes.usdTimecode) data_view.set(value) @property def usePath(self): data_view = og.AttributeValueHelper(self._attributes.usePath) return data_view.get() @usePath.setter def usePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.usePath) data_view = og.AttributeValueHelper(self._attributes.usePath) 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 primBundle(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute outputs.primBundle""" return self.__bundles.primBundle @primBundle.setter def primBundle(self, bundle: og.BundleContents): """Overwrite the bundle attribute outputs.primBundle 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.primBundle.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) self.attrNamesToImport_size = None @property def attrNamesToImport(self): data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) self.attrNamesToImport_size = data_view.get_array_size() return data_view.get() @attrNamesToImport.setter def attrNamesToImport(self, value): data_view = og.AttributeValueHelper(self._attributes.attrNamesToImport) data_view.set(value) self.attrNamesToImport_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): data_view = og.AttributeValueHelper(self._attributes.primPath) data_view.set(value) @property def usdTimecode(self): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) return data_view.get() @usdTimecode.setter def usdTimecode(self, value): data_view = og.AttributeValueHelper(self._attributes.usdTimecode) 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 = OgnReadPrimAttributesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnReadPrimAttributesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnReadPrimAttributesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTrigDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Trig Trigonometric operation of one input in degrees. Supported operations are: SIN, COS, TAN, ARCSIN, ARCCOS, ARCTAN, DEGREES, RADIANS """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTrigDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Trig Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a inputs.operation Outputs: outputs.result Predefined Tokens: tokens.SIN tokens.COS tokens.TAN tokens.ARCSIN tokens.ARCCOS tokens.ARCTAN tokens.DEGREES tokens.RADIANS """ # 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', 'double,float,half,timecode', 1, None, 'Input to the function', {}, True, None, False, ''), ('inputs:operation', 'token', 0, 'Operation', 'The operation to perform', {ogn.MetadataKeys.ALLOWED_TOKENS: 'SIN,COS,TAN,ARCSIN,ARCCOS,ARCTAN,DEGREES,RADIANS', ogn.MetadataKeys.ALLOWED_TOKENS_RAW: '["SIN", "COS", "TAN", "ARCSIN", "ARCCOS", "ARCTAN", "DEGREES", "RADIANS"]', ogn.MetadataKeys.DEFAULT: '"SIN"'}, True, "SIN", False, ''), ('outputs:result', 'double,float,half,timecode', 1, 'Result', 'The result of the function', {}, True, None, False, ''), ]) class tokens: SIN = "SIN" COS = "COS" TAN = "TAN" ARCSIN = "ARCSIN" ARCCOS = "ARCCOS" ARCTAN = "ARCTAN" DEGREES = "DEGREES" RADIANS = "RADIANS" 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 operation(self): data_view = og.AttributeValueHelper(self._attributes.operation) return data_view.get() @operation.setter def operation(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.operation) data_view = og.AttributeValueHelper(self._attributes.operation) 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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnTrigDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTrigDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTrigDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantHalf3Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantHalf3 Holds a 3-component half-precision constant. """ 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 OgnConstantHalf3Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantHalf3 Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'half3', 0, 'Value', 'The constant value', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, [0.0, 0.0, 0.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 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 = { } 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 = OgnConstantHalf3Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantHalf3Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantHalf3Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnIsEmptyDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.IsEmpty Checks if the given input is empty. An input is considered empty if there is no data. A string or array of size 0 is considered empty whereas a blank string ' ' is not empty. A float with value 0.0 and int[2] with value [0, 0] are not empty. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnIsEmptyDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.IsEmpty Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.input Outputs: outputs.isEmpty """ # 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:input', 'any', 2, 'Input', 'The input to check if empty', {}, True, None, False, ''), ('outputs:isEmpty', 'bool', 0, 'Is Empty', 'True if the input is empty, false otherwise', {}, 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 input(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.input""" return og.RuntimeAttribute(self._attributes.input.get_attribute_data(), self._context, True) @input.setter def input(self, value_to_set: Any): """Assign another attribute's value to outputs.input""" if isinstance(value_to_set, og.RuntimeAttribute): self.input.value = value_to_set.value else: self.input.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 isEmpty(self): data_view = og.AttributeValueHelper(self._attributes.isEmpty) return data_view.get() @isEmpty.setter def isEmpty(self, value): data_view = og.AttributeValueHelper(self._attributes.isEmpty) 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 = OgnIsEmptyDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnIsEmptyDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnIsEmptyDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnCeilDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Ceil Computes the ceil of the given decimal number a, which is the smallest integral value greater than a """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnCeilDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Ceil Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.a 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', '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[],half,half[2],half[2][],half[3],half[3][],half[4],half[4][],half[],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[],vectord[3],vectord[3][],vectorf[3],vectorf[3][],vectorh[3],vectorh[3][]', 1, 'A', 'The decimal number', {}, True, None, False, ''), ('outputs:result', 'int,int[2],int[2][],int[3],int[3][],int[4],int[4][],int[]', 1, 'Result', 'The ceil of the input a', {}, 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 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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnCeilDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnCeilDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnCeilDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetPrimPathDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetPrimPath Generates a path from the specified relationship. This is useful when an absolute prim path may change. """ import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetPrimPathDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetPrimPath Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim Outputs: outputs.path outputs.primPath """ # 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:prim', 'target', 0, None, 'The prim to determine the path of', {}, True, [], False, ''), ('outputs:path', 'path', 0, None, 'The absolute path of the given prim as a string', {}, True, None, True, 'Path is deprecated. Use primPath output instead.'), ('outputs:primPath', 'token', 0, None, 'The absolute path of the given prim as a token', {}, 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.prim = og.AttributeRole.TARGET role_data.outputs.path = og.AttributeRole.PATH 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 prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_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.path_size = None self._batchedWriteValues = { } @property def path(self): data_view = og.AttributeValueHelper(self._attributes.path) return data_view.get(reserved_element_count=self.path_size) @path.setter def path(self, value): data_view = og.AttributeValueHelper(self._attributes.path) data_view.set(value) self.path_size = data_view.get_array_size() @property def primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): data_view = og.AttributeValueHelper(self._attributes.primPath) 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 = OgnGetPrimPathDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetPrimPathDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetPrimPathDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnTimelineLoopDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.LoopTimeline Controls looping playback of the main timeline """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnTimelineLoopDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.LoopTimeline Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.loop Outputs: outputs.execOut """ # 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:execIn', 'execution', 0, 'Execute In', 'The input that triggers the execution of this node.', {}, True, None, False, ''), ('inputs:loop', 'bool', 0, 'Loop', 'Enable or disable playback looping?', {}, True, False, False, ''), ('outputs:execOut', 'execution', 0, 'Execute Out', 'The output that is triggered when this node executed.', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.outputs.execOut = og.AttributeRole.EXECUTION 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def loop(self): data_view = og.AttributeValueHelper(self._attributes.loop) return data_view.get() @loop.setter def loop(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.loop) data_view = og.AttributeValueHelper(self._attributes.loop) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) 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 = OgnTimelineLoopDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnTimelineLoopDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnTimelineLoopDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnAttrTypeDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.AttributeType Queries information about the type of a specified attribute in an input bundle """ 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 OgnAttrTypeDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.AttributeType Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.attrName inputs.data Outputs: outputs.arrayDepth outputs.baseType outputs.componentCount outputs.fullType outputs.role """ # 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:attrName', 'token', 0, 'Attribute To Query', 'The name of the attribute to be queried', {ogn.MetadataKeys.DEFAULT: '"input"'}, True, "input", False, ''), ('inputs:data', 'bundle', 0, 'Bundle To Examine', 'Bundle of attributes to examine', {}, True, None, False, ''), ('outputs:arrayDepth', 'int', 0, 'Attribute Array Depth', 'Zero for a single value, one for an array, two for an array of arrays.\nSet to -1 if the named attribute was not in the bundle.', {}, True, None, False, ''), ('outputs:baseType', 'int', 0, 'Attribute Base Type', 'An integer representing the type of the individual components.\nSet to -1 if the named attribute was not in the bundle.', {}, True, None, False, ''), ('outputs:componentCount', 'int', 0, 'Attribute Component Count', 'Number of components in each tuple, e.g. one for float, three for point3f, 16 for\nmatrix4d. Set to -1 if the named attribute was not in the bundle.', {}, True, None, False, ''), ('outputs:fullType', 'int', 0, 'Full Attribute Type', 'A single int representing the full type information.\nSet to -1 if the named attribute was not in the bundle.', {}, True, None, False, ''), ('outputs:role', 'int', 0, 'Attribute Role', 'An integer representing semantic meaning of the type, e.g. point3f vs. normal3f vs. vector3f vs. float3.\nSet to -1 if the named attribute was not in the bundle.', {}, 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.data = 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 attrName(self): data_view = og.AttributeValueHelper(self._attributes.attrName) return data_view.get() @attrName.setter def attrName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.attrName) data_view = og.AttributeValueHelper(self._attributes.attrName) data_view.set(value) @property def data(self) -> og.BundleContents: """Get the bundle wrapper class for the attribute inputs.data""" return self.__bundles.data 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 arrayDepth(self): data_view = og.AttributeValueHelper(self._attributes.arrayDepth) return data_view.get() @arrayDepth.setter def arrayDepth(self, value): data_view = og.AttributeValueHelper(self._attributes.arrayDepth) data_view.set(value) @property def baseType(self): data_view = og.AttributeValueHelper(self._attributes.baseType) return data_view.get() @baseType.setter def baseType(self, value): data_view = og.AttributeValueHelper(self._attributes.baseType) data_view.set(value) @property def componentCount(self): data_view = og.AttributeValueHelper(self._attributes.componentCount) return data_view.get() @componentCount.setter def componentCount(self, value): data_view = og.AttributeValueHelper(self._attributes.componentCount) data_view.set(value) @property def fullType(self): data_view = og.AttributeValueHelper(self._attributes.fullType) return data_view.get() @fullType.setter def fullType(self, value): data_view = og.AttributeValueHelper(self._attributes.fullType) data_view.set(value) @property def role(self): data_view = og.AttributeValueHelper(self._attributes.role) return data_view.get() @role.setter def role(self, value): data_view = og.AttributeValueHelper(self._attributes.role) 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 = OgnAttrTypeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnAttrTypeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnAttrTypeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantQuatdDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantQuatd Holds a double-precision quaternion constant: A real coefficient and three imaginary coefficients """ 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 OgnConstantQuatdDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantQuatd Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'quatd', 0, 'Value', 'The constant value', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, [0.0, 0.0, 0.0, 0.0], 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.value = og.AttributeRole.QUATERNION 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 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 = { } 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 = OgnConstantQuatdDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantQuatdDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantQuatdDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnStopSoundDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.StopSound Stop playing a sound primitive """ 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 OgnStopSoundDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.StopSound Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.soundId Outputs: outputs.execOut """ # 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:execIn', 'execution', 0, None, 'The input execution', {}, True, None, False, ''), ('inputs:soundId', 'uint64', 0, None, 'The sound identifier', {}, True, 0, False, ''), ('outputs:execOut', 'execution', 0, None, 'The output execution', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.outputs.execOut = og.AttributeRole.EXECUTION 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def soundId(self): data_view = og.AttributeValueHelper(self._attributes.soundId) return data_view.get() @soundId.setter def soundId(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.soundId) data_view = og.AttributeValueHelper(self._attributes.soundId) 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 execOut(self): data_view = og.AttributeValueHelper(self._attributes.execOut) return data_view.get() @execOut.setter def execOut(self, value): data_view = og.AttributeValueHelper(self._attributes.execOut) 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 = OgnStopSoundDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnStopSoundDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnStopSoundDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnSetMatrix4QuaternionDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.SetMatrix4Quaternion Sets the rotation of the given matrix4d value which represents a linear transformation. Does not modify the translation (row 3) of the matrix. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnSetMatrix4QuaternionDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.SetMatrix4Quaternion Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.matrix inputs.quaternion Outputs: outputs.matrix """ # 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:matrix', 'matrixd[4],matrixd[4][]', 1, None, 'The matrix to be modified', {}, True, None, False, ''), ('inputs:quaternion', 'quatd[4],quatd[4][]', 1, 'Quaternion', 'The quaternion the matrix will apply about the given rotationAxis.', {}, True, None, False, ''), ('outputs:matrix', 'matrixd[4],matrixd[4][]', 1, None, 'The updated matrix', {}, 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 matrix(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.matrix""" return og.RuntimeAttribute(self._attributes.matrix.get_attribute_data(), self._context, True) @matrix.setter def matrix(self, value_to_set: Any): """Assign another attribute's value to outputs.matrix""" if isinstance(value_to_set, og.RuntimeAttribute): self.matrix.value = value_to_set.value else: self.matrix.value = value_to_set @property def quaternion(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.quaternion""" return og.RuntimeAttribute(self._attributes.quaternion.get_attribute_data(), self._context, True) @quaternion.setter def quaternion(self, value_to_set: Any): """Assign another attribute's value to outputs.quaternion""" if isinstance(value_to_set, og.RuntimeAttribute): self.quaternion.value = value_to_set.value else: self.quaternion.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 matrix(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.matrix""" return og.RuntimeAttribute(self._attributes.matrix.get_attribute_data(), self._context, False) @matrix.setter def matrix(self, value_to_set: Any): """Assign another attribute's value to outputs.matrix""" if isinstance(value_to_set, og.RuntimeAttribute): self.matrix.value = value_to_set.value else: self.matrix.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 = OgnSetMatrix4QuaternionDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnSetMatrix4QuaternionDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnSetMatrix4QuaternionDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantTexCoord3hDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantTexCoord3h Holds a 3D uvw texture coordinate. """ 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 OgnConstantTexCoord3hDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantTexCoord3h Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'texCoord3h', 0, 'Value', 'The constant value', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, [0.0, 0.0, 0.0], 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.value = og.AttributeRole.TEXCOORD 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 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 = { } 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 = OgnConstantTexCoord3hDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantTexCoord3hDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantTexCoord3hDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnBundleInspectorDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.BundleInspector This node creates independent outputs containing information about the contents of a bundle attribute. It can be used for testing or debugging what is inside a bundle as it flows through the graph. The bundle is inspected recursively, so any bundles inside of the main bundle have their contents added to the output as well. The bundle contents can be printed when the node evaluates, and it passes the input straight through unchanged so you can insert this node between two nodes to inspect the data flowing through the graph. """ 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 OgnBundleInspectorDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.BundleInspector Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.bundle inputs.inspectDepth inputs.print Outputs: outputs.arrayDepths outputs.attributeCount outputs.bundle outputs.childCount outputs.count outputs.names outputs.roles outputs.tupleCounts outputs.types outputs.values """ # 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, 'Bundle To Analyze', 'The attribute bundle to be inspected', {}, True, None, False, ''), ('inputs:inspectDepth', 'int', 0, 'Inspect Depth', 'The depth that the inspector is going to traverse and print.\n0 means just attributes on the input bundles. 1 means its immediate children. -1 means infinity.', {ogn.MetadataKeys.DEFAULT: '1'}, True, 1, False, ''), ('inputs:print', 'bool', 0, 'Print Contents', 'Setting to true prints the contents of the bundle when the node evaluates', {}, True, False, False, ''), ('outputs:arrayDepths', 'int[]', 0, 'Array Depths', 'List of the array depths of attributes present in the bundle', {}, True, None, False, ''), ('outputs:attributeCount', 'uint64', 0, 'Attribute Count', 'Number of attributes present in the bundle. Every other output is an array that\nshould have this number of elements in it.', {}, True, None, False, ''), ('outputs:bundle', 'bundle', 0, 'Bundle Passthrough', 'The attribute bundle passed through as-is from the input bundle', {}, True, None, False, ''), ('outputs:childCount', 'uint64', 0, 'Child Count', 'Number of child bundles present in the bundle.', {}, True, None, False, ''), ('outputs:count', 'uint64', 0, 'Attribute Count', 'Number of attributes present in the bundle. Every other output is an array that\nshould have this number of elements in it.', {ogn.MetadataKeys.HIDDEN: 'true'}, True, None, False, ''), ('outputs:names', 'token[]', 0, 'Attribute Names', 'List of the names of attributes present in the bundle', {}, True, None, False, ''), ('outputs:roles', 'token[]', 0, 'Attribute Roles', 'List of the names of the roles of attributes present in the bundle', {}, True, None, False, ''), ('outputs:tupleCounts', 'int[]', 0, 'Tuple Counts', 'List of the tuple counts of attributes present in the bundle', {}, True, None, False, ''), ('outputs:types', 'token[]', 0, 'Attribute Base Types', 'List of the types of attributes present in the bundle', {}, True, None, False, ''), ('outputs:values', 'token[]', 0, 'Attribute Values', 'List of the bundled attribute values, converted to token format', {}, 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 @property def inspectDepth(self): data_view = og.AttributeValueHelper(self._attributes.inspectDepth) return data_view.get() @inspectDepth.setter def inspectDepth(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.inspectDepth) data_view = og.AttributeValueHelper(self._attributes.inspectDepth) data_view.set(value) @property def print(self): data_view = og.AttributeValueHelper(self._attributes.print) return data_view.get() @print.setter def print(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.print) data_view = og.AttributeValueHelper(self._attributes.print) 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.arrayDepths_size = None self.names_size = None self.roles_size = None self.tupleCounts_size = None self.types_size = None self.values_size = None self._batchedWriteValues = { } @property def arrayDepths(self): data_view = og.AttributeValueHelper(self._attributes.arrayDepths) return data_view.get(reserved_element_count=self.arrayDepths_size) @arrayDepths.setter def arrayDepths(self, value): data_view = og.AttributeValueHelper(self._attributes.arrayDepths) data_view.set(value) self.arrayDepths_size = data_view.get_array_size() @property def attributeCount(self): data_view = og.AttributeValueHelper(self._attributes.attributeCount) return data_view.get() @attributeCount.setter def attributeCount(self, value): data_view = og.AttributeValueHelper(self._attributes.attributeCount) data_view.set(value) @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 @property def childCount(self): data_view = og.AttributeValueHelper(self._attributes.childCount) return data_view.get() @childCount.setter def childCount(self, value): data_view = og.AttributeValueHelper(self._attributes.childCount) data_view.set(value) @property def count(self): data_view = og.AttributeValueHelper(self._attributes.count) return data_view.get() @count.setter def count(self, value): data_view = og.AttributeValueHelper(self._attributes.count) data_view.set(value) @property def names(self): data_view = og.AttributeValueHelper(self._attributes.names) return data_view.get(reserved_element_count=self.names_size) @names.setter def names(self, value): data_view = og.AttributeValueHelper(self._attributes.names) data_view.set(value) self.names_size = data_view.get_array_size() @property def roles(self): data_view = og.AttributeValueHelper(self._attributes.roles) return data_view.get(reserved_element_count=self.roles_size) @roles.setter def roles(self, value): data_view = og.AttributeValueHelper(self._attributes.roles) data_view.set(value) self.roles_size = data_view.get_array_size() @property def tupleCounts(self): data_view = og.AttributeValueHelper(self._attributes.tupleCounts) return data_view.get(reserved_element_count=self.tupleCounts_size) @tupleCounts.setter def tupleCounts(self, value): data_view = og.AttributeValueHelper(self._attributes.tupleCounts) data_view.set(value) self.tupleCounts_size = data_view.get_array_size() @property def types(self): data_view = og.AttributeValueHelper(self._attributes.types) return data_view.get(reserved_element_count=self.types_size) @types.setter def types(self, value): data_view = og.AttributeValueHelper(self._attributes.types) data_view.set(value) self.types_size = data_view.get_array_size() @property def values(self): data_view = og.AttributeValueHelper(self._attributes.values) return data_view.get(reserved_element_count=self.values_size) @values.setter def values(self, value): data_view = og.AttributeValueHelper(self._attributes.values) data_view.set(value) self.values_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 = OgnBundleInspectorDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnBundleInspectorDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnBundleInspectorDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetVariantSetNamesDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetVariantSetNames Get variantSet names on a prim """ import carb import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetVariantSetNamesDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetVariantSetNames Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prim Outputs: outputs.variantSetNames """ # 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:prim', 'target', 0, None, 'The prim with the variantSet', {}, True, [], False, ''), ('outputs:variantSetNames', 'token[]', 0, None, 'List of variantSet names', {}, 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.prim = og.AttributeRole.TARGET 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 prim(self): data_view = og.AttributeValueHelper(self._attributes.prim) return data_view.get() @prim.setter def prim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prim) data_view = og.AttributeValueHelper(self._attributes.prim) data_view.set(value) self.prim_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.variantSetNames_size = None self._batchedWriteValues = { } @property def variantSetNames(self): data_view = og.AttributeValueHelper(self._attributes.variantSetNames) return data_view.get(reserved_element_count=self.variantSetNames_size) @variantSetNames.setter def variantSetNames(self, value): data_view = og.AttributeValueHelper(self._attributes.variantSetNames) data_view.set(value) self.variantSetNames_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 = OgnGetVariantSetNamesDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetVariantSetNamesDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetVariantSetNamesDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetGatheredAttributeDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetGatheredAttribute Copies gathered scaler/vector attribute values from the Gather buckets into an array attribute PROTOTYPE DO NOT USE, Requires GatherPrototype """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn from typing import Any class OgnGetGatheredAttributeDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetGatheredAttribute Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.gatherId inputs.name Outputs: outputs.value """ # 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:gatherId', 'uint64', 0, None, 'The GatherId of the Gather containing the attribute values', {}, True, 0, False, ''), ('inputs:name', 'token', 0, None, 'The name of the gathered attribute to join', {}, True, '', False, ''), ('outputs:value', 'any', 2, None, 'The gathered attribute values as an array', {}, True, None, False, ''), ]) class ValuesForInputs(og.DynamicAttributeAccess): LOCAL_PROPERTY_NAMES = {"gatherId", "name", "_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.gatherId, self._attributes.name] self._batchedReadValues = [0, ""] @property def gatherId(self): return self._batchedReadValues[0] @gatherId.setter def gatherId(self, value): self._batchedReadValues[0] = value @property def name(self): return self._batchedReadValues[1] @name.setter def name(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 = { } """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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 = OgnGetGatheredAttributeDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetGatheredAttributeDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetGatheredAttributeDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantPoint3fDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantPoint3f Holds a 3-component float constant. """ 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 OgnConstantPoint3fDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantPoint3f Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'point3f', 0, 'Value', 'The constant value', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, [0.0, 0.0, 0.0], 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.value = og.AttributeRole.POSITION 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 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 = { } 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 = OgnConstantPoint3fDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantPoint3fDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantPoint3fDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGraphTargetDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GraphTarget Access the target prim the graph is being executed on. If the graph is executing itself, this will output the prim path of the graph. Otherwise the graph is being executed via instancing, then this will output the prim path of the target instance. """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGraphTargetDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GraphTarget Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.targetPath Outputs: outputs.primPath """ # 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:targetPath', 'token', 0, None, 'Deprecated. Do not use.', {ogn.MetadataKeys.HIDDEN: 'true'}, True, "", False, ''), ('outputs:primPath', 'token', 0, None, 'The target prim path', {}, 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 targetPath(self): data_view = og.AttributeValueHelper(self._attributes.targetPath) return data_view.get() @targetPath.setter def targetPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.targetPath) data_view = og.AttributeValueHelper(self._attributes.targetPath) 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 primPath(self): data_view = og.AttributeValueHelper(self._attributes.primPath) return data_view.get() @primPath.setter def primPath(self, value): data_view = og.AttributeValueHelper(self._attributes.primPath) 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 = OgnGraphTargetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGraphTargetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGraphTargetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnArrayIndexDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ArrayIndex Copies an element of an input array into an output """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnArrayIndexDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ArrayIndex Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.array inputs.index 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:array', 'bool[],colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, 'Array', 'The array to be indexed', {}, True, None, False, ''), ('inputs:index', 'int', 0, 'Index', 'The index into the array, a negative value indexes from the end of the array', {}, True, 0, False, ''), ('outputs:value', 'bool,colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'The value from the 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 array(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.array""" return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, True) @array.setter def array(self, value_to_set: Any): """Assign another attribute's value to outputs.array""" if isinstance(value_to_set, og.RuntimeAttribute): self.array.value = value_to_set.value else: self.array.value = value_to_set @property def index(self): data_view = og.AttributeValueHelper(self._attributes.index) return data_view.get() @index.setter def index(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.index) data_view = og.AttributeValueHelper(self._attributes.index) 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) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 = OgnArrayIndexDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnArrayIndexDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnArrayIndexDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnMoveToTargetDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.MoveToTarget This node smoothly translates, rotates, and scales a prim object to a target prim object given a speed and easing factor. At the end of the maneuver, the source prim will have the translation, rotation, and scale of the target prim. Note: The Prim must have xform:orient in transform stack in order to interpolate rotations """ import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnMoveToTargetDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.MoveToTarget Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.execIn inputs.exponent inputs.sourcePrim inputs.sourcePrimPath inputs.speed inputs.stop inputs.targetPrim inputs.targetPrimPath inputs.useSourcePath inputs.useTargetPath Outputs: outputs.finished """ # 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:execIn', 'execution', 0, 'Execute In', 'The input execution', {}, True, None, False, ''), ('inputs:exponent', 'float', 0, None, 'The blend exponent, which is the degree of the ease curve\n (1 = linear, 2 = quadratic, 3 = cubic, etc). ', {ogn.MetadataKeys.DEFAULT: '2.0'}, True, 2.0, False, ''), ('inputs:sourcePrim', 'target', 0, None, 'The source prim to be transformed', {}, False, [], False, ''), ('inputs:sourcePrimPath', 'path', 0, None, "The source prim to be transformed, used when 'useSourcePath' is true", {}, False, None, False, ''), ('inputs:speed', 'double', 0, None, 'The peak speed of approach (Units / Second)', {ogn.MetadataKeys.DEFAULT: '1.0'}, True, 1.0, False, ''), ('inputs:stop', 'execution', 0, 'Stop', 'Stops the maneuver', {}, True, None, False, ''), ('inputs:targetPrim', 'target', 0, None, "The destination prim. The target's translation, rotation, and scale will be matched by the sourcePrim", {}, False, [], False, ''), ('inputs:targetPrimPath', 'path', 0, None, "The destination prim. The target's translation, rotation, and scale will be matched by the sourcePrim, used when 'useTargetPath' is true", {}, False, None, False, ''), ('inputs:useSourcePath', 'bool', 0, None, "When true, the 'sourcePrimPath' attribute is used, otherwise it will read the connection at the 'sourcePrim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('inputs:useTargetPath', 'bool', 0, None, "When true, the 'targetPrimPath' attribute is used, otherwise it will read the connection at the 'targetPrim' attribute", {ogn.MetadataKeys.DEFAULT: 'false'}, True, False, False, ''), ('outputs:finished', 'execution', 0, 'Finished', 'The output execution, sent one the maneuver is completed', {}, 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.execIn = og.AttributeRole.EXECUTION role_data.inputs.sourcePrim = og.AttributeRole.TARGET role_data.inputs.sourcePrimPath = og.AttributeRole.PATH role_data.inputs.stop = og.AttributeRole.EXECUTION role_data.inputs.targetPrim = og.AttributeRole.TARGET role_data.inputs.targetPrimPath = og.AttributeRole.PATH role_data.outputs.finished = og.AttributeRole.EXECUTION 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 execIn(self): data_view = og.AttributeValueHelper(self._attributes.execIn) return data_view.get() @execIn.setter def execIn(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.execIn) data_view = og.AttributeValueHelper(self._attributes.execIn) data_view.set(value) @property def exponent(self): data_view = og.AttributeValueHelper(self._attributes.exponent) return data_view.get() @exponent.setter def exponent(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.exponent) data_view = og.AttributeValueHelper(self._attributes.exponent) data_view.set(value) @property def sourcePrim(self): data_view = og.AttributeValueHelper(self._attributes.sourcePrim) return data_view.get() @sourcePrim.setter def sourcePrim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.sourcePrim) data_view = og.AttributeValueHelper(self._attributes.sourcePrim) data_view.set(value) self.sourcePrim_size = data_view.get_array_size() @property def sourcePrimPath(self): data_view = og.AttributeValueHelper(self._attributes.sourcePrimPath) return data_view.get() @sourcePrimPath.setter def sourcePrimPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.sourcePrimPath) data_view = og.AttributeValueHelper(self._attributes.sourcePrimPath) data_view.set(value) self.sourcePrimPath_size = data_view.get_array_size() @property def speed(self): data_view = og.AttributeValueHelper(self._attributes.speed) return data_view.get() @speed.setter def speed(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.speed) data_view = og.AttributeValueHelper(self._attributes.speed) data_view.set(value) @property def stop(self): data_view = og.AttributeValueHelper(self._attributes.stop) return data_view.get() @stop.setter def stop(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.stop) data_view = og.AttributeValueHelper(self._attributes.stop) data_view.set(value) @property def targetPrim(self): data_view = og.AttributeValueHelper(self._attributes.targetPrim) return data_view.get() @targetPrim.setter def targetPrim(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.targetPrim) data_view = og.AttributeValueHelper(self._attributes.targetPrim) data_view.set(value) self.targetPrim_size = data_view.get_array_size() @property def targetPrimPath(self): data_view = og.AttributeValueHelper(self._attributes.targetPrimPath) return data_view.get() @targetPrimPath.setter def targetPrimPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.targetPrimPath) data_view = og.AttributeValueHelper(self._attributes.targetPrimPath) data_view.set(value) self.targetPrimPath_size = data_view.get_array_size() @property def useSourcePath(self): data_view = og.AttributeValueHelper(self._attributes.useSourcePath) return data_view.get() @useSourcePath.setter def useSourcePath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useSourcePath) data_view = og.AttributeValueHelper(self._attributes.useSourcePath) data_view.set(value) @property def useTargetPath(self): data_view = og.AttributeValueHelper(self._attributes.useTargetPath) return data_view.get() @useTargetPath.setter def useTargetPath(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.useTargetPath) data_view = og.AttributeValueHelper(self._attributes.useTargetPath) 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 finished(self): data_view = og.AttributeValueHelper(self._attributes.finished) return data_view.get() @finished.setter def finished(self, value): data_view = og.AttributeValueHelper(self._attributes.finished) 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 = OgnMoveToTargetDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnMoveToTargetDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnMoveToTargetDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnATan2Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ATan2 Outputs the arc tangent of a/b in degrees """ from typing import Any 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 OgnATan2Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ATan2 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', 'double,float,half,timecode', 1, None, 'Input A', {}, True, None, False, ''), ('inputs:b', 'double,float,half,timecode', 1, None, 'Input B', {}, True, None, False, ''), ('outputs:result', 'double,float,half,timecode', 1, 'Result', 'The result of ATan2(A,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) -> 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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnATan2Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnATan2Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnATan2Database.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(OgnATan2Database.NODE_TYPE_CLASS, 'get_node_type', None) if callable(get_node_type_function): return get_node_type_function() return 'omni.graph.nodes.ATan2' @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.result.type.base_type == og.BaseDataType.UNKNOWN: db.log_warning('Required extended attribute outputs:result is not resolved, compute skipped') return False return True try: per_node_data = OgnATan2Database.PER_NODE_DATA[node.node_id()] db = per_node_data.get('_db') if db is None: db = OgnATan2Database(node) per_node_data['_db'] = db if not database_valid(): per_node_data['_db'] = None return False except: db = OgnATan2Database(node) try: compute_function = getattr(OgnATan2Database.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 OgnATan2Database.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): OgnATan2Database._initialize_per_node_data(node) initialize_function = getattr(OgnATan2Database.NODE_TYPE_CLASS, 'initialize', None) if callable(initialize_function): initialize_function(context, node) per_node_data = OgnATan2Database.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(OgnATan2Database.NODE_TYPE_CLASS, 'release', None) if callable(release_function): release_function(node) OgnATan2Database._release_per_node_data(node) @staticmethod def release_instance(node, target): OgnATan2Database._release_per_node_instance_data(node, target) @staticmethod def update_node_version(context, node, old_version, new_version): update_node_version_function = getattr(OgnATan2Database.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(OgnATan2Database.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.nodes") node_type.set_metadata(ogn.MetadataKeys.UI_NAME, "Atan2") node_type.set_metadata(ogn.MetadataKeys.CATEGORIES, "math:operator") node_type.set_metadata(ogn.MetadataKeys.DESCRIPTION, "Outputs the arc tangent of a/b in degrees") node_type.set_metadata(ogn.MetadataKeys.LANGUAGE, "Python") OgnATan2Database.INTERFACE.add_to_node_type(node_type) @staticmethod def on_connection_type_resolve(node): on_connection_type_resolve_function = getattr(OgnATan2Database.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): OgnATan2Database.NODE_TYPE_CLASS = node_type_class og.register_node_type(OgnATan2Database.abi, 1) @staticmethod def deregister(): og.deregister_node_type("omni.graph.nodes.ATan2")
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnClampDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Clamp Clamp a number or array of numbers to a specified range. If an array of numbers is provided as the input and lower/upper are scalers Then each input numeric will be clamped to the range [lower, upper] If all inputs are arrays, clamping will be done element-wise. lower & upper are broadcast against input Error will be reported if lower > upper. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnClampDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Clamp Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.input inputs.lower inputs.upper 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:input', '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, 'Input', 'The input numerics to clamp', {}, True, None, False, ''), ('inputs:lower', '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, 'Lower', 'Lower bound of the clamp', {}, True, None, False, ''), ('inputs:upper', '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, 'Upper', 'Upper bound of the clamp', {}, True, None, False, ''), ('outputs:result', '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, 'Output', 'The resulting clamped output', {}, 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 input(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.input""" return og.RuntimeAttribute(self._attributes.input.get_attribute_data(), self._context, True) @input.setter def input(self, value_to_set: Any): """Assign another attribute's value to outputs.input""" if isinstance(value_to_set, og.RuntimeAttribute): self.input.value = value_to_set.value else: self.input.value = value_to_set @property def lower(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.lower""" return og.RuntimeAttribute(self._attributes.lower.get_attribute_data(), self._context, True) @lower.setter def lower(self, value_to_set: Any): """Assign another attribute's value to outputs.lower""" if isinstance(value_to_set, og.RuntimeAttribute): self.lower.value = value_to_set.value else: self.lower.value = value_to_set @property def upper(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.upper""" return og.RuntimeAttribute(self._attributes.upper.get_attribute_data(), self._context, True) @upper.setter def upper(self, value_to_set: Any): """Assign another attribute's value to outputs.upper""" if isinstance(value_to_set, og.RuntimeAttribute): self.upper.value = value_to_set.value else: self.upper.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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnClampDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnClampDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnClampDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetPrimPathsDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetPrimPaths Generates a path array from the specified relationship. This is useful when absolute prim paths may change. """ import numpy import usdrt import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetPrimPathsDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetPrimPaths Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.prims Outputs: outputs.primPaths """ # 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:prims', 'target', 0, None, 'Relationship to prims on the stage', {ogn.MetadataKeys.ALLOW_MULTI_INPUTS: '1'}, True, [], False, ''), ('outputs:primPaths', 'token[]', 0, None, 'The absolute paths of the given prims as a token 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.inputs.prims = og.AttributeRole.TARGET 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 prims(self): data_view = og.AttributeValueHelper(self._attributes.prims) return data_view.get() @prims.setter def prims(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.prims) data_view = og.AttributeValueHelper(self._attributes.prims) data_view.set(value) self.prims_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.primPaths_size = None self._batchedWriteValues = { } @property def primPaths(self): data_view = og.AttributeValueHelper(self._attributes.primPaths) return data_view.get(reserved_element_count=self.primPaths_size) @primPaths.setter def primPaths(self, value): data_view = og.AttributeValueHelper(self._attributes.primPaths) data_view.set(value) self.primPaths_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 = OgnGetPrimPathsDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetPrimPathsDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetPrimPathsDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnConstantStringDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ConstantString Holds a string constant value """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnConstantStringDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ConstantString Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.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', 'string', 0, 'Value', 'The constant value', {ogn.MetadataKeys.OUTPUT_ONLY: '1'}, True, "", 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.value = 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 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) self.value_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._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 = OgnConstantStringDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnConstantStringDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnConstantStringDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGpuInteropCudaEntryDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GpuInteropCudaEntry Entry point for Cuda RTX Renderer Postprocessing """ import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGpuInteropCudaEntryDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GpuInteropCudaEntry Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.sourceName Outputs: outputs.bufferSize outputs.cudaMipmappedArray outputs.externalTimeOfSimFrame outputs.format outputs.frameId outputs.height outputs.hydraTime outputs.isBuffer outputs.mipCount outputs.simTime outputs.stream outputs.width """ # 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:sourceName', 'string', 0, None, 'Source name of the AOV', {ogn.MetadataKeys.DEFAULT: '"ldrColor"'}, True, "ldrColor", False, ''), ('outputs:bufferSize', 'uint', 0, 'bufferSize', 'Size of the buffer', {}, True, None, False, ''), ('outputs:cudaMipmappedArray', 'uint64', 0, 'cudaMipmappedArray', 'Pointer to the CUDA Mipmapped Array', {}, True, None, False, ''), ('outputs:externalTimeOfSimFrame', 'int64', 0, 'externalTimeOfSimFrame', 'The external time on the master node, matching the simulation frame used to render this frame', {}, True, None, False, ''), ('outputs:format', 'uint64', 0, 'format', 'Format', {}, True, None, False, ''), ('outputs:frameId', 'int64', 0, 'frameId', 'Frame identifier', {}, True, None, False, ''), ('outputs:height', 'uint', 0, 'height', 'Height', {}, True, None, False, ''), ('outputs:hydraTime', 'double', 0, 'hydraTime', 'Hydra time in stage', {}, True, None, False, ''), ('outputs:isBuffer', 'bool', 0, 'isBuffer', 'True if the entry exposes a buffer as opposed to a texture', {}, True, None, False, ''), ('outputs:mipCount', 'uint', 0, 'mipCount', 'Mip Count', {}, True, None, False, ''), ('outputs:simTime', 'double', 0, 'simTime', 'Simulation time', {}, True, None, False, ''), ('outputs:stream', 'uint64', 0, 'stream', 'Pointer to the CUDA Stream', {}, True, None, False, ''), ('outputs:width', 'uint', 0, 'width', 'Width', {}, 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.sourceName = 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 sourceName(self): data_view = og.AttributeValueHelper(self._attributes.sourceName) return data_view.get() @sourceName.setter def sourceName(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.sourceName) data_view = og.AttributeValueHelper(self._attributes.sourceName) data_view.set(value) self.sourceName_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._batchedWriteValues = { } @property def bufferSize(self): data_view = og.AttributeValueHelper(self._attributes.bufferSize) return data_view.get() @bufferSize.setter def bufferSize(self, value): data_view = og.AttributeValueHelper(self._attributes.bufferSize) data_view.set(value) @property def cudaMipmappedArray(self): data_view = og.AttributeValueHelper(self._attributes.cudaMipmappedArray) return data_view.get() @cudaMipmappedArray.setter def cudaMipmappedArray(self, value): data_view = og.AttributeValueHelper(self._attributes.cudaMipmappedArray) data_view.set(value) @property def externalTimeOfSimFrame(self): data_view = og.AttributeValueHelper(self._attributes.externalTimeOfSimFrame) return data_view.get() @externalTimeOfSimFrame.setter def externalTimeOfSimFrame(self, value): data_view = og.AttributeValueHelper(self._attributes.externalTimeOfSimFrame) data_view.set(value) @property def format(self): data_view = og.AttributeValueHelper(self._attributes.format) return data_view.get() @format.setter def format(self, value): data_view = og.AttributeValueHelper(self._attributes.format) data_view.set(value) @property def frameId(self): data_view = og.AttributeValueHelper(self._attributes.frameId) return data_view.get() @frameId.setter def frameId(self, value): data_view = og.AttributeValueHelper(self._attributes.frameId) data_view.set(value) @property def height(self): data_view = og.AttributeValueHelper(self._attributes.height) return data_view.get() @height.setter def height(self, value): data_view = og.AttributeValueHelper(self._attributes.height) data_view.set(value) @property def hydraTime(self): data_view = og.AttributeValueHelper(self._attributes.hydraTime) return data_view.get() @hydraTime.setter def hydraTime(self, value): data_view = og.AttributeValueHelper(self._attributes.hydraTime) data_view.set(value) @property def isBuffer(self): data_view = og.AttributeValueHelper(self._attributes.isBuffer) return data_view.get() @isBuffer.setter def isBuffer(self, value): data_view = og.AttributeValueHelper(self._attributes.isBuffer) data_view.set(value) @property def mipCount(self): data_view = og.AttributeValueHelper(self._attributes.mipCount) return data_view.get() @mipCount.setter def mipCount(self, value): data_view = og.AttributeValueHelper(self._attributes.mipCount) data_view.set(value) @property def simTime(self): data_view = og.AttributeValueHelper(self._attributes.simTime) return data_view.get() @simTime.setter def simTime(self, value): data_view = og.AttributeValueHelper(self._attributes.simTime) data_view.set(value) @property def stream(self): data_view = og.AttributeValueHelper(self._attributes.stream) return data_view.get() @stream.setter def stream(self, value): data_view = og.AttributeValueHelper(self._attributes.stream) data_view.set(value) @property def width(self): data_view = og.AttributeValueHelper(self._attributes.width) return data_view.get() @width.setter def width(self, value): data_view = og.AttributeValueHelper(self._attributes.width) 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 = OgnGpuInteropCudaEntryDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGpuInteropCudaEntryDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGpuInteropCudaEntryDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnBreakVector4Database.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.BreakVector4 Split vector into 4 component values. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnBreakVector4Database(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.BreakVector4 Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.tuple Outputs: outputs.w outputs.x outputs.y outputs.z """ # 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:tuple', 'double[4],float[4],half[4],int[4]', 1, 'Vector', '4-vector to be broken', {}, True, None, False, ''), ('outputs:w', 'double,float,half,int', 1, 'W', 'The fourth component of the vector', {}, True, None, False, ''), ('outputs:x', 'double,float,half,int', 1, 'X', 'The first component of the vector', {}, True, None, False, ''), ('outputs:y', 'double,float,half,int', 1, 'Y', 'The second component of the vector', {}, True, None, False, ''), ('outputs:z', 'double,float,half,int', 1, 'Z', 'The third component of the vector', {}, 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 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 w(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.w""" return og.RuntimeAttribute(self._attributes.w.get_attribute_data(), self._context, False) @w.setter def w(self, value_to_set: Any): """Assign another attribute's value to outputs.w""" if isinstance(value_to_set, og.RuntimeAttribute): self.w.value = value_to_set.value else: self.w.value = value_to_set @property def x(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.x""" return og.RuntimeAttribute(self._attributes.x.get_attribute_data(), self._context, False) @x.setter def x(self, value_to_set: Any): """Assign another attribute's value to outputs.x""" if isinstance(value_to_set, og.RuntimeAttribute): self.x.value = value_to_set.value else: self.x.value = value_to_set @property def y(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.y""" return og.RuntimeAttribute(self._attributes.y.get_attribute_data(), self._context, False) @y.setter def y(self, value_to_set: Any): """Assign another attribute's value to outputs.y""" if isinstance(value_to_set, og.RuntimeAttribute): self.y.value = value_to_set.value else: self.y.value = value_to_set @property def z(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.z""" return og.RuntimeAttribute(self._attributes.z.get_attribute_data(), self._context, False) @z.setter def z(self, value_to_set: Any): """Assign another attribute's value to outputs.z""" if isinstance(value_to_set, og.RuntimeAttribute): self.z.value = value_to_set.value else: self.z.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 = OgnBreakVector4Database.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnBreakVector4Database.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnBreakVector4Database.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnModuloDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.Modulo Computes the modulo of integer inputs (A % B), which is the remainder of A / B If B is zero, the result is zero. If A and B are both non-negative the result is non-negative, otherwise the sign of the result is undefined. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnModuloDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.Modulo 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', 'int,int64,uchar,uint,uint64', 1, 'A', 'The dividend of (A % B)', {}, True, None, False, ''), ('inputs:b', 'int,int64,uchar,uint,uint64', 1, 'B', 'The divisor of (A % B)', {}, True, None, False, ''), ('outputs:result', 'int,int64,uchar,uint,uint64', 1, 'Result', 'Modulo (A % B), the remainder of A / 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) -> 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 result(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.result""" return og.RuntimeAttribute(self._attributes.result.get_attribute_data(), self._context, False) @result.setter def result(self, value_to_set: Any): """Assign another attribute's value to outputs.result""" if isinstance(value_to_set, og.RuntimeAttribute): self.result.value = value_to_set.value else: self.result.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 = OgnModuloDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnModuloDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnModuloDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnGetRelativePathDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.GetRelativePath Generates a path token relative to anchor from path.(ex. (/World, /World/Cube) -> /Cube) """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnGetRelativePathDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.GetRelativePath Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.anchor inputs.path Outputs: outputs.relativePath State: state.anchor state.path """ # 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:anchor', 'token', 0, None, 'Path token to compute relative to (ex. /World)', {}, True, "", False, ''), ('inputs:path', 'token,token[]', 1, None, 'Path token to convert to a relative path (ex. /World/Cube)', {}, True, None, False, ''), ('outputs:relativePath', 'token,token[]', 1, None, 'Relative path token (ex. /Cube)', {}, True, None, False, ''), ('state:anchor', 'token', 0, None, 'Snapshot of previously seen rootPath', {}, True, None, False, ''), ('state:path', 'token', 0, None, 'Snapshot of previously seen path', {}, 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 anchor(self): data_view = og.AttributeValueHelper(self._attributes.anchor) return data_view.get() @anchor.setter def anchor(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.anchor) data_view = og.AttributeValueHelper(self._attributes.anchor) data_view.set(value) @property def path(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.path""" return og.RuntimeAttribute(self._attributes.path.get_attribute_data(), self._context, True) @path.setter def path(self, value_to_set: Any): """Assign another attribute's value to outputs.path""" if isinstance(value_to_set, og.RuntimeAttribute): self.path.value = value_to_set.value else: self.path.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 relativePath(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.relativePath""" return og.RuntimeAttribute(self._attributes.relativePath.get_attribute_data(), self._context, False) @relativePath.setter def relativePath(self, value_to_set: Any): """Assign another attribute's value to outputs.relativePath""" if isinstance(value_to_set, og.RuntimeAttribute): self.relativePath.value = value_to_set.value else: self.relativePath.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) @property def anchor(self): data_view = og.AttributeValueHelper(self._attributes.anchor) return data_view.get() @anchor.setter def anchor(self, value): data_view = og.AttributeValueHelper(self._attributes.anchor) data_view.set(value) @property def path(self): data_view = og.AttributeValueHelper(self._attributes.path) return data_view.get() @path.setter def path(self, value): data_view = og.AttributeValueHelper(self._attributes.path) 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 = OgnGetRelativePathDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnGetRelativePathDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnGetRelativePathDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnAppendStringDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.AppendString Creates a new token or string by appending the given token or string. token[] inputs will be appended element-wise. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnAppendStringDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.AppendString Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.suffix 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:suffix', 'string,token,token[]', 1, None, 'The string to be appended', {}, True, None, False, ''), ('inputs:value', 'string,token,token[]', 1, None, 'The string(s) to be appended to', {}, True, None, False, ''), ('outputs:value', 'string,token,token[]', 1, None, 'The new string(s)', {}, 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 suffix(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.suffix""" return og.RuntimeAttribute(self._attributes.suffix.get_attribute_data(), self._context, True) @suffix.setter def suffix(self, value_to_set: Any): """Assign another attribute's value to outputs.suffix""" if isinstance(value_to_set, og.RuntimeAttribute): self.suffix.value = value_to_set.value else: self.suffix.value = value_to_set @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, False) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 = OgnAppendStringDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnAppendStringDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnAppendStringDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/OgnArrayInsertValueDatabase.py
"""Support for simplified access to data on nodes of type omni.graph.nodes.ArrayInsertValue Inserts an element at the given index. The indexing is zero-based, so 0 adds an element to the front of the array and index = Length inserts at the end of the array. The index will be clamped to the range (0, Length), so an index of -1 will add to the front, and an index larger than the array size will append to the end. """ from typing import Any import omni.graph.core as og import omni.graph.core._omni_graph_core as _og import omni.graph.tools.ogn as ogn class OgnArrayInsertValueDatabase(og.Database): """Helper class providing simplified access to data on nodes of type omni.graph.nodes.ArrayInsertValue Class Members: node: Node being evaluated Attribute Value Properties: Inputs: inputs.array inputs.index inputs.value Outputs: outputs.array """ # 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:array', 'bool[],colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, 'Array', 'The array to be modified', {}, True, None, False, ''), ('inputs:index', 'int', 0, 'Index', 'The array index to insert the value, which is clamped to the valid range', {}, True, 0, False, ''), ('inputs:value', 'bool,colord[3],colord[4],colorf[3],colorf[4],colorh[3],colorh[4],double,double[2],double[3],double[4],float,float[2],float[3],float[4],frame[4],half,half[2],half[3],half[4],int,int64,int[2],int[3],int[4],matrixd[3],matrixd[4],normald[3],normalf[3],normalh[3],pointd[3],pointf[3],pointh[3],quatd[4],quatf[4],quath[4],texcoordd[2],texcoordd[3],texcoordf[2],texcoordf[3],texcoordh[2],texcoordh[3],timecode,token,transform[4],uchar,uint,uint64,vectord[3],vectorf[3],vectorh[3]', 1, None, 'The value to be inserted', {}, True, None, False, ''), ('outputs:array', 'bool[],colord[3][],colord[4][],colorf[3][],colorf[4][],colorh[3][],colorh[4][],double[2][],double[3][],double[4][],double[],float[2][],float[3][],float[4][],float[],frame[4][],half[2][],half[3][],half[4][],half[],int64[],int[2][],int[3][],int[4][],int[],matrixd[3][],matrixd[4][],normald[3][],normalf[3][],normalh[3][],pointd[3][],pointf[3][],pointh[3][],quatd[4][],quatf[4][],quath[4][],texcoordd[2][],texcoordd[3][],texcoordf[2][],texcoordf[3][],texcoordh[2][],texcoordh[3][],timecode[],token[],transform[4][],uchar[],uint64[],uint[],vectord[3][],vectorf[3][],vectorh[3][]', 1, 'Array', 'The modified 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 array(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.array""" return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, True) @array.setter def array(self, value_to_set: Any): """Assign another attribute's value to outputs.array""" if isinstance(value_to_set, og.RuntimeAttribute): self.array.value = value_to_set.value else: self.array.value = value_to_set @property def index(self): data_view = og.AttributeValueHelper(self._attributes.index) return data_view.get() @index.setter def index(self, value): if self._setting_locked: raise og.ReadOnlyError(self._attributes.index) data_view = og.AttributeValueHelper(self._attributes.index) data_view.set(value) @property def value(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute inputs.value""" return og.RuntimeAttribute(self._attributes.value.get_attribute_data(), self._context, True) @value.setter def value(self, value_to_set: Any): """Assign another attribute's value to outputs.value""" if isinstance(value_to_set, og.RuntimeAttribute): self.value.value = value_to_set.value else: self.value.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 array(self) -> og.RuntimeAttribute: """Get the runtime wrapper class for the attribute outputs.array""" return og.RuntimeAttribute(self._attributes.array.get_attribute_data(), self._context, False) @array.setter def array(self, value_to_set: Any): """Assign another attribute's value to outputs.array""" if isinstance(value_to_set, og.RuntimeAttribute): self.array.value = value_to_set.value else: self.array.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 = OgnArrayInsertValueDatabase.ValuesForInputs(node, self.attributes.inputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_OUTPUT) self.outputs = OgnArrayInsertValueDatabase.ValuesForOutputs(node, self.attributes.outputs, dynamic_attributes) dynamic_attributes = self.dynamic_attribute_data(node, og.AttributePortType.ATTRIBUTE_PORT_TYPE_STATE) self.state = OgnArrayInsertValueDatabase.ValuesForState(node, self.attributes.state, dynamic_attributes)
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnGetLookAtRotation.cpp
// Copyright (c) 2021-2022, 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. // // clang-format off #include "UsdPCH.h" // clang-format on #include <omni/graph/core/PreUsdInclude.h> #include <pxr/base/gf/rotation.h> #include <omni/graph/core/PostUsdInclude.h> #include <omni/math/linalg/SafeCast.h> #include <omni/math/linalg/vec.h> #include <OgnGetLookAtRotationDatabase.h> namespace omni { namespace graph { namespace action { class OgnGetLookAtRotation { pxr::TfToken m_upAxisToken; static omni::math::linalg::vec3d getSceneUp(OgnGetLookAtRotationDatabase& db) { // Default to the Y-axis if anything goes wrong. omni::math::linalg::vec3d up = omni::math::linalg::vec3d::YAxis(); long stageId = db.abi_context().iContext->getStageId(db.abi_context()); auto stage = pxr::UsdUtilsStageCache::Get().Find(pxr::UsdStageCache::Id::FromLongInt(stageId)); if (stage) { auto& state = db.internalState<OgnGetLookAtRotation>(); pxr::VtValue value; if (stage->GetMetadata(state.m_upAxisToken, &value)) { std::string upAxisStr = value.Cast<std::string>().Get<std::string>(); if ((upAxisStr == "X") || (upAxisStr == "x")) { up = omni::math::linalg::vec3d::XAxis(); } else if ((upAxisStr == "Z") || (upAxisStr == "z")) { up = omni::math::linalg::vec3d::ZAxis(); } } } return up; } public: OgnGetLookAtRotation() { // Cache the token. m_upAxisToken = pxr::TfToken("upAxis"); } static bool compute(OgnGetLookAtRotationDatabase& db) { auto const start = db.inputs.start(); auto const target = db.inputs.target(); auto const forward = db.inputs.forward(); auto up = db.inputs.up(); // If 'up' is zero, use the scene's up. if (up.GetLengthSq() == 0.0) { up = getSceneUp(db); } omni::math::linalg::vec3d const aimVec = target - start; omni::math::linalg::vec3d const eyeU = aimVec.GetNormalized(); omni::math::linalg::vec3d eyeV = up.GetNormalized(); omni::math::linalg::vec3d const eyeW = (eyeU ^ eyeV).GetNormalized(); // eyeW and eyeU are orthogonal unit vectors so eyeV will be one as well. eyeV = eyeW ^ eyeU; auto localMtx = omni::math::linalg::matrix4d().SetIdentity(); omni::math::linalg::vec3d const eyeUL = forward.GetNormalized(); omni::math::linalg::vec3d eyeVL = up.GetNormalized(); omni::math::linalg::vec3d const eyeWL = (eyeUL ^ eyeVL).GetNormalized(); // eyeWL and eyeUL are orthogonal unit vectors so eyeVL will be one as well. eyeVL = eyeWL ^ eyeUL; localMtx.SetRow3(0, eyeUL); localMtx.SetRow3(1, eyeVL); localMtx.SetRow3(2, eyeWL); // The actual aiming vectors auto newEyeMtx = omni::math::linalg::matrix4d().SetIdentity(); newEyeMtx.SetRow3(0, eyeU); newEyeMtx.SetRow3(1, eyeV); newEyeMtx.SetRow3(2, eyeW); // Output omni::math::linalg::matrix4d aimMtx = localMtx.GetInverse() * newEyeMtx; aimMtx.SetRow3(3, start); omni::math::linalg::quatd orientation = aimMtx.ExtractRotation(); pxr::GfRotation rotation(omni::math::linalg::safeCastToUSD(orientation)); // extract the world space euler angles pxr::GfVec3d decomposed = rotation.Decompose(pxr::GfVec3d::ZAxis(), pxr::GfVec3d::YAxis(), pxr::GfVec3d::XAxis()); pxr::GfVec3d rotateXYZ(decomposed[2], decomposed[1], decomposed[0]); db.outputs.rotateXYZ() = omni::math::linalg::safeCastToOmni(rotateXYZ); db.outputs.orientation() = orientation; return true; } }; REGISTER_OGN_NODE() } // action } // graph } // omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnInvertMatrix.ogn
{ "OgnInvertMatrix": { "version": 1, "description": "Invert a matrix or an array of matrices. Returns the FLOAT_MAX * identity if the matrix is singular", "uiName": "Invert Matrix", "categories": ["math:operator"], "scheduling": ["threadsafe"], "inputs": { "matrix": { "type": ["matrixd[3]", "matrixd[4]", "matrixd[3][]", "matrixd[4][]"], "description": "The input matrix or matrices to invert" } }, "outputs": { "invertedMatrix": { "type": ["matrixd[3]", "matrixd[4]", "matrixd[3][]", "matrixd[4][]"], "description": "the resulting inverted matrix or matrices" } }, "tests": [ { "inputs:matrix": {"type": "matrixd[3]", "value": [1,0,0, 0,1,0, 0,0,1]}, "outputs:invertedMatrix": {"type": "matrixd[3]", "value": [1,0,0, 0,1,0, 0,0,1]} }, { "inputs:matrix": {"type": "matrixd[4][]", "value": [[1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1], [5,6,6,8, 2,2,2,8, 6,6,2,8, 2,3,6,7], [1,2,3,4, 5,6,7,8, 9,10,11,12, 13,14,15,16]]}, "outputs:invertedMatrix": {"type": "matrixd[4][]", "value": [[1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1], [-17,-9,12,16, 17,8.75,-11.75,-16, -4,-2.25,2.75,4, 1,0.75,-0.75,-1], [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnRound.ogn
{ "Round": { "version": 1, "description": "Round a decimal input to the given number of decimals. Accepts float, double, half, or arrays / tuples of the aformentioned types", "uiName": "Round", "categories": ["math:operator"], "scheduling": ["threadsafe"], "inputs": { "input": { "type": ["decimals"], "description": "The input data to round", "uiName": "Input" }, "decimals": { "type": "int", "description": "The number of decimal places to round to. Negative numbers specify the number of positions left of the decimal", "uiName": "Decimals" } }, "outputs": { "output": { "type": ["decimals"], "description": "The resultant rounded numbers", "uiName": "Output" } }, "tests": [ {"inputs:input": {"type": "float", "value": 1.3}, "inputs:decimals": 0, "outputs:output": {"type": "float", "value": 1}}, {"inputs:input": {"type": "double", "value": 1.3}, "inputs:decimals": 0, "outputs:output": {"type": "double", "value": 1}}, {"inputs:input": {"type": "half", "value": 1.3}, "inputs:decimals": 0, "outputs:output": {"type": "half", "value": 1}}, {"inputs:input": {"type": "float[2]", "value": [-3.5352, 4.341]}, "inputs:decimals": 2, "outputs:output": {"type": "float[2]", "value": [-3.54, 4.34]}}, {"inputs:input": {"type": "double[3]", "value": [-3.5352, 4.341, -3.5352]}, "inputs:decimals": 2, "outputs:output": {"type": "double[3]", "value": [-3.54, 4.34, -3.54]}}, {"inputs:input": {"type": "half[4]", "value": [-3.5352, 4.341, -3.5352, 4.341]}, "inputs:decimals": 2, "outputs:output": {"type": "half[4]", "value": [-3.5390625, 4.3398438, -3.5390625, 4.3398438]}}, {"inputs:input": {"type": "double[]", "value": [132, 22221.2, 5.531]}, "inputs:decimals": -1, "outputs:output": {"type": "double[]", "value": [130, 22220, 10]}}, {"inputs:input": {"type": "float[]", "value": [132]}, "inputs:decimals": -1, "outputs:output": {"type": "float[]", "value": [130]}}, {"inputs:input": {"type": "half[2][]", "value": [[132, 22221.2], [5.531, 132]]}, "inputs:decimals": -1, "outputs:output": {"type": "half[2][]", "value": [[1.3000e+02, 2.2224e+04], [1.0000e+01, 1.3000e+02]]}} ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnEachZero.ogn
{ "EachZero": { "version": 1, "description": [ "Outputs a boolean, or array of booleans, indicating which input values are zero within a specified tolerance." ], "uiName": "Each Zero", "categories": ["math:condition"], "scheduling": ["threadsafe"], "inputs": { "value": { "type": ["numerics"], "description": "Value(s) to check for zero.", "uiName": "Value" }, "tolerance": { "type": "double", "description": [ "How close the value must be to 0 to be considered \"zero\"." ], "uiName": "Tolerance", "minimum": 0.0 } }, "outputs": { "result": { "type": ["bool", "bool[]"], "description": [ "If 'value' is a scalar then 'result' will be a boolean set to true if 'value' is zero. If 'value' is non-scalar", "(array, tuple, matrix, etc) then 'result' will be an array of booleans, one for each element/component of the", "input. If those elements are themselves non-scalar (e.g. an array of vectors) they will be considered zero only if", "all of the sub-elements are zero. For example, if 'value' is [3, 0, 1] then 'result' will be [true, false, true]", "because the second element is zero. But if 'value' is [[3, 0, 1], [-5, 4, 17]] then 'result' will", "be [false, false] because neither of the two vectors is fully zero." ], "uiName": "Result" } }, "tests" : [ { "inputs:value": {"type": "int", "value": 6}, "outputs:result": false }, { "inputs:value": {"type": "int", "value": -3}, "outputs:result": false }, { "inputs:value": {"type": "int", "value": 0}, "outputs:result": true }, { "inputs:value": {"type": "float", "value": 42.5}, "outputs:result": false }, { "inputs:value": {"type": "float", "value": -7.1}, "outputs:result": false }, { "inputs:value": {"type": "float", "value": 0.0}, "outputs:result": true }, { "inputs:value": {"type": "float", "value": 0.01}, "outputs:result": false }, { "inputs:value": {"type": "float", "value": -0.01}, "outputs:result": false }, { "inputs:value": {"type": "float", "value": 42.5}, "inputs:tolerance": 0.1, "outputs:result": false }, { "inputs:value": {"type": "float", "value": -7.1}, "inputs:tolerance": 0.1, "outputs:result": false }, { "inputs:value": {"type": "float", "value": 0.0}, "inputs:tolerance": 0.1, "outputs:result": true }, { "inputs:value": {"type": "float", "value": 0.01}, "inputs:tolerance": 0.1, "outputs:result": true }, { "inputs:value": {"type": "float", "value": -0.01}, "inputs:tolerance": 0.1, "outputs:result": true }, { "inputs:value": {"type": "int", "value": 6}, "inputs:tolerance": 0.1, "outputs:result": false }, { "inputs:value": {"type": "int", "value": -3}, "inputs:tolerance": 0.1, "outputs:result": false }, { "inputs:value": {"type": "int", "value": 0}, "inputs:tolerance": 0.1, "outputs:result": true }, { "inputs:value": {"type": "int", "value": 6}, "inputs:tolerance": 10.0, "outputs:result": true }, { "inputs:value": {"type": "int", "value": -3}, "inputs:tolerance": 10.0, "outputs:result": true }, { "inputs:value": {"type": "int", "value": 0}, "inputs:tolerance": 10.0, "outputs:result": true }, { "inputs:value": {"type": "int[2]", "value": [ 0, 0 ]}, "outputs:result": [true, true] }, { "inputs:value": {"type": "int[2]", "value": [ 0, 3 ]}, "outputs:result": [true, false] }, { "inputs:value": {"type": "int[2]", "value": [ 3, 0 ]}, "outputs:result": [false, true] }, { "inputs:value": {"type": "int[2]", "value": [ 3, 5 ]}, "outputs:result": [false, false] }, { "inputs:value": {"type": "float[3]", "value": [1.7, 0.05, -4.3]}, "inputs:tolerance": 0.1, "outputs:result": [false, true, false] }, { "inputs:value": {"type": "float[3][]", "value": [ [1.7, 0.05, -4.3], [0.0, -0.1, 0.3] ]}, "inputs:tolerance": 0.1, "outputs:result": [false, false] }, { "inputs:value": {"type": "float[3][]", "value": [ [1.7, 0.05, -4.3], [0.0, -0.1, 0.3] ]}, "inputs:tolerance": 0.5, "outputs:result": [false, true] } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnConcatenateFloat3Arrays.ogn
{ "ConcatenateFloat3Arrays": { "$note": "This is a placeholder for the concatenate node, until gathers are supported", "version": 1, "exclude": ["tests"], "description": ["Flatten the array of float3 arrays in 'inputArrays' by concatenating all of the array ", "contents into a single float3 array in 'outputArray'. The sizes of each of the input ", "arrays is preserved in the output 'arraySizes'." ], "metadata" : { "uiName": "Concatenate Arrays Of Arrays" }, "categories": ["math:array"], "inputs": { "inputArrays": { "description": "Array of arrays of float3 values to be flattened", "$unsupported-type": "float[3][][]", "type": "any" } }, "outputs": { "outputArray": { "description": "Flattened array of float3 values", "type": "float[3][]" }, "arraySizes": { "description": "List of sizes of each of the float3 input arrays", "type": "int[]" } }, "$tests": [ { "inputs:inputArrays": [[[0.0,0.0,0.0], [1.0,1.0,1.0]], [[2.0,2.0,2.0], [3.0,3.0,3.0]]], "outputs:outputArray": [[0.0,0.0,0.0], [1.0,1.0,1.0], [2.0,2.0,2.0], [3.0,3.0,3.0]], "outputs:arraySizes": [2, 2] } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnDivide.ogn
{ "Divide": { "version": 1, "description": [ "Computes the division of two values: A / B. The result is the same type as the numerator if the numerator", "is a decimal type. Otherwise the result is a double. Vectors can be divided only by a scaler, the result", "being a vector in the same direction with a scaled length. Note that there are combinations of inputs that", "can result in a loss of precision due to different value ranges. Division by zero is an error." ], "uiName": "Divide", "categories": ["math:operator"], "scheduling": ["threadsafe"], "inputs": { "a": { "type": ["numerics"], "description": "The numerator A", "uiName": "A" }, "b": { "type": ["numerics"], "description": "The denominator B", "uiName": "B" } }, "outputs": { "result": { "type": ["numerics"], "description": "Result of division", "uiName": "Result" } }, "tests" : [ { "inputs:a": {"type": "double", "value": 42.0}, "inputs:b": {"type": "double", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "double", "value": 42.0}, "inputs:b": {"type": "float", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "double", "value": 42.0}, "inputs:b": {"type": "half", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "float", "value": 42.0}, "inputs:b": {"type": "double", "value": 2.0}, "outputs:result": {"type": "float", "value": 21.0} }, { "inputs:a": {"type": "float", "value": 42.0}, "inputs:b": {"type": "float", "value": 2.0}, "outputs:result": {"type": "float", "value": 21.0} }, { "inputs:a": {"type": "float", "value": 42.0}, "inputs:b": {"type": "half", "value": 2.0}, "outputs:result": {"type": "float", "value": 21.0} }, { "inputs:a": {"type": "half", "value": 42.0}, "inputs:b": {"type": "double", "value": 2.0}, "outputs:result": {"type": "half", "value": 21.0} }, { "inputs:a": {"type": "half", "value": 42.0}, "inputs:b": {"type": "float", "value": 2.0}, "outputs:result": {"type": "half", "value": 21.0} }, { "inputs:a": {"type": "half", "value": 42.0}, "inputs:b": {"type": "half", "value": 2.0}, "outputs:result": {"type": "half", "value": 21.0} }, { "inputs:a": {"type": "double", "value": 42.0}, "inputs:b": {"type": "int", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "float", "value": 42.0}, "inputs:b": {"type": "int64", "value": 2}, "outputs:result": {"type": "float", "value": 21.0} }, { "inputs:a": {"type": "half", "value": 42.0}, "inputs:b": {"type": "uchar", "value": 2}, "outputs:result": {"type": "half", "value": 21.0} }, { "inputs:a": {"type": "double", "value": 42.0}, "inputs:b": {"type": "uint", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "float", "value": 42.0}, "inputs:b": {"type": "uint64", "value": 2}, "outputs:result": {"type": "float", "value": 21.0} }, { "inputs:a": {"type": "int", "value": 42}, "inputs:b": {"type": "half", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "int64", "value": 42}, "inputs:b": {"type": "double", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "uchar", "value": 42}, "inputs:b": {"type": "float", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "uint", "value": 42}, "inputs:b": {"type": "half", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "uint64", "value": 42}, "inputs:b": {"type": "double", "value": 2.0}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "int", "value": 42}, "inputs:b": {"type": "int", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "int", "value": 42}, "inputs:b": {"type": "uchar", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "int64", "value": 42}, "inputs:b": {"type": "uint", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "uchar", "value": 42}, "inputs:b": {"type": "uint64", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "uint", "value": 42}, "inputs:b": {"type": "int", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "uint64", "value": 42}, "inputs:b": {"type": "int64", "value": 2}, "outputs:result": {"type": "double", "value": 21.0} }, { "inputs:a": {"type": "float[2]", "value": [1.0, 2.0]}, "inputs:b": {"type": "int", "value": 2}, "outputs:result": {"type": "float[2]", "value": [0.5, 1.0]} }, { "inputs:a": {"type": "int[3]", "value": [1, 2, 3]}, "inputs:b": {"type": "half", "value": 2.0}, "outputs:result": {"type": "double[3]", "value": [0.5, 1.0, 1.5]} }, { "inputs:a": {"type": "double[4]", "value": [1.0, 2.0, 3.0, 4.0]}, "inputs:b": {"type": "uchar", "value": 2}, "outputs:result": {"type": "double[4]", "value": [0.5, 1.0, 1.5, 2.0]} }, { "inputs:a": {"type": "float[]", "value": [1.0, 2.0]}, "inputs:b": {"type": "uint", "value": 2}, "outputs:result": {"type": "float[]", "value": [0.5, 1.0]} }, { "inputs:a": {"type": "half[]", "value": [1.0, 2.0, 3.0]}, "inputs:b": {"type": "uint64[]", "value": [2, 4, 6]}, "outputs:result": {"type": "half[]", "value": [0.5, 0.5, 0.5]} }, { "inputs:a": {"type": "int[]", "value": [1, 2, 3, 4]}, "inputs:b": {"type": "int[]", "value": [2, 4, 6, 8]}, "outputs:result": {"type": "double[]", "value": [0.5, 0.5, 0.5, 0.5]} }, { "inputs:a": {"type": "float[2][]", "value": [[1.0, 2.0], [3.0, 4.0]]}, "inputs:b": {"type": "int[]", "value": [1, 2]}, "outputs:result": {"type": "float[2][]", "value": [[1.0, 2.0], [1.5, 2.0]]} }, { "inputs:a": {"type": "int64", "value": 9223372036854775807}, "inputs:b": {"type": "int", "value": 1}, "outputs:result": {"type": "double", "value": 9223372036854775807.0} }, { "inputs:a": {"type": "int", "value": 3}, "inputs:b": {"type": "uint", "value": 2}, "outputs:result": {"type": "double", "value": 1.5} }, { "inputs:a": {"type": "uint64", "value": 3}, "inputs:b": {"type": "half", "value": 2}, "outputs:result": {"type": "double", "value": 1.5} }, { "inputs:a": {"type": "half[2]", "value": [1.0, 2.0]}, "inputs:b": {"type": "int", "value": 2}, "outputs:result": {"type": "half[2]", "value": [0.5, 1.0]} }, { "inputs:a": {"type": "uchar", "value": 10}, "inputs:b": {"type": "uchar", "value": 2}, "outputs:result": {"type": "double", "value": 5.0} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnRandomUnitVector.ogn
{ "RandomUnitVector": { "version": 1, "description": "Generates a random vector with uniform distribution on the unit sphere.", "uiName": "Random Unit Vector", "categories": [ "math:operator" ], "scheduling": [ "threadsafe" ], "inputs": { "execIn": { "type": "execution", "description": "The input execution port to output a new random value" }, "seed": { "type": "uint64", "description": "The seed of the random generator.", "uiName": "Seed", "$optional": "Setting optional=true is a workaround to avoid the USD generated tests for checking the default value of 0, since we override the default seed with a random one", "optional": true }, "useSeed": { "type": "bool", "description": "Use the custom seed instead of a random one", "uiName": "Use seed", "default": false }, "isNoise": { "type": "bool", "description": [ "Turn this node into a noise generator function", "For a given seed, it will then always output the same number(s)" ], "uiName": "Is noise function", "default": false, "metadata": { "hidden": "true", "literalOnly": "1" } } }, "state": { "gen": { "type": "matrixd[3]", "description": "Random number generator internal state (abusing matrix3d because it is large enough)" } }, "outputs": { "random": { "type": "vectorf[3]", "description": "The random unit vector that was generated", "uiName": "Random Unit Vector" }, "execOut": { "type": "execution", "description": "The output execution port" } }, "tests": [ { "inputs:useSeed": true, "inputs:seed": 123456789, "inputs:execIn": 1, "outputs:random": [ 0.99799526, 0.02564502, -0.05785976 ], "outputs:execOut": 1, "inputs:isNoise": true } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnDotProduct.ogn
{ "DotProduct": { "version": 1, "description": [ "Compute the dot product of two (arrays of) vectors.", "If two arrays of vectors are provided, then the dot product will be taken element-wise.", "Inputs must be the same shape" ], "uiName": "Dot Product", "categories": ["math:operator"], "scheduling": ["threadsafe"], "inputs": { "a": { "type": ["decimal_tuples", "decimal_arrays"], "description": "The first vector in the dot product", "uiName": "A" }, "b": { "type": ["decimal_tuples", "decimal_arrays"], "description": "The second vector in the dot product", "uiName": "B" } }, "outputs": { "product": { "type": ["decimal_scalers", "double[]", "float[]", "half[]"], "description": "The resulting product", "uiName": "Product" } }, "tests": [ { "inputs:a": {"type": "double[2]", "value": [1, 2]}, "inputs:b": {"type": "double[2]", "value": [3, 4]}, "outputs:product": {"type": "double", "value": 11} }, { "inputs:a": {"type": "double[3]", "value": [1, 2, 3]}, "inputs:b": {"type": "double[3]", "value": [5, 6, 7]}, "outputs:product": {"type": "double", "value": 38} }, { "inputs:a": {"type": "double[4]", "value": [10.2, 3.5, 7, 0]}, "inputs:b": {"type": "double[4]", "value": [5, 6.1, 4.2, 5]}, "outputs:product": {"type": "double", "value": 101.75} }, { "inputs:a": {"type": "double[4][]", "value": [[3, 6.5, 2, 0], [4, 3.6, 2, 0]]}, "inputs:b": {"type": "double[4][]", "value": [[5, 6.1, -2.1, 5], [3, 5, -2, 7]]}, "outputs:product": {"type": "double[]", "value": [50.449999999999996, 26.0]} }, { "inputs:a": {"type": "half[3]", "value": [1, 2, 3]}, "inputs:b": {"type": "half[3]", "value": [5, 6, 7]}, "outputs:product": {"type": "half", "value": 38} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnRandomNumeric.ogn
{ "RandomNumeric": { "version": 1, "description": [ "Generates a random numeric value in a range, using a uniform distribution.", "The range is specified with two inputs: minimum and maximum.", "These inputs can be numbers, vectors, tuples or arrays of these.", "If one input has a higher dimension than the other, ", "then the input with lower dimension will be repeated to match the dimension of the other input (broadcasting). " ], "uiName": "Random Numeric", "categories": [ "math:operator" ], "scheduling": [ "threadsafe" ], "inputs": { "execIn": { "type": "execution", "description": "The input execution port to output a new random value" }, "seed": { "type": "uint64", "description": "The seed of the random generator.", "uiName": "Seed", "$optional": "Setting optional=true is a workaround to avoid the USD generated tests for checking the default value of 0, since we override the default seed with a random one", "optional": true }, "useSeed": { "type": "bool", "description": "Use the custom seed instead of a random one", "uiName": "Use seed", "default": false }, "isNoise": { "type": "bool", "description": [ "Turn this node into a noise generator function", "For a given seed, it will then always output the same number(s)" ], "uiName": "Is Noise Function", "default": false, "metadata": { "hidden": "true", "literalOnly": "1" } }, "min": { "type": [ "numerics" ], "description": [ "The minimum of the random range (inclusive).", "Can be a number, vector, tuple, or array of these.", "The default value is double 0." ], "uiName": "Minimum", "optional": true }, "max": { "type": [ "numerics" ], "description": [ "The maximum of the random range,", "inclusive of integral numbers", "exclusive for real numbers.", "Can be a number, vector, tuple, or array of these.", "The default value is double 1." ], "uiName": "Maximum", "optional": true } }, "state": { "gen": { "type": "matrixd[3]", "description": "Random number generator internal state (abusing matrix3d because it is large enough)." } }, "outputs": { "random": { "type": [ "numerics" ], "description": "The random numeric value that was generated", "uiName": "Random Numeric", "unvalidated": true }, "execOut": { "type": "execution", "description": "The output execution port" } }, "tests": [ { "$description": "Checks that uint32 0 is generated for the full range", "inputs:useSeed": true, "inputs:seed": 6649909271, "inputs:min": { "type": "uint", "value": 0 }, "inputs:max": { "type": "uint", "value": 4294967295 }, "inputs:execIn": 1, "outputs:random": { "type": "uint", "value": 0 }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks that uint32 2^31 is generated for the full range", "- Checks array broadcasting", "- Checks uint32 sub-range" ], "inputs:useSeed": true, "inputs:seed": 6159018942, "inputs:min": { "type": "uint[]", "value": [ 0, 100 ] }, "inputs:max": { "type": "uint", "value": 4294967295 }, "inputs:execIn": 1, "outputs:random": { "type": "uint[]", "value": [ 2147483648, 2160101208 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks that uint32 2^32-1 is generated for the full range", "- Checks array broadcasting", "- Checks uint32 sub-range" ], "inputs:useSeed": true, "inputs:seed": 3280530163, "inputs:min": { "type": "uint", "value": 0 }, "inputs:max": { "type": "uint[]", "value": [ 4294967295, 199 ] }, "inputs:execIn": 1, "outputs:random": { "type": "uint[]", "value": [ 4294967295, 19 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": "Checks that int32 0 is generated for the full range", "inputs:useSeed": true, "inputs:seed": 6159018942, "inputs:min": { "type": "int", "value": -2147483648 }, "inputs:max": { "type": "int", "value": 2147483647 }, "inputs:execIn": 1, "outputs:random": { "type": "int", "value": 0 }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks that int32 -2^31 is generated for the full range", "- Checks tuple broadcasting", "- Checks int32 sub-range" ], "inputs:useSeed": true, "inputs:seed": 6649909271, "inputs:min": { "type": "int[2]", "value": [ -2147483648, -100 ] }, "inputs:max": { "type": "int", "value": 2147483647 }, "inputs:execIn": 1, "outputs:random": { "type": "int[2]", "value": [ -2147483648, 1629773655 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks that int32 2^32-1 is generated for the full range", "- Checks tuple broadcasting", "- Checks int32 sub-range" ], "inputs:useSeed": true, "inputs:seed": 3280530163, "inputs:min": { "type": "int", "value": -2147483648 }, "inputs:max": { "type": "int[2]", "value": [ 2147483647, 99 ] }, "inputs:execIn": 1, "outputs:random": { "type": "int[2]", "value": [ 2147483647, -2146948710 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": "Checks that float 0 is generated for the range [0..1)", "inputs:useSeed": true, "inputs:seed": 8280086, "inputs:min": { "type": "float", "value": 0 }, "inputs:max": { "type": "float", "value": 1 }, "inputs:execIn": 1, "outputs:random": { "type": "float", "value": 0 }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks that float 0.5 is generated for the range [0..1)", "- Checks array broadcasting" ], "inputs:useSeed": true, "inputs:seed": 17972581, "inputs:min": { "type": "float[]", "value": [ 0, -10 ] }, "inputs:max": { "type": "float", "value": 1 }, "inputs:execIn": 1, "outputs:random": { "type": "float[]", "value": [ 0.5, -6.7663326 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks that float 1-ε in generated for the range [0..1)", "- Checks array broadcasting", "- Checks float sub-range" ], "inputs:useSeed": true, "inputs:seed": 15115159, "inputs:min": { "type": "float", "value": 0 }, "inputs:max": { "type": "float[]", "value": [ 1, 10 ] }, "inputs:execIn": 1, "outputs:random": { "type": "float[]", "value": [ 0.999999940395355224609375, 4.0452986 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": "Checks that uint64 0 is generated for the full range", "inputs:useSeed": true, "inputs:seed": 14092058508772706262, "inputs:min": { "type": "uint64", "value": 0 }, "inputs:max": { "type": "uint64", "value": 18446744073709551615 }, "inputs:execIn": 1, "outputs:random": { "type": "uint64", "value": 0 }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": "Checks that uint64 2^63 is generated for the full range", "inputs:useSeed": true, "inputs:seed": 9302349107990861236, "inputs:min": { "type": "uint64", "value": 0 }, "inputs:max": { "type": "uint64", "value": 18446744073709551615 }, "inputs:execIn": 1, "outputs:random": { "type": "uint64", "value": 9223372036854775808 }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": "Checks that uint64 2^64-1 is generated for the full range", "inputs:useSeed": true, "inputs:seed": 1955209015103813879, "inputs:min": { "type": "uint64", "value": 0 }, "inputs:max": { "type": "uint64", "value": 18446744073709551615 }, "inputs:execIn": 1, "outputs:random": { "type": "uint64", "value": 18446744073709551615 }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": "Checks uint64 generation for a sub-range", "inputs:useSeed": true, "inputs:seed": 123456789, "inputs:min": { "type": "uint64", "value": 1099511627776 }, "inputs:max": { "type": "uint64", "value": 1125899906842624 }, "inputs:execIn": 1, "outputs:random": { "type": "uint64", "value": 923489197424953 }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks double generation", "- Checks array-of-tuple broadcasting", "- Checks min/max swapping", "- Checks overflow edge case" ], "inputs:useSeed": true, "inputs:seed": 1955209015103813879, "inputs:min": { "type": "double[2][]", "value": [ [ 0, -10 ], [ 10, 0 ] ] }, "inputs:max": { "type": "double", "value": 1 }, "inputs:execIn": 1, "outputs:random": { "type": "double[2][]", "value": [ [ 0, 0.28955788 ], [ 7.98645811, 0.09353537 ] ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks half generation", "- Checks array broadcasting" ], "inputs:useSeed": true, "inputs:seed": 123456789, "inputs:min": { "type": "half[]", "value": [ 0, -100 ] }, "inputs:max": { "type": "half[]", "value": [ 1, 100 ] }, "inputs:execIn": 1, "outputs:random": { "type": "half[]", "value": [ 0.17993164, -76.375 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": [ "- Checks uchar generation", "- Checks array broadcasting", "- Checks zero seed doesn't cause zero state" ], "inputs:useSeed": true, "inputs:seed": 0, "inputs:min": { "type": "uchar[]", "value": [ 0, 100 ] }, "inputs:max": { "type": "uchar[]", "value": [ 255, 200 ] }, "inputs:execIn": 1, "outputs:random": { "type": "uchar[]", "value": [ 153, 175 ] }, "outputs:execOut": 1, "inputs:isNoise": true }, { "$description": "Checks that the default input values are used", "inputs:useSeed": true, "inputs:seed": 9302349107990861236, "inputs:execIn": 1, "outputs:random": { "type": "double", "value": 0.5 }, "outputs:execOut": 1, "inputs:isNoise": true } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnDivide_Tuple3.cpp
#include "OgnDivideHelper.h" namespace omni { namespace graph { namespace nodes { namespace OGNDivideHelper { bool tryComputeTuple3(ogn::OmniGraphDatabase& db, InType const& a, InType const& b, ResType& result, size_t count) { return _tryComputeTuple<3>(db, a, b, result, count); } } // namespace OGNDivideHelper } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnFloor.ogn
{ "Floor": { "version": 1, "description": [ "Computes the floor of the given decimal number a, which is the largest integral value not greater than a" ], "uiName": "Floor", "categories": ["math:operator"], "scheduling": ["threadsafe"], "inputs": { "a": { "type": ["decimals"], "description": "The decimal number", "uiName": "A" } }, "outputs": { "result": { "type": ["int", "integral_tuples", "int[]", "int[2][]", "int[3][]", "int[4][]"], "description": "The floor of the input a", "uiName": "Result" } }, "tests" : [ { "inputs:a": {"type": "float", "value": 4.1}, "outputs:result": 4 }, { "inputs:a": {"type": "half", "value": -4.9}, "outputs:result": -5 }, { "inputs:a": {"type": "double[3]", "value": [1.3, 2.4, -3.7]}, "outputs:result": [1, 2, -4] }, { "inputs:a": {"type": "double[]", "value": [1.3, 2.4, -3.7, 4.5]}, "outputs:result": [1, 2, -4, 4] } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnNthRoot.cpp
// Copyright (c) 2022-2023, 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 <OgnNthRootDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <carb/logging/Log.h> #include <math.h> namespace omni { namespace graph { namespace nodes { // unnamed namespace to avoid multiple declaration when linking namespace { /** * Helper functions to try doing an addition operation on two input attributes. * We assume the runtime attributes have type T and the other one is double. * The first input is either an array or a singular value, and the second input is a single double value * * @param db: database object * @return True if we can get a result properly, false if not */ /** * Used when input type is resolved as Half */ bool tryComputeAssumingType(OgnNthRootDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto& result) { double res; switch (b) { case 3: res = std::cbrt(a); break; case 2: res = std::sqrt(a); break; default: res = std::pow(static_cast<double>(static_cast<float>(a)), static_cast<double>(1.0 / static_cast<double>(b))); break; } result = static_cast<pxr::GfHalf>(static_cast<float>(res)); }; return ogn::compute::tryComputeWithArrayBroadcasting<pxr::GfHalf, int, pxr::GfHalf>(db.inputs.value(), db.inputs.nthRoot(), db.outputs.result(), functor, count); } /** * Used when input type is resolved as non-int numeric type other than Half */ template <typename T> bool tryComputeAssumingType(OgnNthRootDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto& result) { switch (b) { case 3: result = static_cast<T>(std::cbrt(a)); break; case 2: result = static_cast<T>(std::sqrt(a)); break; default: result = static_cast<T>(std::pow(a, 1.0 / static_cast<double>(b))); break; } }; return ogn::compute::tryComputeWithArrayBroadcasting<T, int, T>(db.inputs.value(), db.inputs.nthRoot(), db.outputs.result(), functor, count); } /** * Used when input type is resolved as int type */ template <typename T, typename M> bool tryComputeAssumingType(OgnNthRootDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto& result) { switch (b) { case 3: result = static_cast<M>(std::cbrt(a)); break; case 2: result = static_cast<M>(std::sqrt(a)); break; default: result = static_cast<M>(std::pow(a, 1.0 / static_cast<double>(b))); break; } }; return ogn::compute::tryComputeWithArrayBroadcasting<T, int, M>( db.inputs.value(), db.inputs.nthRoot(), db.outputs.result(), functor, count); } /** * Used when input type is resolved as Half */ template <size_t N> bool tryComputeAssumingType(OgnNthRootDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto& result) { double res; switch (b) { case 3: res = std::cbrt(a); break; case 2: res = std::sqrt(a); break; default: res = std::pow(static_cast<double>(static_cast<float>(a)), static_cast<double>(1.0 / static_cast<double>(b))); break; } result = static_cast<pxr::GfHalf>(static_cast<float>(res)); }; return ogn::compute::tryComputeWithTupleBroadcasting<N, pxr::GfHalf, int, pxr::GfHalf>( db.inputs.value(), db.inputs.nthRoot(), db.outputs.result(), functor, count); } /** * Used when input type is resolved as any non-int numeric type other than Half */ template <typename T, size_t N> bool tryComputeAssumingType(OgnNthRootDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto& result) { switch (b) { case 3: result = static_cast<T>(std::cbrt(a)); break; case 2: result = static_cast<T>(std::sqrt(a)); break; default: result = static_cast<T>(std::pow(a, 1.0 / static_cast<double>(b))); break; } }; return ogn::compute::tryComputeWithTupleBroadcasting<N, T, int, T>( db.inputs.value(), db.inputs.nthRoot(), db.outputs.result(), functor, count); } /** * Used when input type is resolved as int type */ template <typename T, size_t N, typename M> bool tryComputeAssumingType(OgnNthRootDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto& result) { switch (b) { case 3: result = static_cast<M>(std::cbrt(a)); break; case 2: result = static_cast<M>(std::sqrt(a)); break; default: result = static_cast<M>(std::pow(a, 1.0 / static_cast<double>(b))); break; } }; return ogn::compute::tryComputeWithTupleBroadcasting<N, T, int, M>( db.inputs.value(), db.inputs.nthRoot(), db.outputs.result(), functor, count); } } // namespace class OgnNthRoot { public: static bool computeVectorized(OgnNthRootDatabase& db, size_t count) { try { const auto& vType = db.inputs.value().type(); switch (vType.componentCount) { case 1: // All possible types excluding ogn::string and bool // scalars switch (vType.baseType) { case BaseDataType::eDouble: return tryComputeAssumingType<double>(db, count); case BaseDataType::eHalf: // Specifically for pxr::GfHalf return tryComputeAssumingType(db, count); case BaseDataType::eFloat: return tryComputeAssumingType<float>(db, count); case BaseDataType::eInt: return tryComputeAssumingType<int32_t, double>(db, count); case BaseDataType::eInt64: return tryComputeAssumingType<int64_t, double>(db, count); case BaseDataType::eUChar: return tryComputeAssumingType<unsigned char, double>(db, count); case BaseDataType::eUInt: return tryComputeAssumingType<uint32_t, double>(db, count); case BaseDataType::eUInt64: return tryComputeAssumingType<uint64_t, double>(db, count); default: break; } case 2: switch (vType.baseType) { case BaseDataType::eInt: return tryComputeAssumingType<int32_t, 2, double>(db, count); case BaseDataType::eDouble: return tryComputeAssumingType<double, 2>(db, count); case BaseDataType::eFloat: return tryComputeAssumingType<float, 2>(db, count); case BaseDataType::eHalf: return tryComputeAssumingType<2>(db, count); default: break; } case 3: switch (vType.baseType) { case BaseDataType::eInt: return tryComputeAssumingType<int32_t, 3, double>(db, count); case BaseDataType::eDouble: return tryComputeAssumingType<double, 3>(db, count); case BaseDataType::eFloat: return tryComputeAssumingType<float, 3>(db, count); case BaseDataType::eHalf: return tryComputeAssumingType<3>(db, count); default: break; } case 4: // quaternion (IJKR), RGBA, etc switch (vType.baseType) { case BaseDataType::eInt: return tryComputeAssumingType<int32_t, 4, double>(db, count); case BaseDataType::eDouble: return tryComputeAssumingType<double, 4>(db, count); case BaseDataType::eFloat: return tryComputeAssumingType<float, 4>(db, count); case BaseDataType::eHalf: return tryComputeAssumingType<4>(db, count); default: break; } case 9: // Matrix3f type if (vType.baseType == BaseDataType::eDouble) { return tryComputeAssumingType<double, 9>(db, count); } case 16: // Matrix4f type if (vType.baseType == BaseDataType::eDouble) { return tryComputeAssumingType<double, 16>(db, count); } } throw ogn::compute::InputError("Failed to resolve input types"); } catch (ogn::compute::InputError &error) { db.logError(error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node){ auto value = node.iNode->getAttributeByToken(node, inputs::value.token()); auto result = node.iNode->getAttributeByToken(node, outputs::result.token()); auto valueType = value.iAttribute->getResolvedType(value); Type newType(BaseDataType::eDouble, valueType.componentCount, valueType.arrayDepth, valueType.role); // Require inputs to be resolved before determining sum's type switch (valueType.baseType) { case BaseDataType::eUChar: case BaseDataType::eInt: case BaseDataType::eUInt: case BaseDataType::eInt64: case BaseDataType::eUInt64: result.iAttribute->setResolvedType(result, newType); break; case BaseDataType::eUnknown: break; default: std::array<AttributeObj, 2> attrs { value, result }; node.iNode->resolveCoupledAttributes(node, attrs.data(), attrs.size()); break; } } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnAcos.cpp
// Copyright (c) 2022, 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 <OgnAcosDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <carb/logging/Log.h> #include <omni/math/linalg/math.h> #include <math.h> namespace omni { namespace graph { namespace nodes { // unnamed namespace to avoid multiple declaration when linking namespace { /** * Used when input type is resolved as non-int numeric type other than Half */ template <typename T> bool tryComputeAssumingType(OgnAcosDatabase& db) { auto functor = [](auto const& in, auto& out) { out = static_cast<T>(pxr::GfRadiansToDegrees(std::acos(in))); }; return ogn::compute::tryComputeWithArrayBroadcasting<T>(db.inputs.value(), db.outputs.value(), functor); } template <> bool tryComputeAssumingType<pxr::GfHalf>(OgnAcosDatabase& db) { auto functor = [](auto const& in, auto& out) { out = static_cast<pxr::GfHalf>(static_cast<float>(pxr::GfRadiansToDegrees(std::acos(in)))); }; return ogn::compute::tryComputeWithArrayBroadcasting<pxr::GfHalf>(db.inputs.value(), db.outputs.value(), functor); } } // namespace class OgnAcos { public: static bool compute(OgnAcosDatabase& db) { try { // All possible types excluding ogn::string and bool // scalers if (tryComputeAssumingType<double>(db)) return true; else if (tryComputeAssumingType<pxr::GfHalf>(db)) return true; // Specifically for pxr::GfHalf else if (tryComputeAssumingType<float>(db)) return true; else { db.logWarning("Failed to resolve input types"); } } catch (std::exception &error) { db.logError("Could not perform Arccosine funtion : %s", error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node){ auto input = node.iNode->getAttributeByToken(node, inputs::value.token()); auto result = node.iNode->getAttributeByToken(node, outputs::value.token()); auto inputType = input.iAttribute->getResolvedType(input); // Require inputs to be resolved before determining output's type if (inputType.baseType != BaseDataType::eUnknown) { std::array<AttributeObj, 2> attrs { input, result }; node.iNode->resolveCoupledAttributes(node, attrs.data(), attrs.size()); } } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnToRad.ogn
{ "ToRad": { "version": 1, "description": [ "Convert degree input into radians" ], "uiName": "To Radians", "categories": ["math:conversion"], "scheduling": ["threadsafe"], "inputs": { "degrees": { "type": ["decimal_scalers", "double[]", "float[]", "half[]"], "description": "Angle value in degrees to be converted", "uiName": "Degrees" } }, "outputs": { "radians": { "type": ["decimal_scalers", "double[]", "float[]", "half[]"], "description": "Angle value in radians", "uiName": "Radians" } }, "tests" : [ { "inputs:degrees": {"type": "double", "value": -57.2958}, "outputs:radians": {"type": "double", "value": -1.0} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnNormalize.ogn
{ "Normalize": { "version": 1, "description": [ "Normalize the input vector.", "If the input vector has a magnitude of zero, the null vector is returned." ], "uiName": "Normalize", "categories": ["math:operator"], "scheduling": ["threadsafe"], "inputs": { "vector": { "type": [ "double[2]", "float[2]", "half[2]", "double[3]", "float[3]", "half[3]", "double[4]", "float[4]", "half[4]", "double[2][]", "float[2][]", "half[2][]", "double[3][]", "float[3][]", "half[3][]", "double[4][]", "float[4][]", "half[4][]" ], "description": "Vector to normalize", "uiName": "Vector" } }, "outputs": { "result": { "type": [ "double[2]", "float[2]", "half[2]", "double[3]", "float[3]", "half[3]", "double[4]", "float[4]", "half[4]", "double[2][]", "float[2][]", "half[2][]", "double[3][]", "float[3][]", "half[3][]", "double[4][]", "float[4][]", "half[4][]" ], "description": "Normalized vector", "uiName": "Result" } }, "tests": [ { "inputs:vector": {"type": "float[3]", "value": [1.0, 1.0, 1.0]}, "outputs:result": {"type": "float[3]", "value": [0.57735027, 0.57735027, 0.57735027]} }, { "inputs:vector": {"type": "float[3]", "value": [1.0, 0.0, 0.0]}, "outputs:result": {"type": "float[3]", "value": [1.0, 0.0, 0.0]} }, { "inputs:vector": {"type": "float[3]", "value": [5.0, 0.0, 0.0]}, "outputs:result": {"type": "float[3]", "value": [1.0, 0.0, 0.0]} }, { "inputs:vector": {"type": "float[3]", "value": [-1.0,2.0,-3.0]}, "outputs:result": {"type": "float[3]", "value": [-0.26726124, 0.53452248, -0.80178373]} }, { "inputs:vector": {"type": "double[3]", "value": [1.0, 1.0, 1.0]}, "outputs:result": {"type": "double[3]", "value": [0.57735027, 0.57735027, 0.57735027]} }, { "inputs:vector": {"type": "half[3]", "value": [1.0, 1.0, 1.0]}, "outputs:result": {"type": "half[3]", "value": [0.57714844, 0.57714844, 0.57714844]} }, { "inputs:vector": {"type": "float[3][]", "value": [[1.0, 2.0, 3.0],[4.0, 5.0, 6.0]]}, "outputs:result": {"type": "float[3][]", "value": [[0.26726124, 0.5345225, 0.8017837],[0.45584232, 0.5698029, 0.6837635]]} }, { "inputs:vector": {"type": "half[3][]", "value": [[1.0, 2.0, 3.0],[4.0, 5.0, 6.0]]}, "outputs:result": {"type": "half[3][]", "value": [[0.26733398, 0.53466797, 0.8017578],[0.45581055, 0.5698242, 0.68359375]]} }, { "inputs:vector": {"type": "float[2]", "value": [1.0, 1.0]}, "outputs:result": {"type": "float[2]", "value": [0.70710677, 0.70710677]} }, { "inputs:vector": {"type": "float[4]", "value": [1.0, 2.0, 3.0, 4.0]}, "outputs:result": {"type": "float[4]", "value": [0.18257418, 0.36514837, 0.5477226, 0.73029673]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnClamp.ogn
{ "Clamp": { "version": 1, "description": [ "Clamp a number or array of numbers to a specified range.", "If an array of numbers is provided as the input and lower/upper are scalers", "Then each input numeric will be clamped to the range [lower, upper]", "If all inputs are arrays, clamping will be done element-wise. lower & upper are broadcast against input", "Error will be reported if lower > upper." ], "uiName": "Clamp", "categories": ["math:operator"], "scheduling": ["threadsafe"], "inputs": { "input": { "type": ["numerics"], "description": "The input numerics to clamp", "uiName": "Input" }, "lower": { "type": ["numerics"], "description": "Lower bound of the clamp", "uiName": "Lower" }, "upper": { "type": ["numerics"], "description": "Upper bound of the clamp", "uiName": "Upper" } }, "outputs": { "result": { "type": ["numerics"], "description": "The resulting clamped output", "uiName": "Output" } }, "tests": [ { "inputs:input": {"type": "int", "value": 51038}, "inputs:lower": {"type": "int", "value": -20}, "inputs:upper": {"type": "int", "value": 5}, "outputs:result": {"type": "int", "value": 5} }, { "inputs:input": {"type": "float[]", "value": [3.1415, -20.432, 50.762, -80.9, 5, 124]}, "inputs:lower": {"type": "float", "value": -20}, "inputs:upper": {"type": "float", "value": 50.4}, "outputs:result": {"type": "float[]", "value": [3.1415, -20, 50.4, -20, 5, 50.4]} }, { "inputs:input": {"type": "double[]", "value": [1, 5, -2.5, 62]}, "inputs:lower": {"type": "double[]", "value": [3, -10, -5, -10]}, "inputs:upper": {"type": "double[]", "value": [5, 3.5, -5, 2]}, "outputs:result": {"type": "double[]", "value": [3, 3.5, -5, 2]} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnAtan.cpp
// Copyright (c) 2022, 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 <OgnAtanDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <carb/logging/Log.h> #include <omni/math/linalg/math.h> #include <math.h> namespace omni { namespace graph { namespace nodes { // unnamed namespace to avoid multiple declaration when linking namespace { /** * Used when input type is resolved as non-int numeric type other than Half */ template <typename T> bool tryComputeAssumingType(OgnAtanDatabase& db) { auto functor = [](auto const& a, auto& result) { result = static_cast<T>(pxr::GfRadiansToDegrees(std::atan(a))); }; return ogn::compute::tryComputeWithArrayBroadcasting<T>(db.inputs.value(), db.outputs.value(), functor); } template <> bool tryComputeAssumingType<pxr::GfHalf>(OgnAtanDatabase& db) { auto functor = [](auto const& a, auto& result) { result = static_cast<pxr::GfHalf>(static_cast<float>(pxr::GfRadiansToDegrees(std::atan(a)))); }; return ogn::compute::tryComputeWithArrayBroadcasting<pxr::GfHalf>(db.inputs.value(), db.outputs.value(), functor); } } // namespace class OgnAtan { public: static bool compute(OgnAtanDatabase& db) { try { // All possible types excluding ogn::string and bool // scalers if (tryComputeAssumingType<double>(db)) return true; else if (tryComputeAssumingType<pxr::GfHalf>(db)) return true; // Specifically for pxr::GfHalf else if (tryComputeAssumingType<float>(db)) return true; else { db.logWarning("Failed to resolve input types"); } } catch (std::exception &error) { db.logError("Could not perform Arctangent funtion : %s", error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node){ auto value = node.iNode->getAttributeByToken(node, inputs::value.token()); auto result = node.iNode->getAttributeByToken(node, outputs::value.token()); auto valueType = value.iAttribute->getResolvedType(value); // Require inputs to be resolved before determining output's type if (valueType.baseType != BaseDataType::eUnknown) { std::array<AttributeObj, 2> attrs { value, result }; node.iNode->resolveCoupledAttributes(node, attrs.data(), attrs.size()); } } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnFMod.ogn
{ "FMod": { "version": 1, "description": [ "Computes the floating point remainder of A / B.", "If B is zero, the result is zero. The returned value has the same sign as A" ], "uiName": "Float Remainder", "language": "python", "categories": ["math:operator"], "inputs": { "a": { "type": ["decimals"], "description": "The dividend of (A / B)", "uiName": "A" }, "b": { "type":["decimals"], "description": "The divisor of (A / B)", "uiName": "B" } }, "outputs": { "result": { "type": ["decimals"], "description": "The floating point remainder of A / B", "uiName": "Result" } }, "tests" : [ { "inputs:a": {"type": "float", "value": 4.0}, "inputs:b": {"type": "float", "value": 3.625}, "outputs:result": {"type": "float", "value": 0.375} }, { "inputs:a": {"type": "float[]", "value": [4.0, 7.625]}, "inputs:b": {"type": "float", "value": 3.625}, "outputs:result": {"type": "float[]", "value": [0.375, 0.375]} }, { "inputs:a": {"type": "half", "value": -4.0}, "inputs:b": {"type": "half", "value": 3.625}, "outputs:result": {"type": "half", "value": -0.375} } ] } }
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnDistance3D.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 <OgnDistance3DDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <carb/logging/Log.h> #include <cmath> namespace omni { namespace graph { namespace nodes { namespace { template<typename T> bool tryComputeAssumingType(OgnDistance3DDatabase& db, size_t count) { auto functor = [](auto const& a, auto const& b, auto& result) { result = sqrt((b[0] - a[0]) * (b[0] - a[0]) + (b[1] - a[1]) * (b[1] - a[1]) + (b[2] - a[2]) * (b[2] - a[2])); }; return ogn::compute::tryComputeWithArrayBroadcasting<T[3], T[3], T>(db.inputs.a(), db.inputs.b(), db.outputs.distance(), functor, count); } } // namespace class OgnDistance3D { public: static bool computeVectorized(OgnDistance3DDatabase& db, size_t count) { try { if (tryComputeAssumingType<double>(db, count)) return true; else if (tryComputeAssumingType<float>(db, count)) return true; else if (tryComputeAssumingType<pxr::GfHalf>(db, count)) return true; else { db.logWarning("OgnDistance3D: Failed to resolve input types"); } } catch (ogn::compute::InputError &error) { db.logWarning("OgnDistance3D: %s", error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node) { auto a = node.iNode->getAttributeByToken(node, inputs::a.token()); auto b = node.iNode->getAttributeByToken(node, inputs::b.token()); auto distance = node.iNode->getAttributeByToken(node, outputs::distance.token()); auto typeA = a.iAttribute->getResolvedType(a); auto typeB = a.iAttribute->getResolvedType(b); const Type invalid; // Require a and b to be resolved before determining result's type if (typeA != invalid && typeB != invalid) { uint8_t ad = std::max(typeA.arrayDepth, typeB.arrayDepth); AttributeObj attrs[] = { a, b, distance }; uint8_t tupleCounts[] = { 3, 3, 1 }; uint8_t arrayDepths[] = { typeA.arrayDepth, typeB.arrayDepth, ad }; AttributeRole roles[] = { AttributeRole::eNone, AttributeRole::eNone, AttributeRole::eNone }; node.iNode->resolvePartiallyCoupledAttributes(node, attrs, tupleCounts, arrayDepths, roles, 3); } } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/math/OgnSubtract.cpp
// Copyright (c) 2022, 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 <OgnSubtractDatabase.h> #include <omni/graph/core/ogn/ComputeHelpers.h> #include <carb/logging/Log.h> namespace omni { namespace graph { namespace nodes { // unnamed namespace to avoid multiple declaration when linking namespace { template<typename T> bool tryComputeAssumingType(OgnSubtractDatabase& db, size_t count) { auto const& dynamicInputs = db.getDynamicInputs(); if (dynamicInputs.empty()) { auto functor = [](auto const& a, auto const& b, auto& result) { result = a - b; }; return ogn::compute::tryComputeWithArrayBroadcasting<T>(db.inputs.a(), db.inputs.b(), db.outputs.difference(), functor, count); } else { std::vector<ogn::InputAttribute> inputArray{ db.inputs.a(), db.inputs.b() }; inputArray.reserve(dynamicInputs.size() + 2); for (auto const& input : dynamicInputs) { inputArray.emplace_back(input()); } auto functor = [](const auto& input, auto& result) { result = result - input; }; return ogn::compute::tryComputeInputsWithArrayBroadcasting<T>(inputArray, db.outputs.difference(), functor, count); } } template<typename T, size_t N> bool tryComputeAssumingType(OgnSubtractDatabase& db, size_t count) { auto const& dynamicInputs = db.getDynamicInputs(); if (dynamicInputs.empty()) { auto functor = [](auto const& a, auto const& b, auto& result) { result = a - b; }; return ogn::compute::tryComputeWithTupleBroadcasting<N, T>(db.inputs.a(), db.inputs.b(), db.outputs.difference(), functor, count); } else { std::vector<ogn::InputAttribute> inputArray{ db.inputs.a(), db.inputs.b() }; inputArray.reserve(dynamicInputs.size() + 2); for (auto const& input : dynamicInputs) { inputArray.emplace_back(input()); } auto functor = [](const auto& input, auto& result) { result = result - input; }; return ogn::compute::tryComputeInputsWithTupleBroadcasting<N, T>(inputArray, db.outputs.difference(), functor, count); } } } // namespace class OgnSubtract { public: static bool computeVectorized(OgnSubtractDatabase& db, size_t count) { auto& differenceType = db.outputs.difference().type(); // Compute the components, if the types are all resolved. try { switch (differenceType.baseType) { case BaseDataType::eDouble: switch (differenceType.componentCount) { case 1: return tryComputeAssumingType<double>(db, count); case 2: return tryComputeAssumingType<double, 2>(db, count); case 3: return tryComputeAssumingType<double, 3>(db, count); case 4: return tryComputeAssumingType<double, 4>(db, count); case 9: return tryComputeAssumingType<double, 9>(db, count); case 16: return tryComputeAssumingType<double, 16>(db, count); default: break; } case BaseDataType::eFloat: switch (differenceType.componentCount) { case 1: return tryComputeAssumingType<float>(db, count); case 2: return tryComputeAssumingType<float, 2>(db, count); case 3: return tryComputeAssumingType<float, 3>(db, count); case 4: return tryComputeAssumingType<float, 4>(db, count); default: break; } case BaseDataType::eHalf: switch (differenceType.componentCount) { case 1: return tryComputeAssumingType<pxr::GfHalf>(db, count); case 2: return tryComputeAssumingType<pxr::GfHalf, 2>(db, count); case 3: return tryComputeAssumingType<pxr::GfHalf, 3>(db, count); case 4: return tryComputeAssumingType<pxr::GfHalf, 4>(db, count); default: break; } case BaseDataType::eInt: switch (differenceType.componentCount) { case 1: return tryComputeAssumingType<int32_t>(db, count); case 2: return tryComputeAssumingType<int32_t, 2>(db, count); case 3: return tryComputeAssumingType<int32_t, 3>(db, count); case 4: return tryComputeAssumingType<int32_t, 4>(db, count); default: break; } ; case BaseDataType::eInt64: return tryComputeAssumingType<int64_t>(db, count); case BaseDataType::eUChar: return tryComputeAssumingType<unsigned char>(db, count); case BaseDataType::eUInt: return tryComputeAssumingType<uint32_t>(db, count); case BaseDataType::eUInt64: return tryComputeAssumingType<uint64_t>(db, count); default: break; } throw ogn::compute::InputError("Failed to resolve input types"); } catch (ogn::compute::InputError &error) { db.logWarning("%s", error.what()); } return false; } static void onConnectionTypeResolve(const NodeObj& node) { auto totalCount = node.iNode->getAttributeCount(node); std::vector<AttributeObj> allAttributes(totalCount); node.iNode->getAttributes(node, allAttributes.data(), totalCount); std::vector<AttributeObj> attributes; std::vector<uint8_t> componentCounts; std::vector<uint8_t> arrayDepths; std::vector<AttributeRole> roles; attributes.reserve(totalCount - 2); componentCounts.reserve(totalCount - 2); arrayDepths.reserve(totalCount - 2); roles.reserve(totalCount - 2); uint8_t maxArrayDepth = 0; uint8_t maxComponentCount = 0; for (auto const& attr : allAttributes) { if (attr.iAttribute->getPortType(attr) == AttributePortType::kAttributePortType_Input) { auto resolvedType = attr.iAttribute->getResolvedType(attr); // if some inputs are not connected stop - the output port resolution is only completed when all inputs // are connected if (resolvedType.baseType == BaseDataType::eUnknown) return; componentCounts.push_back(resolvedType.componentCount); arrayDepths.push_back(resolvedType.arrayDepth); roles.push_back(resolvedType.role); maxComponentCount = std::max(maxComponentCount, resolvedType.componentCount); maxArrayDepth = std::max(maxArrayDepth, resolvedType.arrayDepth); attributes.push_back(attr); } } auto result = node.iNode->getAttributeByToken(node, outputs::difference.token()); attributes.push_back(result); // All inputs and the output should have the same tuple count componentCounts.push_back(maxComponentCount); // Allow for a mix of singular and array inputs. If any input is an array, the output must be an array arrayDepths.push_back(maxArrayDepth); // Copy the attribute role from the resolved type to the output type roles.push_back(AttributeRole::eUnknown); node.iNode->resolvePartiallyCoupledAttributes( node, attributes.data(), componentCounts.data(), arrayDepths.data(), roles.data(), attributes.size()); } }; REGISTER_OGN_NODE() } // namespace nodes } // namespace graph } // namespace omni // end-compute-helpers