Jump to content
Oliver Hope

Mirror Structures across any plane

Recommended Posts

This tutorial will show you how to use the BTH building aids mirror tool to mirror a group of entities across a plane.
This is one of the more powerful tools IMO, so stick through the scary maths language builders, I believe in you! 
BTH building aids main page.

Video Version
Coming soon? Hopefully?

Introducing the problem

Before we get into the tutorial let's look at an example of where this is useful and some possibly simpler solutions.

Lets look at this greenhouse, if we want to mirror the roof and posts it is easy to select them, duplicate, rotate 180o on the y-axis (green) and reposition it.

image.png.35f67b5e405a6800984ef63ad271a352.pngimage.png.5bc8662e98f75d2586ef60671ec88fe9.pngimage.png.c3029712c7470208aabe3992a180f8d2.png

That was easy but its not always as simple as rotating around an axis. 
Lets take a look at a boat hull made by the talented @Yo HasLEGO which I will be using to demonstrate using the mirror tools.

Here we can see one-half of the hull. If we try to rotate as in the previous example, it doesn't matter what axis we rotate it on, we won't be able to mirror it.

image.png.0bc4ca2ea17ed6a8503f815843a83891.pngimage.png.e50635bcf8f7f0aad1ea68d4bba361e7.png

You could try rotating each layer separately, this works okay for the top layer, there is just one block at the stern that is problematic but that could be fixed manually fairly easily.
However, as soon as we go further down the hull where there are more curves, this method really falls apart.
image.png.56b8dacc86db47253c811dcd63c5e33f.pngimage.png.01d3e0b30ebcb1dc8fe48e26d3760d06.png

 

The mirror Tool

Let's see how to use the mirror tool to make mirroring this boat hull possible. There are 2 mirror tools one camed 'Mirror' and the other named 'Mirror templates enabled'. Mirroring all the entities is not a simple process so a few complex parameters are required to use the 1st option, however, I have created a bunch of templates for commonly used entities to make it much easier to use. I'll first show how to use the option with templates enabled.

Mirroring with Templates

Step 1
Create a group with all the entities you want to mirror (this just makes selecting them easier)

Step 2
Place the mirror tool in position, the entities will be reflected across the trigger zone plane (the local XY plane of the trigger zone)
image.png.5f393c814dcd2e381f5328e1ee8da8ea.png

Step 3
Add all entities of a single type to the entity label. (Use ctrl double click to select all entities of a type).
image.thumb.png.32544d50dfc7d482f2ca0e4709693611.png

Step 4
Open the script in the label (Use shift + alt + double click to quickly open a script in a group), select the tile in the 'entity mirror template' parameter and select the block shape from the drop-down list. The dimensions are given in XYZ order and are multiples of 0.375, ie the 2x1x2 block is an entity with the dimension of 0.75x0.375x0.75. (Side note, Iv been checking through the templates and I seem to have made a mistake with some of the formats but they still kinda work, ill try fix them at some point)
The entities I have selected in the above image are 2x1x4 so I have selected this template.
image.thumb.png.107780f8ece55bd0cf3271233247f62e.png

Step 5
Repeat steps 2 - 4 with each different entity type in your build. There are cases where you can use the same mirror tool for different entity types, see important notes point 1.
image.thumb.png.006987c7db5caf2374a073e897e67aae.png

Step 6
Test your world to check that everything is generated correctly. See the following tutorial to learn how to create a composition of the generated section and use it in your world. Using generated structures (video tutorial)
image.thumb.png.e03bc67de260b1a1c954dc98f163bafd.png
If you have sharp eyes you will notice I haven't done the sloped blocks at the end of the boat, oops.
image.thumb.png.57c0d684dbe69e15a32be2d0771e0e3c.png
@Yo HasLEGO was then able to bring both sides of the hull together for his catamaran, looks how great it looks! (Still a WIP)

Important notes

 

  • The templates are based on the wooden blocks, most entities of the same shape have the same origin and orientation and therefore they can be mirrored using the same mirror tool. For example:
    image.png.ab4c08f140254d3bb933301adaf6bef3.pngimage.png.ca595512c60fa0b1774efd33b68eb755.png
  • However, some have different orientations and most of the time this will be problematic:
    image.png.91bddba7b79c6345a654d12b0078e685.pngimage.png.becf89436923b297aaac4a523808e9f3.png

So what happens if there isn't a template for a block I want to use? This is where the other Mirror tool comes into play.

Advanced Mirror Tool

This tool is very similar to the previous one, the only difference is that you need to provide an entity centre offset and an entity mirror plane normal. These parameters can be found on the entity label in the mirror group.
Do the same steps described above but instead of step 4 follow the instructions below.
image.thumb.png.898bfd12763e2ed76bdcbeb24b5da792.png

Entity Center
This is a vector describing where the centre of the entity is relative to the entity's origin. NB: Ensure the vector is in the local space of the entity and remember to use minus for direction.
Here is an example using a simple 2x1x4 block (there is already a template for this, but it's easy to demonstrate on)
image.png.88b5e434153358cd1e54bd471d85ddcb.pngimage.png.bc2c7d3d460627e435da69081f782505.png

Entity mirror plane normal
This one is a little more complex but bare with me. We need to find a plane over which the entity is symmetrical, some objects have multiple planes, you can use any of them.
This block is asymmetric on the XY plane, notice how the x and y-axis are parallel to the orange plane, this is why it's called the XY plane. It's also symmetric about the XZ plane and YZ plane.
image.png.ee3602d74eae4efe8263418e234cdfc8.pngimage.png.c8b5d22190ffee815fe3995b0a18746e.png
The parameter asks for a normal to the plane, in maths a normal is a vector ('arrow') that is perpendicular to a plane, in the first example we can see that the z-axis is perpendicular to the plane therefore the normal is 0,0,1 ( it could also be (0,0,456) or (0,0,-87) but let's keep it normal, pun very much intended.)

image.png.bc2c7d3d460627e435da69081f782505.png

NB: As with the entity centre remember to do everything in the local space relative to the entity.

How about a more complex example. This block is not symmetric about either of the 3 basic plans (XY, XZ, YZ), however, it is about this plane at a 45-degree angle.
image.png.a5372a583f5af0438c2e4cb5d4e39240.pngimage.png.0b5602053658e9a9db824ebee02ea5cb.png
To find a normal to this plane imagine a perpendicular arrow and what the coordinates of that arrowhead must be. In this terrible paint image the black arrow is the normal. A normal vector is a direction vector therefore its position is irrelevant, note how I have moved the origin but kept the same orientation.
image.png.66c081bb298c51eafe814273262ba54f.pngimage.png.91ceab026b84912f3e30fc5ab3e39f35.png

Remember that if any entity types have the same entity centre offset AND entity mirror plane normal you can use the same mirror tool for both those entity types a good example of this is these two wall signs.
image.png.c455300e7ce4bdb47c7ed60956581b8d.png
A few examples of entities that do not have a symmetry plane, note that you may be able to get satisfactory examples using the closest plane.
image.thumb.png.7a4395bf4ac73b9d2cc1e55fe0323450.png

Edited by Oliver Hope
  • Like 2
  • Upvote 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×