SurfaceOffset calculation

  • When I want to build something with complex geometric shape, usually I calculate certain blocs. Obviously, I don't do that manually, but through a libreoffice's spreadsheet and console commands IG (size, surfacescale...). This way, the necessary calculations are done only once to create a tool that can be reused in different situations. Only the parameters need to be adapted to each case. For example, the windmill I recently published uses this technique.


    However, I am currently stuck on calculating the "surface offset". I know there is an inverse function somewhere and that the only two variables are the block dimension and the surface scale in the axis considered, but I can't find the formula that will allow me to control this. Would it be possible to have a point on the math behind the surface offset?

  • The surface scale/offset is indeed a bit confusing. For each vertex of a construction element, the game first multiplies the (local) vertex position (represented as a vector) with the element size, then adds the surface offset to it and multiplies the resulting position with the surface scale. To get the final position, the game then also applies the element rotation to the vertex position. The bold part is only applied to the upper block surface (the one that can be moved), while the rest is always applied to all vertices.


    So the pseudo-code would look like this:


    For a regular, 1x1x1 sized block, all vertices have a local position of 0.5. For example, the upper right front vertex has the coordinates (0.5|0.5|0.5), the upper left front vertex has the coordinates (-0.5|0.5|0.5) etc). Now the size is applied (1x1x1), which doesn't change the position in this case (obviously). Now if there is a surface offset of 1 along the x axis, for example, that value is simply added to the vertex position, i.e. the upper right front vertex moves to (1.5|0.5|0.5). Now the surface scale is applied, if it's 0.5, for example, the resulting position would be (0.75|0.5|0.5).

  • Thanks a lot red :) That will be very helpful next time I (or anyone else) need to calculate the strange shape of certain blocks for some weird object.


    Actually, I found the solution to my specific problem after a night's sleep, but much more complex than what you just explained. Your information should allow me to generalize next time :)


    In my case, I wanted to calculate the shape of the tiles placed on this roof, in particular those above the apse:



    I've also attached my spreadsheet for anyone who might be interested. It's not quite finished, but works pretty well already. It comes without a manual, so you need to have a basic understanding of geometry to use it. Just complete the green boxes and don't touch anything else.

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!