Jump to content

how to import a object transform in vex


Recommended Posts

On 4/25/2008 at 3:27 PM, sanostol said:

hi,

I want to get the matrix4 of a object ( a null ), and use it for some stuff in vex. is it possible? I was looking for something like the object CHOP in chops. where UYou simply provide the path to a object

?

For the record, there is a way to do this, but it's fugly... since coming up with this I have moved to using SpencerL's approach of using an objectmerge Sop instead... but in case someone really needs it, here it is. The full wrangle for making a matrix out of this should be straightforward but for reference it is on http://andy.moonbase.net. Cheers.

// Create vectors to fill a matrix using the second node input's transform (ie a null)
vector translate = set(`chs(opinputpath(".", 1)+"/tx")`, `chs(opinputpath(".", 1)+"/ty")`, `chs(opinputpath(".", 1)+"/tz")`);
vector rotate = set(`chs(opinputpath(".", 1)+"/rx")`, `chs(opinputpath(".", 1)+"/ry")`, `chs(opinputpath(".", 1)+"/rz")`);
vector scale = set(`chs(opinputpath(".", 1)+"/sizex")`, `chs(opinputpath(".", 1)+"/sizey")`, `chs(opinputpath(".", 1)+"/sizez")`);

But there's a much cleaner way, too. Get a matrix for your object (a camera or null usually) via optransform and then use the cracktransform function if you need some portion of the matrix, in this example I extract out the position. (The result is a simple way for getting the position of the camera in vex, which is a subject on a bunch of threads here.)

vector @cdir;

matrix camMatrix = optransform(chs("camera")); 
//get a matrix with the camera's transforms.

@cdir = cracktransform(0, 0, 0, {0,0,0}, camMatrix);
//extract out the camera position as a vector

 

Edited by Matic3D
Link to comment
Share on other sites

Lol yes much simpler... I figured it out around the time you posted and my message has been edited for reference. Thanks Tomas! I'm finding optransform and cracktransform to be pretty handy. Now in my 9'th week of houdini after moving over from ICE and liking it more and more, cheers.

Edited by Matic3D
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...