Getting Camera Position from an Alembic

Dealing with Alembics in Houdini is, for the most part, very straightforward, but sometimes there are times in which you wanna do something very specific that you can do with zero difficulty in SOPs, and turns out that if there’s an Alembic involved, it gets trickier than it should. One of them being extracting the positions vector of cameras. 

Recently I needed to do this, get the x, y, z coordinates of a camera that was part of an alembic file. Easy, just make a point with an Add SOP and reference the camera’s position using the centroid() function in HSCRIPT. Wrong. 

I diged a bit around, and granted there’s (obviously) more than one way to do this, but the one I liked the most (because it’s the one that made most sense to me) was one I found on the SideFX forum, on a reply by Jonathan Mack. Full credit to him!

This method is a super easy and fancy VEX solution.

  1. Make a point, however you like, maybe with an add node?
  2. Append a Point Wrangle, and in it type the following: 
				
					string camera = chs("camera_path"); @P = ptransform(camera, "space:current", {0,0,0}); @N = ntransform(camera, "space:current", {0,0,-1});
				
			

Now, I made the camera string a channel so you can easily use Houdini’s interface to point to the Alembic camera you are looking for. And done! That’s all you need to do. What’s happening here with the ptransform() function is that you are grabbing the camera transforms (obscured by Alembic’s voodoo) and putting them in the current space, and for orientation, you use ntransform(), since through N you can give the point some orientation. 

If you wanna know more about the ptransform() and ntransform() functions, you can take a look at what they do here and here, respectively. 

Leave a Reply

Your email address will not be published. Required fields are marked *