On this page | |
Inheritance |
|
Overview ¶
hou.GeometryDrawableGroup
acts as a regular hou.GeometryDrawable object which can contain several
hou.GeometryDrawable
children. hou.GeometryDrawableGroup
performs operations on its children in the order
they were added. You can also query specific children from hou.GeometryDrawableGroup
for setting their
parameters individually.
Here’s an example that creates a group composed of two hou.GeometryDrawable
objects.
import hou import viewerstate.utils as su class State(object): def __init__(self, state_name, scene_viewer): self.state_name = state_name self.scene_viewer = scene_viewer # create the geometry sops = hou.sopNodeTypeCategory() verb = sops.nodeVerb('tube') verb.setParms({ "rad": (0.2, 0.4), "rows": 3, "cols": 6, 'height': 1.0, "cap":True }) geo = hou.Geometry() verb.execute(geo, []) # creates the drawable group self.cursor = hou.GeometryDrawableGroup("cursor") # adds the drawables self.cursor.addDrawable( hou.GeometryDrawable( self.scene_viewer, hou.drawableGeometryType.Face, "face", params = {'color1' : (0.0,1.0,0.0,1.0)} )) self.cursor.addDrawable( hou.GeometryDrawable(self.scene_viewer, hou.drawableGeometryType.Line, "line", params = {'color1' : (0,0,0,1.0)} )) # set the geometry on all children self.cursor.setGeometry(geo) self.cursor.show(False) self.cursor_pos = hou.Vector3() def onMouseEvent(self, kwargs): ui_event = kwargs["ui_event"] (origin, dir) = ui_event.ray() gi = su.GeometryIntersector(kwargs["node"].geometry()) gi.intersect(origin, dir) if gi.intersected: self.cursor_pos = gi.position self.cursor.show(True) else: self.cursor.show(False) def onDraw(self, kwargs): handle = kwargs['draw_handle'] params = { 'translate' : (self.cursor_pos[0], self.cursor_pos[1], self.cursor_pos[2]), 'line_width' : 0.25 } self.cursor.draw( handle, params )
Methods ¶
__init__(name, label=None)
Creates a new geometry drawable group object. The new object is empty and must be filled with
hou.GeometryDrawable
objects to be useful.
name
Name of the drawable group.
label
An optional string for the drawable label. Defaults to empty.
addDrawable(geometry_drawable)
Adds a hou.GeometryDrawable object at the end of the children.
geometry_drawable
The hou.GeometryDrawable to add.
drawables(): ->
list` of hou.GeometryDrawable
Returns a list of all children.
setGeometry(geometry)
Sets all drawable children with a new geometry. The changes will appear the next time the viewer redraws.
geometry
A hou.Geometry object.
geometry()
: → hou.Geometry
Returns the drawable’s geometry object. The returned geometry is read-only
.
useClipPlane(value)
Enable or disable the clip plane on all drawables in this group. By default the clip plane for all drawables are disabled.
value
True
to enable the clip plane on all drawables and False
to disable it.
Methods from hou.Drawable ¶
name()
The name of this drawable.
label()
The label of this drawable.
setLabel(label)
Set the label for this drawable.
show(value)
Displays or hides the element attached to this drawable in the viewport. The element will appear the next time the viewer redraws.
value
True
to show the element or False
to hide it.
visible()
→ bool
Returns True if the drawable is visible or not.
setTransform(xform)
Sets the transform matrix of the element attached to this drawable. The changes will appear the next time the viewer redraws.
xform
A hou.Matrix4 transformation matrix to set the element’s translation, rotation, and scale.
transform()
: → hou.Matrix4
Returns the transform matrix of the element attached to the drawable.
Methods from hou.AdvancedDrawable ¶
setParams(params)
Sets the parameters of the drawable. The settings will take effect in the viewport the next time hou.AdvancedDrawable.draw is called.
params
A dictionary of parameters for setting the drawable options. Each drawable type uses a specific set of parameters, detailed information can be found in the drawable derived class params documentation such as GeometryDrawable and TextDrawable.
The following are parameters common to all hou.AdvancedDrawable
types:
|
Vector representing an For hou.TextDrawable, |
|
|
Vector representing an For instance, |
|
|
double |
Value used as the occlusion factor of the overlay in areas occluded by the existing geometry as determined by the depth buffer. A fade factor of 1.0 means no distinction must be made and a value of 0.0 completely hides occluded parts. Defaults to 0. |
|
int |
Sets the glow width value. For instance, this changes the glow width of line segments or text. Defaults to 0. |
|
Sets the mode for highlighting the generated matte of the drawable. Defaults to hou.drawableHighlightMode.Matte. |
|
|
hou.Vector3 or sequence of 3 doubles |
Position of the geometry in 3D space. For hou.TextDrawable, it’s the position of the text to display in viewport coordinates. Defaults to hou.Vector3(0, 0, 0). |
|
hou.Vector3 or sequence of 3 doubles |
Rotation vector in degrees. Defaults to hou.Vector3(0, 0, 0). |
|
hou.Vector3 or sequence of 3 doubles |
Scaling vector. Defaults to hou.Vector3(1, 1, 1). |
|
Sequence of doubles or ints |
Assigns a 2D window to the viewport, in viewport coordinates, for drawing a geometry. The sequence defines the location and size of the window, and must contain the following values:
|
|
Bool |
Specifies if the drawable should use the |
|
Bool |
Specifies if the drawable should use the |
draw(handle, params=None)
Method implemented by leaf classes to support the drawing of elements in a viewport. This method should normally be called from the python state onDraw or onDrawInterrupt event to render the drawable in the current viewport.
handle
This is an opaque value created by Houdini to render the drawable. This handle
value is passed
to the python state onDraw
callback by Houdini and should be passed directly to the drawable object’s draw
method.
params
An optional dictionary of parameters for setting the drawable parameters. These are the same parameters hou.AdvancedDrawable.setParams is using.
See also |