Python API Improvements

Added Python functions for saving snapshots of UV layouts, scaling, rotating, and translating, and removing UVs, cutting uv edges, setting depth only passes, and exposing bounding boxes.

setTexCoords

Added the setTexCoords method to vrdGeometryNode to remove UV sets.

Fit Size

Added triplanarProjectionFitSize(), planarProjectionFitSize(), and cylyndricalProjectionFitSize() to vrUVService to fit a specific (planar/tri-planar/cylindrical) projection onto an arbitrary object and enable simple batch processing of arbitrary nodes.

Depth Only Pass

Added the setDepthOnlyPass function for the Advanced OpenGL Settings Depth Only Pass feature. It enables the toggling of Depth Only Pass. setDepthOnlyPass takes parameters similar to setBackfaceCulling, such as SWITCH_TOGGLE, SWITCH_ON, or SWITCH_OFF and True or False. There are no query functions of the current state.

Cut UV Edges

Added vrUVService.cutAlongSeams() to cut UV Edges along a selected seam, using values from Automatic Seam Selection.

vrUVService.cutAlongSeams(nodes, settings, uvSet)

Performs a cut with the given seam settings on the given nodes.

Example of an organic cut:

geometryNodes = [vrNodeService.findNode("Box")]
settings = vrdUVSeamSettings()
settings.setMode(vrUVTypes.SeamMode.Organic)
settings.setOrganicUsePipesCutter(True)
settings.setOrganicSegmentationAmount(0)
vrUVService.cutAlongSeams(geometryNodes, settings, vrUVTypes.UVSet.MaterialUVSet)

Example of a manufactured cut:

geometryNodes = [vrNodeService.findNode("Box")]
settings = vrdUVSeamSettings()
settings.setMode(vrUVTypes.SeamMode.Manufactured)
settings.setManufacturedAngle(45)
settings.setManufacturedAreaRatio(0.5)
vrUVService.cutAlongSeams(geometryNodes, settings, vrUVTypes.UVSet.MaterialUVSet)

Example of a baking cut:

geometryNodes = [vrNodeService.findNode("Box")]
settings = vrdUVSeamSettings()
settings.setMode(vrUVTypes.SeamMode.Baking)
settings.setBakingAngle(45)
settings.setBakingSizeOfMinPatch(0)
vrUVService.cutAlongSeams(geometryNodes, settings, vrUVTypes.UVSet.MaterialUVSet)
Parameters:
  • nodes (List[vrdGeometryNode]) – The list of nodes.
  • settings (vrdUVSeamSettings) – Settings to use for the seaming.
  • uvSet (vrUVTypes.UVSet) – The UV set to work on (`MaterialUVSet` for the material UVs or `LightmapUVSet` for the lightmap UVs).

Rotate UVs

Added vrUVService.rotateUV to rotate UVs around a given center.

To rotate UVs around a given center, try this:

center = QVector2D(0,0)
angle = 25
vrUVService.rotateUV(nodes, center, angle, vrUVTypes.UVSet.MaterialUVSet)

vrUVService.rotateUV(nodes, center, angleDegree, uvSet)

Rotate the UVs of the given nodes around the given center.

Example of rotating all material UVs 90 degrees:

geometryNodes = [vrNodeService.findNode("Box")]
center = QVector2D(0.5,0.5)
angle = 90
vrUVService.rotateUV(geometryNodes, center, angle, vrUVTypes.UVSet.MaterialUVSet)
Parameters:
  • nodes (List[vrdGeometryNode]) –
  • center (QVector2D) – Center of scaling.
  • angleDegree (float) – Rotation angle in degree.
  • uvSet (vrUVTypes.UVSet) – The UV set to work on.

Scale and Translate UVs

Added vrUVService.scaleUV and vrUVService.translateUV for scaling/flipping and translating UVs.

To flip UVs at a given center, try this:

center = QVector2D(0,0)
scaleU = 1
scaleV = -1
vrUVService.scaleUV(nodes, center, scaleU, scaleV, vrUVTypes.UVSet.MaterialUVSet)

To translate UVs at a given center, try this:

translateU = 0.2
translateV = 0.1
vrUVService.translateUV(nodes, translateU, translateV, vrUVTypes.UVSet.MaterialUVSet)

vrUVService.scaleUV(nodes, center, uScale, vScale, uvSet)

Scale the UVs of the given nodes using the given center.

Example of flipping all material UVs:

geometryNodes = [vrNodeService.findNode("Box")]
center = QVector2D(0.5,0.5)
uScale = -1
vScale = 1
vrUVService.scaleUV(geometryNodes, center, uScale, vScale, vrUVTypes.UVSet.MaterialUVSet)
Parameters:
  • nodes (List[vrdGeometryNode]) – The list of nodes.
  • center (QVector2D) – Center of scaling.
  • uScale (float) – Scale factor for u value.
  • vScale (float) – Scale factor for v value.
  • uvSet (vrUVTypes.UVSet) – The UV set to work on.

vrUVService.translateUV(nodes, du, dv, uvSet)

Translates the UVs of the given nodes.

Example of translating all material UVs:

geometryNodes = [vrNodeService.findNode("Box")]
du = 0.2
dv = 0.2
vrUVService.translateUV(geometryNodes, du, dv, vrUVTypes.UVSet.MaterialUVSet)
Parameters:
  • nodes (List[vrdGeometryNode]) – The list of nodes.
  • du (float) – Translation along u.
  • dv (float) – Translation along v.
  • uvSet (vrUVTypes.UVSet) – The UV set to work on.

saveUVSnapshot

Added saveUVSnapshot (as in Extend UV Editor) to vrUVService. It saves a snapshot of the UV layout as an image file.

Note:

If width and height are different, then the output image will be distorted.

vrUVService.saveUVSnapshot(nodes, path, width=1024, height=1024, uvSet=vrUVTypes.MaterialUVSet, style=vrUVTypes.ShowWireframe, mode=vrUVTypes.SnapshotMode.ZeroToOneSpace, customSpace=QVector4D())

Saves a snapshot of the UV layout as image file.

Note: If width and height are different in ZeroToOneSpace mode, then the output image will be distorted.

Example:

geometryNodes = [vrNodeService.findNode("Box")]
vrUVService.saveUVSnapshot(geometryNodes,
                           "c:/vred-snapshots/uv.png",
                           512, 512,
                           vrUVTypes.UVSet.MaterialUVSet,
                           vrUVTypes.ShowBorders | vrUVTypes.ShowWireframe)
Parameters:
  • nodes (List[vrdNode]) – The list of nodes to include in the snapshot.
  • path (string) – The full path where the image should be saved (e.g. ‘c:/uv.png’).
  • width (integer) – The width of the image in pixels (default 1024).
  • height (integer) – The height of the image in pixels (default 1024).
  • uvSet (vrUVTypes.UVSet) – The UV set to capture (MaterialUVSet for the material UVs or LightmapUVSet for the lightmap UVs).
  • style (integer) – Defines the style of the exported snapshot, Bitmask created from vrUVTypes.SnapshotStyle.
  • mode (vrUVTypes.SnapshotMode) – The snapshot mode defines the area to be included in the image. ‘ZeroToOneSpace’ captures the area from 0 to 1 in UV coordinates. ‘Boundingbox’ will capture the entire object.
  • customSpace (QVector4D) – UV space to use for shapshot (min U, max U, min V, max V). Only used if mode is set to `vrUVTypes::SnapshotMode::CustomSpace`.

Expose Bounding Boxes

Added getBoundingBox and getWorldBoundingBox to expose the bounding volume (box) of an object in the scene.

To get the combined bounding box of multiple objects, try this:

def getWorldCenter(geometryNodes):
    bb = vrdBoundingBox()
    for geometryNode in geometryNodes:
        bb.extendBy(geometryNode.getWorldBoundingBox())
    return bb.getCenter()

vrdNode.getWorldBoundingBox()

Returns the world bounding box of the node including its children.

Example of combining multiple bounding boxes:

def getWorldCenter(nodes):
    bb = vrdBoundingBox()
    for node in nodes:
        bb.extendBy(node.getWorldBoundingBox())
    return bb.getCenter()

# Find all nodes whose name starts with "Box". nodes = vrNodeService.findNodes("Box*", True) # Calculate the bounding box center of these nodes center = getWorldCenter(nodes) # Print the result print(center)

Returns:World bounding box of node
Return type:vrdBoundingBox