AnyLogic
Expand
Font size

public class UsdContext
extends Object
The UsdContext object is the main interface for interacting with and managing USD data within your code, providing integration between various elements of your scene and their corresponding USD representations

Nested Class Summary

Modifier and TypeClassDescription
static final record UsdContext.UsdItem
Binding for OM element to USD prim

Field Summary

Modifier and TypeFieldDescription
static longcurrentVersion 

Constructor Summary

ConstructorDescription
UsdContext() 

Method Summary

Modifier and TypeMethodDescription
<T extends UsdRepresentation<?>>
T
addUsdRepresentation(T usdRepresentation)
Add manually created UsdRepresentation to use during model run
PopulationUsdRepresentationcreateAgentsUsdRepresentation(Iterable<? extends Agent> elements, String scenePath)
Create a connection between an agents and a USD prim.
<T extends AbstractPositionalMarkup>
UsdRepresentation<T>
createMarkupsUsdRepresentation(Iterable<T> elements, String scenePath)
Create a connection between provided model elements and a USD prims.
<T extends Shape>
UsdRepresentation<T>
createShapesUsdRepresentation(Iterable<T> elements, String scenePath)
Create a connection between provided shapes collection and a USD prims.
<T extends Shape>
UsdRepresentation<T>
createUsdRepresentation(ReplicatedShape<T> elements, String scenePath)
Create USD representation to bind replicated shape elements to USD prim
<E, T extends UsdRepresentation<E>>
T
createUsdRepresentation(E element, String primPath)
Create a connection between a model element and a USD prim.
<T extends UsdElement>
UsdRepresentation<T>
createUsdRepresentation(Iterable<T> elements, String scenePath)
Create a connection between provided model elements and a USD prims.
UsdContextdisableBasisMirroring()
Applies Y-axis mirroring to the USD scene.
InstancingUsdRepresentation<?>generateAndRegisterUsdRepresentation(Agent rootAgent, UsdContext.UsdItem item, int cacheSize, boolean instanceable, Consumer<UsdRepresentation<?>> init) 
OmniFramegenerateOmniFrame(boolean fullFrame) 
UsdObjectCachegetCache() 
OmniverseSyncParametersgetParameters() 
<T extends Agent>
PopulationUsdRepresentation<T>
getUsdRepresentation(Class<T> cl)
Get UsdRepresentation instance that was generated for Agent USD model configured in graphical editor
InstancingUsdRepresentation<?>getUsdRepresentation(Class cl, String elementName)
Get UsdRepresentation instance that was generated for Agent element that has USD path or USD model configured in graphical editor
UsdRepresentation<?>getUsdRepresentation(Object obj)
Get UsdRepresentation for provided model element
voidreset() 
UsdContextsetConnectionParameters(String scenePath, String password, boolean startLocalConnector, boolean openScene, boolean useAutoGeneratedObjects, UsdRepresentation<?>... usdRepresentations)
Configures the parameters used to connect to the Omniverse scene.
UsdContextsetConnectionParameters(String scenePath, String password, UsdRepresentation<?>... usdRepresentations)
Configures the parameters used to connect to the Omniverse scene.
UsdContextsetGlobalCoordinateTransform(Consumer<PositionAndScale> transformation)
Sets the default position transformation function that will be applied to the positions of the model elements before applying to the connected USD prims.

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

currentVersion

public static volatile long currentVersion

Constructor Details

UsdContext

public UsdContext()

Method Details

reset

@AnyLogicInternalAPI
public void reset()

addUsdRepresentation

public <T extends UsdRepresentation<?>> T addUsdRepresentation(T usdRepresentation)
Add manually created UsdRepresentation to use during model run
Parameters:
usdRepresentation -

createUsdRepresentation

public <T extends Shape> UsdRepresentation<T> createUsdRepresentation(ReplicatedShape<T> elements,
 String scenePath)
Create USD representation to bind replicated shape elements to USD prim
Parameters:
elements - model element
scenePath - USD scene file path
Returns:
USD representation

createShapesUsdRepresentation

public <T extends Shape> UsdRepresentation<T> createShapesUsdRepresentation(Iterable<T> elements,
 String scenePath)
Create a connection between provided shapes collection and a USD prims.
Parameters:
elements - Collection of shapes
scenePath - USD scene file path
Returns:
Created and added to context UsdRepresentation object for provided shapes collection

createMarkupsUsdRepresentation

public <T extends AbstractPositionalMarkup>
UsdRepresentation<T> createMarkupsUsdRepresentation(Iterable<T> elements,
 String scenePath)
Create a connection between provided model elements and a USD prims.
Parameters:
elements - Collection of model elements
scenePath - USD scene file path
Returns:
Created and added to context UsdRepresentation object for provided elements collection

createUsdRepresentation

public <T extends UsdElement> UsdRepresentation<T> createUsdRepresentation(Iterable<T> elements,
 String scenePath)
Create a connection between provided model elements and a USD prims.
Parameters:
elements - Collection of model elements
scenePath - USD scene file path
Returns:
Created and added to context UsdRepresentation object for provided elements collection

createAgentsUsdRepresentation

public PopulationUsdRepresentation createAgentsUsdRepresentation(Iterable<? extends Agent> elements,
 String scenePath)
Create a connection between an agents and a USD prim.
Parameters:
elements - agents
scenePath - USD scene file path
Returns:
Created and added to context UsdRepresentation object for provided agents collection

createUsdRepresentation

public <E,
T extends UsdRepresentation<E>> T createUsdRepresentation(E element,
 String primPath)
Create a connection between a model element and a USD prim.
Type Parameters:
E - An element of the model (an agent, a shape, and so on).
T -
Parameters:
element - The model element
primPath - A path to the prim within the USD scene.
Returns:
Created and added to context UsdRepresentation object for provided model element

disableBasisMirroring

public UsdContext disableBasisMirroring()
Applies Y-axis mirroring to the USD scene. Returns the reconfigured UsdContext object.
Returns:

generateAndRegisterUsdRepresentation

@AnyLogicInternalAPI
public InstancingUsdRepresentation<?> generateAndRegisterUsdRepresentation(Agent rootAgent,
 UsdContext.UsdItem item,
 int cacheSize,
 boolean instanceable,
 Consumer<UsdRepresentation<?>> init)

generateOmniFrame

@AnyLogicInternalAPI
public OmniFrame generateOmniFrame(boolean fullFrame)

getCache

public UsdObjectCache getCache()

getUsdRepresentation

public UsdRepresentation<?> getUsdRepresentation(Object obj)
Get UsdRepresentation for provided model element
Parameters:
obj - modele element
Returns:
configured representation or null if it was not configured

getParameters

@AnyLogicInternalAPI
public OmniverseSyncParameters getParameters()

getUsdRepresentation

public InstancingUsdRepresentation<?> getUsdRepresentation(Class cl,
 String elementName)
Get UsdRepresentation instance that was generated for Agent element that has USD path or USD model configured in graphical editor
Parameters:
cl - Agent class
elementName - element name
Returns:
configured representation or null if it was not configured

getUsdRepresentation

public <T extends Agent>
PopulationUsdRepresentation<T> getUsdRepresentation(Class<T> cl)
Get UsdRepresentation instance that was generated for Agent USD model configured in graphical editor
Type Parameters:
T - agent type
Parameters:
cl - - Agent class
Returns:
configured generator or null if it was not configured

setGlobalCoordinateTransform

public UsdContext setGlobalCoordinateTransform(Consumer<PositionAndScale> transformation)
Sets the default position transformation function that will be applied to the positions of the model elements before applying to the connected USD prims.
Parameters:
transformation - The transformation function
Returns:
Returns the reconfigured UsdContext object.

setConnectionParameters

public UsdContext setConnectionParameters(String scenePath,
 String password,
 boolean startLocalConnector,
 boolean openScene,
 boolean useAutoGeneratedObjects,
 UsdRepresentation<?>... usdRepresentations)
Configures the parameters used to connect to the Omniverse scene.
Parameters:
scenePath - The path to the USD scene on the Omniverse Nucleus server.
password - The password to use to connect to the server in case Omniverse is hosted on a different computer.
startLocalConnector - Run AnyLogic Omniverse Connector at model startup (in case you need to run it separately or on a different computer).
openScene - try to run Omniverse Launcher to open scene provided by scene path at model startup
useAutoGeneratedObjects - try use autogenerated USD files for model 3D Objects
usdRepresentations - The collection of UsdRepresentation objects that connect the model elements to USD prims.
Returns:
Returns the reconfigured UsdContext object.

setConnectionParameters

public UsdContext setConnectionParameters(String scenePath,
 String password,
 UsdRepresentation<?>... usdRepresentations)
Configures the parameters used to connect to the Omniverse scene.
Parameters:
scenePath - The path to the USD scene on the Omniverse Nucleus server.
password - The password to use to connect to the server in case Omniverse is hosted on a different computer.
generators - The collection of UsdRepresentation objects that connect the model elements to USD prims.
Returns:
Returns the reconfigured UsdContext object.