Jump to content
Sign in to follow this  
peliosis

pane size and position

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.

Share this post


Link to post
Share on other sites

Unfortunately I'm pretty sure there currently isn't any way to retrieve that kind of information using HOM.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Guest Swann

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.

Share this post


Link to post
Share on other sites

Serwus Swann,

That's where I started but quicly dropped it.

It calls genericTool() or something which I think is a closed solution.

Will check it again though, thanks for the tip.

Share this post


Link to post
Share on other sites
Guest Swann

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

Share this post


Link to post
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.

Share this post


Link to post
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 ....

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks, I've experimented with viewTransform() a little.

Got to try this HDK solution but ... even if easy, it puts shiver down my neck :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks Graham, Swann mentioned it also it's a nice feature.

Sure for painting with it one should better have a VEry fast finger :D .

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×