Custom Viewer State: Temporarily enter another state?

   924   4   1
User Avatar
Member
41 posts
Joined: Feb. 2018
Offline
I'm trying to write a custom Python SOP viewer state, where, whenever I start dragging the mouse:
  • If some visible geometry is under the cursor when the dragging starts, do something in my custom state.
  • If no visible geometry is under the cursor when the dragging starts, temporarily enter the `sopview` state (manipulating the viewport camera). Return to my custom state when the dragging stops.

So it's like a ZBrush style camera manipulator, where you don't have to hold down the Option/Alt key to transform the camera, as long as nothing is under the cursor when you start a mouse drag.

Any idea on how I should implement this?
User Avatar
Staff
399 posts
Joined: Feb. 2018
Offline
The first seems feasible with onMouseEvent by testing for a visible geometry when LMB is down. For the second one I don't think what you suggest is feasible. Did you consider using the same python state instead ? With onMouseEvent you could manipulate the viewport camera when there is no visible geometry under the mouse like you said.
User Avatar
Member
41 posts
Joined: Feb. 2018
Offline
mabelzile
Did you consider using the same python state instead ? With onMouseEvent you could manipulate the viewport camera when there is no visible geometry under the mouse like you said.

Thanks mab! I'll do that. I thought about it but was too lazy..

Btw, do you happen to have any example file on viewport camera manipulation? Again I'm just a bit lazy so if you don't have one at the moment I'll go figure it out by myself.
Edited by AlanZ - Jan. 10, 2020 10:08:03
User Avatar
Staff
399 posts
Joined: Feb. 2018
Offline
AlanZ
mabelzile
Did you consider using the same python state instead ? With onMouseEvent you could manipulate the viewport camera when there is no visible geometry under the mouse like you said.

Thanks mab! I'll do that. I thought about it but was too lazy..

Btw, do you happen to have any example file on viewport camera manipulation? Again I'm just a bit lazy so if you don't have one at the moment I'll go figure it out by myself.
I don't but take a look at hou.GeometryViewport.defaultCamera()
User Avatar
Member
41 posts
Joined: Feb. 2018
Offline
Thanks again mab!
  • Quick Links