reyan Posted February 17, 2016 Share Posted February 17, 2016 Hello wizards!I have a question about point wrangle SOP.Is it possible create a matrix, and use that matrix in copy SOP as a transform ?In the file attached, i build all axis that i need for create a matrix, and rotate the copies with "roll_on_path" ramp parameter, but until now, no way. If someone have an idea... a big Thanks 1 Quote Link to comment Share on other sites More sharing options...
mestela Posted February 17, 2016 Share Posted February 17, 2016 You didn't attach a file. If it's a matrix just for rotation, convert it to a quaternion and export it as orient: @orient = quaternion(yourmatrix); Quote Link to comment Share on other sites More sharing options...
reyan Posted February 17, 2016 Author Share Posted February 17, 2016 (edited) Thanks mestela, my problem there's some error in the wrangle code for define a matrix Here the file:roll_test_tmp_001.zip Edited February 17, 2016 by reyan Quote Link to comment Share on other sites More sharing options...
mestela Posted February 17, 2016 Share Posted February 17, 2016 Ah, I've not set matrix values manually as you've done before, but looks like its the same as vectors; the {} syntax only works for constant values. If you want to set them based on other variables, use set(): So this: matrix3 mat = {{@N.x, @N.y, @N.z},{@binormal.x, @binormal.y, @binormal.z},{@up.x, @up.y, @up.z}}; becomes this (ie set() each of the internal vectors, and another set() around the whole matrix): matrix3 mat = set(set(@N.x, @N.y, @N.z),set(@binormal.x, @binormal.y, @binormal.z),set(@up.x, @up.y, @up.z)); Then to convert matrix to an orient: @orient = quaternion(mat); That said, it gets wacky results, so you might need to rethink your logic. 2 Quote Link to comment Share on other sites More sharing options...
reyan Posted February 18, 2016 Author Share Posted February 18, 2016 Yep, apparently there's something weird... Thanks anyway Quote Link to comment Share on other sites More sharing options...
reyan Posted February 19, 2016 Author Share Posted February 19, 2016 Finally i solved, actually the logic was right, the vector order in the matrix not: matrix3 mat = set(set(normal.x, normal.y, normal.z), set(up.x, up.y, up.z), set(binormal.x, binormal.y, binormal.z)); 1 Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 19, 2016 Share Posted February 19, 2016 Rows order is is another quite painful issue outside matrix creation scope. This will also work: mat = set(normal, up, binormal); mat = set(normal.x, normal.y, normal.z, up.x, up.y, up.z, binormal.x, binormal.y, binormal.z); All set function signatures, obtained with vcc --list-context CVEX command: float set( float ) float set( int ) float set( vector4 ) float set( vector ) float set( float[] ) float[] set( matrix3 ) float[] set( matrix ) float[] set( float ) float[] set( vector4 ) float[] set( vector ) float[] set( float[] ) float[] set( int[] ) vector2 set( float ) vector2 set( float; float ) vector2 set( int ) vector2 set( vector4 ) vector2 set( vector2 ) vector2 set( vector ) vector2[] set( float[] ) vector2[] set( vector2[] ) vector set( float ) vector set( float; float; float ) vector set( int ) vector set( vector4 ) vector set( vector2 ) vector set( vector ) vector set( float[] ) vector[] set( matrix3 ) vector[] set( float[] ) vector[] set( vector[] ) vector4 set( float ) vector4 set( float; float; float; float ) vector4 set( int ) vector4 set( vector4 ) vector4 set( vector2 ) vector4 set( vector ) vector4 set( float[] ) vector4[] set( matrix ) vector4[] set( float[] ) vector4[] set( vector4[] ) matrix2 set( matrix2 ) matrix2 set( matrix3 ) matrix2 set( matrix ) matrix2 set( float ) matrix2 set( float; float; float; float ) matrix2 set( int ) matrix2 set( vector2; vector2 ) matrix2[] set( matrix2[] ) matrix2[] set( float[] ) matrix3 set( matrix2 ) matrix3 set( matrix3 ) matrix3 set( matrix ) matrix3 set( float ) matrix3 set( float; float; float; float; float; float; float; float; float ) matrix3 set( int ) matrix3 set( vector; vector; vector ) matrix3 set( float[] ) matrix3 set( vector[] ) matrix3[] set( matrix3[] ) matrix3[] set( float[] ) matrix set( matrix2 ) matrix set( matrix3 ) matrix set( matrix ) matrix set( float ) matrix set( float; float; float; float; float; float; float; float; float; float; float; float; float; float; float; float ) matrix set( int ) matrix set( vector4; vector4; vector4; vector4 ) matrix set( float[] ) matrix set( vector4[] ) matrix[] set( matrix[] ) matrix[] set( float[] ) int set( float ) int set( int ) int[] set( float[] ) int[] set( int[] ) string set( string ) string[] set( string[] ) bsdf set( bsdf ) bsdf[] set( bsdf[] ) 6 Quote Link to comment Share on other sites More sharing options...
reyan Posted February 19, 2016 Author Share Posted February 19, 2016 Rows order is is another quite painful issue outside matrix creation scope Absolutely All set function signatures, obtained with vcc --list-context CVEX command: Thanks! Quote Link to comment Share on other sites More sharing options...
reyan Posted February 21, 2016 Author Share Posted February 21, 2016 Hi again, i'm tryng to add a rotation to my path, so after matrix definition i have this code: rotate(mat, angle, set(@N.x, @N.y, @N.z)); This works, and rotate the profile on the path by angle, but i would need control rotation with my spline ramp defined by float ramp = chramp("roll_on_path"); How can i do that ?Thanks in advance Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 22, 2016 Share Posted February 22, 2016 The function uses two arguments. You need a position on ramp also. matrix3 mat = ident(); float angle = chramp("ramp", ch("turn")) * radians(360); rotate(mat, angle, {0, 1, 0}); @P *= mat; Quote Link to comment Share on other sites More sharing options...
reyan Posted February 22, 2016 Author Share Posted February 22, 2016 Thanks, but maybe my code is a bit different let's see: v@up = {0,1,0}; @N = normalize(@N); v@binormal = normalize(cross(@N, @up)); @up = normalize(cross(@binormal, @N)); matrix3 mat = set(set(@N.x, @N.y, @N.z),set(@up.x, @up.y, @up.z), set(@binormal.x, @binormal.y, @binormal.z)); float angle = chramp("ramp", ch("turn")) * radians(360); rotate(mat, angle, set(@N.x, @N.y, @N.z)); @orient = quaternion(mat); //@P *= mat; float ramp = chramp("roll_on_path", @roll); If i set P as you suggested works, but with weird result, seems that the rotation happen in world space and not with the matrix that i defined by hand;But i'm using @orient for pass data to copy SOP, in this case doesn't work...I attached the HDN file for better explanationroll_test_tmp_002.zip Quote Link to comment Share on other sites More sharing options...
anim Posted February 22, 2016 Share Posted February 22, 2016 if you want your ramp to control rotation over the length of the curve then replace your angle line with something like this: ... float angle = chramp("ramp", @ptnum/(@numpt-1.0)) * radians(360) * ch("turn"); ... considering point numbers on your curve are in order Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 22, 2016 Share Posted February 22, 2016 That was an example of function usage. It rotates input around world's up using "Turn" parameter, where 1 does full revolution around axis. No need to set @P in your case. If you want to use roll attribute to control rotation instead, replace ch("turn") with @roll. There is no roll attribute defined on points in scene file, angle will be always zero for default ramp. Code you need now will be something like this: v@up = {0,1,0}; @N = normalize(@N); v@binormal = normalize(cross(@N, @up)); @up = normalize(cross(@binormal, @N)); matrix3 mat = set(@N, @up, @binormal); float angle = chramp("ramp", @roll) * radians(360); rotate(mat, angle, @N); @orient = quaternion(mat); 2 Quote Link to comment Share on other sites More sharing options...
reyan Posted February 22, 2016 Author Share Posted February 22, 2016 (edited) That's exactly what was looking for, thanks both guys ! Edited February 22, 2016 by reyan Quote Link to comment Share on other sites More sharing options...
mirHadi Posted January 27, 2017 Share Posted January 27, 2017 (edited) hello f1, thank you for you great posts. I have a situation here, and can't figure out why it's happening. I'm applying the same code. ( a simple rotation around {1, 1, 1} , the white line) matrix3 mat = ident(); float angle = ch("turn") * radians(360); rotate(mat, angle, {1, 1, 1}); @P *= mat ; but points, instead of rotating also moves. I tried to divide that with position vector of each point to get just rotation and not translation , no success. is it meant to be working like this, with transform? .. I mean It should work.. but.. thank you in advance Edited January 27, 2017 by haaranoos Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 27, 2017 Share Posted January 27, 2017 @haaranoos, rotation axis need to be normalized. {1, 1, 1} is not a unit length vector. Quote Link to comment Share on other sites More sharing options...
mirHadi Posted January 27, 2017 Share Posted January 27, 2017 oh .. thank you... sorry completely forgot that Quote Link to comment Share on other sites More sharing options...
mirHadi Posted February 3, 2017 Share Posted February 3, 2017 hello I did that same thing in a scene with copy sop and simple teapot. ( here : decided to the same vop sop rotation matrix in attribute wrangler .. as you can see in the attached file, everything should work .. like the vop sop version but It doesn't . I couldn't find out why. might you please look at the file? thank you in advance teapot rotation.hip Quote Link to comment Share on other sites More sharing options...
f1480187 Posted February 3, 2017 Share Posted February 3, 2017 @haaranoos, here is the bug: vector tangentu = point(0, 'tangentu', @ptnum); vector tangentv = point(0, 'tangnetv', @ptnum); matrix3 m = set (@tangentv, @tangentu ,@N); Unlike @N, Houdini currently can't guess type of custom attributes like v@tangentu. You have to use proper type prefix. Also, you don't need two lines at the beginning, they just initialize two variables which was never used. They may be used instead of direct attribute access, but in that case you need to delete @. Quote Link to comment Share on other sites More sharing options...
mirHadi Posted February 4, 2017 Share Posted February 4, 2017 (edited) very cool f1 .. working just fine.. I'm new to houdini (vex).. I learn a lot from your posts. thank you Edited February 4, 2017 by haaranoos 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.