Jump to content

Interpolating orient attrib in CHOPs


j00ey

Recommended Posts

I'm having difficulty with flipping normals when copying geometry onto points.

I have a scene with a number of randomly generated structures, just points [each has the same number of points] and I have a CHOP setup to interpolate between them - basically a glorified blendshape - and after the interpolation I'm copying geometry on to them.

The problem is that if I use the normal to orient the copies, it sometimes flips, as in the attached scene. I thought if I brought that into CHOPs and added a quaternion attrib with the attribute CHOP it might fix that problem but it doesn't seem to make any difference. Does anyone know a good way to approach this?

odforce_flipping_geo.hip

Link to comment
Share on other sites

Your goal is to smoothly blend the orientation of your copied geometry, yes?

 

Could you just build some basis vectors from N, convert that to a matrix, then that to a quaternion.? After you do that interpolation is easy, just use a slerp() function in an attribwrangle.

 

 

Link to comment
Share on other sites

Hi Jon

Thanks for replying. That's exactly what I was trying to do yes but I'm struggling to get it to work.

I have a point cloud which has a number of target states - other point clouds - which I'm fetching the position / normal and scale from and then I'm sequencing them in CHOPs so I can control the timing and animation between states and so on. So the problem arises when a point does what's happening in the scene file I uploaded - moves from one position to another and the normal flips 180 degrees. I could instead of getting the normal from CHOPs I could get a slerp bias but I don't understand how to get that working in conjunction with the wrangle method you're talking about. The bias would either go up from 0 to 1 and then from 1 to 2 etc or else I'd reset it so it goes from 0 to 1 and then back again. I can imagine getting that to work in a solver somehow but I thought there must be a CHOPs method.

I imagine that probably all sounds a bit garbled. I can't put up an actual scene file but if I get chance I'll make a dummy version and upload it.

Thanks for reading anyway

Link to comment
Share on other sites

Take a look at the following scene.  I don't have access to a commercial license right now so you'll have to recreate it, but it should do what you want.  It basically reproduces this advice on stackoverflow:

http://stackoverflow.com/questions/15873996/converting-a-direction-vector-to-a-quaternion-rotation

 

You build basis vectors from your normal, then use the built-in VOPs / vex functions to convert a matrix3 to a quaternion.

odforce_flipping_geo_orient.hipnc

  • Like 1
Link to comment
Share on other sites

Hi Jon

Thanks very much, I really appreciate your help.

I do understand the slerping between two states, what I'm stuck with is slerping between A and B and then between B and C.

I've made a file that's more or less the same setup as I have at work - it's not exhibiting quite the same flipping as that one as the work file has many more pieces that move back and forth along one vector with their normals pointing along it in opposite directions but it does have the same issue. I'm still something of a CHOPs novice so that part might be a bit inelegant but it does essentially what I'm trying to do except for the flipping.

I make the target states in SOPs then interpolate between them in CHOPs and fetch the P and N values from there. So to do the quaternion VEX method I'd have to do it somehow inside a solver I think. I'm probably missing something simple but I'm not sure what...

odforce_flipping_geo_orient_sequenced.hipnc

Link to comment
Share on other sites

Ah,

Well I haven't looked at your scene to fully understand what's going on, but I do see you are using a blend CHOP... I have also had problems with flipping when using this node.  I fixed it by replacing blend with a stack of composite CHOPS.  Theoretically they should work the same way, but the composite chops did not have issues with flipping.

Link to comment
Share on other sites

Hi, Tim!

I'm not very familiar with chops, but there is a quick vex solution to avoid flipping artefacts. All you have to do is to check the dot product between the two quaternion vectors and based on the result to invert one of the vectors before slerp-ing them. Check the attached file - it's kind of a library for proper matrix interpolation I created for my personal projects, and it uses the exact same method.

 

Cheers!

Pavel

slerpmx.vfl

  • Like 5
Link to comment
Share on other sites

9 minutes ago, rayman said:

Hi, Tim!

I'm not very familiar with chops, but there is a quick vex solution to avoid flipping artefacts. All you have to do is to check the dot product between the two quaternion vectors and based on the result to invert one of the vectors before slerp-ing them. Check the attached file - it's kind of a library for proper matrix interpolation I created for my personal projects, and it uses the exact same method.

 

Cheers!

Pavel

slerpmx.vfl

Really Nice Pavel!

Thanks for sharing this!!!

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