Viewport facing primitives

   4129   6   2
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
How do you go about making primitives face the active viewport camera? I know the primitive SOP has a look at parameter for this but could not find anything to tie it to the active viewport

I am basically using a font SOP to display some info, but I need this info to always face the user

Thank you in advance!
-G
User Avatar
Staff
181 posts
Joined: July 2005
Offline
Your geometry node should have a Look At field in the Transform folder. You should enter your camera there.
User Avatar
Member
789 posts
Joined: April 2020
Offline
if the geometry is only to inform the user, perhaps a viewport overlay is a better option:
http://www.sidefx.com/docs/houdini11.0/rendering/cameratips [sidefx.com] ?

Cheers,
Koen
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Hey guys, thank you for your replies

the viewport overlay and look at field are great! however, I cannot count on a camera node being used (i.e.user may just be using a simple viewport, such as persp). is there perhaps an expression to return the name of the viewport for the lookat field?

thanks!
-G
User Avatar
Member
1904 posts
Joined: Nov. 2006
Offline
It is quite easy to extract the view transform from a viewport using Python. On thing you could do is use something like the attached quick pass at an asset.

The object, ViewerTransform, allows you to select a viewer and viewport that exists on the desktop and use that viewers transformation as an object location. You can then use that object to drive your lookat parameters.

This method has a downside as it only gets the transform from the view when the operator is cooked, not when you modify the viewport. There is a button on the asset that will cause it to recook but that is not always idea.

An option would be to use Houdini's integrated UI event loop callback to recook the object whenever the interface is idle. Using this you can get a more interactive (not completely smooth however) response.
def refreshViewTransform():
hou.node(“/obj/viewerxform1”).cook(True)

hou.ui.addEventLoopCallback(refreshViewTransform())

Attachments:
object_viewport_xform.otl (7.2 KB)

Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
51 posts
Joined: Oct. 2006
Offline
I think you can also use (a really simple) GLSL material for this.
See attached scene (requires H11).
But it seems this only works properly while in Smooth Shaded view - for Smooth Wire Shaded you'll get a wireframe “ghost” of your geometry, Wireframe mode will simply display untransformed object…
But anyway, just an idea.

Attachments:
bbfont.jpg (51.5 KB)
bbfont.zip (11.2 KB)

User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Oh wow these are both great solutions I think I may go with a hybrid of both methods to allow some of this functionality on both modes. Thank you!
-G
  • Quick Links