Find, define & align transform pivot procedurally in a loop
3458 11 0- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
Hello,
Scenario:
I have a box building with window planes on four sides. I would like to open some windows based on a noise or randomly. I would like to define the position of the hinge (maybe using a guide line). The issue I have is that I cannot figure out how to procedurally define the pivot. If I have a line can how can I tell a transform to use it as the pivot?
I figured out a method for rotating on Y (vertical hinge) but if I want to use a horizontal hinge I run into problems as Houdini doesnt know what direction each plane is facing.
I can set the position of the pivot using a point but I would also need to define the direction of the pivot, like to say always set the Z direction to point from 0 to 1 of the pivot/hinge line.
The idea would be to build a small tool that could open windows on buildings with curved facades so it should work on any orientation. Each window would still just be a 2D plane with 4pts.
See attached images and hip file
Any help or hints is much appreciated
Scenario:
I have a box building with window planes on four sides. I would like to open some windows based on a noise or randomly. I would like to define the position of the hinge (maybe using a guide line). The issue I have is that I cannot figure out how to procedurally define the pivot. If I have a line can how can I tell a transform to use it as the pivot?
I figured out a method for rotating on Y (vertical hinge) but if I want to use a horizontal hinge I run into problems as Houdini doesnt know what direction each plane is facing.
I can set the position of the pivot using a point but I would also need to define the direction of the pivot, like to say always set the Z direction to point from 0 to 1 of the pivot/hinge line.
The idea would be to build a small tool that could open windows on buildings with curved facades so it should work on any orientation. Each window would still just be a 2D plane with 4pts.
See attached images and hip file
Any help or hints is much appreciated
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
Ok I found a better way. By calculating the cross product on the window plane and the tranferring the attribues to the hinge line, then use the cross attribute as the reference on the Transform Axis Sop I get a perfect result on all the planes.
Maybe its helpful to somebody. If anyone is interested I can post an updated hip file, as I seem to be talking to myself
Maybe its helpful to somebody. If anyone is interested I can post an updated hip file, as I seem to be talking to myself
- Librarian
- Member
- 142 posts
- Joined: Aug. 2009
- Offline
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
srletak76
Post file @polimpiado Thanx
I will once I really found the answer, not there yet. turns out I shouted hi before crossing the river(Swedish saying).
I managed to do it for a horizontal hinge but now I have a problem with the vertical, I cannot figure out how to define what is outward and inward. My trigonometry / calculus is rusty to non existent. I have the cross product but it is not enough.
Plowing through quaternions and orient on cgwiki, mind boggling.
- Konstantin Magnus
- Member
- 670 posts
- Joined: Sept. 2013
- Offline
Hi Polimpiado,
after setting continuous random values on opening angles and discrete values on hinge locations, you can define hinge positions with primuv() and open windows with rotate():
after setting continuous random values on opening angles and discrete values on hinge locations, you can define hinge positions with primuv() and open windows with rotate():
float angle = prim(0, 'angle', i@primnum); vector nml = prim_normal(0, i@primnum, vector(0.0)); vector hinge = prim(0, 'hinge', i@primnum); vector pos = primuv(0, 'P', i@primnum, hinge); vector up = {0, 1, 0}; vector hor = cross(nml, up); vector axis = hinge.z > 0.25 ? up : hor; float amount = hinge.y > 0.25 ? angle : -angle; matrix3 m_rot = ident(); rotate(m_rot, amount, axis); v@P = (v@P - pos) * m_rot + pos;
Edited by Konstantin Magnus - May 23, 2020 18:38:37
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
Thanks Konstantin! Very interesting!
One key issue, which is what I am truly struggling with. I want to be able to make the windows set all windows to open out or inwards based on the primitive normal. Maybe its possible in your setup but at the moment they are totally random.
I am looking to set define the pivot as horizontal (top or bottom) or vertical (left or right), then set rotation as going in or out. The only randomization should be on the amount of rotation. As you can see on my screen shot the upper band of windows have a horizontal hinge and the mid band would have a vertical hinge…
Right now I am working with a basic box but I looking to apply the tool to curved facades as well.
One key issue, which is what I am truly struggling with. I want to be able to make the windows set all windows to open out or inwards based on the primitive normal. Maybe its possible in your setup but at the moment they are totally random.
I am looking to set define the pivot as horizontal (top or bottom) or vertical (left or right), then set rotation as going in or out. The only randomization should be on the amount of rotation. As you can see on my screen shot the upper band of windows have a horizontal hinge and the mid band would have a vertical hinge…
Right now I am working with a basic box but I looking to apply the tool to curved facades as well.
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
- polimpiado
- Member
- 42 posts
- Joined: Dec. 2016
- Offline
- Konstantin Magnus
- Member
- 670 posts
- Joined: Sept. 2013
- Offline
polimpiado
It works also with non square facades
Nice progress! And thanks for keeping us updated live
The basic idea was to control the hinge variations solely by an attribute and rather less by hard switches but it depends on the case I guess.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
-
- Quick Links