Method of model projective transformations

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Introduce a way to transform your mesh in a irregular way, often used for bending.
    In Transport Fever, a mod creator can do transforms to any model, it's easy once the transformations is an affine transformations.
    Written in vector and matrix:

    With




    and



    Where



    So the between the original coordinate (x, y, z)ᵀ and (x', y', z')ᵀ, it's an linear projection. For any triangle:



    With the same matrix you can get



    So



    And



    In this way we will be able to get the M we need

    But since the rank(X) = 3 and rank(Y) =3, and the rank(M) = 4, with two triangles, you can't get such M.
    So we need to introduce another extra point in X and Y, and these (two) points should not be coplanar with the rest three in order to have 4-rank matrice, for example




    Then you will get the M you want.

    So back to the subject, how to do any transformation to any meshes?

    In the Ultimate Station, each unit is in a rectangle mesh viewed from Z, when the station is curved, the rectangle becomes trapezium, this is NOT an affine transformation but a perspective transformation! But it doesn't matter, you can divide a rectangle into two triangles, and you will be able to get two triangles at the output side, the difference is you need two different affine transformation matrice to finish this.

    This is the method I used.

    Is there a better way to avoid the division?

    There is, but not implemented by the game.

    Note the matrix M, the last line is always (0, 0, 0, 1), and note the vector that I have written above, there are always for elements, the last is always 1.
    If it's a perspective transformation, the last line of M will be no longer (0, 0, 0, 1), but something else. However, in this case, the output vector will have a non 1 element as last, we call it w

    We will have



    With five non-coplanar coordinates, you will be able to get an matrix M that can transform a rectangle to any form in the space, however, you need to deal with the last element w, to make it 1



    However, this can not be done with the mod, it should be done with the compiled code of Transport Fever, and UG didn't do this step.

    So the only way to do such transformation is to divide your mesh diagonally.

    894 times viewed

Comments 2

  • ritknat -

    "But it doesn't matter, you can divide a rectangle into two triangles, and you will be able to get two triangles at the output side, the difference is you need two different affine transformation matrice to finish this." - Does this mean you have to export triangular models from blender as a basic element, or do you use rectangular model parts ?

    • Enzojz -

      Cut the models by one diagonal cut, and export in two models.