4
$\begingroup$

enter image description here

I'm doing some buildings and, as some dimension varies, I found a way to center the doors and windows on specific faces selected via different materials. However the door is "lifted" up. More verticies on the upper edge more the door is shifted on +Z Axis. There is a way to stay at the center, the REAL center of that rectangle?

$\endgroup$

1 Answer 1

3
$\begingroup$

Mesh to PointsFaces node generates the points at the average of all of each face’s vertices, so when you add more vertices at the top edge of a face by dividing the neighboring face, you're adding more Z value to that position, thus moving it up. I'm not aware of a native, simpler method, so to get the real (mass) center of the face you need to do some math. Here's a setup that would calculate the center of mass for each face:

enter image description here

That setup's from user LordoftheFleas on BlenderArtists. Here's a slightly simplified, updated version courtesy of @Robin-Betts:

enter image description here

Here's the result:

enter image description here

I'm attaching the blend file so instead of re-creating the setup from scratch you can just append the node group "FaceCenterOfMass" and link it to your Mesh to Points node as you see in the screenshot.

Original version:

Updated version (Blender 3.3):

$\endgroup$
6
  • $\begingroup$ Brilliant. When you've got a moment. can you give a brief description of the math you're doing? Having trouble reverse-engineering. $\endgroup$
    – Robin Betts
    Nov 19 at 19:54
  • $\begingroup$ @RobinBetts I'm nowhere near smart enough to do that myself haha. Got it from who knows somewhere sometime ago and been using it as an asset. Let me see if I can find the original again. $\endgroup$
    – Kuboå
    Nov 19 at 20:00
  • 1
    $\begingroup$ @RobinBetts Found it: blenderartists.org/t/… If you can put it into words, I'm all ears. I can kinda sorta follow it, but get lost at the Accumulate Field node. $\endgroup$
    – Kuboå
    Nov 19 at 20:05
  • 1
    $\begingroup$ Okydoky.. Rebuilt for 3.3 with a slightly different transfer method (I prefer by index, if possible, so as to avoid a search though geometry for 'closest') . The group finds the center of mass of a face by finding the mean location of the centers of mass of its constituent triangles, weighted by triangle-area. I /you can pop in an edit, if you like. Just IMO, but I think it might be diplomatic to credit the original author of this one. There's no shame in that :) Well found, and nicely presented! $\endgroup$
    – Robin Betts
    Nov 20 at 10:17
  • 1
    $\begingroup$ Thanks Robin, updated the answer. $\endgroup$
    – Kuboå
    Nov 20 at 13:34

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.