5
$\begingroup$

I have a lot of meshes of different houses, each house is a single mesh, but parts of this single mesh has some repeating features, such as windows, doors, etc.

I am looking for a way to reduce the poly-count of the mesh, since this will be used in a (Unity) game.

Is there any simple way to select a single piece of the mesh (E.g. a window), separate this into another mesh, and let blender find similar shapes (may be rotated) in the original mesh and replace those with a linked duplicates?

$\endgroup$
3
  • 1
    $\begingroup$ AFAIK there is no real solution at the moment. In your case it probably makes sense to find a developer who can implement this idea in c++, because using unit_test_compare() is really slooowww. Another idea would be building a custom 'library Add-on' in order to instantly work with linked duplicates. Unfortunately I have no idea about unity. Just out of interest: How linked duplicates can help to reduce the polycount? $\endgroup$
    – p2or
    Mar 9 '16 at 9:24
  • $\begingroup$ "How linked duplicates can help to reduce the polycount? " Yeah I thought the same initially then I made a quick test exporting to fbx and indeed there is a difference! $\endgroup$ Mar 9 '16 at 13:07
  • 1
    $\begingroup$ It doesn't necessarily reduce poly count, although it can have a big impact in scene optimization through memory usage if the particular task can take advantage of instancing (Cycles rendering does I believe), it can also have a positive impact in workflow modularity and amount of manual work required to do an edit. Blender viewport does have some trouble with large numbers of independent objects, so it can also have an adverse effect in viewport performance unfortunately. $\endgroup$ Mar 10 '16 at 1:42
2
+75
$\begingroup$

you can write a script to separate every object into loose parts. Then for every object do a unit_test_compare with the data of the other object if the result it's "Same" then make it a linked duplicate, but before copy the world matrix to not loose the position scaling and rotation and apply it to the newly linked duplicate ie.

print(firstObj.data.unit_test_compare(secondObj.data))

will yield to the string "Same" if they are the same and "Number of verts don't match" for different objects

Let me know if this is not enough

edit : possible duplicate answer

$\endgroup$
2
$\begingroup$

While this will certainly not deal with different rotations or orientations automatically the closest thing I can think of without resorting to coding would be the following, assuming each window, door, or other feature is a separate entity from the rest of the house mesh (with no shared vertex or faces)

  1. Enter edit mode on your mesh
  2. Select a single face or edge from one of soon-to-be independent objects, like say one of your windows, that as a very distinct feature, like a particularly unique face area, a unique number of concurrent edges, a particular length, or a specific number of surrounding faces, specific to that type of window
  3. This will allow you to use Shift + G to select similar and choose the particular feature that is unique among all windows
  4. Adjust the threshold to a value low enough that will only select edges exclusively from sub-objects of the same type (windows in this example)
  5. Now press Ctrl + L to select all linked so that Blender selects the whole windows
  6. Now you have all windows selected and you can separate them from the main mesh using P > Selection
  7. Exit edit mode and enter edit mode on your newly created all-windows mesh. If all windows are comprised of a single linked set of faces you can now use P again to separate all windows into their own object with the option By loose parts
  8. Every window should now be an independent object, although still not sharing objectdata, so now exit edit mode, with all windows selected and press Shift + Ctrl + Alt + C and choose Origin to geometry
  9. Still with all windows selected (make sure one of them is the active object) now press Ctrl + L Make Links > Object Data
  10. Your windows should now be all correctly placed and sharing object data, although rotations will still be messed up

If these are regular orthogonal buildings manually rotating them back into place should not be too laborious, as they will likely fall into either 90 -90 or 180 rotations but will still require some manual labor. If someone smarter than me can come up with a way to solve this last part without manual work I would love to hear it.

For whole buildings, if they are all equal or share a few different designs that repeat you could separately build a few groups comprised of several repeating parts (windows, doors, etc) and use group instances to replace whole buildings making a more modular approach, though I can think of no technique to correctly place them in the scene.

$\endgroup$
1
  • 1
    $\begingroup$ If you could go thru similar steps for the flat bottom face of each house, and iterate through them, you could set view to selected (Shift+Ctrl+Numpad 7), change your coordinate system from global to view, and add an empty at that location, then you could switch back to global, and do a rotation delta to figure out how you need to rotate. If you can merge this answer with this comment into a script it sounds pretty powerful. $\endgroup$
    – Rick Riggs
    Mar 10 '16 at 18:40

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.