Page 1 of 1

Orient instances properly around Normals

Posted: Wed Feb 10, 2021 10:46 am
by g.bailey
I was trying to build a setup where I instance an animation onto a soccer ball-type shape. When I did, the instances were all oriented properly along the Normals, but they weren't properly oriented around the Normals. If you image the hexes being mapped, they were facing the right way, but rotated wrong around their z-axis. I'm guessing there's something in the orient mesh that I'm missing.

I included a file below if that's not clear. Thanks.

Geoff
madebygeoff.com
@made.by.geoff

Re: Orient instances properly around Normals

Posted: Wed Feb 10, 2021 11:20 am
by toadstorm
Hey Geoff,

Part of the issue here is determining which way is the "right" orientation on a soccer ball. If you were to run Polyframe or MOPs Orient Mesh on the source geometry before you add those points, and you visualize the up vectors, you can see that it's hard to really know for sure what the up vector is going to end up as for any given face. It's not an easy problem to solve... the shape that's generated is based on a dual mesh, so each of those primitives, even if they're the same general shape, aren't thinking of themselves as oriented copies of the same shape; they're individual polygon faces.

You'll probably have to manually adjust the up vectors to make this work. If you want an intuitive way of aiming these, I'd suggest using the Comb SOP to modify the up vector attribute (though this only works on meshes, not disconnected points).

Also, the way that you're creating your points to instance to is a problem... you're copying the N attribute across to your new points, but not the up attribute (you need both vectors to define an orientation), and additionally you have an orient attribute coming along from MOPs Orient Mesh, and if that attribute is present it overrules anything done with N and up. You'd probably want to delete the orient attribute if you prefer working with N and up. For what it's worth, the MOPs Instancer has an option to instance directly to primitive centers; it'll use the average of the point N and up attributes from the source mesh to determine the final orientation of the template points.

Sorry this isn't an easy answer! Orientations are pretty tough, and even on a cube it's easy to tell which way is "out" (N) but not as easy to tell which way is "forward" (up).

Re: Orient instances properly around Normals

Posted: Wed Feb 10, 2021 12:49 pm
by g.bailey
Ah! Thank you. That helps a lot to solve it. It doesn't matter exactly how each instance is oriented, only that they are oriented consistently, meaning that the points are aligned. So I just made an up vector pointing from the center to an arbitrary point and now they all line up.

Also, I had tried using the "prim center" function on the instancer, but it wasn't working properly. The copies weren't at all close to the visual center of each prim. I'm guessing it has something to do with the "compute dual" since it works on any other mesh I use... But to this day I still can't figure out what the "compute dual" is actually doing under the hood, so I'll leave that one to you :)