4
\$\begingroup\$

I'm working on a build mode but the thing of it is the player is able to deform meshes. Part of my build system includes having "snap" points thus I need to be able to find the face and recenter the snap point on deformed meshes.

So, how do I find the face of an object and the center of said face? Also how would I find the center?

Rectangular Prism with snap points.

To clarify: The end goal is to keep the snap point positioned properly with the face that has been deformed/manipulated.

\$\endgroup\$
7
  • \$\begingroup\$ Which face do you want to find? \$\endgroup\$ – DMGregory Jul 1 '16 at 18:32
  • \$\begingroup\$ @DMGregory Basically any of them that have been changed. In code it should go something like this: If face has been changed/deformed find it, recalculate where the snap point should go (roughly in the center), and place it there. \$\endgroup\$ – Sie Jul 1 '16 at 18:35
  • \$\begingroup\$ Do you need to find center on known face or all faces on mesh? If it changed you still know it, right? \$\endgroup\$ – wondra Jul 1 '16 at 18:43
  • \$\begingroup\$ If you know the set of vertices you've changed, you could iterate over the list of faces and recalculate the centroid of any face that includes a modified vertex. Is that the sort of solution you're looking for? \$\endgroup\$ – DMGregory Jul 1 '16 at 18:45
  • \$\begingroup\$ @wondra Not quite sure I follow. Essentially what I'm trying to accomplish is always knowing the position/center of the current face so I can place the snap point properly. \$\endgroup\$ – Sie Jul 1 '16 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.