Whatsinaname Posted October 27, 2015 Share Posted October 27, 2015 (edited) A while ago I used some very simple Matrix multiplications to bring geometry, that is positioned anywhere in space, back to the origin and from there, back to its original position. Maybe anybody here can help me remember? I think I created a world space transformation Matrix, called it myMatrix, and then multiplied it by its reverse to transform geo to the origin. In order to translate the geo back, I just multiplied by myMatrix...is that possible or am I getting something wrong? (Not in fromt of a Houdini right now) Anyway, how do I get the world space transformation matrix for an object positioned anywhere in world space, for example for some geo that came into my scene as an ABC from Maya? Lookattransform in VOPSOPs? Thanks for your hints and patience. Edited October 27, 2015 by Phlok Quote Link to comment Share on other sites More sharing options...
Whatsinaname Posted October 27, 2015 Author Share Posted October 27, 2015 transform.hipncIt seems like nobody understands what I am trying to say and where I got stuck. So, I'll try again. I've got an object_merge inside a GeoSOP, mimicking any geo that comes from an external source...abc, bgeo cache...anything. Then I created a matrix attribute , myTransformMatrix in a PointVOP and did a Bind Export. After that, I tried multiplying my points by the inverse of that matrix, but it doesn't seem to have any effect at all. I know I'm doing something wrong, but I'm stuck or blind (or both). In order to illustrate the sad truth, I uploaded an example file. Quote Link to comment Share on other sites More sharing options...
mine Posted October 27, 2015 Share Posted October 27, 2015 II'm just starting to learn Houdini, so don't trust me much in this, but I saw this in a tutorial not so long ago. You should need to create a coordinate system from your object (an up, front and side vectors) to create a matrix3, and then create a matrix 4 (m3tom4 node), isn't it? Then you can translate matrix4 with your object position (the centroid) And is this matrix4 that you can multiply (inverted) in your second vopsop by the position to have the object in 0,0,0 Maybe doesn't have much sense. Just trying to help. Quote Link to comment Share on other sites More sharing options...
Popular Post f1480187 Posted October 28, 2015 Popular Post Share Posted October 28, 2015 (edited) I'm sure you can't do it without an additional data. For example, is it possible to retain transform matrix on points of original geometry? Then yes, just multiply it by inverse. Dealing with object transforms is the most straightforward way, and you need only transform, simple box with some snapping techniques with desired transform is fine. Extract Transform OBJ. There is another nice method I didn't found in Houdini, maybe it will fit you. If you have at least two triangles, or any arbitrary 3 points transformed, of before-transform and after-transform states (for example, if you store rest position or if you could recreate it more or less exact), then you may easily calculate transform matrix between them using triangles's "local spaces" created from triangles's sides. Here the code for Primitive Wrangle (I used "0" as group, it runs only for first polygon) with two identical geometries on inputs, where second is arbitrarily transformed. // Create a basis from points of triangle. matrix3 basis_from_triangle(vector p1, p2, p3) { // Axes vectors. May not be orthogonal. vector X, Y, Z; Z = p2 - p1; X = p3 - p1; Y = normalize(cross(Z, X)) * length(p2 - p3); return set(X, Y, Z); } // Calculate rotation matrix rotating triangle ABC into triangle DEF. matrix3 rotation_between_triangles(vector a, b, c, d, e, f) { matrix3 basisABC, basisDEF; basisABC = basis_from_triangle(a, b, c); basisDEF = basis_from_triangle(d, e, f); return invert(basisABC) * basisDEF; } // Calculate transform matrix transforming triangle ABC into triangle DEF. matrix transform_between_triangles(vector a, b, c, d, e, f) { matrix transform = ident(); matrix3 r = rotation_between_triangles(a, b, c, d, e, f); transform *= r; translate(transform, d - a * transform); return transform; } 4@transform = transform_between_triangles(point(1, "P", primpoint(1, @primnum, 0)), point(1, "P", primpoint(1, @primnum, 1)), point(1, "P", primpoint(1, @primnum, 2)), point(0, "P", primpoint(0, @primnum, 0)), point(0, "P", primpoint(0, @primnum, 1)), point(0, "P", primpoint(0, @primnum, 2))); Now, transform points using Point Wrangle with second input as geometry, simply getting first primitive's transform attribute. @P *= matrix(prim(1, "transform", 0)); Or, being contemporary, Deformation Wrangle, because it is exactly why it was created. pos *= matrix(prim(1, "transform", 0)); It will properly transform attributes you need to have transformed. With Point Wrangle you need to use other wrangles to transform vertex normals or other attributes. Actually, for normals only there is special checkbox on Point Wrangle, and sometimes it works. betweentria.hipnc Edited July 28, 2016 by f1480187 15 Quote Link to comment Share on other sites More sharing options...
dedeks3000 Posted October 28, 2015 Share Posted October 28, 2015 (edited) I think this is what you try to achieve : transform__001.hipnc Edited October 28, 2015 by dedeks3000 Quote Link to comment Share on other sites More sharing options...
alksndr Posted May 13, 2016 Share Posted May 13, 2016 Gonna necro this, ive basically used pavel's example in some thread to move stuff back to origin.. So it can move the object based on the transform, i have 2 questions 1. Is this the proper way to do this? It feels like it can be simplified at least with connecting all those float to vectors.. Maybe a few lines of wrangle that can do all this easier? Pavel was doing more complex things so maybe theres additional steps i accidentally also copied. 2. Its obviously not a great solution to have to manually transform to the new (origin) position, I have the simple line thing built in the file which can easily be measured so no matter how many pieces there are you can just have a vec to the origin. How can that be used to bring the object back to the origin? matrixv1.hip Quote Link to comment Share on other sites More sharing options...
old school Posted May 13, 2016 Share Posted May 13, 2016 First off amazing example F1!!! Very nice lattice deformer. Many ways to do this where you take the centroid of the input geometry, move to origin, do work then move back. Using VOPs makes it artist friendly and re-usable. Using Wranglers for those that like vex. See the example file for both set-ups. In the set-up, I do the easy thing and use the centroid() hscript function to fetch the origin of the input grouped geometry in to a declared vector parameter. If you don't want to use the centroid() function (or $CEX $CEY and $CEZ in the Transform SOP), you can use this vex code grabbed from the Expression Cookbook in the help http://www.sidefx.com/docs/houdini15.0/ref/expression_cookbook: Centroid $CEX, $CEY, $CEZ v@min = {0.0, 0.0, 0.0}; v@max = {0.0, 0.0, 0.0}; getpointbbox(0, @min, @max); v@cent = (@max + @min) / 2.0; // @cent.x, @cent.y, @cent.z inverse_transform_example.hip 4 Quote Link to comment Share on other sites More sharing options...
alksndr Posted May 17, 2016 Share Posted May 17, 2016 (edited) Hey old school, I am back with another question. Perhaps this can also be made clear to me.. Lets say I have an object that is also rotated, in this case it is just in the transform node but hypothetically it can also be rotated from say a noisy particle sim that trails lines going in all directions.. And I want to be able to figure out that rotation angle and then when its brought back to the origin, have that rotation inverted and thus aligned in such a way that its now always pointing up in Y. Such as this diagram: the file I attached isnt necessary to do it in there or anything, its the same as your example. I just wanted to avoid the expressions so it will just pack to get the centroid. I think this rotation thing would be super useful, scale doesn't seem like it would be necessary ever but perhaps if I have translation and rotation explained then scale is a good challenge to try on my own. edit: and the reason I bring up the particle sim is so this can work on an all case basis, I can easily link the rotation in the transform node to the make transform vop rotation. But thats not as cool as it working for non transform'd rotations off the origin. Thanks guys! matrix_v2.hip Edited May 17, 2016 by alksndr Quote Link to comment Share on other sites More sharing options...
jeremiah Posted June 3, 2020 Share Posted June 3, 2020 Found out this old thread while searching stuff to remind myself of matrix stuff. For those who happen to searching for the same info. Quote Link to comment Share on other sites More sharing options...
jeremiah Posted June 3, 2020 Share Posted June 3, 2020 (edited) TOO LONG TO WATCH: Matrix_invert.hipnc Edited June 3, 2020 by jeremiah delete old hip file Quote Link to comment Share on other sites More sharing options...
tamagochy Posted June 3, 2020 Share Posted June 3, 2020 Not sure if it need someone 4 years later, but I create more simple way. )) matrix_transform.hipnc 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.