Inheritence |
|
Methods
sample(position)
→ float
Given a sequence of three floats containing a 3D position, return the value of the volume at that position. If the position is not in the middle of a voxel, Houdini will interpolate using values from surrounding voxels.
See also hou.VDB.voxel() and hou.VDB.posToIndex().
gradient(position)
→ hou.Vector3
Given a sequence of three floats containing a 3D position, return a vector which points in the direction of the greatest rate of increase of the volume’s value.
See Wikipedia’s gradient page for more information.
voxel(index)
→ float
Given a sequence of three integers containing a voxel index, return the value of the corresponding voxel.
resolution()
→ hou.Vector3
Return the x, y, and z dimensions of hou.VDB.activeVoxelBoundingBox(). Since VDB volumes are sparse, this represents the virtual resolution of all the voxels which have data (or are "active").
indexToPos(index)
→ hou.Vector3
Given a sequence of three ints containing an index into the voxel array, return the corresponding 3D position of the middle of that voxel.
posToIndex(position)
→ tuple
of int
Given a sequence of three floats containing a 3D position, return a tuple of three ints containing the corresponding index into the voxel array.
isSDF()
→ bool
Return whether or not the volume should be semantically treated as a signed distance field. If true, the volume can be thought of as representing a closed surface, where the negative voxel values are inside, the positive voxel values are outside, and voxels on the surace are zero.
For VDB volumes, there is typically only a 3 voxel radius around the surface where there exists data.
transform()
→ hou.Matrix3
Return a 3×3 matrix containing the scale and rotation transformations for this volume.
Note that the position information for the volume can be obtained by
calling volume.vertex(0).point().position()
.
The following function returns a 4×4 transformation matrix for the volume that includes the translation:
def fullTransform(volume): return (hou.Matrix4(volume.transform()) * hou.hmath.buildTranslate(volume.vertex(0).point().position()))
Note
You need to get the object node’s transform to get to worldspace.
taper()
→ int
Returns the taper value of the volume’s transform. For untapered transforms, this value will be 1.
isEmpty()
→ bool
Returns whether the VDB volume has no data.
activeVoxelCount()
→ int
Returns the number of active voxels in the volume.
activeVoxelBoundingBox()
→ hou.BoundingBox
Returns the smallest exclusive bounding box within the VDB volume that has active voxels.
voxelSize()
→ hou.Vector3
Returns the size of voxels within the VDB volume. All voxels will be of this size for untapered volumes. For tapered volumes, this size represents the size of voxel at the origin of the frustum.
dataType()
→ hou.vdbData
Returns the voxel data type within the VDB volume.
voxelRange(range)
→ tuple of bool, float, int, or hou.Vector3
Return a tuple containing the values of all voxels withing a bounding box range. It is faster to call this method to retrieve all the voxels than it is to loop through the voxel array in Python.
The result voxel type is determine by the underlying hou.VDB.dataType().
This method can be approximately implemented as follows (though this Python implementation is much slower):
def allVoxels(self): result = [] xres, yres, zres = self.activeVoxelBoundingBox() for z in range(zres): for y in range(yres): for x in range(xres): result.append(self.voxel((x, y, z))) return tuple(result)
See also hou.VDB.voxelRangeAsBool(), hou.VDB.voxelRangeAsFloat(), hou.VDB.voxelRangeAsInt(), hou.VDB.voxelRangeAsVector3().
voxelRangeAsBool(range)
→ tuple of bool
Return a tuple containing the values of all voxels withing a bounding box range. It is faster to call this method to retrieve all the voxels than it is to loop through the voxel array in Python.
See help for hou.VDB.voxelRange() for implementation details.
voxelRangeAsFloat(range)
→ tuple of float
Return a tuple containing the values of all voxels withing a bounding box range. It is faster to call this method to retrieve all the voxels than it is to loop through the voxel array in Python.
See help for hou.VDB.voxelRange() for implementation details.
voxelRangeAsInt(range)
→ tuple of int
Return a tuple containing the values of all voxels withing a bounding box range. It is faster to call this method to retrieve all the voxels than it is to loop through the voxel array in Python.
See help for hou.VDB.voxelRange() for implementation details.
voxelRangeAsVector3(range)
→ tuple of hou.Vector3
Return a tuple containing the values of all voxels withing a bounding box range. It is faster to call this method to retrieve all the voxels than it is to loop through the voxel array in Python.
See help for hou.VDB.voxelRange() for implementation details.
Methods from hou.Prim
attribValue(name_or_attrib)
→ int
, float
, str
or tuple
Return the value stored in this primitive for a particular attribute. The attribute may be specified by name or by hou.Attrib object.
Looking an attribute value using a hou.Attrib object is slightly faster than looking it up by name. When looking up attribute values inside a loop, look up the hou.Attrib object outside the loop, and pass it into this method.
When looking up the attribute values of all primitives, it is faster to call hou.Geometry.primFloatAttribValues() or hou.Geometry.primFloatAttribValuesAsString() than to call this method for each primitive in the geometry.
Raises hou.OperationFailed if no attribute exists with this name.
floatAttribValue(attrib)
→ float
Return the primitive attribute value for a particular floating point attribute. The attribute may be specified by name or by hou.Attrib object.
Raises hou.OperationFailed if no attribute exists with this name or the attribute is not float of size 1.
In most cases, you’ll just use hou.Prim.attribValue() to access attribute values. Houdini uses this method internally to implement attribValue.
floatListAttribValue(name_or_attrib)
→ tuple
of float
Return the primitive attribute value for a particular floating point attribute. The attribute may be specified by name or by hou.Attrib object. The return value is a tuple of floats.
It is valid to call this method when the attribute’s size is 1. In this case, a tuple with one element is returned.
See also hou.Prim.attribValue().
intAttribValue(name_or_attrib)
→ int
Return the primitive attribute value for a particular integer attribute of size 1. The attribute may be specified by name or by hou.Attrib object. See hou.Point.floatAttribValue() for more information.
intListAttribValue(name_or_attrib)
→ tuple
of int
Return the primitive attribute value for a particular integer attribute. The attribute may be specified by name or by hou.Attrib object. The return value is a tuple of ints. See hou.Prim.floatListAttribValue() for more information.
stringAttribValue(name_or_attrib)
→ str
Return the primitive attribute value for a particular string attribute. The attribute may be specified by name or by hou.Attrib object. See hou.Prim.floatAttribValue() for more information.
stringListAttribValue(name_or_attrib)
→ tuple
of str
Return the primitive attribute value for a particular string attribute. The attribute may be specified by name or by hou.Attrib object. The return value is a tuple of strings.
It is valid to call this method when the attribute’s size is 1. In this case, a tuple with one element is returned.
See also hou.Prim.attribValue().
setAttribValue(name_or_attrib, attrib_value)
Store an attribute value in this primitive. The attribute may be specified by name or by hou.Attrib object, and must be an existing primitive attribute in the geometry. You would typically call this method from the code of a Python-defined SOP.
Raises hou.OperationFailed if no attribute exists with this name or if the attribute’s data type does not match the value passed in. If the attribute’s size is more than 1, the attribute value must be a sequence of integers/floats, and the size of the sequence must match the attribute’s size.
Raises hou.GeometryPermissionError if this geometry is not modifiable.
# Create a float primitive attribute of size 3 named "Cd", and assign # each primitive a unique color. This code will work from inside a Python # SOP, but not from the Python shell. geo = hou.pwd().geometry() color_attrib = geo.addAttrib(hou.attribType.Prim, "Cd", (1.0, 1.0, 1.0)) num_prims = len(geo.prims()) color = hou.Color() for prim in geo.prims(): fraction = float(prim.number()) / num_prims # Give each primitive a different hue, but full saturation and value. # Store the RGB value in the attribute. color.setHSV((fraction * 255, 1, 1)) prim.setAttribValue(color_attrib, color.rgb())
attribType()
→ hou.attribType enum value
Return the enumerated value hou.attribType.Prim. Points, primitives, vertices, and geometry support the same set of methods for querying their attributes, and this method is one of them.
See also:
intrinsicValueDict()
→ dict
of str
to value
Returns a dictionary mapping intrinsic names to their values.
intrinsicValue(intrinsic_name)
→ int
, float
, str
, or tuple
intrinsicNames()
→ tuple
of str
setIntrinsicValue(intrinsic_name, value)
intrinsicReadOnly(intrinsic_name)
→ bool
intrinsicSize(intrinsic_name)
→ int
positionAtInterior(u, v, w=0.0)
→ hou.Vector3
Given normalized (i.e. from 0 to 1) u, v, w values, return the interior position of the primitive at that parametric location.
Use hou.Face.positionAt() for querying positions along the perimeter.
attribValueAtInterior(attrib_or_name, u, v, w=0.0)
→ int
, float
, str
or tuple
Return an attribute value at the normalized u, v, w parametric position in the interior of the primitive.
Raises hou.OperationFailed if the attribute is not a point or vertex attribute. If you want a primitive attribute value, it doesn’t vary across the surface, so use hou.Prim.attribValue().
Use hou.Face.attribValueAt() for querying attributes along the perimeter.
geometry()
→ hou.Geometry
Return the hou.Geometry object containing this primitive.
number()
→ int
Return the number of this primitive. Primitives are numbered sequentially starting from 0, and the primitives returned by hou.Geometry.prims() are in order by their number.
type()
→ hou.primType enum value
Return a hou.primType value containing the type of this primitive (e.g. polygon, NURBS curve, metaball, etc).
vertices()
→ generator of hou.Vertex
Return a sequence of the vertices contained in this primitive.
If the primitive is a face (e.g. a polygon or NURBS curve), the result corresponds to the order of the vertices in that face. If it is a surface (e.g. a NURBS mesh), however, the primitive has a 2D array of vertices, and this method returns all vertices in the 2D array, ordered by the rows.
See hou.Surface.vertex() for more information about the relationship between the 2D vertex array and the sequential vertex index, and for more ways to access the vertices in a surface.
numVertices()
→ int
A shortcut for len(self.vertices())
. You probably don’t need to call
this method.
vertex(index)
→ hou.Vertex
A shortcut for self.vertices()[index]
. You probably don’t need to
call this method.
This method supports negative indices to index from the end, just like
self.vertices()[index]
would. Also, like Python’s indexing operator,
it will raise IndexError when the index is out of range.
isSplineType()
→ bool
boundingBox()
→ hou.BoundingBox
Return an axis-aligned 3D bounding box that is sized and positioned to be large enough to hold this primitive.
nearestToPosition(pos3)
Given a sequence of three floats containing a position, find the location on this primitive that is closest to that position. Returns a tuple containing the u value on this primitive, the v value on this primitive, and the distance to this primitive.
minDistanceToPrim(prim)
ourUVAtClosestLocationToPrim(prim)
groups()
→ tuple
of hou.PrimGroup
Return a tuple of the primitive groups that contain this primitive.