Jump to content

pane size and position


peliosis

Recommended Posts

Hello guys,

Do you know a way to acquire pane size and position in pixels of sceneViewer?

I try to get position of mouse in 3d viewport.

The solution could be remapping what mouse CHOP spits out to 3D viewport and transforming it to current camera space.

I hoped it's stored in hou.Pane hou.SceneViewer but can't find it.

Maximizing viewport would do the trick but it's dirty.

Link to comment
Share on other sites

Thanks Graham,

So I assume hscript also doesn't have this functionality, otherwise it could be wrapped with hou.hscript?

Perhaps I'm looking in wrong direction and there is another way to get mouse position in 3D viewport?

For example when creating a curve with ortho grid off, the points are placed on a plane defined by perspective camera(pov).

I'm looking for a way to do viewport painting. Like maya paintFX. It's easy doable with maxScript also.

Link to comment
Share on other sites

When you invoke null tool in viewport it shows position coordinates as you move mouse.I didn't looked at how this is done but if I will need this functionality propably I would start there.

Link to comment
Share on other sites

Heya,

Check this http://www.sidefx.com/docs/houdini10.0/ref/windows/edittool. Look for "Prompting the user for a position, multiple positions, or a path". SelectPositions shows coordinates in viewport. Maybe this will drive you somewhere.

Here is copy paste from help.

import toolutils

# The selectPositions() method of the hou.SceneViewer object lets
# you prompt the user for one or more positions (using the
# number_of_positions keyword), optionally connecting multiple
# positions (for example when prompting for a path), displaying
# a bounding box (when prompting to place geometry), etc.

# The result is a tuple of Vector3 objects.

scene_viewer = toolutils.sceneViewer()
positions = scene_viewer.selectPositions(prompt='Click to specify a position',
                                         number_of_positions = 1,
                                         connect_positions = True,
                                         show_coordinates = True,
                                         bbox = BoundingBox(),
                                         position_type = positionType.WorldSpace,
                                         icon = None,
                                         label = None)

It also returns position as Vector3 and you can set number_of_positions to whatever number you wan't.

Edited by SWANN
Link to comment
Share on other sites

It's a really nifty feature, thanks.

If only it was possible to read the values without clicking...

Now it needs a click to get the position and it's kinda counter sketching behaviour.

Perhaps there is a way to read the positions as mouse moves, just as mouse CHOP.

Link to comment
Share on other sites

It's a really nifty feature, thanks.

If only it was possible to read the values without clicking...

Now it needs a click to get the position and it's kinda counter sketching behaviour.

Perhaps there is a way to read the positions as mouse moves, just as mouse CHOP.

I am very interested in this too. I had a few scripts that became dead end because they were unworth the effort and would have been simple if I could have pulled the viewer size. There was brief chat about it on the listserv too, it would seem there are many places 'aware' of the viewer size but I haven't found a simple mechanism for access via hscript, expression or anything else either. I too would like to see this info become more accessible -- it would be very useful in a lot of places. It doesn't seem the sort of thing that would need to be buried ....

Link to comment
Share on other sites

It should be accessible from HDK.

Then we could call the function getMyMousePos() from inlineCpp every fraction of a second until any escaping event happens.

EDIT: Just found this:

HDK docs

There are functions : getViewportItransform and getViewportTransform, with an example.

Edited by peliosis
Link to comment
Share on other sites

I was also going to suggest you take a look at the HDK/inlinecpp route. As I recall there is an example of writing a custom brush type thing for use with hair that might have some ideas for getting you the mouse position and such.

getViewportTransform is also available through HOM in Houdini 11 but it isn't quite enough.

>>> import toolutils
>>> v = toolutils.sceneViewer()
>>> p = v.curViewport()
>>> p.viewTransform()
<hou.Matrix4 [[1, 0, -0, 0], [-0, 1, -0, 0], [0, -0, 1, 0], [0, -0, 18.7298, 1]]>

Edited by graham
Link to comment
Share on other sites

One quick thing I forgot about is that you can do hou.SceneViewer.selectPositions(position_type=hou.positionType.ViewportXY) and when you click in the viewport you'll get the XY position of your click where (0,0) is located in the bottom left of the viewport. You can also try hou.positionType.ViewportUV for a 0-1 range.

You still run into the issue that you can't smoothly paint the positions though.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...