1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Transformation matrix questions

Discussion in 'Tools programming' started by Manuel Ambulo, 19/2/07.

  1. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Hi,

    I have some couple of questions about the MDL format...:



    1) The transformation matrix in the FSX MDL files, is represented like this?:

    Code:
        //----(x)--(z)--(y)---(t)--
        float m00, m01, m02, m03;
        float m10, m11, m12, m13;
        float m20, m21, m22, m23;
        float m30, m31, m32, m33;
        
    Where, from left to right, the first colum is (X = pitch) axis, second column (Z = bank) axis, thrid colum (Y = heading) axis and fourth column (T = translation).


    **OR! the matrix is represented like this?**:


    Code:
        //----(x)--(y)--(z)---(t)--
        float m00, m01, m02, m03;
        float m10, m11, m12, m13;
        float m20, m21, m22, m23;
        float m30, m31, m32, m33;
        
    Where, from left to right, the first colum is (X = pitch) axis, second column (Y = bank) axis, thrid colum (Z = heading) axis and fourth column (T = translation).??

    I mean how it is interpreted the columns, according to which axis order?:

    X, Z, Y, T......(from left to right)

    OR! its:

    X, Y, Z, T......(from left to right)?????


    Same question goes for the (0xAF) opcode in FS2002/2004...in the FS2002 SDK it appears like: "BGL_TRANSFORM_MATRIX", and in SCASM its: "Transform_Mat", i also, want to know if the columns interpretation is:

    X, Z, Y, T......(from left to right)

    OR! its:

    X, Y, Z, T......(from left to right)?????

    **NOTE**: I know that in FSX MDL files matrices are 4x4 columns, and that the "Transform_Mat" contains a 3x3 matrix, so the translation information is in dx,dy,dz, parameters of the "Transform_Mat" BGL command.



    2) In the FS world, the (X,Y,Z) axis are (pitch,bank,heading).....OR! ...its like this->... (X,Z,Y) axis are....(pitch,bank,heading)???



    3) The increments and decrements in the Y axis is the same to same increments and decrements in Altitude?..i mean the Y axis in the FS world represents the Altitude right? (Just asking to confirm that the Y axis represents the altitude or height of an 3D object)...


    4) Another thing, when does the TRAN section appears in FS2004 MDL files?..i mean..i know that in the BGL section, there are commands that let me set the transformation matrices, so i want to know if there could be any cases where i could have a 3D model's MDL file, containning a BGL section with the drawing code and its matrices commands inside (in the BGL section..like "Transform_Mat" and some others), and a TRAN section...??...i mean...does the TRAN section takes effect in the drawing of primitives 3D models..like building and terminals...(in FS2004?)....or the transformations are ONLY done in the BGL section?...(i dont know if i explained myself...clear :( hope someone understand this doubt).


    Best Regards,

    Manuel Ambulo
  2. Marginal

    Marginal

    Joined:
    25/10/06
    Messages:
    41
    Country:
    unitedkingdom
    The BGL_TRANSFORM_MATRIX (0xAF) opcode and the FS2004 TRAN section work essentially the same way - they both define a translation, rotation and/or scaling matrix. x is east, y is up, and z is north. I assume that the FSX TRAN section works the same way.

    Stop thinking about "columns" and pitch/bank/yaw. Read up on matrices instead.

    The matrix in the TRAN section applies to all of the opcodes in the BGL section.
  3. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,251
    Country:
    netherlands
    Hi,

    I think by default the axes order is still XZY in FS, but I have seen it quite often that in the TRAN section the order of the axis is changed to XYZ. In models using animations that is a quite common transformation matrix to start with.

    I guess the old Transform_Mat command (in ASM form) might also work in Fs2004 MDL files, so that the matrix is in the BGL section. But if you follow the standard that should never happen, all matrices should be in the TRAN section then, just refered to by their index.
  4. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Hi,


    Thanks marginal, i was asking about the X,Y,Z axes to see if i was wrong or right that X=east, Z=north and Y=up, i was just trying to confirm that. About matrices, i had already read some websites that explains what are matrices and how to work with them, example...like combining multiple matrices by multiplying them, to get a single matrix that could do all, rotations, and translations. Before, posting these questions, i had read some sites like:

    http://www.geocities.com/pcgpe/matrices.html


    Yes, arno, i was thinking same as you that the order was XZY, because the "Transform_Mat" (BGL_TRANSFORM_MATRIX = 0xAF) references says that the order is X,Z,Y. So as a result, i was thinking that the matrix (inside of the "Transform_Mat" (BGL_TRANSFORM_MATRIX = 0xAF) should be interpreted like this:

    //----(x)--(z)---(y)
    float m00, m01, m02;
    float m10, m11, m12;
    float m20, m21, m22;

    But i recently (well, few hours ago, of today), i decided to make a little test or experiment, to see if the order is X,Z,Y or X,Y,Z, by using SCASM. So i went to the SCASM's homepage and downloaded the lastest version of SCASM (v2.96), and had built a little test SCASM file (*.sca), with this code:

    Code:
    ; ----------------------------------------
    ; loko.bgl disassembled by BGLAnalyze (c) on Tue Feb 20 14:32:14 2007
    
    ; ----------------------------------------
    Header( 1  N52:26:00.00 N52:19:00.00 E013:37:00.00 E013:26:00.00 )
    LatRange(  N52:19:00.00  N52:26:00.00 )
    ; since SCASM does not support multiple latitude ranges
    ; the range has been set to the minimum/maximum latitude.
    ; LatRange information in the BGL file is given as comment.
    ; If you want to use band separation, you must edit
    ; the source file manually.
    
    ; Insert the "Set( FSVers 0x800 )" instruction at the beginning
    ; of the file, if you want to use the FS2002 instructions
    ; for the facilities section
    mif( [$Version < 285] )
       Error( You need at least SCASM version 2.85 to compile this code )
    mifend
    
    ; ----------------------------------------
    ; Procedural scenery
    ; ----------------------------------------
    
    
    ; LatRange(  N52:18:52.87  N52:25:47.51 )
    ; ----------------------------------------
    ; ----------------------------------------
    ; Object # 1, offset: 0x000A size: 88 bytes (0x0058) 
    ;; Lat: 00058D558h Lon: 0099E1365h
    ; ----------------------------------------
    Area( 5 N52:23:12.80 E013:31:28.51 2 )
    	Transform_Mat(a  0 0 0  0 0 50)
    	Specular( 0 ) ; in FS2000 reserved?
    	LoadBitmap( 0 1 EF 128 128 128
    		xyz.bmp )
    	TransformEnd
    EndA
    
    ; sorted list of objects
    ;  N52:23:12.80  E013:31:28.51 Object # 1
    ; ----------------------------------------
    ; end of SCASM source
    As you can see the purpose is to produce a *.BGL file, using the "Transform_Mat" BGL command, like this:

    Code:
    Transform_Mat(a  0 0 0  0 0 50)
    Where i set: dx = 0, dy = 0, dz = 0, pitch = 0, bank = 0, heading = 50 (degrees).

    Then using the SCASM, i convert this source code, to *.BGL, after that....i get a SCASM disassembler (i used the BGLAnalyze, the version that is for FS2002), then openned the *.BGL file, and disassembled it, to a SCASM file (*.sca), so then i can see what is the resulting matrix, and i saw, (after some experiments, by setting all values to "0" and setting one value like: pitch or bank or heading), that the matrix displayed in the "Transform_Mat" command, uses an order of X,Y,Z, which was the opposite of what i was thinking (all the time, before now) because of the references of the SCASM. Now i had to change most of my source code to then fix it from X,Z,Y order to X,Y,Z. Like this:

    //----(x)--(y)---(z)
    float m00, m01, m02;
    float m10, m11, m12;
    float m20, m21, m22;


    Yep, i also think that some people maybe can still be using "Transform_Mat", in FS2004 MDL files (in the BGL section). But i also has a little question, how do i know which matrix in the TRAN section, affects to which part of the code in the BGL section?...as far as i understand, in a single TRAN section can exists more than one matrix. But the question is,...which matrix (in the TRAN section) affects to which part of the code in the BGL section?, is there a BGL opcode command, that calls from the BGL section a specified matrix from the TRAN section to be used in a BGL subroutine or something? (if so which command is?)....i mean, how and where in the BGL section (where the drawing code is), are refered each matrix in the TRAN section?)...I will really appreciate if u can tell me how or which command (in the BGL section) calls the matrices in the TRAN section.

    And also, now that in FSX MDL files there is no BGL section, then how matrices (from the TRAN section) are called?, because the drawing code is different. I mean now there are sections like: LODT, LODE, PARTs and others, that defines the drawing of the 3D model. I was trying to guess how the matrices in TRAN section are used or called, i was thinking that maybe it is necesary to put a TRAN section after every LODT section so that TRAN section can affect the LODT of and theirs parts, and so on...im not sure if it is how they are used...:confused:


    Best Regards,

    Manuel Ambulo
    Last edited: 20/2/07
  5. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,251
    Country:
    netherlands
    Hi Manual,

    I don't think using the Transform_Mat command inside the BGL section is very common. Only people that really like to tweak with ASM code are able to do that, most people simply use MakeMDL and will never get that kind of code in their BGL section.

    About the calling of the matrices in Fs2004. In the code you can use the BGL_MATRIX_INDIRECT command to load a certain transformation. You can not calling the matrices directly here, but the different entries from the SCEN section of the MDL file. This SCEN section calls the entries from the ANIC section where the actual interpolation of animation matrices is done (for static TRAN transformations just a number is assigned to the matrix in this section). The peer/child relations defined in the SCEN section define if the previous transformation should be popped back or not, before applying the selected one. I hope this short description makes sort of sense to you :).

    About the FsX format, I have not really studied MDL files with animations or transformations. If you export simple object it will only have one TRAN entry in total. But I suspect that each PART section can refer to a certain transformation matrix. I don't expect that there will be multiple TRAN section in the same MDL file.

Share This Page