Jump to content

Procedural Pivot Orientation


zarroun

Recommended Posts

Hello everyone,

I hope one of you guys can help me finish up my latest idea. The image shows just a test geometry. Each color represents its own group of polis. What I want to happen is that each group flips back. Like a bonnet on a car or a hatch, if you will. The rotation is coming from CHOPs The two red marked points should make the hinge points, the red line is the resulting axis I want the group to rotate around.

Here's where I'm stuck though. While it is no problem to move the pivot, I have not found a way to orient it. But I figure that redefining a new local axis is a bit tricky. So maybe a better plan of attack is to move/rotate each group so that the hinge point are on the x axis, do the rotation, then return the points to their original position and add the offset from the rotation. Still don't know how I would get the two anchor points to rest on the x axis. Anyone have an idea how I could do this? Thank you very much!

Cheers

P.S: Why isn't rotation anywhere in the details view anyway?

post-3960-128410956031_thumb.jpg

Link to comment
Share on other sites

Here's my take on it using Python to drive the operation.

What you can do is create a vector from the positions of your two pivot points and use that to rotate the geometry about that axis.

Attached is something I through together really quickly using a Python SOP asset with a couple of controls. It works inside a ForEach that's iterating over each group. Inside the ForEach I have the SOP that plugs into the group geometry but right now it requires a second input. The second input geo has been run through a Divide and Facet SOP to just isolate the 4 corner points. One thing this does require right now is that your tube/polygons be aligned along an axis. In this case I have my tube going along Z. This is important because in order to find the pivot location we can choose from the points who have their position at the min/max value for that axis. In this case since it is Z, I can use the points that share the min or max Z values with the whole piece of geometry. We also use those two points to figure out what to rotate from. I'd like to create a better system but for a quick hack it works. It then uses the pivot point and axis to transform the geometry. Because of various issues involving using matrices to do transformations, sometimes some prims can rotate the opposite direction. We do some simple vector operations to figure out if it will screw up or not and adjust accordingly, resulting in the group being nice and rotated.

rotate_groups.hipnc

Link to comment
Share on other sites

Here's my take on it using Python to drive the operation.

What you can do is create a vector from the positions of your two pivot points and use that to rotate the geometry about that axis.

Attached is something I through together really quickly using a Python SOP asset with a couple of controls. It works inside a ForEach that's iterating over each group. Inside the ForEach I have the SOP that plugs into the group geometry but right now it requires a second input. The second input geo has been run through a Divide and Facet SOP to just isolate the 4 corner points. One thing this does require right now is that your tube/polygons be aligned along an axis. In this case I have my tube going along Z. This is important because in order to find the pivot location we can choose from the points who have their position at the min/max value for that axis. In this case since it is Z, I can use the points that share the min or max Z values with the whole piece of geometry. We also use those two points to figure out what to rotate from. I'd like to create a better system but for a quick hack it works. It then uses the pivot point and axis to transform the geometry. Because of various issues involving using matrices to do transformations, sometimes some prims can rotate the opposite direction. We do some simple vector operations to figure out if it will screw up or not and adjust accordingly, resulting in the group being nice and rotated.

Hi Graham,

What kind of dark secret magic do have going on in this file? because if I run it in the current production build 11.0.469 than it instantly crashes (on my mac book pro and my Linux machine). If I run it in the current daily build there doesn't seem to be any problem :P

Link to comment
Share on other sites

Well I created it using today's build (11.0.499). Judging from the crash log I get when I open it up in an older version it's crashing because of some display options having to do with the viewer/cop viewer. I'll submit a bug and/or talk to Mark A about it.

Link to comment
Share on other sites

Well I created it using today's build (11.0.499). Judging from the crash log I get when I open it up in an older version it's crashing because of some display options having to do with the viewer/cop viewer. I'll submit a bug and/or talk to Mark A about it.

That sounds like a former bug which has been fix in today's build. It made crashed Houdini when you tried to create flip fluids from the shelf for instance. I don't know what it exactly caused from crashing.

Link to comment
Share on other sites

Here's another version, this time using the Transform Axis SOP. It still uses the same method of finding the pivot corners though.

I was able to make both methods work better overall by sorting the points in the geometry after I reduced it down. Without sorting, one row of groups always rotates the wrong way and it was easy enough to fix in Python but I was somewhat worried about it in the entirely SOP approach. However, while messing around with a better way to get the pivot corners I was sorting and for whatever reason it seems to cause the problem to disappear, making it easier and cleaner to do in SOPs.

rotate_groups2.hipnc

Link to comment
Share on other sites

Thank you graham, it sounds like you put quite some effort into this. Unfortunately, they wont let me install programs at work by myself, and the person responsible for this task is hardly around. It's rather stupid. Anyway, I needed a method that I can open at work. I'll have to study your way of selecting the corner points though!

Nerox, your idea does not work because I can not rely on the hinge being parallel to the X axis. The final geo will be an airplane.

I ended up using the transform axis SOP. The direction of the rotation is coming from the average normal from the two hinge points. Not 100% accurate, but it works just fine for this. The flip book previews looked promising, I'll have to post the final version once it's done.

Thanks again for all your help!

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...