vray.Proxy

class vray.Proxy

Bases: object

A group of methods for reading data and creating V-Ray geometry proxies. Below is a description of the mapping types used.

ProxyReadParams: A mapping type with the necessary parameters for reading data in a proxy file.

Keys:

* file                       - Obligatory. (string) file name to read
* object_path                  - Optional. (string) starting object path in Alembic hierarchy
* compute_normals              - Optional. (int) true to calculate smooth normals
* flip_axis                    - Optional. (int) 0 do not rotate; 1 transform from Maya to 3dsMax coordinate system (90 deg. rotation around x axis); 2 transform from 3dsMax to Maya (-90 deg. rotation around x axis)
* subdiv_level                 - Optional. (int) the subdivision level
* subdiv_preserve_map_borders  - Optional. (int) determines the smoothing mode of the mapping channels' borders. 0-None, 1-Internal and 2-All
* anim_type                    - Optional. (int) animated proxy playback type(0 - loop; 1 - once; 2 - ping - pong; 3 - still)
* num_preview_faces            - Optional. (int) number of faces in preview
* smooth_angle                 - Optional. (float) smooth angle in degrees
* anim_speed                   - Optional. (float) animated proxy playback speed
* anim_offset                  - Optional. (float) animated proxy initial frame offset
* fps                          - Optional. (float) frames per second for calculation of current time and frame
* use_full_names               - Optional. (bool) read the full path instead of only the name
* compute_bbox                 - Optional. (bool) true to compute the bounding box, false to read it from the file
* subdiv_all_meshes            - Optional. (bool) true to subdivide Alembic PolyMesh and SubD objects; false to subdivide only SubD objects
* subdiv_uvs                   - Optional. (bool) subdivide or skip mapping channels
* subdiv_preserve_geom_borders - Optional. (bool) if true, the borders won't be subdivided
* instancing                   - Optional. (bool) turns on/off the instancing of Alembic duplicated objects
* use_alembic_offset           - Optional. (bool) true to use Alembic animation frame offset
* hair_width_multiplier        - Optional. (float) a multiplier to the hair width data
* particle_width_multiplier    - Optional. (float) a multiplier to the particle width data

MeshFileData: A mapping type containing the data necessary to a export vrmesh with geometry, hair or particles. Used by vray.Proxy.createMeshFile() and vray.Proxy.createCombinedMeshFile().

Keys:

* vertices              -  ( VectorList )   (single frame)   OR  ( List ( List (int, VectorList) ) )  (multiple frames - where int is the corresponding keyFrame)
* faces                 -  (  IntList   )   (single frame)   OR  ( List ( List (int, IntList  )  ) )  (multiple frames - where int is the corresponding keyFrame)
* normals               -  ( VectorList )   (single frame)   OR  ( List ( List (int, VectorList) ) )  (multiple frames - where int is the corresponding keyFrame)
* faceNormals           -  (  IntList   )   (single frame)   OR  ( List ( List (int, IntList  )  ) )  (multiple frames - where int is the corresponding keyFrame)
* velocities            -  ( VectorList )   (single frame)   OR  ( List ( List (int, VectorList) ) )  (multiple frames - where int is the corresponding keyFrame)
* faceMtlIDs            -  (  IntList   )   (single frame)   OR  ( List ( List (int, IntList  )  ) )  (multiple frames - where int is the corresponding keyFrame)
* mapChannels           -  ( List ( List (int, VectorList, IntList) ) )
* mapChNames            -  ( List (string) ) 
* shaderNames           -  ( List ( List (int, string) ) )
* edgeVisibility        -  (  IntList   )   (single frame)   OR  ( List ( List (int, IntList  )  ) )  (multiple frames - where int is the corresponding keyFrame)
* hairVertices          -  ( VectorList )   (single frame)   OR  ( List ( List (int, VectorList) ) )  (multiple frames - where int is the corresponding keyFrame)
* hairVerticesPerStrand -  (  IntList   )   (single frame)   OR  ( List ( List (int, IntList  )  ) )  (multiple frames - where int is the corresponding keyFrame)
* hairWidths            -  (  FloatList )   (single frame)   OR  ( List ( List (int, FloatList ) ) )  (multiple frames - where int is the corresponding keyFrame)
* particleVertices      -  ( VectorList )   (single frame)   OR  ( List ( List (int, VectorList) ) )  (multiple frames - where int is the corresponding keyFrame)
* particleWidths        -  (  FloatList )   (single frame)   OR  ( List ( List (int, FloatList ) ) )  (multiple frames - where int is the corresponding keyFrame)

AnimatedTransform: A mapping type used in vray.Proxy.createMeshFile() and vray.Proxy.createCombinedMeshFile(). Keys:

* transforms - ( List (Transform) ) List of transformations contained in the animation. The size must be equal to the size of the keyFrames list. 
* keyFrames  - (   List (int)    )  List of keyFrames contained in the animation. The size must be equal to the size of the transformations list.

ProxyReadData: A dictionary object holding the data returned by vray.Proxy.readFullData() and vray.Proxy.readPreviewData(). Keys:

* vertices (VectorList) - Full mesh vertex positions array
* vertexIndices (IntList) - Indices in the vertex array for each triangle. Every 3 consecutive ints are one triangle.
* normals (VectorList) - Full mesh normal vectors array.
* normalIndices (IntList) - Indices in the normal for each triangle. Every 3 consecutive ints are one triangle
* materialIDs (IntList) - Material IDs for each consecutive triangle in the full mesh
* velocities (VectorList) - Velocity vectors for each vertex in the vertex array
* uvOriginalIndices (IntList) - Array with the original proxy file indices of the UV sets. They may not equal their index in the data arrays here
* uvSetNames (List(string)) - Names of the UV sets
* uvValues (List(VectorList)) - Array of arrays of UVW mapping coordinates for the given mapping channel index
* uvValueIndices (List(IntList)) - Array of index arrays for the coordinates in uvValues
* shaderNames (List(string)) - Names of shaders (materials)
* shaderIDs (IntList) - IDs of shaders (materials)
* objectInfoNames (List(string)) - Names of objects (geometry meshes)
* objectInfoIDs (IntList) - IDs of objects (geometry meshes)
* objectInfoVBegins (IntList) - Array of begin indices of the voxel range of geometry objects (vBegin is included in the range)
* objectInfoVEnds (IntList) - Array of end indices of the voxel range of geometry objects (vEnd is excluded from the range)
* hairObjectInfoNames (List(string)) - Names of hair objects
* hairObjectInfoIDs (IntList) - IDs of hair objects
* hairObjectInfoVBegins (IntList) - Array of begin indices of the voxel range of hair objects (vBegin is included in the range)
* hairObjectInfoVEnds (IntList) - Array of end indices of the voxel range of hair objects (vEnd is excluded from the range)
* particleObjectInfoNames (List(string)) - Names of particle objects
* particleObjectInfoIDs (IntList) - IDs of particle objects
* particleObjectInfoVBegins (IntList) - Array of begin indices of the voxel range of particle objects (vBegin is included in the range)
* particleObjectInfoVEnds (IntList) - Array of end indices of the voxel range of particle objects (vEnd is excluded from the range)
* hairVertices (VectorList) - Full array of the hair geometry vertices
* hairVerticesPerStrand (IntList) - Full array of the hair strands length data (The i-th strand has hairVerticesPerStrand[i] consecutive vertices in hairVertices)
* particleVertices (VectorList) - Full array of the particle geometry vertices
* voxelVerticesStartIndices (IntList) - Full array of indices, where the voxel vertices data starts - the i-th voxel starts at vertices[voxelVerticesStartIndices[i]]
* voxelVertexIndicesStartIndices (IntList) - Full array of indices, where the voxel vertex indices data starts - the i-th voxel starts at vertexIndices[voxelVertexIndicesStartIndices[i]]
* voxelNormalsStartIndices (IntList) - Full array of indices, where the voxel normals data starts - the i-th voxel starts at normals[voxelNormalsStartIndices[i]]
* voxelNormalIndicesStartIndices (IntList) - Full array of indices, where the voxel normalIndices data starts - the i-th voxel starts at normalIndices[voxelNormalIndicesStartIndices[i]]
* voxelMaterialIDsStartIndices (IntList) - Full array of indices, where the voxel materialIDs data starts - the i-th voxel starts at materialIDs[voxelMaterialIDsStartIndices[i]]
* voxelVelocitiesStartIndices (IntList) - Full array of indices, where the voxel velocities data starts - the i-th voxel starts at velocities[voxelVelocitiesStartIndices[i]]
* voxelUVValuesStartIndices (IntList) - Full array of indices, where the voxel UV values data starts - the j-th set of the i-th voxel starts at uvValues[voxelUVValuesStartIndices[j * geometryVoxels_count + i]]
* voxelUVValueIndicesStartIndices (IntList) - Full array of indices, where the voxel UV value indices data starts - the j-th set of the i-th voxel starts at uvValueIndices[voxelUVValueIndicesStartIndices[j * geometryVoxels_count + i]]
* geometryVoxelsBBoxes (VectorList) - Full array of bounding boxes of all geometry voxels
* hairVoxelsBBoxes (VectorList) - Full array of bounding boxes of all hair voxels
* particleVoxelsBBoxes (VectorList) - Full array of bounding boxes of all particle voxels
* hairVerticesStartIndices (IntList) - Full array of indices, where the hair vertices data starts - the i-th hair voxel starts at hairVertices[hairVerticesStartIndices[i]]
* hairVerticesPerStrandStartIndices (IntList) - Full array of indices, where the hair strands data starts - the strands data of the i-th hair voxel starts at hairVerticesPerStrand[hairVerticesPerStrandStartIndices[i]]
* particleVerticesStartIndices (IntList) - Full array of indices, where the particle vertices data starts - the i-th particle voxel starts at particleVertices[particleVerticesStartIndices[i]]
* edgeVisibility (IntList) - Array of edge visibility flags, each integer in the array has edge visibility information for 10 consecutive faces (3 bits per face).
* voxelInfoWireColor (ColorList) - Array of diffuse (wire) colors - 1 Color per mesh object
* voxelInfoSmoothed (IntList) - Array of smoothed flags (1 flag per mesh object - true if the voxel should be rendered with smoothed normals)
* voxelInfoFlipNormals (IntList) - Array of flipNormals flags (1 flag per mesh object - true if the geometric normals should be flipped)
* hairWidths (FloatList) - Full array of the hair geometry widths
* hairWidthsStartIndices (IntList) - Full array of indices, where the hair widths data starts - the i-th hair voxel starts at hairWidths[hairWidthsStartIndices[i]]
* particleWidths (FloatList) - Full array of the particle geometry widths
* particleWidthsStartIndices (IntList) - Full array of indices, where the particle widths data starts - the i-th particle voxel starts at particleWidths[particleWidthsStartIndices[i]]
* numFrames (int) - The number of frames in the file
* hasVelocityChannel (bool) - True, in case the currently read frame contains at least one of geometry / hair / particle velocity data
* hairVelocities (VectorList) - Velocity vectors for each vertex in the hairVertices array
* particleVelocities (VectorList) - Velocity vectors for each vertex in the particleVertices array
* hairVelocitiesStartIndices (IntList) - Full array of indices, where the hair velocities data starts - the i - th hair voxel starts at hairVelocities[hairVelocitiesStartIndices[i]]
* particleVelocitiesStartIndices (IntList) - Full array of indices, where the particle velocities data starts - the i - th particle voxel starts at particleVelocities[particleVelocitiesStartIndices[i]]

Integer constants, which could be combined and passed as flags to Proxy.readFullData and Proxy.readPreviewData:

* vray.READ_FLAGS_MESH_VERTICES
* vray.READ_FLAGS_MESH_NORMALS
* vray.READ_FLAGS_MESH_MTLIDS
* vray.READ_FLAGS_MESH_VELOCITIES`
* vray.READ_FLAGS_MESH_UVS
* vray.READ_FLAGS_MESH_SHADERS
* vray.READ_FLAGS_MESH_OBJECTINFOS
* vray.READ_FLAGS_MESH_HAIROBJECTINFOS
* vray.READ_FLAGS_MESH_PARTICLEOBJECTINFOS
* vray.READ_FLAGS_MESH_HAIRGEOMETRY
* vray.READ_FLAGS_MESH_PARTICLESGEOMETRY
* vray.READ_FLAGS_MESH_GEOMETRYMESHESBBOXES
* vray.READ_FLAGS_MESH_HAIROBJECTBBOXES
* vray.READ_FLAGS_MESH_PARTICLEOBJECTBBOXES
* vray.READ_FLAGS_MESH_ALL

Methods

__init__()

createCombinedMeshFile

Creates a vrmesh file from data stored in multiple plugins or in multiple mapping type objects.

createMeshFile

Creates a .vrmesh file from data stored in a plugin or in a mapping type object.

readFullData

Read the full data from a proxy file (.vrmesh, .abc)

readPreviewData

Read the preview data from a proxy file (.vrmesh, .abc)

readPreviewGeometry

Read simplified geometry preview data from a proxy file (.vrmesh, .abc)

readPreviewHair

Read simplified hair preview data from a proxy file (.vrmesh, .abc)

readPreviewParticles

Read simplified particles preview data from a proxy file (.vrmesh, .abc)

static createCombinedMeshFile()

Creates a vrmesh file from data stored in multiple plugins or in multiple mapping type objects.

The plugin types for geomPlugins could be:
  • one of these geometry types - GeomStaticMesh/GeomMayaHair/GeomParticleSystem

  • one of these instancer types - Instancer/Instancer2/GeomInstancer/GeomRayserverInstancer

  • Node with geometry property one of the supported geometry or instancer types

Keyword arguments:

  • geomPlugins - Obligatory. Either a list of plugins supplying the data to combine in the proxy file - see supported plugin types above

    or a list of mapping type objects for the data necessary to a export vrmesh with geometry, hair or particles. See the Proxy doc MeshFileData for keys description.

  • file - Obligatory. Destination filename (.vrmesh format).

  • transforms - Optional. A list of Transform objects for transforming the vertices and normals in 3D space. Must match the geomPlugins list.

  • animTransforms - Optional. A list of mapping type objects containing transformations at corresponding keyframes, to be written to the created file.

    The size must equal the geomPlugins list size. See the Proxy doc AnimatedTransform for keys description.

  • voxelElements - Optional. Target number of triangles in each voxel.

  • numPreviewElements - Optional. Number of preview triangles to generate. Set to 0 to disable preview. (default 10000)

  • previewType - Optional. One of ‘face_sampling’, ‘clustering’, ‘edge_collapse’ or ‘combined’ (default).

  • isAnimated - Optional. True if the mesh is animated.

  • startFrame - Optional. Where to start exporting the animation from.

  • endFrame - Optional. Where to stop exporting the animation.

  • objectNames - Optional. List of names to associate with respective meshes. This can be used to identify the pieces when reading the proxy.

  • objectIDs - Optional. List of unique IDs for the respective meshes. This should usually match Node.objectID values.

  • customPreviewFile - Optional. A file name to read and use its vertices and faces for the preview voxel.

  • mergeVoxels - Optional. Merge all voxels of the same type, before subdivision.

  • voxelInfoWireColor - List of diffuse (wire) colors - 1 Color per mesh object

  • voxelInfoSmoothed - List of smoothed flags (1 flag per mesh object - true if the voxel should be rendered with smoothed normals)

  • voxelInfoFlipNormals - List of flipNormals flags (1 flag per mesh object - true if the geometric normals should be flipped)

  • exportPointCloud - When enabled, adds a point cloud representation of the mesh separated into different levels of detail. The various levels of detail can be used by proxies for saving memory when rendering distant objects.

  • pointSize - Determines the size of point cloud disks at the most detailed level. If this value is small, point clouds rendered at the lowest level appear closer to original mesh but use more memory.

  • previewHairs - Optional. Number of preview hairs (default 1000)

  • previewParticles - Optional. Number of preview particles (default 20000)

  • bakeTransforms - Optional. When enabled (default), applies the input Transform(s) to the geometry data, otherwise writes the Transform(s) into separate data channel.

static createMeshFile()

Creates a .vrmesh file from data stored in a plugin or in a mapping type object.

The plugin types for geomPlugin could be:
  • one of these geometry types - GeomStaticMesh/GeomMayaHair/GeomParticleSystem

  • one of these instancer types - Instancer/Instancer2/GeomInstancer/GeomRayserverInstancer

  • Node with geometry property one of the supported geometry or instancer types

Keyword arguments:

  • geomPlugin - Obligatory. Either a plugin supplying the data for the proxy file - see supported plugin types above

    or a mapping type object with the data necessary to a export vrmesh with geometry, hair or particles. See the Proxy doc MeshFileData for keys description.

  • file - Obligatory. Destination filename (.vrmesh format).

  • transform - Optional. A Transform object for transforming the vertices and normals in 3D space.

  • animTransform - Optional. A mapping type object containing transformations at corresponding keyframes, to be written to the created file.

    See the Proxy doc AnimatedTransform for keys description.

  • voxelElements - Optional. Target number of triangles in each voxel.

  • numPreviewElements - Optional. Number of preview triangles to generate. Set to 0 to disable preview. (default 10000)

  • previewType - Optional. One of ‘face_sampling’, ‘clustering’, ‘edge_collapse’ or ‘combined’ (default).

  • isAnimated - Optional. True if the mesh is animated.

  • startFrame - Optional. Where to start exporting the animation from.

  • endFrame - Optional. Where to stop exporting the animation.

  • objectName - Optional. A name to associate with the mesh. This can be used to identify the object when reading the proxy.

  • objectID - Optional. A unique ID for the mesh. This should usually match a Node.objectID value.

  • customPreviewFile - Optional. A file name to read and use its vertices and faces for the preview voxel.

  • mergeVoxels - Optional. Merge all voxels of the same type, before subdivision.

  • voxelInfoWireColor - List of diffuse (wire) colors - 1 Color per mesh object

  • voxelInfoSmoothed - List of smoothed flags (1 flag per mesh object - true if the voxel should be rendered with smoothed normals)

  • voxelInfoFlipNormals - List of flipNormals flags (1 flag per mesh object - true if the geometric normals should be flipped)

  • exportPointCloud - When enabled, adds a point cloud representation of the mesh separated into different levels of detail. The various levels of detail can be used by proxies for saving memory when rendering distant objects.

  • pointSize - Determines the size of point cloud disks at the most detailed level. If this value is small, point clouds rendered at the lowest level appear closer to original mesh but use more memory.

  • previewHairs - Optional. Number of preview hairs (default 1000)

  • previewParticles - Optional. Number of preview particles (default 20000)

  • bakeTransforms - Optional. When enabled (default), applies the input Transform(s) to the geometry data, otherwise writes the Transform(s) into separate data channel.

static readFullData()

Read the full data from a proxy file (.vrmesh, .abc)

Arguments:
  • proxyPlugin - Obligatory. A GeomMeshFile plugin instance to read the file path and parameters from or

    a mapping type object containing the necessary parameters. See the Proxy doc ProxyReadParams for keys description.

  • flags - Optional (int) flags defining, which parts of the data to be read. If omitted, vray.READ_FLAGS_MESH_ALL is assumed.

    The integer constants vray.READ_FLAGS_MESH_VERTICES, vray.READ_FLAGS_MESH_NORMALS and so on can be used or combined.

Returns a dictionary object, containing the data. See the Proxy doc ProxyReadData for keys description.

static readPreviewData()

Read the preview data from a proxy file (.vrmesh, .abc)

Arguments:
  • proxyPlugin - Obligatory. A GeomMeshFile plugin instance to read the file path and parameters from or

    a mapping type object containing the necessary parameters. See the Proxy doc ProxyReadParams for keys description.

  • flags - Optional (int) flags defining, which parts of the data to be read. If omitted, vray.READ_FLAGS_MESH_ALL is assumed.

    The integer constants vray.READ_FLAGS_MESH_VERTICES, vray.READ_FLAGS_MESH_NORMALS and so on can be used or combined.

Returns a dictionary object, containing the data. See the Proxy doc ProxyReadData for keys description.

static readPreviewGeometry()

Read simplified geometry preview data from a proxy file (.vrmesh, .abc)

Arguments:
  • proxyPlugin - Obligatory. A GeomMeshFile plugin instance to read the file path and parameters from or

    a mapping type object containing the necessary parameters. See the Proxy doc ProxyReadParams for keys description.

  • countHint - Optional. (int) number of triangles to return. The exact number of elements in ‘vertices’ may differ slightly.

If countHint is not specified, proxyPlugin.num_preview_faces or readParams.num_preview_faces is used.

Returns a tuple (vertices, indices) or None on failure:
  • vertices, VectorList - Output vertex preview data. The array can be passed on directly to DirectX/OpenGL etc. (and the indices too)

  • indices, IntList - Output face index data. Each three consecutive elements make up one triangle

static readPreviewHair()

Read simplified hair preview data from a proxy file (.vrmesh, .abc)

Arguments:
  • proxyPlugin - Obligatory. A GeomMeshFile plugin instance to read the file path and parameters from or

    a mapping type object containing the necessary parameters. See the Proxy doc ProxyReadParams for keys description.

  • countHint - Optional. (int) number of triangles to return. The exact number of elements in ‘vertices’ may differ slightly.

If countHint is not specified, proxyPlugin.num_preview_faces or readParams.num_preview_faces is used.

Returns a tuple (vertices, lengths) or None on failure:
  • vertices, VectorList - Output vertex preview data. Consecutive vertices form hair strands. The i-th strand has lengths[i] consecutive vertices

  • lengths, FloatList - Output hair strand length data. Each strand can have a different number of vertices

static readPreviewParticles()

Read simplified particles preview data from a proxy file (.vrmesh, .abc)

Arguments:
  • proxyPlugin - Obligatory. A GeomMeshFile plugin instance to read the file path and parameters from or

    a mapping type object containing the necessary parameters. See the Proxy doc ProxyReadParams for keys description.

  • countHint - Optional. (int) number of triangles to return. The exact number of elements in ‘vertices’ may differ slightly.

If countHint is not specified, proxyPlugin.num_preview_faces or readParams.num_preview_faces is used.

Returns a positions list (VectorList) or None on failure: