peliosis Posted September 7, 2010 Share Posted September 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
graham Posted September 7, 2010 Share Posted September 7, 2010 Unfortunately I'm pretty sure there currently isn't any way to retrieve that kind of information using HOM. Quote Link to comment Share on other sites More sharing options...
peliosis Posted September 7, 2010 Author Share Posted September 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
Guest Swann Posted September 7, 2010 Share Posted September 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
peliosis Posted September 7, 2010 Author Share Posted September 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
Guest Swann Posted September 7, 2010 Share Posted September 7, 2010 (edited) 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 September 7, 2010 by SWANN Quote Link to comment Share on other sites More sharing options...
peliosis Posted September 7, 2010 Author Share Posted September 7, 2010 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. Quote Link to comment Share on other sites More sharing options...
eyevex Posted September 8, 2010 Share Posted September 8, 2010 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 .... Quote Link to comment Share on other sites More sharing options...
peliosis Posted September 8, 2010 Author Share Posted September 8, 2010 (edited) 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 September 8, 2010 by peliosis Quote Link to comment Share on other sites More sharing options...
graham Posted September 8, 2010 Share Posted September 8, 2010 (edited) 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 September 8, 2010 by graham Quote Link to comment Share on other sites More sharing options...
peliosis Posted September 8, 2010 Author Share Posted September 8, 2010 Thanks, I've experimented with viewTransform() a little. Got to try this HDK solution but ... even if easy, it puts shiver down my neck Quote Link to comment Share on other sites More sharing options...
graham Posted September 8, 2010 Share Posted September 8, 2010 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. Quote Link to comment Share on other sites More sharing options...
peliosis Posted September 13, 2010 Author Share Posted September 13, 2010 Thanks Graham, Swann mentioned it also it's a nice feature. Sure for painting with it one should better have a VEry fast finger . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.