vrdGeometryNode

class vrdGeometryNode

(Inherits vrdTransformNode)

This class gives low level access to geometry data. It allows to make changes to vertices, normals and texture coordinates.

A short introduction how geometries work: A geometry consists of primitives, for example triangles or lines. The 3D coordinates of those primitives are stored in the ‘positions’ list. Note that the positions list is a flat list of float values, not points. That means, the position (x/y/z coordinates) of a vertex is represented by three consecutive float values in the list.

The indices list defines which vertices form a primitive, for example a triangle. An entry of the indices list is a vertex index that points to the vertex data. This way you can use the vertex in multiple primitives. A triangle has three vertices, so it has three indices, one for each vertex. Each triangle has three consecutive vertex indices in the indices list.

You can use the value from the index list to calculate which three floats from the position list are the position of a vertex. If for example the index list contains the value ‘7’, then the floats from the position list would be ‘7*3=21’, ‘7*3+1=22’ and ‘7*3+2=23’. So index 21, 22, and 23 of the positions list are the three consecutive floats for value 7 from the index list.

lineGeometry-texCoords.py
    def getPosition(self, vertexIndex):
        """
            Args:
                vertexIndex (int): The vertex index in range from 0 to N-1
                                   where N is the vertex count.
            Returns:
                3d vertex position.
        """
        return QVector3D(self.__positions[3*vertexIndex],
                         self.__positions[3*vertexIndex+1],
                         self.__positions[3*vertexIndex+2])

The values for the normals are calculated in the same way. You just need to do the lookup in the ‘normals’ list instead.

The supported primitive types are triangle, lines, line strips, and points. The indices list for those primitives must be built as follows:

- for triangles, 3 vertex indices per triangle.
- for lines, 2 vertex indices per line
- for line strips, a line is build from the first and second index, second and third, and so on.
- for points, 1 vertex index per point.

Functions

vrdGeometryNode.createTextureBake()

Creates an empty texture bake object.

The function will create an empty texture bake object. This object can e.g. be used to set a new lightmap image.

Returns:The texture bake object.
Return type:vrdTextureBake
vrdGeometryNode.getActiveBakeType()
Returns:The active bake type.
Return type:vrBakeTypes.BakeType
vrdGeometryNode.getIndices()

Gets the list of indices.

The indices define how the vertices of the geometry data are connected.

Returns:The list of indices.
Return type:List[integer]
vrdGeometryNode.getNormals()

Gets the normals of the geometry.

Returns the vertex normals as a list of floating point values. These are 3d vectors (x,y,z) so every three consecutive floats represent a vertex normal of the geometry.

Returns:The normals as a list of floating point values.
Return type:List[float]
vrdGeometryNode.getPositions()

Gets the positions of the geometry.

This provides access to the vertex positions as a list of floats. These are 3d coordinates (x,y,z) so every three consecutive floats represent a vertex position of the geometry.

Returns:The positions of the geometry as a list of floating point values.
Return type:List[float]
vrdGeometryNode.getPrimitiveCount()

Gets the primitive count (number of triangles, lines, or points in this geometry).

Returns:The primitive count.
Return type:integer
vrdGeometryNode.getPrimitiveType()

Gets the primitive type.

Returns:The primitive type used to render the geometry.
Return type:vrGeometryTypes.PrimitiveType
vrdGeometryNode.getTexCoords(texSlot=0)

Gets the texture coordinates.

Returns the texture coordinates as a list of floating point values. The number of values per coordinate depends on the dimension of the texSlot. VRED uses 2d coordinates in slot 0 for material textures. See also setTexCoords and getTexCoordsDimension.

Parameters:texSlot (integer) – The texture slot (0 to 7, default: slot 0)
Returns:The texture coordinates as a list of floating point values.
Return type:List[float]
vrdGeometryNode.getTexCoordsDimension(texSlot=0)

Returns the dimension of the texture coordinates.

Depending of the dimension of the texture coordinates, valid values are 2, 3 or 4.

Parameters:texSlot (integer) – The texture slot (0 to 7, default: 0)
Returns:The texture coordinates dimension.
Return type:integer
vrdGeometryNode.getTextureBake()

Gets the texture bake object.

The function will return a null object, if the geometry node doesn’t contain any texture baking.

Returns:The texture bake object.
Return type:vrdTextureBake
vrdGeometryNode.getTextureBakeState()
Returns:The texture bake state.
Return type:vrBakeTypes.BakeState
vrdGeometryNode.getVertexBake()

Gets the vertex bake object.

The function will return a null object, if the geometry node doesn’t contain any vertex baking.

Returns:The vertex bake object.
Return type:vrdVertexBake
vrdGeometryNode.getVertexBakeState()
Returns:The vertex bake state.
Return type:vrBakeTypes.BakeState
vrdGeometryNode.getVertexCount()
Returns:The number of vertices.
Return type:integer
vrdGeometryNode.hasUVSet(set)

Checks the existance of a specific UV set.

Parameters:set (vrUVTypes.UVSet) – The UV set to check for.
Returns:True if the UV set exists, False otherwise.
Return type:bool
vrdGeometryNode.isBSide()

Determines if the geometry is classified as a B-Side.

Returns:True if B-Side, False if it is classified as an A-Side.
Return type:bool
vrdGeometryNode.isComponent()

Returns whether the geometry node is a surface within a shell.

Returns:True if geometry node is a component, False otherwise.
Return type:bool
vrdGeometryNode.isMesh()

Returns whether the geometry node is a mesh of polygons or lines.

Returns:True if geometry node is a mesh, False otherwise.
Return type:bool
vrdGeometryNode.isShell()

Returns whether the geometry node is a shell. A shell holds multiple surfaces and has no primitive data itself.

Returns:True if geometry node is a shell, False otherwise.
Return type:bool
vrdGeometryNode.isSurface()

Returns whether the geometry node is a surface with nurbs data.

Returns:True if geometry node is a surface, False otherwise.
Return type:bool
vrdGeometryNode.setActiveBakeType(type)

Sets the active bake type.

This determines which bake data will be used for rendering.

Parameters:type (vrBakeTypes.BakeType) – The bake type.
vrdGeometryNode.setBSide(isBSide)

Sets the geometry to B-Side.

Parameters:isBSide (bool) – True if the geometry is classified as a B-Side, False if it is classified as an A-Side.
vrdGeometryNode.setIndices(indices)

Sets the list of indices.

The indices in the index list refere to values of the positions list.

Parameters:indices (List[integer]) – The list of indices
vrdGeometryNode.setNormals(normals)

Sets the normals.

Sets the vertex normals as a list of floating point values. Three consecutive values represent a vertex normal. The size of the normal buffer should be the same as the positions buffer.

Parameters:normals (List[float]) – The normals as a list of floating point values.
vrdGeometryNode.setPositions(positions)

Sets the positions of the geometry.

Sets the vertex positions as a list of floating point values. Three consecutive values represent a vertex position. The number of positions in the list must be divisible by three with no remainder.

Parameters:positions (List[float]) – The positions of the geometry as a list of floating point values.
vrdGeometryNode.setPrimitiveType(primitiveType)

Sets the primitive type.

This determines which primitive type will be used to render the geometry (triangles / points / lines).

Parameters:primitiveType (vrGeometryTypes.PrimitiveType) – The primitive type.
vrdGeometryNode.setTexCoords(coordinates, texSlot=0, dimension=2)

Sets the texture coordinates.

Sets the texture coordinates as a list of floating point values. The range of available slots is 0 to 7. Valid dimensions are 2, 3 and 4. Note: VRED currently uses 2d coordinates in slot 0 for material and slot 1 for lightmap textures. Slot 5 is internally used to store vertex ambient occlusion data while slot 7 is used for vertex light baking data. Setting an empty list will remove the corresponding texture coordinates.

Parameters:
  • coordinates (List[float]) – The list of texture coordinates as floating point values.
  • texSlot (integer) – The texture slot (0 to 7)
  • dimension (integer) – The dimension (2, 3 or 4)