Inheritance |
|
hou.ViewerEvent
objects are used with Python states. Houdini will call event handlers with a dictionary containing various useful data, including a ui_event
key containing a ViewerEvent
object. You do not instantiate this type of object yourself.
See Python states for more information.
hou.ViewerEvent
is a specialized hou.UIEvent class that you can used for accessing ray coordinates in a viewer.
Methods ¶
ray()
→ (origin_point, direction)
Returns a tuple of two hou.Vector3 objects representing the origin point and a direction vector of a “pointing ray” in 3D world space corresponding to the underlying hou.UIEventDevice's mouse coordinates in screen space.
The resulting ray can be used to shoot into the scene that passes through whatever is under the mouse. The method puts the ray origin at the mouse screen coordinates on the near plane and then maps the camera space position to world space. For a perspective projection, the near plane part of the frustum is usually small in world space, so the origin point will be pretty close to the camera position.
snappingRay()
→ dict
Same as hou.ViewerEvent.ray, but the returned original point may be snapped with respect to scene geometry, the Houdini construction or the reference plane. Snapping is performed using the settings from the snapping options window available on the left side of the viewport. The dictionary contains the following key/value pairs:
Key |
Type |
Description |
---|---|---|
|
Bool |
True if the user snapped to scene geometry, to the Houdini construction plane, or to the reference plane in the viewport. |
|
The origin of a “pointing ray” in 3D world space corresponding to
the mouse coordinates in screen space. If |
|
|
The direction vector of a “pointing ray” in 3D world space
corresponding to the mouse coordinates in screen space. It may be
moved from the actual mouse position if |
|
|
The position that was snapped to, in 3D world space. This key is
only included if |
|
|
The type of geometry which was snapped to. This key is only
included if |
|
|
int |
The session node id of the node whose geometry has been snapped to. The node itself can be retrieved by calling hou.nodebySessionId(). |
|
int |
The primitive number corresponding to the snapped geometry. This is
only included in the dictionary if |
|
int |
The point number corresponding to the snapped geometry. This is
only included in the dictionary if |
|
int |
The first endpoint of the snapped edge. This is only included in
the dictionary if |
|
int |
The second endpoint of the snapped edge. This is only included in
the dictionary if |
|
int |
The first coordinate of the snapped breakpoint. This is only
included in the dictionary if |
|
int |
The second coordinate of the snapped breakpoint. This is only
included in the dictionary if |
|
int |
The index of the guide corresponding to the snapped geometry. This
is only included in the dictionary if |
|
The position on the grid of the snapped geometry. This is only
included in the dictionary if |
|
|
The position on the grid of the first endpoint of the snapped edge.
This is only included in the dictionary if |
|
|
The position on the grid of the second endpoint of the snapped
edge. This is only included in the dictionary if |
Note
snapped
will always be False if snapping is not enabled in the
viewport. See hou.SceneViewer.setSnappingMode to change the
current snapping mode.
screenToRay(scrx, scry)
→ (origin_point, direction)
Returns a tuple of two hou.Vector3 objects representing the origin point and a direction vector of a “pointing ray” in 3D world space corresponding to the provided mouse coordinates in screen space.
curViewport()
→ hou.GeometryViewport
Returns the viewport this event occurred within.
Methods from hou.UIEvent ¶
device()
→ hou.UIEventDevice
Returns an object containing input-device-specific event data.
For example, if this is a mouse click event, you can use event.device().mouseX()
to get the X coordinate in screen space, and event.device().isLeftButton()
to check whether the left mouse button was pressed.
if ui_event.device().isLeftButton(): ...
hasQueuedEvents()
→ bool
Returns true if this event contains queued device events.
queuedEvents()
→ list
of hou.UIEventDevice
If hou.UIEvent.hasQueuedEvents returns True, this method returns the list of queued input device events.
value()
→ obj
Returns the value
payload of this event. You can tell the type of this value by calling hou.UIEvent.valueType.
valueType()
→ hou.uiEventValueType
Returns an enum value corresponding to the event value’s type, or hou.uiEventValueType.NoType
if the event contains no single scalar value.
reason()
→ hou.uiEventReason
For events related to state changes, returns an enum value representing the type of state change that triggered the event.
See also |